private void OnMouseDown() { if (isWalkable && gm.selectedUnit != null) { gm.selectedUnit.Move(this.transform.position); } else if (isCreatable == true) { BarrackItem item = Instantiate(gm.purchasedItem, new Vector2(transform.position.x, transform.position.y), Quaternion.identity); //spawns the purchased item on the selected tile gm.ResetTiles(); Units unit = item.GetComponent <Units>(); if (unit != null) { unit.hasAttacked = true; unit.hasMoved = true; } } }
private void OnMouseDown() { if (isWalkable == true && gm.selectedUnit != null) { gm.selectedUnit.Move(this.transform); } else if (isCreatable) { BarrackItem item = Instantiate(gm.purchasedItem, new Vector2(Mathf.Round(transform.position.x), Mathf.Round(transform.position.y)), Quaternion.identity); gm.ResetTiles(); Units unit = item.GetComponent <Units>(); if (unit != null) { unit.hasMoved = true; unit.hasAttack = true; } } }
private void OnMouseDown() { if (isWalkable == true && gm.selectedUnit != null) //if the tile is walkable and a unit is selected { gm.selectedUnit.Move(this.transform.position); } else if (isCreatable == true) { BarrackItem item = Instantiate(gm.purchasedItem, new Vector2(transform.position.x, transform.position.y), Quaternion.identity); gm.ResetTiles(); //instantiate the chosen unit type and reset tiles Unit unit = item.GetComponent <Unit>(); if (unit != null) //if a unit was purchased, not a chest, make sure it is unable to move that same turn { unit.hasMoved = true; unit.hasAttacked = true; } } }
private void OnMouseDown() { if (isWalkable && gm.SelectedUnit != null) { gm.SelectedUnit.Move(this.transform.position); } else if (isCreatable) { Debug.Log("Create"); BarrackItem item = Instantiate(gm.purchasedItem, new Vector2(transform.position.x, transform.position.y), Quaternion.identity); gm.ResetTiles(); Unit unit = item.GetComponent <Unit>(); if (unit != null) { unit.hasAttacked = true; unit.hasMoved = true; } } }