예제 #1
0
    IEnumerator CombatPhase()
    {
        string moveData = "";
        string output   = SceneManager.GetActiveScene().name + "\n";

        while (!CombatComplete())
        {
            SortUnitsBySpeed(units);
            foreach (Unit u in units)
            {
                u.SetTurnComplete(false);
                if (u.GetTaunting())
                {
                    u.SetTaunt(false);
                }
                if (!u.GetDead() && u.GetStatus() != Status.STUNNED && !CombatComplete())
                {
                    output  += "\n" + u.gameObject.name + "\'s Turn. \n";
                    moveData = u.DoMove(playerManager.Players, enemyManager.Enemies);
                    while (!u.GetTurnComplete())
                    {
                        yield return(new WaitForSeconds(0.05f));
                    }
                    if (moveData == "")
                    {
                        moveData = u.GetOutputLog();
                    }

                    output += moveData;
                    scrollWindow.GetComponentInChildren <Text> ().text = output.Replace("\n", Environment.NewLine);
                }
                else
                {
                    u.SetStatus(Status.NONE);
                }
                yield return(new WaitForSeconds(1.0f));
            }
        }
        foreach (Unit u in units)
        {
            u.GetComponentInChildren <Canvas> ().sortingOrder = 0;
        }
        WriteToOutputFile(output);

        if (Victory())
        {
            sceneNavigator.GoToVictoryScreen();
        }
        else
        {
            sceneNavigator.GoToDefeatScreen();
        }
        //if victory go to victory / level up screen
        //if defeat try again
    }