public void EnterIncite(RtSkData sk, EffectConfigData efCfg, ServerNPC caster, IEnumerable <ServerNPC> targets) { bool canEnter = CheckIncite(sk, efCfg); if (canEnter) { bool injured = CheckBeHead(sk); if (injured) { float Delay = 0.6F; /// /// 检测伤害类的还需要至少延迟了两个FixedUpdate,因为承受伤害的逻辑,还没开始执行 /// 所以,目标血量的判定还不能开始 /// DelayedSkData data = new DelayedSkData() { caster = caster, chosen = targets, rtsk = sk, }; SkAsyncRunner.AysncRun(EnterIncite, Delay, data); } else { EnterIncite(sk, caster, targets); } } }
/// <summary> /// 这个是给技能使用的,可能不会立即有结果 /// </summary> /// <param name="caster">Caster.</param> /// <param name="chosen">Chosen.</param> /// <param name="rtSk">技能</param> /// <param name="pos">技能的索引</param> /// <param name="Report">Report.</param> public void Cast(ServerNPC Caster, IEnumerable <ServerNPC> Chosen, RtSkData RtSk, Action <MsgParam> ReportFunc) { #if DEBUG Utils.Assert(Caster == null, "Effect Castor"); Utils.Assert(RtSk == null, "Effect Castor"); #endif List <EffectConfigData> effCfg = new List <EffectConfigData>(); foreach (EffectConfigData cfg in RtSk.effectCfgDic.Values) { effCfg.Add(cfg); } //虚假的Buff桩对象 EffectConfigData stub = ctorStubEffCfg(RtSk); if (stub != null) { effCfg.Add(stub); } ICastEffect[] castor = effMgr.getImplements(effCfg.ToArray(), RtSk.skillCfg); if (castor != null) { int len = castor.Length; for (int i = 0; i < len; ++i) { if (castor[i] == null) { ConsoleEx.DebugLog("ICastEffect Not Implement. ID = " + effCfg[i].ID, ConsoleEx.YELLOW); } else { float Delay = RtSk.skillCfg.EffectDelayTime[i]; if (Delay > 0) { DelayedSkData data = new DelayedSkData() { caster = Caster, chosen = Chosen, castor = castor[i], cfg = effCfg[i], Report = ReportFunc, rtsk = RtSk, }; SkAsyncRunner.AysncRun(DelayCast, Delay, data); } else { DelayCast(Caster, Chosen, castor[i], effCfg[i], RtSk, ReportFunc); } } } } castor = null; }
static void Initialize() { if (!initialized) { if (!Application.isPlaying) { return; } initialized = true; var g = new GameObject("SkAsyncRunner"); var gobal = GameObject.FindGameObjectWithTag("Global"); if (gobal != null) { g.transform.parent = gobal.transform; } _current = g.AddComponent <SkAsyncRunner>(); DontDestroyOnLoad(g); } }
void Awake() { _current = this; initialized = true; }