예제 #1
0
    /// <summary>
    /// Handles the next unit.
    /// </summary>
    protected void HandleNextUnit()
    {
        if (enemyIndex == enemies.Count)           //If we reach the last unit end the turn
        {
            TurnInProgress = false;
            return;
        }

        currentUnit = enemies[enemyIndex];
        BoardManager.instance.StartTurn();
        currentUnit.StartTurn();
        enemyIndex++;

        if (!currentUnit.CanTakeTurn())           //If this unit can take its turn (no stuns)
        {
            HandleNextUnit();
            return;
        }
        StartCoroutine("MoveUnit");
    }
예제 #2
0
    /// <summary>
    /// Setup combat initialization like party, enemies, map, etc
    /// </summary>
    public void SetupCombat(int mapIndex, List <PartyUnit> currentParty, List <EnemyUnitInfo> listEnemies)
    {
        map       = BoardManager.instance.Maps [mapIndex];
        AIManager = gameObject.AddComponent <CombatAIManager> ();
        AIManager.combatManager = this;
        EnterStateWaiting();

        if (listEnemies.Count == 0)
        {
            Debug.LogError("No enemies found for combat, lots of errors incoming");
        }

        foreach (PartyUnit unit in currentParty)
        {
            GameObject go = Instantiate(unit.UnitPrefab) as GameObject;
            if (go.GetComponent <MyHeroController3rdPerson> ())
            {
                Destroy(go.GetComponent <MyHeroController3rdPerson> ());
            }
            go.AddComponent <PlayerControlledBoardUnit> ();
            go.AddComponent <AbilityActivator> ();
            PlayerControlledBoardUnit bu = go.GetComponent <PlayerControlledBoardUnit> ();
            bu.Initialize(unit);
            go.name = bu.UnitClass.ToString();
            bu.Spawn(BoardManager.instance.GetHexagonFromArray((int)map.PlayerSpawns [currentParty.IndexOf(unit)].x, (int)map.PlayerSpawns [currentParty.IndexOf(unit)].y));
            CurrentParty.Add(bu);
        }

        foreach (EnemyUnitInfo unit in listEnemies)
        {
            GameObject go = Instantiate(unit.UnitPrefab) as GameObject;
            go.AddComponent <NonPlayerControlledBoardUnit> ();
            go.AddComponent <AbilityActivator> ();
            NonPlayerControlledBoardUnit bu = go.GetComponent <NonPlayerControlledBoardUnit> ();
            bu.Initialize(unit);
            bu.Spawn(BoardManager.instance.GetHexagonFromArray((int)map.EnemySpawns [listEnemies.IndexOf(unit)].x, (int)map.EnemySpawns [listEnemies.IndexOf(unit)].y));
            CurrentEnemies.Add(bu);
        }

        StartTurn(CurrentParty [0]);          //should be started from a list of characters
    }