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

  1. using UnityEngine;
  2. using System.Collections;
  3. public class collectable : MonoBehaviour {
  4. public float waitTime;
  5. float startTime;
  6. // Use this for initialization
  7. void Start () {
  8. startTime = Time.time;
  9. float rand = Random.Range (0, 7);
  10. int randColour = Mathf.FloorToInt (rand);
  11. switch (randColour) {
  12. case 0:
  13. renderer.material.color = Color.cyan;
  14. break;
  15. case 1:
  16. renderer.material.color = Color.red;
  17. break;
  18. case 2:
  19. renderer.material.color = Color.blue;
  20. break;
  21. case 3:
  22. renderer.material.color = Color.green;
  23. break;
  24. case 4:
  25. renderer.material.color = Color.yellow;
  26. break;
  27. case 5:
  28. renderer.material.color = Color.magenta;
  29. break;
  30. default:
  31. renderer.material.color = Color.black;
  32. break;
  33. }
  34. }
  35. // Update is called once per frame
  36. void Update () {
  37. transform.Rotate (new Vector3 (15, 30, 45) * Time.deltaTime);
  38. if (waitTime < Time.time - startTime) {
  39. gameObject.GetComponent<BoxCollider2D>().enabled = true;
  40. }
  41. }
  42. }