Exemple #1
0
    public void Update()
    {
        if (cc.IsTouchingLayers(LayerMask.GetMask("Player")) && !touching)
        {
            touching = true;
            UI_manager.ShowConvIndicator();
        }
        else if (!(cc.IsTouchingLayers(LayerMask.GetMask("Player"))) && touching)
        {
            touching = false;
            UI_manager.HideConvIndicator();
        }
        if (touching && !talking)
        {
            if (Input.GetKeyDown(KeyCode.S))
            {
                //Debug.Log("space received");
                talking = true;
                gameObject.GetComponent <DialogueTrigger>().TriggerDialogue();
            }
        }
        leftArea();

        // if Jelly is in the circle collider trigger of an NPC, the player should be able to talk to them by pressing a key
        // when those two conditions are met, it should trigger a function on the DialogueTrigger script called TriggerDialogue, which stores the character's dialogue
        // the trigger dialogue script will then trigger a function on DialogueManager to actually start the dialogue
    }
Exemple #2
0
    private void Jump()
    {
        //Debug.Log("y velocity: " + playerRigidBody.velocity.y);


        if (!(playerFeetCollider.IsTouchingLayers(LayerMask.GetMask("Ground")) || playerFeetCollider.IsTouchingLayers(LayerMask.GetMask("DropThroughGround"))))
        {
            return;
        }

        if (CrossPlatformInputManager.GetButtonDown("Jump"))
        {
            jump = true;
        }
        else
        {
            jump = false;
        }

        if (jump)
        {
            Vector2 jumpVelocityToAdd = new Vector2(0, jumpStrength);
            playerRigidBody.velocity += jumpVelocityToAdd;
            playerAnimator.SetBool("Jumping", true);
        }
        else
        {
            playerAnimator.SetBool("Jumping", false);
        }
    }
Exemple #3
0
    void Update()
    {
        if (Input.GetButtonDown("Jump"))
        {
            CancelInvoke();
            EnableJumpBuffer();
            Invoke("DisableJumpBuffer", 0.2f);
        }

        if (groundCheck.IsTouchingLayers(whatIsGround) && jumpBuffer == true)
        {
            Jump();
            GameObject go = Instantiate(jumpEffect, new Vector3(groundCheck.gameObject.transform.position.x, groundCheck.gameObject.transform.position.y, 0), Quaternion.Euler(-90, 0, 0));
            go.transform.localScale = new Vector3(1, 1, 1);
            Destroy(go, 2f);
            CancelInvoke();
            DisableJumpBuffer();
            doubleJump = false;
        }

        if (!groundCheck.IsTouchingLayers(whatIsGround) && jumpBuffer == true && doubleJump == false)
        {
            Jump();
            CancelInvoke();
            DisableJumpBuffer();
            doubleJump = true;
        }
    }
 void Update() //This built-in method runs during each frame.
 {
     boltUnusedForLongTime++;
     if (nlgMan.hasStabbed && !groundCircle.IsTouchingLayers(gnd))
     {
         nlgMan.aerialKill = true;
     }
     if (boltUnusedForLongTime > 10000)
     {
         nlgMan.boltUnusedForLong = true;
     }
     if (groundCircle.IsTouchingLayers(walls) && !wallL.IsTouchingLayers(walls) && !wallR.IsTouchingLayers(walls)) //If the groundCircle touches the walls and neither wallL nor wallR touches the walls, perform the following.
     {
         playerRgdBdy.AddForce(new Vector2(0, jumpForce / 4), ForceMode2D.Impulse);                                //Execute a small leap so that the player may not slide along horizontal segments of the wall.
         return;                                                                                                   //Ensure that there are no especially high leaps.
     }
     if (Input.GetKeyDown(KeyCode.Space) && !playerAnim.GetBool("isAttacking"))                                    //If the player has attacked and is not attacking, already, perform the following.
     {
         playerAnim.SetBool("isSliding", false);                                                                   //Stop the wall slide animation if the player is attacking.
         StartCoroutine(Strike());                                                                                 //Begin the Strike( ) function.
     }
     boltBar.sizeDelta = new Vector2(focusAmt, 5);                                                                 //Change the size of the boltBar given the focusAmt.
     movementAerial();                                                                                             //Execute the movementAerial( ) function.
     if (playerRgdBdy.velocity.y < -5)                                                                             //If the player's y-component velocity is less than -5 m/s, perform the following.
     {
         playerAnim.SetBool("isFalling", true);                                                                    //Begin the falling animation.
     }
     else
     {
         playerAnim.SetBool("isFalling", false); //Perform the jumping animation, instead.
     }
 }
