CubeStyle.cs 796 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using UnityEngine;
  2. using System.Collections;
  3. public class CubeStyle : MonoBehaviour {
  4. public int Style;
  5. public GameObject lifeCube;
  6. public GameObject speedCube;
  7. public GameObject bombCube;
  8. // Use this for initialization
  9. void Start () {
  10. }
  11. // Update is called once per frame
  12. void Update () {
  13. }
  14. public void OnTriggerEnter(Collider other){
  15. if (other.CompareTag ("Explosion")) {
  16. if (Style == 1) {
  17. Destroy (gameObject);
  18. Instantiate (lifeCube, transform.position, transform.rotation);
  19. Debug.Log ("2");
  20. }
  21. if (Style == 2) {
  22. Destroy (gameObject);
  23. Instantiate (speedCube, transform.position, transform.rotation);
  24. }
  25. if (Style == 3) {
  26. Destroy (gameObject);
  27. Instantiate (bombCube, transform.position, transform.rotation);
  28. }
  29. }
  30. }
  31. }