init
This commit is contained in:
commit
862afc9b7a
478 changed files with 197737 additions and 0 deletions
54
Assets/Scripts/PlataformaFalling.cs
Normal file
54
Assets/Scripts/PlataformaFalling.cs
Normal file
|
@ -0,0 +1,54 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlataformaFalling : MonoBehaviour {
|
||||
|
||||
public float fallDelay = 1f;
|
||||
public float respawnDelay = 5f;
|
||||
|
||||
public GameObject particles;
|
||||
private Rigidbody2D rb2d;
|
||||
private BoxCollider2D pc2d;
|
||||
private Vector3 start;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
rb2d = GetComponent<Rigidbody2D>();
|
||||
pc2d = GetComponent<BoxCollider2D>();
|
||||
start = transform.position;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
void OnCollisionEnter2D(Collision2D col){
|
||||
if (col.gameObject.CompareTag("Player")){
|
||||
Instantiate(particles, new Vector2(transform.position.x, transform.position.y + .5f), Quaternion.identity);
|
||||
Invoke("Fall", fallDelay);
|
||||
Invoke("Respawn", fallDelay + respawnDelay);
|
||||
AudioManager.instance.Play("FallingPlatform");
|
||||
}
|
||||
}
|
||||
|
||||
public void ButtonFall(){
|
||||
AudioManager.instance.Play("FallingPlatform");
|
||||
Invoke("Fall", fallDelay);
|
||||
Invoke("Respawn", fallDelay + respawnDelay);
|
||||
Instantiate(particles, new Vector2(transform.position.x, transform.position.y + .5f), Quaternion.identity);
|
||||
}
|
||||
|
||||
void Fall(){
|
||||
rb2d.isKinematic = false;
|
||||
pc2d.isTrigger = true;
|
||||
}
|
||||
|
||||
void Respawn(){
|
||||
transform.position = start;
|
||||
rb2d.isKinematic = true;
|
||||
rb2d.velocity = Vector3.zero;
|
||||
pc2d.isTrigger = false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue