Пример #1
0
    private void SelectUnit(Unit unit)
    {
        selectedUnit = unit;

        uiManager.SelectedUnit(selectedUnit, playerMana);

        ClearIndicators();

        // add selection indicator
        Vector2Int[] selectIndicatorPoss = { unit.GetPosition() };
        indicatorManager.AddIndicators(selectIndicatorPoss, selectIndicatorColor, true);

        var selectedAlly = selectedUnit as Ally;

        if (selectedAlly != null)
        {
            // add move indicators
            if (selectedAlly.GetNumMovesLeft() > 0)
            {
                moveIndicatorNodes.Clear();
                var indicatorPoss = new List <Vector2Int>();
                foreach (var move in board.GetWalkablePossInRange(selectedUnit.GetPosition(), selectedUnit.GetMoveRange()))
                {
                    moveIndicatorNodes.Add(move);
                    indicatorPoss.Add(move.pos);
                }
                indicatorManager.AddIndicators(indicatorPoss, moveIndicatorColor);
            }

            // add attack indicators
            if (selectedAlly.GetNumAttacksLeft() > 0)
            {
                attackIndicatorPoss.Clear();
                foreach (var posNode in board.GetPossWithEnemyInRange(selectedUnit.GetPosition(), selectedUnit.GetAttackRange()))
                {
                    attackIndicatorPoss.Add(posNode.pos);
                }
                indicatorManager.AddIndicators(attackIndicatorPoss, attackIndicatorColor, true);
            }
        }
    }