Commit 9c8bb1e1 by Juliper

fixing-level4

parent c3f77cf5
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="Assets\Scripts\BackgroundChanger.cs" /> <Compile Include="Assets\Scripts\BackgroundChanger.cs" />
<Compile Include="Assets\Scripts\CameraController.cs" /> <Compile Include="Assets\Scripts\CameraController.cs" />
<Compile Include="Assets\Scripts\Move.cs" />
<Compile Include="Assets\Scripts\PhysicObject.cs" /> <Compile Include="Assets\Scripts\PhysicObject.cs" />
<Compile Include="Assets\Scripts\PlayerController.cs" /> <Compile Include="Assets\Scripts\PlayerController.cs" />
<Compile Include="Assets\Scripts\SceneLoader.cs" /> <Compile Include="Assets\Scripts\SceneLoader.cs" />
......
This source diff could not be displayed because it is too large. You can view the blob instead.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Move : MonoBehaviour {
public float speed = 10f;
public bool finish = false;
public string kindOfMove;
public float max;
public float min;
[SerializeField]
private Transform childTransform;
void Update () {
if (kindOfMove == "Horizontal") {
GerakHorizontal ();
} else {
GerakVertical ();
}
}
public virtual void GerakHorizontal(){
Vector2 posisiSementara = posisi;
if (finish) {
posisiSementara.x += speed * Time.deltaTime;
if (posisiSementara.x > max) {
finish = false;
}
}else{
posisiSementara.x -= speed * Time.deltaTime;
if (posisiSementara.x < min) {
finish = true;
}
}
posisi = posisiSementara;
childTransform = transform;
}
public virtual void GerakVertical(){
Vector2 posisiSementara = posisi;
if (finish) {
posisiSementara.y += speed * Time.deltaTime;
if (posisiSementara.y > max) {
finish = false;
}
}else{
posisiSementara.y -= speed * Time.deltaTime;
if (posisiSementara.y < min) {
finish = true;
}
}
posisi = posisiSementara;
childTransform = transform;
}
public Vector2 posisi{
get{
return(this.transform.position);
}
set{
this.transform.position = value;
}
}
private void OnTriggerEnter2D(Collider2D collision){
if (collision.gameObject.tag == "Player") {
collision.transform.SetParent (childTransform);
}
}
private void OnTriggerExit2D(Collider2D collision){
collision.transform.SetParent (null);
}
}
fileFormatVersion: 2
guid: 0254838888fbcec4db78101410c4992d
timeCreated: 1515311159
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -8,11 +8,18 @@ public class PlayerController : PhysicsObject ...@@ -8,11 +8,18 @@ public class PlayerController : PhysicsObject
public float maxSpeed = 7; public float maxSpeed = 7;
public float jumpTakeOffSpeed = 7; public float jumpTakeOffSpeed = 7;
private SpriteRenderer spriteRenderer; private SpriteRenderer spriteRenderer;
private Rigidbody2D myRigidBody;
private Vector2 startPost;
public GameObject player;
private void Awake() private void Awake()
{ {
spriteRenderer = GetComponent<SpriteRenderer>(); spriteRenderer = GetComponent<SpriteRenderer>();
} }
private void Start(){
startPost = transform.position;
myRigidBody = GetComponent<Rigidbody2D> ();
}
protected override void ComputeVelocity() protected override void ComputeVelocity()
{ {
...@@ -44,9 +51,13 @@ public class PlayerController : PhysicsObject ...@@ -44,9 +51,13 @@ public class PlayerController : PhysicsObject
private void OnTriggerEnter2D(Collider2D collision) private void OnTriggerEnter2D(Collider2D collision)
{ {
if (collision.gameObject.CompareTag("Finish")) if (collision.gameObject.CompareTag ("Finish")) {
{ SceneLoader.LoadLevelScene ();
SceneLoader.LoadLevelScene(); } else if (collision.gameObject.CompareTag ("Water")) {
} myRigidBody.velocity = Vector2.zero;
transform.position = startPost;
}
} }
} }
...@@ -10,6 +10,9 @@ TagManager: ...@@ -10,6 +10,9 @@ TagManager:
- BlueBackground - BlueBackground
- GreenBackground - GreenBackground
- WhiteObstacle - WhiteObstacle
- YellowObstacle
- GreyObstacle
- Water
layers: layers:
- Default - Default
- TransparentFX - TransparentFX
......
<Properties StartupItem="Assembly-CSharp.csproj"> <Properties StartupItem="Assembly-CSharp.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="Unity.Instance.Unity Editor" /> <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="Assets\Scripts\SceneLoader.cs"> <MonoDevelop.Ide.Workbench ActiveDocument="Assets\Scripts\PlayerController.cs">
<Files> <Files>
<File FileName="Assets\Scripts\PlayerController.cs" Line="32" Column="14" /> <File FileName="Assets\Scripts\Move.cs" Line="1" Column="1" />
<File FileName="Assets\Scripts\BackgroundChanger.cs" Line="1" Column="1" />
<File FileName="Assets\Scripts\PlayerController.cs" Line="51" Column="4" />
<File FileName="Assets\Scripts\CameraController.cs" Line="1" Column="1" /> <File FileName="Assets\Scripts\CameraController.cs" Line="1" Column="1" />
<File FileName="Assets\Scripts\PhysicObject.cs" Line="1" Column="1" />
<File FileName="Assets\Scripts\SceneLoader.cs" Line="1" Column="1" />
<File FileName="Assets\Scripts\BackgroundChanger.cs" Line="61" Column="2" />
</Files> </Files>
</MonoDevelop.Ide.Workbench> </MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints> <MonoDevelop.Ide.DebuggingService.Breakpoints>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment