Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class GenCubeEffects : MonoBehaviour
  6. {
  7. public string genEffect;//name of the genCubeEffect (what happens when the cibe hits a tile is it turned to grass, spawn a enemy etc)
  8.  
  9. private void OnCollisionEnter(Collision objectHit)
  10. {
  11. if(objectHit.gameObject.tag == "tile")
  12. {
  13. if(genEffect == "lava")
  14. {
  15. objectHit.gameObject.GetComponent<Renderer>().material.color = Color.red;//change the color of the tile
  16. objectHit.gameObject.GetComponent<tileControl>().tileType = "lava";//change tile Control of hit tile to type
  17. }
  18. else if (genEffect == "grass")
  19. {
  20. objectHit.gameObject.GetComponent<Renderer>().material.color = Color.green;
  21. objectHit.gameObject.GetComponent<tileControl>().tileType = "grass";
  22. }
  23. else if (genEffect == "height")
  24. {
  25. objectHit.gameObject.GetComponent<Renderer>().material.color = Color.black;
  26. objectHit.transform.localScale += new Vector3(0,1,0);//increas height of tile
  27. objectHit.transform.position += new Vector3(0, .5f, 0);//move tile to half the size of increase from last line
  28. objectHit.gameObject.GetComponent<tileControl>().tileType = "height";
  29. }
  30.  
  31. Destroy(this.gameObject);//destory the genCube
  32. }
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement