예제 #1
0
파일: Tile.cs 프로젝트: Hozy0/Safy-NEA
 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;
         }
     }
 }
예제 #2
0
 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;
         }
     }
 }
예제 #3
0
    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;
            }
        }
    }
예제 #4
0
 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;
         }
     }
 }