Пример #1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Ground")
     {
         MyInpulse.GenerateImpulse();
     }
 }
Пример #2
0
 //hit the ground, shake vCamera
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Tilemap")
     {
         MyInpulse.GenerateImpulse();
         audioSource.Play();
     }
 }
Пример #3
0
 // Update is called once per frame
 protected virtual void Update()
 {
     if (_player.death)
     {
         return;
     }
     if (Input.GetButton("Fire1"))
     {
         IsFire = true;
         Fire(_movement.side);
         MyInpulse.GenerateImpulse();
     }
     else
     {
         IsFire = false;
     }
 }
Пример #4
0
    //空中攻击
    private void AttackOnAir()
    {
        //空中攻击判断:1、2结束时
        if ((stateInfo.IsName("attack_air_1") || stateInfo.IsName("attack_air_2")) && stateInfo.normalizedTime > 1f)
        {
            count = 0;
            animator.SetInteger("attack", count);
            state.isAttacking    = false;
            state.canJump        = true;
            state.canAttackAgain = false;
        }
        else if ((stateInfo.IsName("jump") || stateInfo.IsName("jump_fall") || stateInfo.IsName("attack_air_1") || stateInfo.IsName("attack_air_2")) && state.isOnGround)
        {
            //空中攻击判断:空中几个普通状态时着陆
            count = 0;
            animator.SetInteger("attack", count);
            state.isAttacking = false;
            state.canJump     = true;

            state.canAttackAgain = true;
        }
        else if (stateInfo.IsName("attack_air_3") && state.isOnGround)
        {
            //attack_air_3持续进行直至接触地面,自动切换到attack_air_4
            //对attack_air_4动画延时结束

            //最终一击期间无敌
            state.canBeHurt = false;

            //相机抖动
            MyInpulse.GenerateImpulse();
            StartCoroutine(Attck_3CD());
        }


        //空中攻击
        if (!state.isOnGround && (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.V)) && state.canAttackAgain)
        {
            state.isAttacking = true;
            state.canJump     = false;

            //攻击阶段一:
            if (count == 0)
            {
                count = 4;
                animator.SetInteger("attack", count);
                SetMoveDelta(Vector2.up, 1.0f, 5.0f);
            }
            else if (stateInfo.IsName("attack_air_1") && count == 4 && stateInfo.normalizedTime > 0.4f)
            {
                //攻击阶段二:
                count = 5;
                animator.SetInteger("attack", count);
                SetMoveDelta(Vector2.up, 1.6f, 10f);
            }
            else if (stateInfo.IsName("attack_air_2") && count == 5 && stateInfo.normalizedTime > 0.4f)
            {
                //攻击阶段三:
                count = 6;
                animator.SetInteger("attack", count);
                SetMoveDelta(Vector2.down, 3f, 0f);

                //三阶段攻击时禁止输入
                state.canInput = false;
            }
            else if (count == 6)
            {
                //state.canAttackAgain = true;
            }
        }
    }