Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class GenCubeEffects : MonoBehaviour
- {
- public string genEffect;//name of the genCubeEffect (what happens when the cibe hits a tile is it turned to grass, spawn a enemy etc)
- private void OnCollisionEnter(Collision objectHit)
- {
- if(objectHit.gameObject.tag == "tile")
- {
- if(genEffect == "lava")
- {
- objectHit.gameObject.GetComponent<Renderer>().material.color = Color.red;//change the color of the tile
- objectHit.gameObject.GetComponent<tileControl>().tileType = "lava";//change tile Control of hit tile to type
- }
- else if (genEffect == "grass")
- {
- objectHit.gameObject.GetComponent<Renderer>().material.color = Color.green;
- objectHit.gameObject.GetComponent<tileControl>().tileType = "grass";
- }
- else if (genEffect == "height")
- {
- objectHit.gameObject.GetComponent<Renderer>().material.color = Color.black;
- objectHit.transform.localScale += new Vector3(0,1,0);//increas height of tile
- objectHit.transform.position += new Vector3(0, .5f, 0);//move tile to half the size of increase from last line
- objectHit.gameObject.GetComponent<tileControl>().tileType = "height";
- }
- Destroy(this.gameObject);//destory the genCube
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement