Esempio n. 1
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.tag == "Player")
     {
         Death.KillPlayer();
     }
 }
Esempio n. 2
0
 private void OnTriggerEnter(Collider collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         Death de = collision.gameObject.GetComponentInParent <Death>();
         if (de != null)
         {
             de.KillPlayer();
         }
     }
 }
Esempio n. 3
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space) && isGround)
     {
         GetComponent <Rigidbody2D>().velocity = new Vector2(GetComponent <Rigidbody2D>().velocity.x, Jump);
     }
     if (Input.GetKeyDown(KeyCode.R))
     {
         death.KillPlayer();
     }
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         Application.Quit();
     }
 }
Esempio n. 4
0
    //void update()
    //{
    //    //Shoot a raycast down from the groundcheck transform.
    //    isGrounded = Physics.Raycast(groundCheck.position, Vector3.down, out hit, groundDistance);
    //    print(isGrounded);
    //    //if (isGrounded)
    //    //{
    //    //
    //    //    //Store the normal of the surface we are on.
    //    //    groundNormal = hit.normal;
    //    //
    //    //    if (playerGravity.velocity.y == -2 && stateManager.currentState != PlayerStateManager.PlayerState.Pushing && stateManager.currentState != PlayerStateManager.PlayerState.Primed && stateManager.currentState != PlayerStateManager.PlayerState.Grinding)
    //    //    {
    //    //        if (stateManager.doingTrick == true) //If they are doing a trick
    //    //        {
    //    //            //TODO DEATH/FAILURE/RAGDOLL METHOD HERE
    //    //            Debug.Log("The player failed to complete their trick before landing.");
    //    //            stateManager.ActiveState(PlayerStateManager.PlayerState.Ragdoll);
    //    //            death.KillPlayer();
    //    //            death.End();
    //    //        }
    //    //        else if (!horizontalMovement.leaning && !Input.GetKey("down"))
    //    //            stateManager.ActiveState(PlayerStateManager.PlayerState.Pushing);
    //    //        //And tell the state manager that the player is on the ground, pushing their scooter.
    //    //    }
    //    //    else if (!horizontalMovement.leaning && Input.GetKey("down") && playerGravity.velocity.y == -2 && stateManager.currentState == PlayerStateManager.PlayerState.Pushing && stateManager.currentState != PlayerStateManager.PlayerState.Primed && stateManager.currentState != PlayerStateManager.PlayerState.Grinding)
    //    //    {
    //    //        stateManager.ActiveState(PlayerStateManager.PlayerState.Manual);
    //    //    }
    //    //
    //    //    if (hit.transform.tag == "Ramp")
    //    //    {
    //    //        audioSource.clip = audioManager.clips[5];
    //    //        audioSource.Play();
    //    //    }
    //    //}
    //    //else if (stateManager.currentState == PlayerStateManager.PlayerState.Grinding)
    //    //    stateManager.currentState = PlayerStateManager.PlayerState.Airborne;
    //}

    private void OnTriggerEnter(Collider other)
    {
        //print(other.tag);
        if (other.tag == "Mountain" || other.tag == "Ramp" || other.tag == "Untagged" && !death.dead)
        {
            isGrounded = true;
            if (stateManager.currentState != PlayerStateManager.PlayerState.Pushing && stateManager.currentState != PlayerStateManager.PlayerState.Lean_Left && stateManager.currentState != PlayerStateManager.PlayerState.Lean_Right && stateManager.currentState != PlayerStateManager.PlayerState.Primed &&
                stateManager.currentState != PlayerStateManager.PlayerState.Primed_Left && stateManager.currentState != PlayerStateManager.PlayerState.Primed_Right && stateManager.currentState != PlayerStateManager.PlayerState.Manual)
            {
                stateManager.ActiveState(PlayerStateManager.PlayerState.Pushing);
            }
            if (other.tag == "Ramp")
            {
                audioSource.clip = audioManager.clips[5];
                audioSource.Play();
            }
            if (jumpSuccess)
            {
                comboManager.newComboValue = 1;
                comboManager.AddToCombo();
                jumpSuccess = false;
            }
        }
        if (other.tag == "Obstacle")
        {
            isOnObstacle = true;
            if (stateManager.currentState != PlayerStateManager.PlayerState.Pushing && stateManager.currentState != PlayerStateManager.PlayerState.Lean_Left && stateManager.currentState != PlayerStateManager.PlayerState.Lean_Right && stateManager.currentState != PlayerStateManager.PlayerState.Primed &&
                stateManager.currentState != PlayerStateManager.PlayerState.Primed_Left && stateManager.currentState != PlayerStateManager.PlayerState.Primed_Right && stateManager.currentState != PlayerStateManager.PlayerState.Manual)
            {
                stateManager.ActiveState(PlayerStateManager.PlayerState.Pushing);
            }
        }

        if (stateManager.doingTrick == true && isGrounded) //If they are doing a trick
        {
            //TODO DEATH/FAILURE/RAGDOLL METHOD HERE
            Debug.Log("The player failed to complete their trick before landing.");
            stateManager.ActiveState(PlayerStateManager.PlayerState.Ragdoll);
            death.KillPlayer();
            death.End();
            stateManager.doingTrick = false;
        }
    }