/// <summary> /// 将子npc加入列表 /// </summary> /// <param name="child">Child.</param> public void addChildNpc(ServerNPC child) { if (!childNpc.Contains(child)) { childNpc.Add(child); } }
public ServerNPC removeChild(int id) { ServerNPC child = childNpc.Find(n => n.UniqueId == id); removeChild(child); return(child); }
public void Suffer(ServerNPC caster, ServerNPC sufferer, SelfDescribed des, WarServerNpcMgr npcMgr) { //拿到算子 InjuryOp CoreS = OperatorMgr.instance.getImplement <InjuryOp>(EffectOp.Injury); //TODO: find buff EffectConfigData[] help = null; handled = new Treat { treatValue = des.targetEnd.param1, treatType = (SkillTypeClass)des.targetEnd.param3, isCritical = des.targetEnd.param2 == 1, }; SufTreat res = CoreS.toSufferTreat(ref handled, sufferer.data, caster.data, help); if (res.isCureProtectioin) { //TODO : add Info here. } /// /// 最终结果的计算 /// NPCRuntimeData rtdata = sufferer.data.rtData; rtdata.curHp += (int)handled.treatValue; rtdata.curHp = rtdata.curHp > rtdata.totalHp ? rtdata.totalHp : rtdata.curHp; }
//清理逻辑 void clearDeadNpcStatus(MsgParam msg, WarServerNpcMgr npcMgr) { WarAnimParam warMsg = msg as WarAnimParam; if (warMsg != null && warMsg.described != null) { int deadNpcId = warMsg.described.srcEnd.param2; ServerNPC npc = npcMgr.GetNPCByUniqueID(deadNpcId); ServerLifeNpc life = npc as ServerLifeNpc; if (life != null) { life.curStatus = NpcStatus.None; /// /// ---- 解除挂载的Trigger ---- /// WarServerManager.Instance.triMgr.RemoveAllTrigger(deadNpcId); /// /// ---- 解除挂载的Buff ---- /// WarServerManager.Instance.bufMgr.rmAllBuff(deadNpcId); //--- 解除仇恨信息 ---- life.clearHatred(); } } }
public void Init(ServerNPC parent, WarMsgParam param) { owner = parent; wmMgr = WarServerManager.Instance; tran = transform; if (param is WarSrcAnimParam) { WarSrcAnimParam wp = param as WarSrcAnimParam; sphereParam = wp; WarTarAnimParam[] tars = wp.InjureTar; speed = wp.described.targetEnd.param8; maxDis = wp.described.targetEnd.param9; if (tars != null && tars.Length > 0) { SelfDescribed sd = tars[0].described; npcId = sd.targetEnd.param5; if (wmMgr != null) { target = wmMgr.npcMgr.GetNPCByUniqueID(npcId); if (target != null && parent.outLog) { Debug.Log("Sphere target : " + target.name); } } } else { target = null; } } inited = true; }
void EnterIncite(RtSkData sk, ServerNPC caster, IEnumerable <ServerNPC> targets) { ConditionConfigure ConCfg = null; //获取激活的判定规则ID列表 int[] IncideCon = sk.skillCfg.Incite; if (IncideCon != null && IncideCon.Length > 0) { int len = IncideCon.Length; for (int i = 0; i < len; ++i) { //获取激活的判定规则ID int CondiId = IncideCon[i]; if (CondiId > 0) { ConCfg = ConModel.get(CondiId); Utils.Assert(ConCfg == null, "Can't find Condition Configure. Condition ID = " + ConCfg); //判定器--- 如果成功就跳出 ICondition decider = Mgr.getImplement(ConCfg.ConditionType); bool suc = decider.check(sk, ConCfg, caster, targets); if (suc) { ServerLifeNpc life = caster as ServerLifeNpc; bool isReset = ConCfg.ConditionClass == SkConditionClass.ResetSkill; life.runSkMd.switchToSkill(sk.pos, ConCfg.TargetSkID, isReset); break; } } } } }
/// <summary> /// 这个Targets不能为空 /// </summary> /// <param name="caster">Caster.</param> /// <param name="targets">Targets.</param> /// <param name="efCfg">Ef cfg.</param> /// <param name="npcMgr">Npc mgr.</param> public List <ServerNPC> Select(ServerNPC caster, List <ServerNPC> targets, EffectConfigData efCfg, WarServerNpcMgr npcMgr) { #if DEBUG Utils.Assert(efCfg == null, "Can't find target unless EffectConfigData isn't null."); Utils.Assert(npcMgr == null, "Can't find target unless WarServerNpcMgr isn't null."); Utils.Assert(targets == null, "Can't find target unless targets isn't null."); #endif List <ServerNPC> reTarget = new List <ServerNPC>(); //转换为Camp类型,还有一部分的检查不在这里 //剔除自己的是在Factory里面(即EffectAreaSector) CAMP camp = efCfg.Flags.switchTo(caster.Camp); int count = targets.Count; if (count > 0) { for (int i = 0; i < count; ++i) { UVec3 anchor = targets[i].transform.position; reTarget.AddRange(SelectorTools.GetNPCRadius(anchor, caster.data.configData.radius + efCfg.eParam1, camp, npcMgr)); } } return(reTarget); }
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); } } }
public void analyze(MsgParam msg, WarServerNpcMgr npcMgr) { WarAnimParam warParam = msg as WarAnimParam; if (warParam != null && warParam.described != null) { SelfDescribed des = warParam.described; int castor = des.srcEnd.param1; int sufferer = des.srcEnd.param2; ServerNPC bCast = npcMgr.GetNPCByUniqueID(castor); ServerNPC bSuf = npcMgr.GetNPCByUniqueID(sufferer); if (bCast != null && bSuf != null) { Pair pair = new Pair() { CastorNum = bCast.data.num, KilledNum = bCast.data.num, }; killingInfo.Add(pair); } } }
/// <summary> /// Suffer the specified caster, target and damage. /// 收到伤害的时候,没有返回值. /// </summary> /// <param name="caster">释放者</param> /// <param name="target">目标者</param> /// <param name="damage">伤害值</param> public void Suffer(ServerNPC caster, ServerNPC sufferer, SelfDescribed des, WarServerNpcMgr npcMgr) { //拿到算子 InjuryOp sufOp = OperatorMgr.instance.getImplement <InjuryOp>(EffectOp.Injury); handled = new Dmg { dmgValue = des.targetEnd.param1, dmgType = (SkillTypeClass)des.targetEnd.param3, isCritical = des.targetEnd.param2 == 1, hitCls = (HurtHitClass)Enum.ToObject(typeof(HurtHitClass), des.targetEnd.param4), }; //TODO: find buff EffectConfigData[] help = null; suf = sufOp.toSuffer(ref handled, sufferer.data, caster.data, help); /// ///更多的事情发生了,比如护盾,吸血,反弹 /// report(caster.UniqueID, sufferer.UniqueID, suf, npcMgr); /// /// --------- 最终结算 -------- /// sufferer.data.rtData.curHp -= (int)handled.dmgValue; /// /// --------- 通知Trigger,OnKilled ---------- /// toTriggerMsg(caster, sufferer, npcMgr); }
/// <summary> /// Gets the npc with in range. /// </summary> /// <returns>The npc with in range.</returns> /// <param name="anchor">起点</param> /// <param name="range">范围</param> /// <param name="NpcSource">NPC 容器</param> /// <param name="capm">阵营</param> /// <param name="kind">是否是lifeNpc</param> /// <param name="type">如果是LifeNpc的时候,又是什么子类型</param> public static List <ServerNPC> GetNpcWithInRange(ServerNPC caster, float range, WarServerNpcMgr NpcSource, CAMP camp, KindOfNPC kind, LifeNPCType type = LifeNPCType.SkTarAll) { IEnumerable <ServerNPC> filter = NpcSource.getCampBnpc(camp); if (kind == KindOfNPC.Life) { filter = filter.Where(n => (n.WhatKindOf() == kind) && (type.check(((ServerLifeNpc)n).WhatTypeOf))); } else if (kind == KindOfNPC.NonLife) { filter = filter.Where(n => n.WhatKindOf() == kind); } int count = filter.Count(); if (count > 0) { Vector3 anchor = caster.transform.position; float radius = caster.data.configData.radius; filter = filter.Where(n => IsInRange(anchor, n.data.configData.radius + range + radius, n.transform)); } return(filter.ToList()); }
//选择目标 List <ServerNPC> selectTarget(BulletHurtType HurtType, ServerNPC suffer, bool isFinal, WarServerNpcMgr npcMgr, float radius) { List <ServerNPC> target = new List <ServerNPC>(); switch (HurtType) { /// 伤害所有碰见的敌人 case BulletHurtType.Keep_Dmg: target.Add(suffer); break; /// 伤害最终的敌人 case BulletHurtType.Final_Target_Radius: if (isFinal) { /// --- 默认对敌人的各种类型友方产生攻击 --- /// IEnumerable <ServerNPC> itor = SelectorTools.GetNPCInRange(suffer, radius, npcMgr, KindOfNPC.Life, TargetClass.Friendly, NpcStatus.None); target.AddRange(itor); } break; /// 伤害最终的敌人 case BulletHurtType.Final_Target: if (isFinal) { target.Add(suffer); } break; } return(target); }
/// <summary> /// Raises the trigger enter event. /// </summary> /// <param name="col">Col.</param> void OnTriggerEnter(Collider col) { if (alreadyContacted.Contains(col.gameObject) || !inited) { return; } alreadyContacted.Add(col.gameObject); ServerNPC npc = col.GetComponent <ServerNPC>(); if (npc != null) { WarTarAnimParam param = new WarTarAnimParam(); param.arg1 = effectID; param.arg2 = parent.UniqueID; param.OP = EffectOp.Bullet_NPC; param.cmdType = WarMsg_Type.OnAttacked; param.Sender = parent.UniqueID; param.Receiver = npc.UniqueID; wmMgr.npcMgr.SendMessageAsync(npc.UniqueID, npc.UniqueID, param); if (damageType == 1 || damageType == 2) { if (target != null && npc.UniqueID == target.UniqueID && disappearType == 0) { inited = false; DestroyMe(); } } } }
/// <summary> /// 目前,Trigger的这个触发器,仅仅用来触发场景里面的,和技能无关 /// 技能触发器在WarManager里面 /// </summary> /// <returns>The trigger.</returns> protected ServerNPC createTrigger() { GameObject go = new GameObject("Trigger"); UnityUtils.AddChild_Reverse(go, WarPoint); ServerNPC npc = go.AddComponent <ServerNPC>(); npc.Group = 0; npc.Camp = CAMP.None; /// /// 向WarManager注册 /// if (WarSMgr != null) { WarSMgr.npcMgr.SignID(npc); WarSMgr.npcMgr.RegisterTagNpc("Trigger", npc); /// /// --- 这里创建的都是逻辑型触发器,没有配置 ---- /// --- UseSkill 和 OnKilled都有转发的功能 ---- /// WarSMgr.triMgr.CreateTrigger(WarMsg_Type.BeKilled, npc.UniqueID); WarSMgr.triMgr.CreateTrigger(WarMsg_Type.OnAttacked, npc.UniqueID); WarSMgr.triMgr.CreateTrigger(WarMsg_Type.BeAttacked, npc.UniqueID); WarSMgr.triMgr.CreateTrigger(WarMsg_Type.UseSkill, npc.UniqueID); WarSMgr.triMgr.CreateTrigger(WarMsg_Type.OnKilled, npc.UniqueID); } return(npc); }
/// <summary> /// 检测是否符合逻辑 /// </summary> /// <param name="sk">技能</param> /// <param name="cfg">条件配置技能</param> /// <param name="caster">施法者忽略</param> /// <param name="targets">目标者们忽略</param> public bool check(RtSkData sk, ConditionConfigure cfg, ServerNPC caster, IEnumerable <ServerNPC> targets) { #if DEBUG Utils.Assert(sk == null, "Skill is null in TimeoutCondition."); Utils.Assert(cfg == null, "ConditionConfigure is null in TimeoutCondition."); #endif bool Condi = false; /// /// 1. 判定是否符合关心的BeHead类型 /// var self = this.GetType(); var classAttribute = (ConditionAttribute)Attribute.GetCustomAttribute(self, typeof(ConditionAttribute)); if (cfg.ConditionType == classAttribute.Con) { RtFakeSkData fakeSk = sk as RtFakeSkData; if (fakeSk != null) { float TimeOut = cfg.Param1 * Consts.OneThousand; /// ///2.判定是否超时 /// Condi = fakeSk.aliveDur >= TimeOut; ///3.判定概率 if (Condi) { Condi = PseudoRandom.getInstance().happen(cfg.Prop); } } } return(Condi); }
public void CastSk(params Object[] args) { if (castor != null && param != null) { WarSrcAnimParam srcParam = param as WarSrcAnimParam; if (srcParam != null) { SelfDescribed sd = srcParam.described; if (sd != null) { EndResult result = sd.targetEnd; if (result != null) { WarServerManager mgr = WarServerManager.Instance; int target = result.param3; ServerNPC npc = mgr.npcMgr.GetNPCByUniqueID(target); if (npc != null) { Vector3 dir = npc.transform.position; dir.y = castor.transform.position.y; dir = dir - castor.transform.position; Quaternion rot = Quaternion.LookRotation(dir, Vector3.up); castor.transform.rotation = rot; LeanTween.cancel(castor.gameObject); LeanTween.move(castor.gameObject, npc.transform.position, 0.2f); castor.SendNpcMoveMsg(true); } } } } } }
/// <summary> /// pos 普通攻击的第几步 /// </summary> public List <MsgParam> NormalAttack(ServerNPC caster, short pos) { container.Clear(); #if DEBUG Utils.Assert(caster == null, "Caster is null when cast skill."); #endif ServerLifeNpc src = caster as ServerLifeNpc; if (src.IsAlive == false) { return(container); } RtSkData rtSk = src.runSkMd.getAttack(pos); if (rtSk != null) { IEnumerable <ServerNPC> targets = SelectS.Select(caster, rtSk, Sight.NearSight); EfCastor.Cast(caster, targets, rtSk, container); } int cnt = container.Count; if (cnt > 0) { for (int i = 0; i < cnt; ++i) { ((WarMsgParam)container[i]).cmdType = WarMsg_Type.Attack; } } return(container); }
/// <summary> /// buff属于OriginOfBuff.BornWithSkill这个方法才有效 /// 选择出Buff的目标 /// </summary> /// <param name="adhere">Adhere.</param> /// <param name="bufCfg">Buffer cfg.</param> public ServerNPC locateTarget(RtBufData rtBf) { #if DEBUG Utils.Assert(rtBf == null, "RtBufData is null when relocate buff target."); #endif ServerNPC target = null; if (rtBf.origin == OriginOfBuff.Alone) { target = npcMgr.GetNPCByUniqueID(rtBf.HangUpNpcID); } else { switch (rtBf.BuffCfg.Target) { case BufSel.Add_To_Adhere: target = npcMgr.GetNPCByUniqueID(rtBf.HangUpNpcID); break; case BufSel.Add_To_Caster: target = npcMgr.GetNPCByUniqueID(rtBf.CastorNpcID); break; } } return(target); }
/// /// 释放技能, pos的第几个技能 /// public void Cast(ServerNPC caster, short pos, Action <MsgParam> Report) { #if DEBUG Utils.Assert(caster == null, "Caster is null when cast skill."); #endif ServerLifeNpc src = caster as ServerLifeNpc; if (src.IsAlive == false) { return; } RtSkData rtSk = src.runSkMd.getRuntimeSkill(pos); /// /// 冷却时间好了吗, 死亡了吗 /// if (rtSk != null && rtSk.canCast) { //进入Skill释放的状态 src.curStatus = src.curStatus.set(NpcStatus.InSkill); IEnumerable <ServerNPC> targets = SelectS.Select(caster, rtSk, Sight.NearSight); EfCastor.Cast(caster, targets, rtSk, Report); } }
void castBuff_Skill(RtBufData rtbf, BuffPhase phase) { container.Clear(); RtSkData skill = null; switch (phase) { case BuffPhase.Start: skill = rtbf.OnStartSkill; break; case BuffPhase.End: skill = rtbf.OnEndSkill; break; case BuffPhase.Cycle: skill = rtbf.onCycleskill; break; } if (skill != null) { ServerNPC castor = BFSelector.locateCastor(rtbf); ServerNPC target = BFSelector.locateTarget(rtbf); List <ServerNPC> Targets = new List <ServerNPC>(); Targets.Add(target); IEnumerable <ServerNPC> itor = Targets.AsEnumerable <ServerNPC>(); EfCastor.Cast(castor, itor, skill, container, false); dispatchMsg(container, skill); } }
/// <summary> /// 这个函数目前没有作用, /// 准备将来用于Buff第一次释放时,需要调用的函数 /// </summary> public void FirstCast(RtBufData rtbf) { /// /// --- 设置NPC的状态 --- /// ServerNPC hang = BFSelector.getHangUp(rtbf); ServerLifeNpc life = hang as ServerLifeNpc; if (life != null) { NpcStatus status = (NpcStatus)Enum.ToObject(typeof(NpcStatus), rtbf.BuffCfg.Status); //去除不需要挂载的状态 status = status.rmDiscrete(); if (status != NpcStatus.None) { life.curStatus = life.curStatus.set(status); } //如果有嘲讽的话 if (status.AnySame(NpcStatus.Taunt)) { life.addHatred(rtbf.CastorNpcID, 1); } } /// /// ---- 释放技能 --- /// castBuff_Skill(rtbf, BuffPhase.Start); }
public void OnHappen(MsgParam msg, WarServerNpcMgr npcMgr) { WarAnimParam warParam = msg as WarAnimParam; if (warParam != null && warParam.described != null) { SelfDescribed described = warParam.described; if (described.srcEnd != null) { /// /// 每次被攻击几率对周围造成伤害 /// int casterId = described.srcEnd.param1; int sufferId = described.srcEnd.param2; //不能自己打自己也反弹 if (sufferId == casterId) { return; } if (sufferId == HangUpNpcId) { //选择自己和目标 //目标也是自己 ServerNPC castor = npcMgr.GetNPCByUniqueID(sufferId); List <ServerNPC> targets = new List <ServerNPC>(); targets.Add(castor); warMgr.triMgr.trigCastor.cast(castor, targets, cfg); } } } }
//挑出阵营,但是不应该把施法者过滤掉 //后续如果有要求,才会过滤施法者 IEnumerable <ServerNPC> SelectCamp(ServerNPC caster, IEnumerable <ServerNPC> targets, EffectConfigData efCfg) { CAMP camp = efCfg.Flags.switchTo(caster.Camp); IEnumerable <ServerNPC> itor = targets.Where(n => camp.check(n.Camp) || caster.UniqueID == n.UniqueID); return(itor); }
public void Cast(ServerNPC caster, IEnumerable <ServerNPC> chosen, RtSkData rtSk, List <MsgParam> MsgContainer, bool skDirecHurt) { #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); } ICastEffect[] castor = effMgr.getImplements(effCfg.ToArray(), rtSk.skillCfg); if (castor != null) { int len = castor.Length; for (int i = 0; i < len; ++i) { IEnumerable <ServerNPC> reTarget = selector.Select(caster, chosen, effCfg[i]); castor[i].Cast(caster, chosen, reTarget, skDirecHurt, MsgContainer); effMgr.Recycle(effCfg[i], castor[i]); } } castor = null; }
/// <summary> /// 判定最大,最小生命值的NPC /// </summary> /// <returns>The NPC by hp.</returns> public static IEnumerable <ServerNPC> GetNPCByHp(ServerNPC caster, TargetClass target, IEnumerable <ServerNPC> Itor1) { List <ServerNPC> found = new List <ServerNPC>(); /// /// 枚举器,其实不用返回特定类型,返回枚举器就可以了。(在不需要Copy容器里面的数据时,就是用枚举器) /// IEnumerable <ServerNPC> Itor = found.AsEnumerable(); if (target.AnySame(TargetClass.HpLowest)) { ServerNPC lowest = Itor1.OrderBy(n => n.data.rtData.CurHpNested).FirstOrDefault(); if (lowest != null) { found.Add(lowest); } } else if (target.AnySame(TargetClass.HpHighest)) { ServerNPC highest = Itor1.OrderByDescending(n => n.data.rtData.CurHpNested).FirstOrDefault(); if (highest != null) { found.Add(highest); } } else { Itor = Itor1; } return(Itor); }
public void OnHappen(MsgParam msg, WarServerNpcMgr npcMgr) { WarAnimParam warParam = msg as WarAnimParam; if (warParam != null && warParam.described != null) { SelfDescribed described = warParam.described; if (described.srcEnd != null && described.srcEnd.param1 > 0) { //转发消息 ServerNPC tag = npcMgr.TagNpc("Trigger"); switch (described.act) { case Verb.LineEnemy: warParam.cmdType = WarMsg_Type.LineEnemy; //创建一个触发器 warMgr.triMgr.CreateTrigger(described.src, described.srcEnd.param1, null); npcMgr.SendMessageAsync(tag.UniqueID, tag.UniqueID, msg); break; } } } }
/// <summary> /// 释放技能效果 /// </summary> /// <param name="src">效果发起者</param> /// <param name="target">目标参数无效</param> /// <param name="skDirectHurt">是否是技能的直接伤害, 这个没有伤害</param> /// <param name="container">所有数据展现的容器,本次Effect施法的效果会依次加入</param> /// <param name="skTarget">Sk target.</param> public void Cast(ServerNPC src, IEnumerable <ServerNPC> skTarget, IEnumerable <ServerNPC> target, bool skDirectHurt, List <MsgParam> container) { #if DEBUG Utils.Assert(skCfg == null, "Skill Configure is null in BulletNpcEffect routine."); #endif WarSrcAnimParam SrcParam = new WarSrcAnimParam() { OP = EffectOp.Bullet_NPC, ShootAction = skCfg.ShootAction, ShootTime = skCfg.ShootTime, ShootEventTime = skCfg.ShootEventTime, }; /// /// 有延迟的伤害类技能,伤害的结算都推后 /// SelfDescribed des = new SelfDescribed() { src = src.UniqueID, target = src.UniqueID, act = Verb.Creature, srcEnd = null, targetEnd = new EndResult() { param1 = src.UniqueID, param2 = cfg.ID, param3 = cfg.Param1, } }; SrcParam.described = des; container.Add(SrcParam); }
public void CreateNpc() { Utils.Assert(curChapConfig == null, "Chapter Configdata is null."); if (reader.loadSceneConfig(curChapConfig.scene_config)) { NPCInSceneData[] npcInScene = reader.GetSceneEditorElementData <NPCInSceneData>(); if (npcInScene != null && npcInScene.Length > 0) { int len = npcInScene.Length; CrtHero[] toClient = new CrtHero[len]; for (int i = 0; i < len; i++) { NPCInSceneData sceneD = npcInScene [i]; ServerNPC npc = virNpcLoader.Load(sceneD.npcID, sceneD.camp, WarPoint); if (npc == null) { ConsoleEx.DebugWarning("Create npc fail!!!!!!!!! id:: " + sceneD.npcID); continue; } npc.transform.localPosition = new Vector3(sceneD.pos [0], sceneD.pos [1], sceneD.pos [2]); npc.transform.localScale = new Vector3(sceneD.scale [0], sceneD.scale [1], sceneD.scale [2]); npc.transform.localEulerAngles = new Vector3(sceneD.rotation [0], sceneD.rotation [1], sceneD.rotation [2]); npc.spawnPos = npc.transform.position; npc.spawnRot = npc.transform.rotation; npc.dataInScene = sceneD; npc.data.btData.way = sceneD.way; //初始化buff InitBuff(npc); //初始化AI InitAi(npc); toClient[i] = new CrtHero() { npcID = sceneD.npcID, uniqueId = npc.UniqueID, pos = VectorWrap.ToVector(npc.transform.position), rotation = VectorWrap.ToVector(npc.transform.eulerAngles), camp = (int)npc.Camp, }; } //send creating npc message to client IpcCreateNpcMsg msg = new IpcCreateNpcMsg() { npclist = toClient, }; WarSMgr.realServer.proxyCli.CtorNpc(msg); } } else { ConsoleEx.DebugWarning(curChapConfig.scene_config + " scene config is not find."); } }
/// <summary> /// 将子npc移出列表 /// </summary> /// <param name="child">Child.</param> public void removeChild(ServerNPC child) { if (childNpc.Contains(child)) { childNpc.Remove(child); childNpc.TrimExcess(); } }
/// <summary> /// 删除NPC身上特定的触发器 /// </summary> /// <returns>The trigger.</returns> /// <param name="TriggerId">Trigger identifier.</param> /// <param name="npcId">Npc identifier.</param> public ITriggerItem RemoveTrigger(int TriggerId, int npcId) { if (TriggerId <= 0) { return(null); } ITriggerItem one = null; foreach (WarMsg_Type key in OnWork.Keys) { List <ITriggerItem> list = null; //有队列 if (OnWork.TryGetValue(key, out list)) { int count = list.Count; if (count > 0) { int idx = -1; for (int i = 0; i < count; ++i) { if (list[i].GetID() == TriggerId) { idx = i; one = list[i]; break; } } //删除管理器里面的 if (idx >= 0) { list.RemoveAt(idx); //移回Idle List <ITriggerItem> idleList = null; if (!OnIdle.TryGetValue(key, out idleList)) { idleList = new List <ITriggerItem>(); OnIdle[key] = idleList; } one.OnRest(); OnIdle[key].Add(one); break; } } } } //挂在Npc上删除 ServerNPC npc = WarServerManager.Instance.npcMgr.GetNPCByUniqueID(npcId); npc.rmTrigger(TriggerId); return(one); }