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;
    }
Esempio n. 2
0
    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());
        }
    }
    public static void Execute(this Pipeline_Programmable pipeline_Programmable, SkillHelper.ExecuteSkillParams skillParams)
    {
        SkillData_Var skillData_Var = default;

        skillData_Var.pipelineSignal = pipeline_Programmable.pipelineSignal;
        skillData_Var.skillId        = skillParams.skillId;
        skillData_Var.source         = skillParams.source;
        skillParams.cancelToken.Token.Register(() => pipeline_Programmable.pmb.Break(skillData_Var));
        pipeline_Programmable.pmb.Excute(skillData_Var);
    }
Esempio n. 4
0
        static void ExcutePassiveSkill(this PassiveSkillComponent self, string skillId)
        {
            Unit source = self.GetParent <Unit>();

            if (!self.bufferDatas.ContainsKey(skillId))
            {
                self.bufferDatas[skillId] = new PassiveSkillBufferData();
            }
            SkillHelper.ExecuteSkillParams excuteSkillParams = new SkillHelper.ExecuteSkillParams();
            excuteSkillParams.skillId    = skillId;
            excuteSkillParams.source     = self.GetParent <Unit>();
            excuteSkillParams.skillLevel = 1;

            self.cancelToken = new CancellationTokenSource();
            excuteSkillParams.cancelToken = self.cancelToken;

            PassiveSkillData passiveSkillData = Game.Scene.GetComponent <SkillConfigComponent>().GetPassiveSkill(skillId);

            if (passiveSkillData.listenToEvent)
            {
                if (!self.bufferDatas[skillId].apply)
                {
                    self.bufferDatas[skillId].apply  = true;
                    self.bufferDatas[skillId].aEvent = new ListenPassiveSkillEvent(
                        (unitId) =>
                    {
                        if (unitId == source.Id)
                        {
                            if (SkillHelper.CheckIfSkillCanUse(skillId, source))
                            {
                                self.tokenSource = new ETCancellationTokenSource();

                                SkillHelper.ExecutePassiveSkill(excuteSkillParams);
                            }
                        }
                    }
                        );
                    Game.EventSystem.RegisterEvent(passiveSkillData.eventIdType, self.bufferDatas[skillId].aEvent);
                }
                return;
            }
            else
            {
                if (self.bufferDatas[skillId].apply)
                {
                    return;
                }
            }
            if (SkillHelper.CheckIfSkillCanUse(skillId, source))
            {
                self.tokenSource = new ETCancellationTokenSource();
                SkillHelper.ExecutePassiveSkill(excuteSkillParams);
                self.bufferDatas[skillId].apply = true;
            }
        }
    public static async ETTask  Execute(this Pipeline_FixedTime pipeline_fixedTime, SkillHelper.ExecuteSkillParams skillParams, BuffHandlerVar buffHandlerVar)
    {
        if (pipeline_fixedTime.delayTime > 0)
        {
            await TimerComponent.Instance.WaitAsync((long)(pipeline_fixedTime.delayTime * skillParams.playSpeed * 1000), skillParams.cancelToken.Token);
        }

        SkillHelper.HandleBuffs(pipeline_fixedTime, buffHandlerVar, skillParams).Coroutine();

        if (pipeline_fixedTime.fixedTime > 0)
        {
            await TimerComponent.Instance.WaitAsync((long)(pipeline_fixedTime.fixedTime * skillParams.playSpeed * 1000), skillParams.cancelToken.Token);
        }
    }
