Ejemplo n.º 1
0
    private void GameManager_OnGameStateChanged(GameState newState)
    {
        switch (newState)
        {
        case GameState.NotStarted:
            Initialize();
            ActiveShape?.gameObject?.SetActive(false);
            NextShape?.gameObject?.SetActive(false);
            landingGuideShape?.gameObject?.SetActive(false);
            gridHandler?.SetObstacleActive(false);
            break;

        case GameState.Playing:
            ActiveShape?.gameObject?.SetActive(true);
            NextShape?.gameObject?.SetActive(true);
            landingGuideShape?.gameObject?.SetActive(true);
            gridHandler?.SetObstacleActive(true);
            break;

        case GameState.Paused:
            ActiveShape?.gameObject?.SetActive(false);
            NextShape?.gameObject?.SetActive(false);
            landingGuideShape?.gameObject?.SetActive(false);
            gridHandler?.SetObstacleActive(false);
            break;

        case GameState.Over:
            Destroy(ActiveShape?.gameObject);
            Destroy(NextShape?.gameObject);
            Destroy(landingGuideShape?.gameObject);

            gridHandler.GrayoutObstacles();
            break;

        case GameState.Restart:
            gridHandler.ClearGrid();
            Initialize();
            gameManager.GameState = GameState.Playing;
            break;
        }
    }