Exemplo n.º 1
0
        private void OnTriggerEnter2D(Collider2D collision)
        {
            if (TutorialCoordinator.IsControlTutorialActive || Player.State.IsDead)
            {
                return;
            }

            switch (collision.gameObject.layer)
            {
            // Trees and graves
            case 8:
            // Enemies
            case 10:
            case 18:
            // Ground
            case 14:
                Player.Kill();
                FlightCoordinator.OnPlayerDeath();
                break;

            // Pickup
            case 9:
                worldGenerator.RemoveContent(collision.GetComponentInParent <WorldTile>());
                switch (collision.name)
                {
                case "Coin":
                    Player.State.Coins          += GameState.CoinValue;
                    Player.State.CoinsCollected += GameState.CoinValue;
                    popUpSpawner.SpawnCoin(GameState.CoinValue);
                    AudioClipPlayer.PlayCoin();
                    break;

                case "Gem":
                    Player.State.Coins += GameState.CoinValue * 10;
                    popUpSpawner.SpawnCoin(GameState.CoinValue * 10);
                    AudioClipPlayer.PlayGem();
                    break;
                }

                break;

            // Web
            case 12:
                if (Player.IsBoosting)
                {
                    worldGenerator.RemoveContent(collision.GetComponentInParent <WorldTile>());
                }
                else
                {
                    Player.Kill();
                    FlightCoordinator.OnPlayerDeath();
                }

                break;

            // Checkpoint
            case 13:
                if (inCheckpoint)
                {
                    // Player sometimes collides with the same checkpoint twice
                    return;
                }

                inCheckpoint = true;
                StartCoroutine(WorldScroller.ActiveCheckpointSpeed());
                StartCoroutine(DelayedSpeedReset());
                worldGenerator.RemoveContent(collision.GetComponentInParent <WorldTile>());
                GameState.DifficultyLevel++;
                GameState.CoinValue += 2;
                var timeBonus = Player.State.RewardTimeBonus();
                Player.StartNewTimeBonusDrain();
                timeBonusViewModel.ShowTimeBonus(timeBonus);
                AudioClipPlayer.PlayCheckpoint();
                break;
            }
        }