Пример #1
0
        public bool HandleEvent(AFEvent afEvent)
        {
            switch (afEvent.type)
            {
            case AFEventType.KILLED:
            {
                HandlePlayerKilledEvent((KilledEventPayload)afEvent.payload);
                return(true);
            }

            case AFEventType.PLAYERS_ALL_CREATED:
            {
                var payload = (PlayersAllCreatedPayload)afEvent.payload;
                HandleGameStart(payload.AllPlayers);
                return(true);
            }

            case AFEventType.COUNT_DOWN_FINISHED:
            {
                var payload = (CountDownFinishedPayload)afEvent.payload;
                if (!payload.TimerName.Equals(RoundTimerName))
                {
                    break;
                }
                countDownTimerInstance.StopTimer();
                if (IsEntireGameOver())
                {
                    Debug.Log("Game over, time ran out!");
                    var winningScore = currentRoundScores.SortedByDescendingScores()[0];
                    AFEventManager.INSTANCE.PostEvent(AFEvents.GameOver(winningScore.PlayerNumber(), winningScore.Score(), winningScore.PlayerColor()));
                }
                else
                {
                    Debug.Log("Round over, time ran out!");
                    var winningScore = currentRoundScores.SortedByDescendingScores()[0];
                    AFEventManager.INSTANCE.PostEvent(AFEvents.RoundOver(winningScore.PlayerNumber(), winningScore.Score(), winningScore.PlayerColor()));
                }
                break;
            }

            case AFEventType.GAME_START:
            {
                countDownTimerInstance.StartTimer();
                break;
            }
            }
            return(false);
        }
Пример #2
0
    public void GameOver()
    {
        Time.timeScale = 0f;
        audioSource.Stop();
        audioSource.PlayOneShot(gameOverSound);
        og.CancelGenerateObject();
        cdTimer.StopTimer();

        gameOver = (GameObject)Resources.Load("Prefab/GameOverPanel");
        GameObject gameOverPrefab = (GameObject)Instantiate(gameOver);

        gameOverPrefab.transform.SetParent(canvas.transform, false);

        buttons = gameOverPrefab.GetComponentsInChildren <Button>();
        buttons[0].onClick.AddListener(Retry);
        buttons[1].onClick.AddListener(Title);
    }
Пример #3
0
 public void EndGame()
 {
     timer.StopTimer();
     SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
 }