Пример #1
0
    private void ChooseAction()
    {
        Debug.Log("Choose action");
        List <GameObject> unitsWithTarget = Units.FindAll((GameObject o) => o.GetComponent <BattleUnit>().HasUnitsInAttackRange());

        if (unitsWithTarget.Count > 0)
        {
            Debug.Log("attack");
            CurrentUnit = unitsWithTarget[UnityEngine.Random.Range(0, unitsWithTarget.Count)];
            List <GameObject> possibleTargets = CurrentUnit.GetComponent <BattleUnit>().GetUnitsInRange();
            Attack(possibleTargets[UnityEngine.Random.Range(0, possibleTargets.Count)]);
        }
        else
        {
            Move();
        }
    }
Пример #2
0
    private void HighlightTiles()
    {
        switch (state)
        {
        case ControllerState.Atttacking:
            GridController.GetGridController().EnableValidTiles((Tile t) => { return(UnitInAttackRange(t, CurrentUnit) &&
                                                                                     t.CurrentUnit.GetComponent <BattleUnit>().team != CurrentUnit.GetComponent <BattleUnit>().team); });
            break;

        case ControllerState.Moving:
            GridController.GetGridController().EnableValidTiles((Tile t) => { return(TileInMoveRange(t, CurrentUnit)); });
            break;

        case ControllerState.ModePicking:
            GridController.GetGridController().SetGridEnabled(false);
            break;
        }
        UpdateDisplayedButtons();
    }