Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (_roundManager.RoundIsReady())
        {
            // Progress GM specific time
            _gameTimer += Time.deltaTime;

            // Update player energies
            if (_gameTimer >= CreationTime)
            {
                _playerManager.AddEnergyToPlayers();

                _playerViewOutputController.UpdatePlayerView(ConvertToPlayerData(Constants.PLAYER_ONE));
                _playerViewOutputController.UpdatePlayerView(ConvertToPlayerData(Constants.PLAYER_TWO));
                _gameTimer = 0.0f;
            }


            // Check for game end
            if (_playerManager.GetPlayersCurrentHealth(Constants.PLAYER_ONE) <= 0)
            {
                _roundManager.EndRound(Constants.PLAYER_TWO);

                CheckForWinner();
            }
            else if (_playerManager.GetPlayersCurrentHealth(Constants.PLAYER_TWO) <= 0)
            {
                _roundManager.EndRound(Constants.PLAYER_ONE);

                CheckForWinner();
            }
        }
    }
Exemplo n.º 2
0
 public void StartGame()
 {
     FindObjectOfType <AudioManager>().Play("Music");
     hideTitleMenu();
     roundManager.ResetGame();
     roundManager.EndRound();
 }
Exemplo n.º 3
0
    public void ReturnsWinnerIfBestOfIsReached()
    {
        _roundManager.EndRound(1);

        Assert.IsFalse(_roundManager.HasWinner());

        _roundManager.EndRound(1);

        Assert.IsFalse(_roundManager.HasWinner());

        _roundManager.EndRound(1);

        Assert.IsTrue(_roundManager.HasWinner());
        Assert.AreEqual(1, _roundManager.GetWinner());



        _roundManager = new RoundManager(3);
        _roundManager.SetVisual(new NullRoundManagerVisual());

        _roundManager.EndRound(0);

        Assert.IsFalse(_roundManager.HasWinner());

        _roundManager.EndRound(1);

        Assert.IsFalse(_roundManager.HasWinner());

        _roundManager.EndRound(0);

        Assert.IsTrue(_roundManager.HasWinner());
        Assert.AreEqual(0, _roundManager.GetWinner());
    }
Exemplo n.º 4
0
    public void TracksCurrentRound()
    {
        Assert.AreEqual(1, _roundManager.GetCurrentRound());

        _roundManager.EndRound(42);

        Assert.AreEqual(2, _roundManager.GetCurrentRound());
    }
    public IEnumerator InformThatRoundIsReadyOnceVisualIsDone()
    {
        _roundManager.EndRound(0);

        Assert.IsFalse(_roundManager.RoundIsReady());

        yield return(new WaitForSeconds(2.0f));

        Assert.IsTrue(_roundManager.RoundIsReady());
    }
Exemplo n.º 6
0
    public void SuddenDeathOnTieGameWithEvenNumberOfRounds()
    {
        _roundManager = new RoundManager(2);
        _roundManager.SetVisual(new NullRoundManagerVisual());

        _roundManager.EndRound(0);

        _roundManager.EndRound(1);

        Assert.IsFalse(_roundManager.HasWinner());

        _roundManager.EndRound(0);

        Assert.IsTrue(_roundManager.HasWinner());
        Assert.AreEqual(0, _roundManager.GetWinner());
    }
Exemplo n.º 7
0
 public void OnEndRoundButtonPressed()
 {
     RoundManager.ServerWarmupStarted -= OnWarmupStarted;
     RoundManager.ServerRoundStarted  -= OnRoundStarted;
     RoundManager.ClientTimerUpdated  -= OnTimerUpdated;
     roundManager?.EndRound();
 }
Exemplo n.º 8
0
 public void LeaveGame()
 {
     // Stop player from toggling the Escape Menu
     UiManager.Instance.SetEscMenuValid(false);
     // Boot to main menu
     UiManager.Instance.ShowMainMenu();
     // If roundmanager exists, end round
     if (roundManager != null)
     {
         roundManager.EndRound();
     }
     if (localPlayerObject != null)
     {
         localPlayerObject.DestroyCharacter();
         Destroy(localPlayerObject.gameObject);
     }
     UiManager.Instance.minimap.RemoveTarget();
     // Forget previous character selections
     characterSelectionManager.Reset();
     PhotonNetwork.Disconnect();
 }
Exemplo n.º 9
0
        //
        public void HandleRoundButton()
        {
            RoundManager roundManager = RoundManager.singleton;

            if (roundManager.IsOnWarmup || roundManager.IsRoundStarted)
            {
                startRoundButtonText.text = "start round";
                startRoundImage.color     = MaterialChanger.GetColor(MaterialChanger.Palette01.green);
                roundManager.EndRound();
            }

            else if (!roundManager.IsRoundStarted || !roundManager.IsOnWarmup)
            {
                startRoundButtonText.text = "stop round";
                startRoundImage.color     = MaterialChanger.GetColor(MaterialChanger.Palette01.red);
                roundManager.StartWarmup();
            }
        }
Exemplo n.º 10
0
    /// <summary>
    /// Audio callback, called ever ~20ms. About as close to the beat as we can get.
    /// </summary>
    /// <param name="data"></param>
    /// <param name="channels"></param>
    private void Update()
    {
        double beat = (_audioSource.time) / (.5 * 60.0 / _bpm);

        beat %= 8;
        _currentBeatUnQuantized = beat;
        beat = (int)beat;
        if (lastTime != beat)
        {
            BeatEvent.Invoke((int)beat, _accentBeats[(int)beat]);
            lastTime = (int)beat;
        }

        if (_isPlaying && !_audioSource.isPlaying)
        {
            _roundManager.EndRound();
            _isPlaying = false;
        }
        _timeElapsed += Time.deltaTime;
    }
Exemplo n.º 11
0
    void OnTimerEnd()
    {
        var winner = roundManager.GetWinnerIndex();

        gameScore[winner]++;
        roundManager.EndRound();

        bool gameWinner = false;

        foreach (var score in gameScore)
        {
            if (score.Value > 1)
            {
                EndGame(score.Key);
                gameWinner = true;
            }
        }

        if (!gameWinner)
        {
            int[] scores = new int[4];
            scores[0] = gameScore[0];
            scores[1] = gameScore[1];
            scores[2] = gameScore[2];
            scores[3] = gameScore[3];

            uiManager.SetPlayerScores(scores);

            // Reinitialize the RoundManager
            roundManager.InitializeNewRound(gameSetup);

            uiManager.ResetTimer();
            uiManager.DisplayGameUI(false, gameSetup);
            uiManager.PlayRoundIntro(OnRoundIntroPlayed);
        }
    }