Ejemplo n.º 1
0
        private void OnCollisionEnter(Collision other)
        {
            switch (other.gameObject.tag)
            {
            case "Food":
                other.gameObject.SetActive(false);
                pacmanScore.AddScore(Constants.FOOD_SCORE);
                audioManager.Play(SoundNames.FOOD);
                goManager.CountFood();

                if (goManager.GetNumberOfFood() <= 0)
                {
                    gameEventManager.CompleteLevel();
                }
                else if (goManager.GetNumberOfFood().IsAMultipleOf(Constants.FRUIT_EATEN_BEFORE_SPEED_INCREASE))
                {
                    audioManager.GetSound(SoundNames.GHOST_MOVE).source.pitch += Constants.GHOST_SPEED_INCREASE_PITCH_INCREASE;
                    foreach (Ghost ghost in goManager.GetGhosts())
                    {
                        ghost.IncreaseSpeed();
                    }
                }
                break;

            case "Powerup":
                debugger.Info("activated powerup");
                other.gameObject.SetActive(false);
                audioManager.PlayForDuration(SoundNames.GHOST_EDIBLE, Constants.POWERUP_DURATION);
                goManager.MakeGhostsEdible();
                pacmanMovement.BoostSpeed();
                break;

            case "Cherry":
                debugger.Info("collected a cherry");
                audioManager.Play(SoundNames.EAT_FRUIT);
                pacmanScore.AddScore(Constants.FRUIT_EATEN_SCORE);
                Destroy(other.gameObject);
                break;
            }
        }