Exemple #5
0
 public void FixedUpdate()
 {
     if (playerFound)
     {
         cc.isTrigger = true;
         direction    = (player.transform.position - orbtransform.position).normalized;
         force        = direction * speed;
         rb.AddForce(force * 15);
         if (cc.IsTouchingLayers(LayerMask.GetMask("Player")))
         {
             StartCoroutine(Absorb());
         }
     }
     else
     {
         if (cc.IsTouchingLayers(LayerMask.GetMask("Item")))
         {
             StartCoroutine(Absorb());
         }
     }
     if (active && !playerFound)
     {
         playerFound = cc.IsTouchingLayers(LayerMask.GetMask("Pickup"));
     }
 }
Exemple #6
0
    private void Jump()
    {
        if (myFeet.IsTouchingLayers(LayerMask.GetMask("Ground")) || myFeet.IsTouchingLayers(LayerMask.GetMask("Grabbable")) || myFeet.IsTouchingLayers(LayerMask.GetMask("Switch")))
        {
            myAnimator.SetBool("IsJumping", false);
        }
        else
        {
            return;
        }



        if (myjumpbutton.Pressed == true && canJump)
        {
            canJump = false;
            StartCoroutine(JumpCoroutine());
            Vector2 jumpVelocityToAdd = new Vector2(0f, jumpSpeed);
            myRigidBody.velocity += jumpVelocityToAdd;
            myAnimator.SetBool("IsJumping", true);
        }


        if (myRigidBody.velocity.y < 0)
        {
            myRigidBody.velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime;
        }
        else if (myRigidBody.velocity.y > 0 && !Input.GetButton("Jump"))
        {
            myRigidBody.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime;
        }
    }
    private void Movement()
    {
        //float hdirection = Input.GetAxis("Horizontal");
        //Moving Left
        //if (hdirection < 0)
        //{
        //    rb.velocity = new Vector2(-speed, rb.velocity.y);
        //    transform.localScale = new Vector2(-1, 1);
        //}
        //Moving right
        //else if (hdirection > 0)
        //{
        //    rb.velocity = new Vector2(speed, rb.velocity.y);
        //    transform.localScale = new Vector2(1, 1);
        //}
        horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;

        //Jumping
        if (Input.GetButtonDown("Jump") && !jumped)
        {
            //groundCheck.IsTouchingLayers(ground)
            if (circleColl.IsTouchingLayers(ground) || boxColl.IsTouchingLayers(ground) || coyote)
            {
                Jump();
            }
        }
    }
Exemple #8
0
    private void ClimbLadder()
    {
        if (!myCirclebody.IsTouchingLayers(LayerMask.GetMask("Climbing")))
        {
            myAnimator.SetBool("Climbing", false);
            myRigidBody.gravityScale = gravityScaleAtStart;
            if (timer == 1)
            {
                timeCollect[i] = Time.timeSinceLevelLoad;
                i++;
                timer = 0;
            }
            return;
        }

        //float controlThrow = CrossPlatformInputManager.GetAxis("Vertical");
        //Vector2 climbVelocity = new Vector2(myRigidBody.velocity.x, controlThrow * climbSpeed);
        float   controlThrow  = x;
        Vector2 climbVelocity = new Vector2(myRigidBody.velocity.x, controlThrow * climbSpeed);

        myRigidBody.velocity     = climbVelocity;
        myRigidBody.gravityScale = 0f;

        bool playerHasHorizontalSpeed = Mathf.Abs(myRigidBody.velocity.y) > Mathf.Epsilon;

        myAnimator.SetBool("Climbing", playerHasHorizontalSpeed);
        if (timer == 0)
        {
            timeCollect[i] = Time.timeSinceLevelLoad;
            i++;
            timer = 1;
        }
    }
