private void OnRoundOver_Internal() { if (!m_RoundIsOver) { PlayerHealthComponent player1HealthComp = GameManager.Instance.GetPlayerComponent <PlayerHealthComponent>(EPlayer.Player1); m_PlayersEndRoundHPPercentage[0] = player1HealthComp.GetHPPercentage(); PlayerHealthComponent player2HealthComp = GameManager.Instance.GetPlayerComponent <PlayerHealthComponent>(EPlayer.Player2); m_PlayersEndRoundHPPercentage[1] = player2HealthComp.GetHPPercentage(); if (m_PlayersEndRoundHPPercentage[0] > m_PlayersEndRoundHPPercentage[1]) { UpdateRoundVictoryCounter(ELastRoundWinner.Player1); } else if (m_PlayersEndRoundHPPercentage[1] > m_PlayersEndRoundHPPercentage[0]) { UpdateRoundVictoryCounter(ELastRoundWinner.Player2); } else { uint maxRoundsToWin = m_GameConfig.m_MaxRoundsToWin; if (GetPlayerRoundVictoryCounter(EPlayer.Player1) < maxRoundsToWin - 1 && GetPlayerRoundVictoryCounter(EPlayer.Player2) < maxRoundsToWin - 1) { UpdateRoundVictoryCounter(ELastRoundWinner.Both); } m_LastRoundWinner = ELastRoundWinner.Both; } m_RoundIsOver = true; OnRoundOver?.Invoke(m_LastRoundWinner); m_PlayWonAndLostRoundAnimCoroutine = PlayWonAndLostRoundAnimation(); GameManager.Instance.StartCoroutine(m_PlayWonAndLostRoundAnimCoroutine); } }
private void UpdateRoundVictoryCounter(ELastRoundWinner roundWinner) { switch (roundWinner) { case ELastRoundWinner.Player1: case ELastRoundWinner.Player2: m_PlayersRoundVictoryCounter[(int)roundWinner]++; break; case ELastRoundWinner.Both: m_PlayersRoundVictoryCounter[(int)EPlayer.Player1]++; m_PlayersRoundVictoryCounter[(int)EPlayer.Player2]++; break; } m_LastRoundWinner = roundWinner; OnRoundVictoryCounterChanged?.Invoke(); }