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.

43 lines
825 B

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