Exemple #1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag("Sword") && gameObject.tag != "Dying")
     {
         gamePad.SetVibration(100, 100, 0.15f);
         gameObject.tag = "Dying";
         gameObject.GetComponent <Animator>().Play("Die");
         Destroy(Instantiate(BloodParticle, transform.position, Quaternion.identity), 1.0f);
         camShake.Shakee(0.1f, 0.1f);
         gameObject.GetComponent <AudioSource>().Play();
         Destroy(gameObject, 0.8f);
     }
 }
Exemple #2
0
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.layer == 17)
     {
         isGrounded = true;
         Destroy(Instantiate(FallingParticle, new Vector3(transform.position.x, transform.position.y - 1, transform.position.z), Quaternion.identity), 2.5f);
         gameObject.GetComponent <AudioSource>().Play();
         {
             gamePad.SetVibration(100, 100, 0.15f);
             camShake.Shakee(0.1f, 0.1f);
         }
     }
 }
Exemple #3
0
    void Update()
    {
        if (gamePad.A.Held)
        {
            gamePad.SetVibration(100);
        }
        else
        {
            gamePad.StopVibration();
        }

        axis = new Vector3(gamePad.LeftStick.X, gamePad.LeftStick.Y, 0);
        transform.Rotate(axis * Time.deltaTime * speed);
    }
Exemple #4
0
    void HandleMovement()
    {
        if (!Anim.GetCurrentAnimatorStateInfo(0).IsName("AttackMoving") && !Anim.GetCurrentAnimatorStateInfo(0).IsName("Attack"))
        {
            if (Input.GetButtonDown("Attack"))
            {
                if (Input.GetAxisRaw("Horizontal") != 0 && isGrounded == true)
                {
                    Anim.Play("AttackMoving");
                }
                else
                {
                    Anim.Play("Attack");
                }
                if (haveSword == true)
                {
                    attackSoundSword.Play();
                }
                if (unarmed == true)
                {
                    attackSoundUnarmed.Play();
                }
            }
            else if (dead == false)
            {
                if (Input.GetAxisRaw("Horizontal") == 0 && isGrounded == true)
                {
                    Anim.Play("Idle");
                }
                else if (Input.GetAxisRaw("Horizontal") != 0 && isGrounded == true)
                {
                    Anim.Play("Run");
                }
                else if (isGrounded == false)
                {
                    Anim.Play("Jump");
                }
            }
        }
        if (Input.GetAxisRaw("Horizontal") > 0)
        {
            transform.transform.Translate(Vector2.right * Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime);
            if (Input.GetAxisRaw("Horizontal") > 0)
            {
                Flip(false);
            }
        }

        else if (Input.GetAxisRaw("Horizontal") < 0)
        {
            transform.transform.Translate(Vector2.right * Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime);
            if (Input.GetAxisRaw("Horizontal") < 0)
            {
                Flip(true);
            }
        }
        if ((Input.GetButtonDown("Dash") || Input.GetAxis("Dash") > 0) && isGrounded == false && dashCount == 0)
        {
            gamePad.SetVibration(100, 100, 0.15f);
            isJumping = false;
            Destroy(Instantiate(dashEffect, transform.position, Quaternion.identity), 1.0f);
            DashSound.Play();
            dashCount            = 1;
            moveSpeed            = 0;
            rigidBody2D.velocity = new Vector2(0, 0);
            if (right == true)
            {
                rigidBody2D.velocity = Vector2.right * 20;
            }
            if (left == true)
            {
                rigidBody2D.velocity = Vector2.left * 20;
            }
            rigidBody2D.gravityScale = 0.0f;
            camShake.Shakee(camShakeAmount, 0.1f);
            (CameraObject.GetComponent("MotionBlur") as MonoBehaviour).enabled = true;
            StartCoroutine(DashGravity(0.20f));
        }
        if (isGrounded == true && Input.GetButtonDown("Jump"))
        {
            Anim.Play("Jump");
            if (inWater == false)
            {
                Destroy(Instantiate(JumpParticle, new Vector3(transform.position.x, transform.position.y - 0.6f, transform.position.z), Quaternion.identity), 1.0f);
            }
            isJumping            = true;
            jumpTimeCounter      = jumpTime;
            rigidBody2D.velocity = new Vector2(rigidBody2D.velocity.x, 1 * jumpSpeed);
        }
        if (Input.GetButton("Jump") && isJumping == true)
        {
            if (jumpTimeCounter > 0)
            {
                rigidBody2D.velocity = new Vector2(rigidBody2D.velocity.x, 1 * jumpSpeed);
                jumpTimeCounter     -= Time.deltaTime * 2;
            }
            else
            {
                isJumping = false;
            }
        }
        if (Input.GetButtonUp("Jump"))
        {
            isJumping = false;
        }
    }