33 lines
825 B
C#
33 lines
825 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class FallingPlatformButton : MonoBehaviour{
|
|
|
|
public float fallDelay = .25f;
|
|
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;
|
|
fallDelay = Random.Range(fallDelay - .1f, fallDelay + .1f);
|
|
}
|
|
|
|
public void ButtonFall(){
|
|
AudioManager.instance.Play("FallingPlatform");
|
|
Invoke("Fall", fallDelay);
|
|
Instantiate(particles, new Vector2(transform.position.x, transform.position.y + .5f), Quaternion.identity);
|
|
}
|
|
|
|
void Fall(){
|
|
rb2d.isKinematic = false;
|
|
pc2d.isTrigger = true;
|
|
}
|
|
}
|