コード例 #1
0
 public static void BattleFinished(DanceTeam winner)
 {
     if (OnBattleFinished != null)
     {
         OnBattleFinished(winner);
     }
 }
コード例 #2
0
ファイル: BattleSystem.cs プロジェクト: chayward-sae/Brief_2
    public float fightCompletedWaitTime = 2; // the amount of time we need to wait till a fight/round is completed.

    /// <summary>
    /// This occurs every round or every X number of seconds, is the core battle logic/game loop.
    /// </summary>
    /// <returns></returns>
    IEnumerator DoRound()
    {
        // waits for a float number of seconds....
        yield return(new WaitForSeconds(battlePrepTime));

        //checking for no dancers on either team
        if (teamA.allDancers.Count == 0 && teamB.allDancers.Count == 0)
        {
            Debug.LogWarning("DoRound called, but there are no dancers on either team. DanceTeamInit needs to be completed");
            // This will be called if there are 0 dancers on both teams.
        }
        else if (teamA.activeDancers.Count > 0 && teamB.activeDancers.Count > 0)
        {
            Debug.LogWarning("DoRound called, it needs to select a dancer from each team to dance off and put in the FightEventData below");

            //Randomly chooses team members to compete against each other
            Character teamAChosenOne = teamA.activeDancers[Random.Range(0, teamA.activeDancers.Count)];
            Character teamBChosenOne = teamB.activeDancers[Random.Range(0, teamB.activeDancers.Count)];

            fightManager.Fight(teamAChosenOne, teamBChosenOne);
        }
        else
        {
            //Sets the winning team based off who still has dancers.
            DanceTeam winner = null;

            if (teamA.activeDancers.Count > 0)
            {
                winner = teamA;
            }
            else if (teamB.activeDancers.Count > 0)
            {
                winner = teamB;
            }

            //Enables the win effects, and logs it out to the console.
            winner.EnableWinEffects();
            BattleLog.Log(winner.ToString(), winner.teamColor);

            Debug.Log("DoRound called, but we have a winner so Game Over");
        }
    }