コード例 #1
0
ファイル: Pattern.cs プロジェクト: aoue/DF---unity
    public void click_tile(PatternSlot tile)
    {
        //if the tile WITHOUT a unit on it is clicked
        if (grid[tile.get_tileX(), tile.get_tileY()] == null) //if tile has no unit on it
        {
            if (selectedUnit != null)                         //if a unit is selected
            {
                ////set tile image image back to default
                tilegrid[tile.get_tileY(), tile.get_tileX()].color = new Color(255 / 255f, 255 / 255f, 255 / 255f);
                tilegrid[selectedUnit.get_x(), selectedUnit.get_y()].gameObject.GetComponent <Image>().sprite = blank_tile_img;

                grid[selectedUnit.get_y(), selectedUnit.get_x()] = null; //remove unit from grid

                //set new tile to unit's tileportrait
                tilegrid[tile.get_tileY(), tile.get_tileX()].sprite = selectedUnit.get_tilePortrait();

                selectedUnit.set_x(tile.get_tileY());
                selectedUnit.set_y(tile.get_tileX());

                grid[selectedUnit.get_y(), selectedUnit.get_x()] = selectedUnit;
                //Debug.Log("placed " + selectedUnit.get_nom() + " at y=" + selectedUnit.get_y() + " x=" + selectedUnit.get_x());
                selectedUnit = null;
            }
        }
        //if the tile has a unit on it
        else
        {
            selectedUnit = grid[tile.get_tileX(), tile.get_tileY()];
            preview_unit(selectedUnit);
            //Debug.Log("selected " + selectedUnit.get_nom() + "at y=" + selectedUnit.get_y() + " x=" + selectedUnit.get_x());
        }
    }
コード例 #2
0
ファイル: Pattern.cs プロジェクト: aoue/DF---unity
 public void unhighlight_tile(PatternSlot tile)
 {
     if (selectedUnit != null)
     {
         preview_unit(selectedUnit);
     }
     tilegrid[tile.get_tileY(), tile.get_tileX()].color = new Color(255f / 255f, 255f / 255f, 255f / 255f); //make white
 }
コード例 #3
0
ファイル: Pattern.cs プロジェクト: aoue/DF---unity
 public void hightlight_tile(PatternSlot tile)
 {
     //when a tile is moused over, if there is no unit, then highlight it
     if (grid[tile.get_tileX(), tile.get_tileY()] == null)
     {
         //Debug.Log("trying to highlight tile " + tile.get_tileY() + ", " + tile.get_tileX());
         tilegrid[tile.get_tileY(), tile.get_tileX()].color = new Color(0 / 255f, 0 / 255f, 150 / 255f); //change colour
     }
     else //if there is a unit, preview it and highlight it lighting
     {
         preview_unit(grid[tile.get_tileX(), tile.get_tileY()]);
         tilegrid[tile.get_tileY(), tile.get_tileX()].color = new Color(0 / 255f, 150 / 255f, 150 / 255f); //change colour
     }
 }