Esempio n. 6
0
    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);
    }
 public static void Execute(this Pipeline_FindTarget findTarget, SkillHelper.ExecuteSkillParams skillParams)
 {
     switch (findTarget.findTargetType)
     {
     case FindTargetType.自身:
         SkillHelper.tempData[(skillParams.source, findTarget.pipelineSignal)] = new Dictionary <Type, IBufferValue>();
Esempio n. 8
0
    public static async ETTask <bool> Execute(this Pipeline_WaitForInput pipeline_WaitForInput, SkillHelper.ExecuteSkillParams skillParams)
    {
        await ETTask.CompletedTask;

#if !SERVER
        switch (pipeline_WaitForInput.inputType)
        {
        //等待用户输入,可能有正确输入/取消/输入超时三种情况

        case InputType.Tar:
            CommandInput_UseSkill commandInput_UseSkill = new CommandInput_UseSkill();

            if (skillParams.source != UnitComponent.Instance.MyUnit)
            {
                //非玩家角色使用技能直接跳过等待输入步骤.
                //非玩家角色使用技能的输入来自于其他地方(服务器下发)
                return(true);
            }

            if (SkillHelper.tempData.ContainsKey((skillParams.source, pipeline_WaitForInput.pipelineSignal)))
            {
                //可能还存在着之前使用技能时找到的数据. 所以这里清理掉它
                SkillHelper.tempData.Remove((skillParams.source, pipeline_WaitForInput.pipelineSignal));
            }
            BufferValue_TargetUnits bufferValue_TargetUnits = new BufferValue_TargetUnits();
            bufferValue_TargetUnits.targets = new Unit[1];
            if (UnitComponent.Instance.MyUnit.GetComponent <InputComponent>().GetInputTarget(out bufferValue_TargetUnits.targets[0], pipeline_WaitForInput.findFriend, skillParams.source.UnitData.groupIndex))
            {
                UnityEngine.Vector3 _forward1 = bufferValue_TargetUnits.targets[0].Position - skillParams.source.Position;
                skillParams.source.Rotation = UnityEngine.Quaternion.LookRotation(new UnityEngine.Vector3(_forward1.x, 0, _forward1.z), UnityEngine.Vector3.up);


                commandInput_UseSkill.skillId        = skillParams.skillId;
                commandInput_UseSkill.pipelineSignal = pipeline_WaitForInput.pipelineSignal;
                commandInput_UseSkill.bufferValue    = bufferValue_TargetUnits;
                UnitComponent.Instance.MyUnit.GetComponent <CommandComponent>().CollectCommandInput(commandInput_UseSkill);
            }
            else
            {
                Log.Debug("找不到目标! 技能终止!");
                return(false);
            }

            break;

        case InputType.Dir:
            commandInput_UseSkill = new CommandInput_UseSkill();
            if (skillParams.source != UnitComponent.Instance.MyUnit)
            {
                //非玩家角色使用技能直接跳过等待输入步骤.
                //非玩家角色使用技能的输入来自于其他地方(服务器下发)
                return(true);
            }

            if (SkillHelper.tempData.ContainsKey((skillParams.source, pipeline_WaitForInput.pipelineSignal)))
            {
                //可能还存在着之前使用技能时找到的数据. 所以这里清理掉它
                SkillHelper.tempData.Remove((skillParams.source, pipeline_WaitForInput.pipelineSignal));
            }
            //直接智能施法模式
            BufferValue_Dir bufferValue_Dir = new BufferValue_Dir();
            bufferValue_Dir.dir = UnitComponent.Instance.MyUnit.GetComponent <InputComponent>().GetInputDir();

            //直接改变使用技能时角色的转向
            skillParams.source.Rotation = UnityEngine.Quaternion.LookRotation(bufferValue_Dir.dir, UnityEngine.Vector3.up);

            commandInput_UseSkill.skillId        = skillParams.skillId;
            commandInput_UseSkill.pipelineSignal = pipeline_WaitForInput.pipelineSignal;
            commandInput_UseSkill.bufferValue    = bufferValue_Dir;
            UnitComponent.Instance.MyUnit.GetComponent <CommandComponent>().CollectCommandInput(commandInput_UseSkill);

            break;

        case InputType.Pos:
            commandInput_UseSkill = new CommandInput_UseSkill();
            if (skillParams.source != UnitComponent.Instance.MyUnit)
            {
                //非玩家角色使用技能直接跳过等待输入步骤.
                //非玩家角色使用技能的输入来自于其他地方(服务器下发)
                return(true);
            }

            if (SkillHelper.tempData.ContainsKey((skillParams.source, pipeline_WaitForInput.pipelineSignal)))
            {
                //可能还存在着之前使用技能时找到的数据. 所以这里清理掉它
                SkillHelper.tempData.Remove((skillParams.source, pipeline_WaitForInput.pipelineSignal));
            }
            BufferValue_Pos bufferValue_Pos = new BufferValue_Pos();
            if (!UnitComponent.Instance.MyUnit.GetComponent <InputComponent>().GetInputPos(out bufferValue_Pos.aimPos))
            {
                return(false);
            }

            //直接改变使用技能时角色的转向
            UnityEngine.Vector3 forward = bufferValue_Pos.aimPos - skillParams.source.Position;
            skillParams.source.Rotation = UnityEngine.Quaternion.LookRotation(new UnityEngine.Vector3(forward.x, 0, forward.z), UnityEngine.Vector3.up);

            commandInput_UseSkill.skillId        = skillParams.skillId;
            commandInput_UseSkill.pipelineSignal = pipeline_WaitForInput.pipelineSignal;
            commandInput_UseSkill.bufferValue    = bufferValue_Pos;
            UnitComponent.Instance.MyUnit.GetComponent <CommandComponent>().CollectCommandInput(commandInput_UseSkill);
            break;

        case InputType.Charge:
            break;

        case InputType.Spell:

            break;

        case InputType.ContinualSpell:

            SpellForTime(pipeline_WaitForInput.value, skillParams).Coroutine();
            break;
        }
#else
        switch (pipeline_WaitForInput.inputType)
        {
        case InputType.Tar:
            break;

        case InputType.Dir:
            break;

        case InputType.Pos:
            break;

        case InputType.Charge:
            break;

        case InputType.Spell:
            break;

        case InputType.ContinualSpell:
            SpellForTime(pipeline_WaitForInput.value, skillParams).Coroutine();
            break;
        }
#endif
        return(true);
    }
Esempio n. 9
0
 public static async ETTask <LinkedListNode <BasePipelineData> > Execute(this Pipeline_CycleEnd cycleEnd, LinkedListNode <BasePipelineData> node, SkillHelper.ExecuteSkillParams skillParams)
 {
     (LinkedListNode <BasePipelineData>, int, int)stackItem = default;
     stackItem = skillParams.cycleStartsStack.Pop();
     if (stackItem.Item2 >= stackItem.Item3)
     {
         return(node.Next);
     }
     else
     {
         if (cycleEnd.waitTime > 0)
         {
             await TimerComponent.Instance.WaitAsync((long)(cycleEnd.waitTime * skillParams.playSpeed * 1000), skillParams.cancelToken.Token);
         }
         skillParams.cycleStartsStack.Push(stackItem);
         return(stackItem.Item1);
     }
 }
Esempio n. 10
0
 public static void Execute(this Pipeline_CycleStart pipeline_CycleStart, LinkedListNode <BasePipelineData> node, SkillHelper.ExecuteSkillParams skillParams)
 {
     (LinkedListNode <BasePipelineData>, int, int)stackItem = default;
     if (skillParams.cycleStartsStack.Count > 0)
     {
         stackItem = skillParams.cycleStartsStack.Pop();
     }
     stackItem.Item1 = node;
     stackItem.Item2++;
     stackItem.Item3 = pipeline_CycleStart.repeatCount;
     skillParams.cycleStartsStack.Push(stackItem);
 }