Created
April 8, 2019 23:39
-
-
Save DB-009/f8257f1026aac2b16996a8da50f40c85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment