/// <summary> /// 设置物理技能攻击 /// </summary> /// <param name="playerObj">玩家操纵状态对象</param> /// <param name="physicsSkillStateStruct">本技能释放时的数据状态</param> /// <param name="skillType">技能类型</param> /// <param name="weaponTypeByPlayerState">武器类型</param> public void SetPhysicSkillAttack(IPlayerState iPlayerState, PhysicsSkillStateStruct physicsSkillStateStruct, EnumSkillType skillType, EnumWeaponTypeByPlayerState weaponTypeByPlayerState) { if (iPlayerState == null || physicsSkillStateStruct == null) { return; } IPlayerState _iPlayerState = iPlayerState; PhysicsSkillStateStruct _physicsSkillStateStruct = physicsSkillStateStruct; EnumSkillType _SKillType = skillType; EnumWeaponTypeByPlayerState _WeaponTypeByPlayerState = weaponTypeByPlayerState; PhysicSkillInjuryDetection physicSkillInjuryDetection = _iPlayerState.PhysicSkillInjuryDetection; if (physicSkillInjuryDetection != null) { physicSkillInjuryDetection.CheckAttack(_SKillType, _WeaponTypeByPlayerState, 1, null, (innerOrder, target) => { return(CalculatePhysicSkillHurt(_SKillType, _WeaponTypeByPlayerState, _physicsSkillStateStruct, innerOrder, target)); }); } //如果这是冲锋则开启任务(移动对象) switch (skillType) { case EnumSkillType.ZS03: float zs03Time = 0; runTaskStruct_Charge.StartTask(0, () => { zs03Time += Time.deltaTime; float speedRate = 0; if (zs03Time < 0.3f) { speedRate = 0; } else { speedRate = 1; } _iPlayerState.ForceMoveStruct = new ForceMoveStruct() { MoveSpeed = _physicsSkillStateStruct.AttributeState.MoveSpeed * speedRate }; if (zs03Time > 1f) { runTaskStruct_Charge.StopTask(); IAnimatorState iAnimatorState = GameState.Instance.GetEntity <IAnimatorState>(); iAnimatorState.SkillSustainable = false; } }, 0, false); break; } }
/// <summary> /// 设置普通攻击 /// </summary> /// <param name="iPlayerState">玩家状态对象</param> /// <param name="attackOrder">攻击的编号</param> /// <param name="nowIAttributeState">本技能释放时的数据状态</param> /// <param name="weaponTypeByPlayerState">武器类型</param> public void SetNormalAttack(IPlayerState iPlayerState, int attackOrder, IAttributeState nowIAttributeState, EnumWeaponTypeByPlayerState weaponTypeByPlayerState) { if (iPlayerState == null || nowIAttributeState == null) { return; } IPlayerState _iPlayerState = iPlayerState; IAttributeState _NowIAttributeState = nowIAttributeState; EnumWeaponTypeByPlayerState _WeaponTypeByPlayerState = weaponTypeByPlayerState; IAnimatorState iAnimatorState = GameState.Instance.GetEntity <IAnimatorState>(); int _attackOrder = attackOrder; PhysicSkillInjuryDetection physicSkillInjuryDetection = _iPlayerState.PhysicSkillInjuryDetection; float runTime = 0;//检测超时时间 if (physicSkillInjuryDetection != null) { Action BeginCheckAttack = () => { runTaskStruct_NormalAttack.StopTask();//停止任务 physicSkillInjuryDetection.CheckAttack(EnumSkillType.PhysicAttack, _WeaponTypeByPlayerState, 1, null, (innerOrder, target) => { return(CalculateNormalActionHurt(_WeaponTypeByPlayerState, _NowIAttributeState, innerOrder, target)); }, attackOrder ); }; //该任务用于检测是否可以进入该普通攻击的检测 runTaskStruct_NormalAttack.StartTask(0, () => { switch (attackOrder) { case 1: if (iAnimatorState.AnimationClipTypeState != null && iAnimatorState.AnimationClipTypeState.AnimationClipType == EnumAnimationClipType.Attack1 && iAnimatorState.AnimationClipTypeState.TimeType == EnumAnimationClipTimeType.In) { BeginCheckAttack(); } break; case 2: if (iAnimatorState.AnimationClipTypeState != null && iAnimatorState.AnimationClipTypeState.AnimationClipType == EnumAnimationClipType.Attack2 && iAnimatorState.AnimationClipTypeState.TimeType == EnumAnimationClipTimeType.In) { BeginCheckAttack(); } break; case 3: if (iAnimatorState.AnimationClipTypeState != null && iAnimatorState.AnimationClipTypeState.AnimationClipType == EnumAnimationClipType.Attack3 && iAnimatorState.AnimationClipTypeState.TimeType == EnumAnimationClipTimeType.In) { BeginCheckAttack(); } break; default: runTaskStruct_NormalAttack.StopTask(); //停止任务 break; } }, 0, true, () => { runTime += Time.deltaTime; if (runTime > 1) { return(false); } return(true); }); } }