Ejemplo n.º 1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Target"))             // Check if player has arrived at target.
        {
            arrivedAtTarget = true;
        }

        if (other.CompareTag("Hand"))               // If the hand has grabbed the player.  The GAME IS OVER!
        {
            gameOver = true;
            GameManager.Instance.gameSettings.gameStart = false;
            GameManager.Instance.gameSettings.ZeroSpeed();
            HandMovement hand = other.gameObject.GetComponentInParent <HandMovement>();
            transform.parent.position = hand.GetGrabPosition().position;
            hand.SetGrabAnim();
            hand.SetGameOver(true);
            m_Animations.Play(PlayerAnimation.PlayerStates.Caught);
            m_PlayerAudio.PlaySound(3);
            AttachToHand(hand.yogurtGrabPos);
            StartCoroutine(FadeOutSprite(shadowSprite));
            m_CurrentState = State.EndGame;
            if (m_GameController != null)
            {
                m_GameController.SetGameOver(true);
            }
            else if (m_GC != null)
            {
                m_GC.SetGameOver(true);
            }
        }

        if (other.CompareTag("KillBox"))
        {
            gameOver = true;
            GameManager.Instance.gameSettings.gameStart = false;
            GameManager.Instance.gameSettings.ZeroSpeed();
            m_PlayerAudio.PlaySound(3);
            StartCoroutine(FadeOutSprite(shadowSprite));
            m_CurrentState = State.EndGame;
            if (m_GameController != null)
            {
                m_GameController.SetGameOver(true);
            }
            else if (m_GC != null)
            {
                m_GC.SetGameOver(true);
            }
        }

        if (other.CompareTag("Collectable"))        // Pick up a collectable that gives you points
        {
            //Debug.Log("CANDY!");
            effectController.Collected();
            if (m_GameController != null)
            {
                m_GameController.IncrementScore(125);   // Increment score [NOTE: there is a better way to do this.]
            }
            else if (m_GC != null)
            {
                m_GC.IncrementScore(125);
            }
            m_PlayerAudio.PlaySound(1);
        }

        if (other.CompareTag("Obstacle"))           // Hit an obstacle
        {
            effectController.Hit();
            //Debug.Log("OBSTACLE!");
            m_PlayerAudio.PlaySound(2);
            GetHit();
        }

        if (other.CompareTag("ObstacleLarge"))           // Hit a large obstacle
        {
            effectController.Hit();
            //Debug.Log("OBSTACLE!");
            m_PlayerAudio.PlaySound(2);
            GetBigHit();
        }

        if (other.CompareTag("SpeedModifier"))      // Collectable that slows down the speed
        {
            if (!speedModifierChecker)
            {
                StartCoroutine(SpeedModifierEffect(speedModifierDuration, speedModifierAmount));
            }
        }

        if (other.CompareTag("Spoon"))
        {
            Surf(true);
        }

        if (other.CompareTag("JumpHeight"))         // If the player hits the "ceiling" of it's jump
        {
            isFallingDown = true;
        }
    }