Example #1
0
 void AfterImageInput()
 {
     if (Input.GetButtonDown("Locate"))
     {
         // 目前先做成只有1个残影和1次瞬移
         if (skillAfterImage.CanInstantMove())   // 瞬移
         {
             CurrentSP    -= 25;
             recoveryTimer = 2 * recoveryWait;    // 因为CD长所以回复也要变慢
             animator.SetTrigger(aniInstant);
             animator.applyRootMotion = false;    // 关闭rootmotion,因为要转向
             katanaAnimEvent.TrailSwitch(0);      // 关闭col和trail
             if (targetDirection != Vector3.zero) //如果不是向前方闪避,那么先转向
             {
                 Rgbd.MoveRotation(Quaternion.LookRotation(targetDirection, Vector3.up));
             }
         }
         // 残像
         else
         {
             skillAfterImage.CreateAfterImage();
             skillAfterImage.KatanaAfterImage();
         }
     }
 }
Example #2
0
 /// <summary>
 /// 平滑旋转
 /// </summary>
 void Rotating()
 {
     //计算出旋转
     if (targetDirection != Vector3.zero)
     {
         // 目标方向的旋转角度
         Quaternion targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up);
         // 平滑插值
         Quaternion newRotation = Quaternion.Slerp(Rgbd.rotation, targetRotation, 5 * Time.deltaTime);
         Rgbd.MoveRotation(newRotation);
     }
 }
Example #3
0
 /// <summary>
 /// 平滑旋转
 /// </summary>
 private void Rotating()
 {
     // Combat状态下,角色朝向随相机朝向变化而变化
     if (isCombatState && forwardDirection != Vector3.zero)
     {
         // 目标方向的旋转角度
         Quaternion targetRotation = Quaternion.LookRotation(forwardDirection, Vector3.up);
         // 不需要平滑插值
         Rgbd.MoveRotation(targetRotation);
     }
     // Normal状态下,角色朝向随输入方向变化而变化
     else if (targetDirection != Vector3.zero)
     {
         // 目标方向的旋转角度
         Quaternion targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up);
         // 平滑插值
         Quaternion newRotation = Quaternion.Slerp(Rgbd.rotation, targetRotation, 5 * Time.deltaTime);
         Rgbd.MoveRotation(targetRotation);
     }
 }
Example #4
0
        //void CastInput()
        //{
        //    // 只要Num>=1,就说明装备了可以使用的道具
        //    if (Input.GetButtonDown("Avoid"))
        //    {
        //        animator.applyRootMotion = false;   // 关闭rootmotion,因为要转向
        //        katanaAnimEvent.TrailSwitch(0);     // 关闭col和trail
        //        if (targetDirection != Vector3.zero)//如果不是向前方闪避,那么先转向
        //        {
        //            Rgbd.MoveRotation(Quaternion.LookRotation(targetDirection, Vector3.up));
        //        }



        //        释放magicball
        //        if (canCast)
        //        {
        //            canCast = false;
        //            animator.SetTrigger(aniCast);
        //            katanaAnimEvent.MagicBall.Cast();
        //        }
        //        需要等球停下
        //        else if (katanaAnimEvent.MagicBall.Rgbd.velocity.magnitude < 1)
        //        {
        //            canCast = true;
        //            animator.SetTrigger(aniInstant);
        //        }
        //    }
        //}

        void AvoidInput()
        {
            //如果是Transition状态(如avoid->run,run->avoid)或正在avoid则不允许输入
            if (!animator.IsInTransition(0) && (stateInfo.IsName("Idle") || stateInfo.IsName("Run") || stateInfo.IsName("Att1") ||
                                                stateInfo.IsName("Att2") || stateInfo.IsName("Att3") || stateInfo.IsName("Att4")))
            {
                if (Input.GetButtonDown("Avoid") && CurrentSP >= 25)//闪避
                {
                    CurrentSP               -= 25;
                    recoveryTimer            = recoveryWait;
                    animator.applyRootMotion = false;    // 关闭rootmotion,因为要转向
                    animator.SetTrigger(aniAvoid);
                    katanaAnimEvent.TrailSwitch(0);      //关闭col和trail
                    if (targetDirection != Vector3.zero) //如果不是向前方闪避,那么先转向
                    {
                        Rgbd.MoveRotation(Quaternion.LookRotation(targetDirection, Vector3.up));
                    }
                }
            }
        }
