// Update is called once per frame void Update() { ItemScript.itemType tra = GameObject.Find("GameHandler").GetComponent <Game>().searchedForTypes.ToArray()[0]; if (tra == ItemScript.itemType.Wood) { imageWood.SetActive(true); imageRock.SetActive(false); imageWater.SetActive(false); } if (tra == ItemScript.itemType.Rock) { imageWood.SetActive(false); imageRock.SetActive(true); imageWater.SetActive(false); } if (tra == ItemScript.itemType.Water) { imageWood.SetActive(false); imageRock.SetActive(false); imageWater.SetActive(true); } }
// Use this for initialization void Awake() { mat = GetComponent <Renderer>().material; baseColor = mat.color; neighbours = new List <TileScript>(); it = ItemScript.itemType.blank; }
//Set the item chosen to be displayed on this tile public void SetItem(ItemScript.itemType it) { if (chosen) { this.it = it; if (model.GetComponent <ItemScript> () != null) { model.GetComponent <ItemScript> ().enabled = false; } currentModel = Instantiate(this.model, new Vector3(transform.position.x, yOffset, transform.position.z), model.transform.rotation); currentModel.transform.parent = this.transform; if (it == ItemScript.itemType.table) { //Check all neighbours, if any are chairs call UpdateTableChosen on their ChairModelScripts foreach (TileScript t in neighbours) { if (t.it == ItemScript.itemType.chair) { ChairModelScript c = t.currentModel.GetComponent <ChairModelScript> (); c.UpdateTableChosen(currentModel); } } GameManager.itemAmount [0]++; GameManager.money -= GameManager.itemPrices [0]; } if (it == ItemScript.itemType.chair) { foreach (TileScript t in neighbours) { if (t.it == ItemScript.itemType.table) { ChairModelScript c = currentModel.GetComponent <ChairModelScript> (); c.UpdateTableChosen(t.currentModel); } } GameManager.itemAmount [1]++; GameManager.money -= GameManager.itemPrices [1]; } //Wont set an item down if it's waiter: will cause blockage. if (it != ItemScript.itemType.waiter) { itemSet = true; } else if (it == ItemScript.itemType.waiter) { GameManager.itemAmount [2]++; GameManager.money -= GameManager.itemPrices [2]; } } else { Debug.Log("Tile has not been chosen"); } }
public bool UnchooseTile() { if (chosen) { mat.color = baseColor; chosen = false; itemSet = false; if (it != ItemScript.itemType.blank) { switch (this.it) { case ItemScript.itemType.table: GameManager.itemAmount [0]--; GameManager.money += GameManager.itemPrices [0]; break; case ItemScript.itemType.chair: GameManager.itemAmount [1]--; GameManager.money += GameManager.itemPrices [1]; break; case ItemScript.itemType.waiter: GameManager.itemAmount [2]--; GameManager.money += GameManager.itemPrices [2]; break; } it = ItemScript.itemType.blank; } if (currentModel != null) { Destroy(currentModel); } return(true); } else { return(false); } }