Exemple #9
0
 void DestroyBullet()
 {
     if (myCircleCollider.IsTouchingLayers(LayerMask.GetMask("Player")) ||
         myCircleCollider.IsTouchingLayers(LayerMask.GetMask("Ground")))
     {
         Destroy(gameObject);
     }
 }
Exemple #10
0
 private void jump()
 {
     if (Input.GetButtonDown("Jump") && foot.IsTouchingLayers(ground))
     {
         rigidbody2D.AddForce(Vector2.up * jumpForce);
     }
     animator.SetBool("isGround", foot.IsTouchingLayers(ground));
 }
Exemple #11
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (myAgroRange.IsTouchingLayers(LayerMask.GetMask("Player")))
     {
         myTarget  = new Vector2(collision.GetComponent <Transform>().position.x, collision.GetComponent <Transform>().position.y);
         agressive = true;
     }
 }
Exemple #12
0
 private void OnCollisionStay2D(Collision2D col)
 {
     //if (!p.onground && (col.collider.gameObject.layer == LayerMask.NameToLayer("Map") || col.gameObject.layer == LayerMask.NameToLayer("EnemyBody"))) {
     if (!p.onground && foot.IsTouchingLayers(footMask))
     {
         p.onground = true;
         p.jumphold = 62;
         //p.Hold();
     }
 }
Exemple #13
0
 void moverPular()
 {
     if ((Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W)) && circleDino.IsTouchingLayers(ground))
     {
         rbd.AddForce(Vector2.up * forca);
     }
     else if ((Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S)))
     {
         rbd.AddForce(Vector2.down * forca);
     }
     ani.SetBool("pula", !circleDino.IsTouchingLayers(ground));
 }
 bool colided()
 {
     if (crcCol.IsTouchingLayers(1 << LayerMask.NameToLayer("Ground")))
     {
         return(true);
     }
     else if (crcCol.IsTouchingLayers(1 << LayerMask.NameToLayer("Wall")))
     {
         return(true);
     }
     return(false);
 }
 void DestroyBullet()
 {
     if (myCircleCollider.IsTouchingLayers(LayerMask.GetMask("Enemy")) ||
         myCircleCollider.IsTouchingLayers(LayerMask.GetMask("Ground")))
     {
         Destroy(gameObject);
     }
     if (Mathf.Abs(myRigidBody.velocity.x) <= 0.1)
     {
         Destroy(gameObject);
     }
 }
 void FixedUpdate()
 {
     if (SelfCol.IsTouchingLayers(ColLayer) || SelfCol.IsTouchingLayers(EndLevel))
     {
         Destroy(gameObject);
     }
     laif--;
     if (laif == 0)
     {
         Destroy(gameObject);
     }
 }
 // Update is called once per frame
 void FixedUpdate()
 {
     if (col.IsTouchingLayers(ground) && !onGround)
     {
         onGround = true;
     }
     if (!col.IsTouchingLayers(ground) && onGround)
     {
         onGround = false;
     }
     Movement();
     SwitchAnim();
 }
