예제 #1
0
    public void Init(Targets targets = Targets.enemy)
    {
        bsMachine.TransitionToState(BattleStateMachine.MenuState.Targetting);

        _showHighlights = true;
        HighlightAll    = HighlightEnemies = HighlightTeam = false;
        switch (targets)
        {
        case Targets.enemy:
            for (int i = 0; i < unitSlots.Length; i++)
            {
                if (unitSlots[i].IsEnemy && unitSlots[i].GetUnit() != null &&
                    !unitSlots[i].GetUnit().GetComponent <BattleUnitEnemy>().IsDead)
                {
                    currentHighlight = unitSlots[i];
                    break;
                }
            }

            break;

        case Targets.teammate:
            for (int i = 0; i < unitSlots.Length; i++)
            {
                if (!unitSlots[i].IsEnemy &&
                    !unitSlots[i].GetUnit().GetComponent <BattleUnitPlayer>().IsDead)
                {
                    currentHighlight = unitSlots[i];
                    break;
                }
            }
            break;

        case Targets.allEnemies:
            HighlightEnemies = true;
            for (int i = 0; i < unitSlots.Length; i++)
            {
                if (unitSlots[i].IsEnemy)
                {
                    currentHighlight = unitSlots[i];
                    break;
                }
            }
            break;

        case Targets.all:
            HighlightAll     = true;
            currentHighlight = null;
            break;

        case Targets.team:
            HighlightTeam    = true;
            currentHighlight = null;
            break;

        default:
            Debug.Log("invalid choice");
            break;
        }
    }
예제 #2
0
    public void OpenList(List type)
    {
        if (type != List.None && type != List.JustHide)
        {
            //Transition to Ability List
            bsMachine.TransitionToState(BattleStateMachine.MenuState.AbilityList);
            currentList = currentlySelected;
            ListOpen    = true;
            //SlashList.SetActive(type == List.Slash);
            //CrushList.SetActive(type == List.Crush);
            //ItemList.SetActive(type == List.Item);

            Button[] abilities = GetListFromEnum(type).GetComponentsInChildren <Button>();
            OrganizeList(abilities);
            eventSystem.SetSelectedGameObject(abilities[0].gameObject);
        }
        else if (type == List.JustHide)
        {
            //Just hide lists and action buttons
            ListOpen    = true;
            currentList = currentlySelected;
            //SlashList.SetActive(type == List.Slash);
            //CrushList.SetActive(type == List.Crush);
            //ItemList.SetActive(type == List.Item);
            eventSystem.SetSelectedGameObject(null);
            eventSystem.UpdateModules();
        }
        else
        {
            //Hide Lists
            bsMachine.TransitionToState(BattleStateMachine.MenuState.ActionButtons);
            ListOpen          = false;
            currentlySelected = currentList;
            eventSystem.SetSelectedGameObject(currentlySelected);
            eventSystem.UpdateModules();
            //SlashList.SetActive(type == List.Slash);
            //CrushList.SetActive(type == List.Crush);
            //ItemList.SetActive(type == List.Item);
        }
    }
예제 #3
0
    public void UpdateTurnLogic()
    {
        #region check win

        _playerCount = 0;
        _enemyCount  = 0;

        foreach (BattleUnitBase unit in _units)
        {
            if (!unit || unit.IsDead)
            {
                continue;
            }

            if (unit is BattleUnitPlayer)
            {
                _playerCount++;
            }

            if (unit is BattleUnitEnemy)
            {
                _enemyCount++;
            }
        }

        if (_playerCount == 0)
        {
            Debug.Log("Player lost, reloading scene");
            GameManager.ReloadScene();
        }

        if (_enemyCount == 0)
        {
            Debug.Log("Enemy lost, loading new wave");
            _waveManager.NextWave();
        }

        #endregion

        #region turn done logic

        foreach (BattleUnitBase unit in _units)
        {
            if (!unit || unit.IsDead || unit.isDoneForTurn)
            {
                continue;
            }

            if (unit is BattleUnitPlayer && !_playerTurn)
            {
                Debug.Log("I thought that this would not come up :)");
                continue;
            }

            if (unit is BattleUnitEnemy && _playerTurn)
            {
                Debug.Log("I thought that this would not come up :)");
                continue;
            }

            return;
        }
        #endregion

        // switch turn
        _playerTurn = !_playerTurn;

        #region start turn logic

        foreach (BattleUnitBase unit in _units)
        {
            if (_playerTurn && unit is BattleUnitPlayer)
            {
                (unit as BattleUnitPlayer).StartTurn();
            }

            if (!_playerTurn && unit is BattleUnitEnemy)
            {
                (unit as BattleUnitEnemy).StartTurn();
            }
        }

        if (_playerTurn)
        {
            bsMachine.TransitionToState(BattleStateMachine.MenuState.ActionButtons);
        }
        else
        {
            StartCoroutine("EnemyLoop");
        }
        #endregion
    }