mirror of
https://github.com/ConjureETS/MeltedBananasOJam2016.git
synced 2026-03-26 03:21:11 +00:00
ajout scripts et prefabs pour tuiles
This commit is contained in:
parent
999055b8f8
commit
0259352313
BIN
Assets/Prefabs/Tile.prefab
Normal file
BIN
Assets/Prefabs/Tile.prefab
Normal file
Binary file not shown.
BIN
Assets/Prefabs/TileTrap.prefab
Normal file
BIN
Assets/Prefabs/TileTrap.prefab
Normal file
Binary file not shown.
44
Assets/Scripts/PlayerController.cs
Normal file
44
Assets/Scripts/PlayerController.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
public class PlayerController : MonoBehaviour {
|
||||||
|
|
||||||
|
public float speed;
|
||||||
|
GameObject gameController;
|
||||||
|
|
||||||
|
|
||||||
|
// Use this for initialization
|
||||||
|
void Start () {
|
||||||
|
|
||||||
|
gameController = GameObject.Find("GameController");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void FixedUpdate()
|
||||||
|
{
|
||||||
|
float moveHorizontal = Input.GetAxis("Horizontal");
|
||||||
|
//float moveVertical = Input.GetAxis("Vertical");
|
||||||
|
|
||||||
|
Vector3 movement = new Vector3(moveHorizontal, 0.0f, 0);
|
||||||
|
|
||||||
|
GetComponent<Rigidbody>().AddForce(movement * speed * Time.deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnTriggerEnter(Collider other)
|
||||||
|
{
|
||||||
|
if (other.tag == "Tile")
|
||||||
|
{// && gameController.GetComponent<GameController>().fallTriggerActivated == true
|
||||||
|
other.GetComponent<TileController>().wasTouched = true;
|
||||||
|
Debug.Log("Tile touched");
|
||||||
|
}
|
||||||
|
if (other.tag == "Trigger")
|
||||||
|
{
|
||||||
|
Debug.Log("Trigger entered");
|
||||||
|
gameController.GetComponent<GameController>().fallTriggerActivated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
58
Assets/Scripts/TileController.cs
Normal file
58
Assets/Scripts/TileController.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
public class TileController : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
public float speed;
|
||||||
|
public float speedAddition;
|
||||||
|
public float seconds;
|
||||||
|
public bool wasTouched;
|
||||||
|
public bool timerStart;
|
||||||
|
float initialTime;
|
||||||
|
private bool hasStartedMovement;
|
||||||
|
Vector3 movement;
|
||||||
|
//GameObject gameController;
|
||||||
|
|
||||||
|
// Use this for initialization
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
movement = new Vector3(0.0f, -1, 0.0f);
|
||||||
|
timerStart = false;
|
||||||
|
//gameController = GameObject.Find("GameController");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void FixedUpdate()
|
||||||
|
{
|
||||||
|
if (wasTouched == true)
|
||||||
|
{
|
||||||
|
CountdownUntilFall(seconds);
|
||||||
|
}
|
||||||
|
if (hasStartedMovement == true)
|
||||||
|
{
|
||||||
|
GetComponent<Rigidbody>().isKinematic = false;
|
||||||
|
GetComponent<Rigidbody>().AddForce(movement * speed * Time.deltaTime);
|
||||||
|
speed = speed + speedAddition;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CountdownUntilFall(float seconds)
|
||||||
|
{
|
||||||
|
if (!timerStart)
|
||||||
|
{
|
||||||
|
initialTime = Time.realtimeSinceStartup + seconds;
|
||||||
|
timerStart = true;
|
||||||
|
}
|
||||||
|
if (Time.realtimeSinceStartup >= initialTime)
|
||||||
|
{
|
||||||
|
hasStartedMovement = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user