Exemple #18
0
 private void GetEnterDoorInput()
 {
     if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W))
     {
         if (foot.IsTouchingLayers(door))
         {
             if (GameVariables.Key)
             {
                 GameVariables.Key = false;
                 //fim da fase, vai para a proxima
                 SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
             }
         }
     }
 }
 // Update is called once per frame
 void FixedUpdate()
 {
     if (col.IsTouchingLayers(ground) && !onGround)
     {
         onGround = true;
         jumpParticle.Play();
     }
     if (!col.IsTouchingLayers(ground) && onGround)
     {
         onGround = false;
     }
     Dash();
     Movement();
     SwitchAnim();
 }
 private void fallingMovement()
 {
     if (cirColli.IsTouchingLayers(ground))
     {
         state = State.idling;
     }
 }
    private void Fall()
    {
        if (currentState == State.isFalling)
        {
            animator.SetBool("isFalling", true);

            rb.velocity = new Vector2(fallVelocityX, rb.velocity.y - fallVelocityY);

            if (preRollCheckCollider.IsTouchingLayers(LayerMask.GetMask("Ground")))
            {
                currentState = State.isPreRolling;

                animator.SetBool("isFalling", false);
                animator.SetTrigger("isPreRolling");
            }
        }

        if (currentState == State.isPreRolling && feetCollider.IsTouchingLayers(LayerMask.GetMask("Ground")))
        {
            currentState = State.isMoving;

            animator.SetBool("isPreRolling", false);
            animator.SetTrigger("isRolling");
        }
    }
Exemple #22
0
    // Update is called once per frame
    void Update()
    {
        if (hasWallJump)
        {
            wallDir = rightWall.IsTouchingLayers(wallMask) ? 1 : leftWall.IsTouchingLayers(wallMask) ? -1 : 0;
            onWall  = wallDir != 0;
        }

        onGround = groundCheck.IsTouchingLayers();

        if (onGround)
        {
            canDoubleJump = true;
        }

        bool newJumpAxis = Input.GetAxisRaw("Vertical") == 1 || Input.GetAxisRaw("Jump") == 1;

        if (newJumpAxis && !jumpAxis)
        {
            jumpDown = true;
        }
        else
        {
            jumpDown = false;
        }
        jumpAxis = newJumpAxis;
    }
Exemple #23
0
    void Update()
    {
        if (myColliderTop.IsTouchingLayers(LayerMask.GetMask("Player")))
        {
            if (!enemyIsAlive || enemyIsAttacking)
            {
                return;
            }
            else
            {
                Destroy(gameObject, dyingTime);
                movementSpeed = 0;
                myAnimator.SetBool("IsDead", true);
                FindObjectOfType <SFXPlayer>().DeathSqueak();
                //Could add a death animation or particle effect here.

                enemyIsAlive = false;
            }
        }

        //Knockback player when he takes damage
        else if (myColliderMid.IsTouchingLayers(LayerMask.GetMask("Player")))
        {
            if (!enemyIsAlive)
            {
                return;
            }
            enemyIsAttacking = true;
            FindObjectOfType <Player>().TakeDamage();
            FindObjectOfType <Player>().knockbackCount = FindObjectOfType <Player>().knockbackLength;
            StartCoroutine(DamagePlayer());
        }
    }
Exemple #24
0
    private void Jump()
    {
        if (!myFeet.IsTouchingLayers(LayerMask.GetMask("Ground")))
        {
            return;
        }
        else
        {
            myAnimator.SetBool("IsJumping", false);
        }



        if (myjumpbutton.Pressed == true)
        {
            Vector2 jumpVelocityToAdd = new Vector2(0f, jumpSpeed);
            myRigidBody.velocity += jumpVelocityToAdd;
            myAnimator.SetBool("IsJumping", true);
        }


        /*if (myRigidBody.velocity.y < 0)
         * {
         *  myRigidBody.velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime;
         * }
         * else if (myRigidBody.velocity.y > 0 && !Input.GetButton("Jump"))
         * {
         *  myRigidBody.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime;
         * }
         */
    }
Exemple #25
0
    void SwitchAnim()
    {
        if (rb.velocity.y < 0.1f && !IsGroud())
        {
            anim.SetBool("is_fall", true);
        }

        if (anim.GetBool("is_jump"))
        {
            if (rb.velocity.y < 0)
            {
                anim.SetBool("is_jump", false);

                anim.SetBool("is_fall", true);
            }
        }
        else if (isHurt)
        {
            anim.SetBool("is_hurt", true);

            if (Mathf.Abs(rb.velocity.x) < 0.1f)
            {
                anim.SetBool("is_hurt", false);

                anim.SetFloat("is_run", 0);

                isHurt = false;
            }
        }
        else if (coll.IsTouchingLayers(groud))
        {
            anim.SetBool("is_fall", false);
        }
    }
