public static async ETVoid Execute(this ActiveSkillComponent self, string skillId) { ActiveSkillData activeSkillData = Game.Scene.GetComponent <SkillConfigComponent>().GetActiveSkill(skillId); SkillHelper.ExecuteSkillParams excuteSkillParams = new SkillHelper.ExecuteSkillParams(); excuteSkillParams.skillId = skillId; excuteSkillParams.source = self.GetParent <Unit>(); excuteSkillParams.skillLevel = 1; self.currUsingSkillId = skillId; //TODO: 暂时先直接取消之前的行动 self.cancelToken?.Cancel(); Game.EventSystem.Run(EventIdType.CancelPreAction, self.GetParent <Unit>()); CharacterStateComponent characterStateComponent = self.GetParent <Unit>().GetComponent <CharacterStateComponent>(); characterStateComponent.Set(SpecialStateType.NotInControl, true); self.cancelToken = new CancellationTokenSource(); excuteSkillParams.cancelToken = self.cancelToken; await SkillHelper.ExecuteActiveSkill(excuteSkillParams); self.cancelToken = null; characterStateComponent.Set(SpecialStateType.NotInControl, false); self.currUsingSkillId = string.Empty; }
public void Remove(BuffHandlerVar buffHandlerVar) { Buff_GiveSpecialDebuff buff = (Buff_GiveSpecialDebuff)buffHandlerVar.data; if (!buffHandlerVar.GetBufferValue(out BufferValue_TargetUnits targetUnits)) { return; } //if (buff.currStackNum < buff.aimStackNum) return;//叠加层数没达到 foreach (var v in targetUnits.targets) { CharacterStateComponent unitState = v.GetComponent <CharacterStateComponent>(); //从一个特殊效果配置中,拿到对应效果的BuffGroup,添加到角色的BuffMgrComponent中 switch (buff.restrictionType) { case RestrictionType.击退: unitState.Set(SpecialStateType.NotInControl, false); break; case RestrictionType.眩晕: unitState.Set(SpecialStateType.CantDoAction, false); break; } } }
public async ETVoid Execute(string skillId) { try { if (usingSkill) { return; } if (!skillList.ContainsKey(skillId)) { return; } if (!SkillHelper.CheckIfSkillCanUse(skillId, GetParent <Unit>())) { return; } ActiveSkillData activeSkillData = Game.Scene.GetComponent <SkillConfigComponent>().GetActiveSkill(skillId); SkillHelper.ExecuteSkillParams excuteSkillParams = new SkillHelper.ExecuteSkillParams(); excuteSkillParams.skillId = skillId; excuteSkillParams.source = GetParent <Unit>(); excuteSkillParams.skillLevel = 1; usingSkill = true; bool canUse = await SkillHelper.CheckInput(excuteSkillParams); if (GetParent <Unit>() == UnitComponent.Instance.MyUnit) { //联网模式玩家主动使用技能需要等待服务器确认消息,以决定技能是否真的可以使用 tcs = new ETTaskCompletionSource <bool>(); canUse = await tcs.Task; tcs = null; usingSkill = false; } if (!canUse) { return; } usingSkill = false; currUsingSkillId = skillId; // 联网模式非玩家单位使用技能直接跳过检测,因为是收到使用技能的确定消息了才开始执行技能. //TODO: 暂时先直接取消之前的行动 cancelToken?.Cancel(); Game.EventSystem.Run(EventIdType.CancelPreAction, GetParent <Unit>()); CharacterStateComponent characterStateComponent = GetParent <Unit>().GetComponent <CharacterStateComponent>(); characterStateComponent.Set(SpecialStateType.NotInControl, true); cancelToken = new CancellationTokenSource(); excuteSkillParams.cancelToken = cancelToken; await SkillHelper.ExecuteActiveSkill(excuteSkillParams); cancelToken = null; characterStateComponent.Set(SpecialStateType.NotInControl, false); currUsingSkillId = string.Empty; } catch (Exception e) { Log.Error(e.ToString()); } }
async ETVoid PushBack(Unit unit, Vector3 target, Buff_PushBack buff) { CharacterMoveComponent characterMoveComponent = unit.GetComponent <CharacterMoveComponent>(); float moveSpeed = Vector3.Distance(unit.Position, target) / buff.moveDuration; CharacterStateComponent characterStateComponent = unit.GetComponent <CharacterStateComponent>(); characterStateComponent.Set(SpecialStateType.NotInControl, true); //击退效果尝试打断. 以后这里要传参数,代表打断来源,然后下面这个方法里判断来源和技能允许被打断的类型 unit.GetComponent <ActiveSkillComponent>().Interrupt(TypeOfInterruption.FromNotInControl); await characterMoveComponent.PushBackedTo(target, moveSpeed); characterStateComponent.Set(SpecialStateType.NotInControl, false); }
protected override async void Run(ETModel.Session session, M2C_Pushback message) { Unit unit = UnitComponent.Instance.Get(message.Id); CharacterMoveComponent characterMoveComponent = unit.GetComponent <CharacterMoveComponent>(); float moveSpeed = Vector3.Distance(unit.Position, message.MoveTarget.ToV3()) / message.Time; CharacterStateComponent characterStateComponent = unit.GetComponent <CharacterStateComponent>(); characterStateComponent.Set(SpecialStateType.NotInControl, true); await characterMoveComponent.PushBackedTo(message.MoveTarget.ToV3(), moveSpeed); characterStateComponent.Set(SpecialStateType.NotInControl, false); }
async static ETVoid SpellForTime(float value, SkillHelper.ExecuteSkillParams skillParams) { CharacterStateComponent characterStateComponent = skillParams.source.GetComponent <CharacterStateComponent>(); characterStateComponent.Set(SpecialStateType.NotInControl, true); skillParams.cancelToken.Token.Register(() => { characterStateComponent.Set(SpecialStateType.NotInControl, false); }); await TimerComponent.Instance.WaitAsync((long)(value * 1000), skillParams.cancelToken.Token); characterStateComponent.Set(SpecialStateType.NotInControl, false); }