コード例 #1
0
 private void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.CompareTag("Player"))
     {
         killPlayer.isPlayerDead = true;
         playerManager.RespawnPlayer();
         camShaker.camShake();
         timeMaster.CutTimeInHalf();
         timeMaster.IncrementNumOfResets();
     }
 }
コード例 #2
0
 private void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.CompareTag("Player"))
     {
         playerManager.RespawnPlayer();
         camShaker.camShake();
         timeMaster.CutTimeInHalf();
         timeMaster.IncrementNumOfResets();
         deathSound.Play();
     }
 }
コード例 #3
0
ファイル: PlayerMovement.cs プロジェクト: Miki-Miki/Santrum
    void Update()
    {
        //    Jump
        // -----------
        // Checking if player grounded by OverlapCircle positioned at player's feet
        isGrounded = Physics2D.OverlapCircle(feetPosition.position, checkRadius, whatIsGround);

        // Transforming player eulerAngles as for the sprite to face the direction of movement
        if (facingDirection == "RIGHT")
        {
            transform.eulerAngles = new Vector3(0, 0, 0);
        }
        else if (facingDirection == "LEFT")
        {
            transform.eulerAngles = new Vector3(0, 180, 0);
        }

        // Jumping
        if (isGrounded == true && Input.GetKeyDown(KeyCode.Space))
        {
            isJumping       = true;
            jumpTimeCounter = jumpTime;
            rb2d.velocity   = Vector2.up * jumpHeight;
        }

        // If the space bar is held down the jump is longer by how long we hold down < jumpTimeCounter
        if (Input.GetKey(KeyCode.Space) && isJumping == true)
        {
            if (jumpTimeCounter > 0)
            {
                rb2d.velocity    = Vector2.up * jumpHeight;
                jumpTimeCounter -= Time.deltaTime;
            }
            else
            {
                isJumping = false;
            }
        }

        if (Input.GetKeyUp(KeyCode.Space))
        {
            isJumping = false;
        }

        // -----------
        if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.DownArrow))
        {
            GetFacingDirection();
        }


        isDashing = dash.isDashing;
        //   Animation
        // -------------
        // Player
        anim.SetFloat("Speed", Mathf.Abs(moveInput));
        anim.SetBool("IsJumping", !isGrounded);
        anim.SetBool("IsDashing", isDashing);

        // Check if player dead
        if (deadlyObjects != null && deadlyObjects.isPlayerDead)
        {
            RespawnPlayer();
            cameraShaker.camShake();
            timeMaster.CutTimeInHalf();
            timeMaster.IncrementNumOfResets();
            Debug.Log("Player dead?");
        }

        //  Timer
        // --------
        if ((Input.GetAxis("Horizontal") > Mathf.Abs(startingOffset) ||
             Input.GetAxis("Vertical") > Mathf.Abs(startingOffset)) &&
            timeMaster != null)
        {
            timeMaster.isStarted = true;
        }

        if (timeMaster != null && timeMaster.isTimeOver())
        {
            StartCoroutine(GameOver());
        }
    }