Exemple #26
0
    // MARK:- PRIVATE METHODS
    private void UpdateLocation(float horizontalMovement)
    {
        Vector3 targetVelocity = new Vector2(horizontalMovement * MoveForce, objectRigidbody.velocity.y);

        objectRigidbody.velocity = Vector3.SmoothDamp(objectRigidbody.velocity, targetVelocity, ref currentVelocity, MovementSmoothing);

        animator.SetFloat("HSpeed", Mathf.Abs(objectRigidbody.velocity.x));
        animator.SetFloat("VSpeed", objectRigidbody.velocity.y);

        if (horizontalMovement > 0 && !isFacingRight)
        {
            Flip();
        }
        if (horizontalMovement < 0 && isFacingRight)
        {
            Flip();
        }
        if (groundCollider.IsTouchingLayers(GroundLayer))
        {
            animator.SetBool("Grounded", true);
            if (isJumpPressed)
            {
                objectRigidbody.AddForce(new Vector2(0f, JumpForce));
                isJumpPressed = false;
                animator.SetTrigger("Jump");
            }
        }
        else
        {
            animator.SetBool("Grounded", false);
        }
    }
Exemple #27
0
    // Update is called once per frame
    void Update()
    {
        grounded = groundCheck.IsTouchingLayers(whatIsGround);

        move = Input.GetAxis("Horizontal");
        if (move > 0 && !facingRight)
        {
            Flip();
        }
        else if (move < 0 && facingRight)
        {
            Flip();
        }
        if (move != 0)
        {
            animator.SetBool("isMoving", true);
        }
        else
        {
            animator.SetBool("isMoving", false);
        }

        jump = Input.GetButtonDown("Jump") || Input.GetButtonDown("Vertical");

        //Debug.Log ("move = " + move);
    }
 void FixedUpdate()
 {
     if (PlayerCc.IsTouchingLayers(Ground))
     {
         transform.Rotate(new Vector3(0, 0, PlayerRb.velocity.x / PlayerCc.radius / 2 * -Mathf.Sign(PlayerRb.gravityScale)));
     }
 }
    private void FixedUpdate()
    {
        //Must set Ground layer for jumpable surfaces or this won't work (rip english)
        if (c_Collider.IsTouchingLayers(LayerMask.GetMask("Ground")))
        {
            //Land();
            grounded = true;
        }
        else
        {
            grounded = false;
        }

        if (jump && grounded)
        {
            //Unity is dumb so here's a dumb solution to a dumb bug.. geez
            transform.position = new Vector3(transform.position.x, transform.position.y + 0.1f, transform.position.z);

            Jump(jumpForce);
        }

        if (p_Rigidbody.velocity.y < 0)
        {
            p_Rigidbody.velocity += Vector2.up * Physics2D.gravity.y * (fallModifier - 1) * Time.deltaTime;
        }
        else if (p_Rigidbody.velocity.y > 0 && !Input.GetButton("Jump"))
        {
            p_Rigidbody.velocity += Vector2.up * Physics2D.gravity.y * (jumpModifier - 1) * Time.deltaTime;
        }

        Vector2 movement = new Vector2(horizontal_Move, 0f);

        Move(movement);
    }
Exemple #30
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        //Shows the player that the bat has recognized them if within range
        if (detectionRange.IsTouchingLayers(LayerMask.GetMask("Player")) || detectionRange.IsTouchingLayers(LayerMask.GetMask("Invulnerable")))
        {
            anim.SetBool("Detected", true);
        }

        //Chases player if within range
        if (chaseRange.IsTouchingLayers(LayerMask.GetMask("Player")) || detectionRange.IsTouchingLayers(LayerMask.GetMask("Invulnerable")))
        {
            anim.SetTrigger("Chasing");
            chaseRange.radius = 9;  //Increases chasing size once they have detected the player
            chasing           = true;
        }
    }