Example #5
0
 void DushInput()
 {
     if (!animator.IsInTransition(0) &&
         (stateInfo.IsName("Idle") || stateInfo.IsName("Run") || stateInfo.IsName("Att1") ||
          stateInfo.IsName("Att2") || stateInfo.IsName("Att3") || stateInfo.IsName("Att4")))
     {
         if (Input.GetButtonDown("Dush") && CurrentSP >= 35) //闪避
         {
             CurrentSP               -= 35;
             recoveryTimer            = recoveryWait;
             animator.applyRootMotion = false;    // 关闭rootmotion,因为要转向
             animator.SetTrigger(aniDush);
             katanaAnimEvent.TrailSwitch(0);      //关闭col和trail
             if (targetDirection != Vector3.zero) //如果不是向前方闪避,那么先转向
             {
                 Rgbd.MoveRotation(Quaternion.LookRotation(targetDirection, Vector3.up));
             }
             // 切换layer并自动切换回来
             GameObjectInScene.layer = (int)ObjectLayer.Without;
             CoroutineMgr.Instance.StartCoroutine(DushEnd());
         }
     }
 }
Example #6
0
 void IdleOrRun()
 {
     if (!animator.IsInTransition(0))
     {
         if (Input.GetButtonDown("Attack1"))
         {
             lightAttack  = 1;
             heavyAttack  = 0;                   //清除
             strongAttack = 0;
             animator.SetTrigger(aniLAttack1);
             animator.SetInteger(aniLAttack, lightAttack);                    //清除之前记录的lightAttack
             animator.SetInteger(aniHAttack, heavyAttack);                    //清除之前记录的heavyAttack
             animator.SetInteger(aniSAttack, strongAttack);
             CanMove = false;
             //攻击前瞬时转向
             if (targetDirection != Vector3.zero)
             {
                 Rgbd.MoveRotation(Quaternion.LookRotation(targetDirection, Vector3.up));
             }
         }
         else if (CanAttack2 && Input.GetButtonDown("Attack2"))
         {
             lightAttack  = 0;                   //清除
             heavyAttack  = 1;                   //第一击重击设为0以区别开
             strongAttack = 0;
             animator.SetTrigger(aniHAttack1);
             animator.SetInteger(aniLAttack, lightAttack);                    //清除之前记录的lightAttack
             animator.SetInteger(aniHAttack, heavyAttack);                    //清除之前记录的lightAttack
             animator.SetInteger(aniSAttack, strongAttack);
             CanMove = false;
             //攻击前瞬时转向
             if (targetDirection != Vector3.zero)
             {
                 Rgbd.MoveRotation(Quaternion.LookRotation(targetDirection, Vector3.up));
             }
         }
         else if (CanAttack3 && Input.GetButtonDown("Attack3"))
         {
             lightAttack  = 0;               //清除
             heavyAttack  = 0;
             strongAttack = 1;
             animator.SetTrigger(aniSAttack1);
             animator.SetInteger(aniLAttack, lightAttack);                //清除之前记录的lightAttack
             animator.SetInteger(aniHAttack, heavyAttack);                //清除之前记录的lightAttack
             animator.SetInteger(aniSAttack, strongAttack);
             CanMove = false;
             //攻击前瞬时转向
             if (targetDirection != Vector3.zero)
             {
                 Rgbd.MoveRotation(Quaternion.LookRotation(targetDirection, Vector3.up));
             }
         }
     }
     #region Transition(0)
     //else
     //{
     //    //idle->run的Transition时也要检测输入
     //    if (lightAttack == 1)
     //    {
     //        if (Input.GetButtonDown("Attack1"))
     //        {
     //            lightAttack = 2;
     //        }
     //    }
     //    else if (heavyAttack == 1)
     //    {
     //        if (Input.GetButtonDown("Attack2"))
     //        {
     //            heavyAttack = 2;
     //        }
     //    }
     //    else if (strongAttack == 1)
     //    {
     //        if (Input.GetButtonDown("Attack3"))
     //        {
     //            strongAttack = 2;
     //        }
     //    }
     //}
     #endregion
 }