You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

50 lines
999 B

using UnityEngine;
using System.Collections;
public class collectable : MonoBehaviour {
public float waitTime;
float startTime;
// Use this for initialization
void Start () {
startTime = Time.time;
float rand = Random.Range (0, 7);
int randColour = Mathf.FloorToInt (rand);
switch (randColour) {
case 0:
renderer.material.color = Color.cyan;
break;
case 1:
renderer.material.color = Color.red;
break;
case 2:
renderer.material.color = Color.blue;
break;
case 3:
renderer.material.color = Color.green;
break;
case 4:
renderer.material.color = Color.yellow;
break;
case 5:
renderer.material.color = Color.magenta;
break;
default:
renderer.material.color = Color.black;
break;
}
}
// Update is called once per frame
void Update () {
transform.Rotate (new Vector3 (15, 30, 45) * Time.deltaTime);
if (waitTime < Time.time - startTime) {
gameObject.GetComponent<BoxCollider2D>().enabled = true;
}
}
}