Пример #1
0
 public void notifyMatchFinished(bool bOwnerWon, TDWinCondition winCondition)
 {
     if (m_roundText)
     {
         if (!gameOverManager)
         {
             gameOverManager = FindObjectOfType <GameOver>();
         }
         if (winCondition == TDWinCondition.Tie)
         {
             m_roundText.text = "Draw";
             gameOverManager.SetGameOverScreen("Draw");
         }
         else if (bOwnerWon)
         {
             m_roundText.text = "You Won!";
             gameOverManager.SetGameOverScreen("Win");
         }
         else
         {
             m_roundText.text = "You Lost...";
             gameOverManager.SetGameOverScreen("Lose");
         }
         m_roundText.gameObject.SetActive(true);
     }
 }
Пример #2
0
 public void finishMatch(TDWinCondition winCondition, int winnerId)
 {
     if (PhotonNetwork.IsConnected)
     {
         photonView.RPC("onMatchFinishedRPC", RpcTarget.All, (byte)winCondition, winnerId);
     }
     else
     {
         onMatchFinishedRPC((byte)winCondition, winnerId);
     }
 }
Пример #3
0
    private void onWaveFinishedImpl()
    {
        if (PhotonNetwork.IsConnected && !PhotonNetwork.IsMasterClient)
        {
            return;
        }

        if (m_waveSpawner.isValidWaveId(m_waveNum + 1))
        {
            if (PhotonNetwork.IsConnected)
            {
                photonView.RPC("onWaveFinishedRPC", RpcTarget.All);
            }
            else
            {
                onWaveFinishedRPC();
            }

            Invoke("startNextWave", Mathf.Max(m_waveDelay, 1f));
        }
        else
        {
            // Use player 1 as winner by default (Play in Editor)
            int winnerId = 0;

            if (PhotonNetwork.IsConnected)
            {
                // Actually find the winner
                winnerId = -1;

                // Check who has more health
                if (PlayerController.localPlayer.Health > PlayerController.remotePlayer.Health)
                {
                    winnerId = PlayerController.localPlayer.playerId;
                }
                else if (PlayerController.remotePlayer.Health > PlayerController.localPlayer.Health)
                {
                    winnerId = PlayerController.remotePlayer.playerId;
                }
            }

            TDWinCondition winCondition = TDWinCondition.Tie;
            if (winnerId != -1)
            {
                winCondition = TDWinCondition.OutOfTime;
            }

            finishMatch(winCondition, winnerId);
        }
    }
Пример #4
0
    public void notifyMatchFinished(TDWinCondition winCondition, int winnerId)
    {
        m_canPlaceTowers   = false;
        m_canSpawnMonsters = false;
        m_canUseAbilities  = false;

        bool bIsWinner = winnerId == m_id;

        if (m_playerUI)
        {
            m_playerUI.notifyMatchFinished(bIsWinner, winCondition);
        }

        // for now
        GameManager.manager.Invoke("LeaveGame", 5f);
    }
Пример #5
0
    private void onMatchFinishedRPC(byte condAsByte, int winnerId)
    {
        matchState = TDMatchState.PostMatch;

        TDWinCondition winCondition = (TDWinCondition)condAsByte;

        PlayerController.localPlayer.notifyMatchFinished(winCondition, winnerId);

        if (m_cosmetics)
        {
            m_cosmetics.playMatchEndSound(PlayerController.localPlayer.playerId == winnerId);
        }

        if (!PhotonNetwork.IsConnected || PhotonNetwork.IsMasterClient)
        {
            m_waveSpawner.onWaveFinished      -= onWaveFinished;
            MonsterManager.onMonsterDestroyed -= onMonsterDestroyed;
        }
    }