Example #1
0
    /// <summary>
    /// Select the specified unit, which will display all the tiles that it can move to
    /// </summary>
    /// <param name="pUnit">The specific unit that should be selected</param>
    public void SelectUnit(Unit pUnit)
    {
        if ((selectedUnit == null || !selectedUnit.IsMoving()) && !pUnit.GetSelected())
        {
            if (pUnit != null && pUnit != selectedUnit)
            {
                DeselectUnit();
            }

            canDeselect = false;

            pUnit.BecomeSelected();

            UnitSelectMessage message;
            message.unitID   = pUnit.GetID();
            message.selected = '1';

            ChampNetManager.SendUnitSelectMessage(message.unitID, message.selected);

            selectedUnit = pUnit;
            GridManagerScript.instance.DisplayWalkableTiles(pUnit.Tile, pUnit.GetMovesLeft(), pUnit.endedOnDiagonal);

            StartCoroutine(DeflagDeselect());
        }
    }
Example #2
0
    /// <summary>
    /// Deselect the selected unit, which will stop displaying it's walkable tiles.
    /// </summary>
    public void DeselectUnit()
    {
        if (canDeselect && selectedUnit && !selectedUnit.IsMoving())
        {
            UnitSelectMessage message;
            message.unitID   = selectedUnit.GetID();
            message.selected = '0';

            ChampNetManager.SendUnitSelectMessage(message.unitID, message.selected);

            selectedUnit.DeselectUnit();
            selectedUnit = null;
            GridManagerScript.instance.ClearDisplayedTiles();

            EndShooting();
        }
    }