using UnityEngine;
using System.Collections;
public class CubeScript : MonoBehaviour {
public bool isActivated = false;
public Color ColorToChangeTo;
public float LerpSpeed = 0.025f;
private float speedLerp;
private Color defaultCol;
private float timeActivated = 0.0f;
private Vector3 startingScale;
public float timeToDestroy = 1500;
private float startingYValue;
public GameObject explosion;
public ParticleSystem ps;
private float yPositionDesired = 4;
// Use this for initialization
void Start ()
{
startingScale = this.transform.localScale;
speedLerp = LerpSpeed;
ColorToChangeTo = defaultCol = this.renderer.material.color;
startingYValue = this.transform.position.y;
}
// Update is called once per frame
void Update ()
{
//if (this.renderer.material.color != ColorToChangeTo)
this.renderer.material.color = Color.Lerp (this.renderer.material.color, ColorToChangeTo, speedLerp);
if (isActivated) {
if ((timeActivated + timeToDestroy) < ((Time.realtimeSinceStartup * 1000))) {
transform.localScale += new Vector3 (0.0025f, 0.0025f, 0.0025f);
//speedLerp = 0.075f;
//ColorToChangeTo = new Color (0, 0, 0);
if ((timeActivated + timeToDestroy * 1.5f) < ((Time.realtimeSinceStartup * 1000))) {
Debug.Log ("DESTORY???");
//GAME OVERRRRR
isActivated = false;
Instantiate(explosion, this.transform.position, Quaternion.identity);
ps.Stop ();
GetComponent
}
}
} else {
transform.localScale = startingScale;
}
Debug.Log (“Y POS: ” + this.transform.position.y);
this.transform.position = Vector3.Lerp( this.transform.position,
new Vector3 (this.transform.position.x,
yPositionDesired,
this.transform.position.z),
speedLerp);
}
public void SetActive()
{
ps.Play ();
speedLerp = LerpSpeed;
timeActivated = Time.realtimeSinceStartup * 1000;
isActivated = true;
}
public void SetDefault()
{
this.transform.position = new Vector3 (this.transform.position.x,
3.5f,
this.transform.position.z);
ps.Stop ();
speedLerp = LerpSpeed;
ColorToChangeTo = defaultCol;
isActivated = false;
}
}