Exemplo n.º 1
0
    private void OnCollisionEnter(Collision other)
    {
        if (!other.transform.CompareTag("Platform"))
        {
            return;
        }

        // Play land sound
        audioPlayer.Play("Land");
        // Reset audio pitch
        audioPlayer.ResetPitch();

        // Spawn new platform
        gameController.SpawnPlatform();

        // Trigger landing animations
        animator.SetTrigger(Land);
        gameController.currentPlatform.GetComponent <Animator>().SetTrigger(Land);

        // Camera start following player
        mainCamera.IsFollowing = true;
        isGrounded             = true;

        // Pad active
        pad.SetActive(true);

        // Calculate next perfect path
        perfectPath.CalculateNextPath(gameController.nextPlatform, this);

        // Add an explosion
        Instantiate(explosion, transform.position, explosion.transform.rotation);

        if (gameController.GameState == GameState.Started)
        {
            // Init pop up text
            popUpText.Init(quotes[Random.Range(0, quotes.Length)]);

            // Add score
            gameController.AddScore(1);
        }

        // Shake camera
        cameraShake.Shake();
    }