public override void OnUpdate() { if (Input.GetKeyDown(KeyCode.Keypad9)) { // this.DropItemList(); this.DropItemCustom(); } UpdateAnimatorState(); // refreshRoleAnim(); // 刷新角色数据 add by TangJian 2017/08/23 15:04:50 UpdateAttr(); UpdateValueMonitorPool(); if (_fsm != null) { _fsm.Update(); } // 角色升级检测 add by TangJian 2019/3/6 22:09 UpgradeTest(); // 用于修复转正的时候, clipInfo切换不及时的问题 add by TangJian 2019/5/24 16:05 RoleAnimator.Update(0); RoleAnimator.Update(0); RoleAnimator.Update(Time.deltaTime); skeletonAnimator.Update(); }
// 受伤 add by TangJian 2018/12/8 1:54 public virtual bool Hurt(DamageData damageData) { Direction oldDirection = GetDirection(); // 扣血 add by TangJian 2017/07/14 18:02:17 if (IsDefending && damageData.ignoreShield == false // 不无视防御 add by TangJian 2019/4/3 17:16 ) { //方向判断 AnimationSwitch(damageData, false, true); //体力判断 { // 伤害计算和扣血 add by TangJian 2019/4/2 16:44 float HurtNum = this.DoLoseHp(damageData.atk); // 自身动画状态设置 add by TangJian 2019/4/2 16:44 { if (animatorParams.ContainsKey("NoDefence")) { _animator.SetBool("NoDefence", true); } _animator.SetInteger("Defence_hurt_type", 3); AnimManager.Instance.WeaponCremaShake(FrameEventInfo.CameraShakeType.mediumshape); if (RoleData.Hp <= 0) { WeaponByDieAni(damageData.WeapondeadType, HurtNum); } else { _animator.SetTrigger("hurt"); } } // 额外效果 add by TangJian 2019/4/2 16:44 { float angle = damageData.SpecialEffectRotation; Bounds bounds = new Bounds(transform.position + RoleData.DefendBoundcenter, RoleData.DefendBoundsize); Vector3 localPos = transform.InverseTransformPoint(damageData.collideBounds.center); Vector3 posse = transform.position + localPos; Vector3 overpos = bounds.ClosestPoint(posse); Vector3 moveOrientation = Quaternion.AngleAxis(angle, Vector3.forward) * Vector3.right; moveOrientation.y = Mathf.Abs(moveOrientation.y); } } } else { // 伤害计算和扣血 add by TangJian 2019/4/2 16:44 float HurtNum = this.DoLoseHp(damageData.atk); #region //2019.3.29// 动画状态机设置 { // 设置无视防御状态 add by TangJian 2019/4/3 17:50 if (damageData.ignoreShield) { RoleAnimator.SetTrigger("ignore_shield"); } if (RoleData.Hp <= 0) { WeaponByDieAni(damageData.WeapondeadType, HurtNum); } //地面血迹 2019.3.29 AnimManager.Instance.PlayAnimEffect("BloodSubface", transform.position, 0, damageData.direction.x < 0, Vector3.right, transform); //判断是否需要转身 2019.4.4 bool IsneedTurnback = RoleData.NeedTurnBack; if (IsneedTurnback) { if (damageData.hitType != (int)HitType.Fly) { IsneedTurnback = false; } } AnimationSwitch(damageData, IsneedTurnback); } #endregion // 额外动画 { // 播放掉血动画 if (HurtNum > 0) { this.PlayLoseHpAnim(HurtNum, damageData.isCritical); } } // 使用代理实现受伤 add by TangJian 2019/5/10 17:56 _hitAndHurtDelegate.Hurt(damageData); } // 霸体状态处理 add by TangJian 2018/12/8 14:56 if (RoleData.IsSuperArmor) { SetDirection(oldDirection); // 霸体被攻击不转面 add by TangJian 2019/3/25 10:54 _animator.SetBool("hurt", false); } else { if (OnHurtEvent != null) { OnHurtEvent(damageData); } } //击退 add by TangJian 2018/12/8 14:55 if (damageData.targetMoveBy.magnitude > 0.01f) { Speed = (damageData.targetMoveBy * (1f - (IsDefending ? RoleData.DefenseRepellingResistance : RoleData.RepellingResistance))).MoveByToSpeed(); } // 触发受伤事件 add by TangJian 2018/05/14 20:09:38 BuffController.TriggerBuffEvent(BuffEventType.OnHurt); return(true); }
void UpdateAttr() { if (RoleData != null) { RoleData.locationData.position = transform.localPosition; if (RoleAnimator.GetCurrentAnimatorStateInfo(0).IsTag("attack") || RoleAnimator.GetCurrentAnimatorStateInfo(0).IsTag("jumpingAttack") || RoleAnimator.GetCurrentAnimatorStateInfo(0).IsTag("jump") || RoleAnimator.GetCurrentAnimatorStateInfo(0).IsTag("roll") // || RoleAnimator.GetCurrentAnimatorStateInfo(0).IsTag("run") || RoleAnimator.GetCurrentAnimatorStateInfo(0).IsTag("rush") || RoleAnimator.GetCurrentAnimatorStateInfo(0).IsTag("dun-idle") || RoleAnimator.GetCurrentAnimatorStateInfo(0).IsTag("dun-move") || RoleAnimator.GetCurrentAnimatorStateInfo(0).IsTag("dun-hurt")) { regainDelay = 2; } else { regainDelay -= Time.deltaTime; if (regainDelay <= 0) { Vigor = (Vigor + 1f * Time.deltaTime).Range(0, VigorMax); } } if (RoleAnimator.GetCurrentAnimatorStateInfo(0).IsTag("roll") && Vigor > 20 && !IsRoll) { Vigor -= 20; IsRoll = true; } if (!RoleAnimator.GetCurrentAnimatorStateInfo(0).IsTag("roll")) { IsRoll = false; } if (RoleAnimator.GetCurrentAnimatorStateInfo(0).IsTag("rush") && Vigor > 0) { // Vigor -=(VigorMax / 3f) *Time.deltaTime; Vigor = Vigor - 4f * Time.deltaTime; } if (animatorParams.ContainsKey("role_data_tili")) { _animator.SetFloat("role_data_tili", Vigor); } if (RoleAnimator.GetCurrentAnimatorStateInfo(0).IsTag("dun-idle") || RoleAnimator.GetCurrentAnimatorStateInfo(0).IsTag("dun-move") || RoleAnimator.GetCurrentAnimatorStateInfo(0).IsTag("dun-hurt")) { if (Vigor > 0) { // Vigor -=(VigorMax / 3f) *Time.deltaTime; Vigor = Vigor - 5f * Time.deltaTime; } } } }