private void TickEntities() { m_DeletedEntities.Clear(); for (LinkedListNode <EntityInfo> linkNode = m_EntityMgr.Entities.FirstNode; null != linkNode; linkNode = linkNode.Next) { EntityInfo info = linkNode.Value; info.RetireAttackerInfos(60000); if (info.LevelChanged || info.GetSkillStateInfo().BuffChanged) { AttrCalculator.Calc(info); info.LevelChanged = false; info.GetSkillStateInfo().BuffChanged = false; } if (info.IsBorning) { if (info.BornTime <= 0) { SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.BornSkillId); if (info.BornSkillId > 0 && null != skillInfo) { info.BornTime = TimeUtility.GetLocalMilliseconds(); } else { info.IsBorning = false; info.BornTime = 0; info.SetAIEnable(true); info.RemoveState(CharacterPropertyEnum.x3009_无敌); } } else if (info.BornTime + info.BornTimeout < TimeUtility.GetLocalMilliseconds()) { info.IsBorning = false; info.BornTime = 0; info.SetAIEnable(true); info.RemoveState(CharacterPropertyEnum.x3009_无敌); } } if (info.IsDead() && !info.NeedDelete) { if (info.DeadTime <= 0) { CalcKillIncome(info); //发送npc死亡消息 Msg_RC_NpcDead npcDeadBuilder = new Msg_RC_NpcDead(); npcDeadBuilder.npc_id = info.GetId(); NotifyAllUser(RoomMessageDefine.Msg_RC_NpcDead, npcDeadBuilder); SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.DeadSkillId); if (info.DeadSkillId > 0 && null != skillInfo) { info.DeadTime = TimeUtility.GetLocalMilliseconds(); OnEntityKilled(info); } else { if (null == info.CustomData as User) { info.DeadTime = 0; info.NeedDelete = true; OnEntityKilled(info); } else { info.DeadTime = TimeUtility.GetLocalMilliseconds(); } } } else { if (null == info.CustomData as User && info.DeadTime + info.DeadTimeout < TimeUtility.GetLocalMilliseconds()) { info.DeadTime = 0; info.NeedDelete = true; //重新发送npc死亡消息 Msg_RC_NpcDead npcDeadBuilder = new Msg_RC_NpcDead(); npcDeadBuilder.npc_id = info.GetId(); NotifyAllUser(RoomMessageDefine.Msg_RC_NpcDead, npcDeadBuilder); } else if (null != info.CustomData as User && info.DeadTime + info.ReliveTimeout < TimeUtility.GetLocalMilliseconds()) { info.DeadTime = 0; info.Hp = info.HpMax; info.Energy = info.EnergyMax; Msg_RC_SyncProperty npcProp = DataSyncUtility.BuildSyncPropertyMessage(info); NotifyAllUser(RoomMessageDefine.Msg_RC_SyncProperty, npcProp); } } } if (info.NeedDelete) { m_DeletedEntities.Add(info); } } if (m_DeletedEntities.Count > 0) { int enemyCt = 0; int friendCt = 0; Msg_RC_DestroyNpc destroyNpcBuilder = new Msg_RC_DestroyNpc(); for (int i = 0; i < m_DeletedEntities.Count; ++i) { EntityInfo ni = m_DeletedEntities[i]; if (CharacterRelation.RELATION_ENEMY == EntityInfo.GetRelation((int)CampIdEnum.Blue, ni.GetCampId())) { ++enemyCt; } else if (CharacterRelation.RELATION_FRIEND == EntityInfo.GetRelation((int)CampIdEnum.Blue, ni.GetCampId())) { ++friendCt; } //发送npc消失消息 destroyNpcBuilder.npc_id = ni.GetId(); NotifyAllUser(RoomMessageDefine.Msg_RC_DestroyNpc, destroyNpcBuilder); DestroyEntity(ni); } TryAllKilledOrAllDied(enemyCt > 0, friendCt > 0); } m_EntityMgr.ExecuteDelayAdd(); }
private void TickEntities() { m_DeletedEntities.Clear(); for (LinkedListNode <EntityInfo> linkNode = m_EntityManager.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next) { EntityInfo info = linkNode.Value; info.RetireAttackerInfos(10000); if (info.LevelChanged || info.GetSkillStateInfo().BuffChanged) { AttrCalculator.Calc(info); info.LevelChanged = false; info.GetSkillStateInfo().BuffChanged = false; } if (info.IsBorning) { if (info.BornTime <= 0) { SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.BornSkillId); if (info.BornSkillId > 0 && null != skillInfo) { info.BornTime = TimeUtility.GetLocalMilliseconds(); GfxSkillSystem.Instance.StartSkill(info.GetId(), skillInfo.ConfigData, 0); } else { info.IsBorning = false; info.BornTime = 0; info.SetAIEnable(true); info.SetStateFlag(Operate_Type.OT_RemoveBit, CharacterState_Type.CST_Invincible); } } else if (info.BornTime + info.BornTimeout < TimeUtility.GetLocalMilliseconds()) { info.IsBorning = false; info.BornTime = 0; info.SetAIEnable(true); info.SetStateFlag(Operate_Type.OT_RemoveBit, CharacterState_Type.CST_Invincible); } } if (info.IsDead() && !info.NeedDelete) { if (info.CanDead) { if (info.DeadTime <= 0) { SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.DeadSkillId); if (info.DeadSkillId > 0 && null != skillInfo) { info.DeadTime = TimeUtility.GetLocalMilliseconds(); GfxSkillSystem.Instance.StopAllSkill(info.GetId(), true, false, true); GfxSkillSystem.Instance.StartSkill(info.GetId(), skillInfo.ConfigData, 0); OnEntityKilled(info); EntityDrop(info); // 掉落 } else { info.DeadTime = 0; info.NeedDelete = true; OnEntityKilled(info); EntityDrop(info); // 掉落 } } else if (info.DeadTime + info.DeadTimeout < TimeUtility.GetLocalMilliseconds()) { info.DeadTime = 0; info.NeedDelete = true; } } else { info.CanDead = true; } } else { //每个tick复位CanDead,技能里需要鞭尸时应使用触发器每帧标记目标不可死亡(keeplive) info.CanDead = true; } if (info.NeedDelete) { m_DeletedEntities.Add(info); } } if (m_DeletedEntities.Count > 0) { int enemyCt = 0; int friendCt = 0; for (int i = 0; i < m_DeletedEntities.Count; ++i) { EntityInfo ni = m_DeletedEntities[i]; if (CharacterRelation.RELATION_ENEMY == EntityInfo.GetRelation(CampId, ni.GetCampId())) { ++enemyCt; } else if (CharacterRelation.RELATION_FRIEND == EntityInfo.GetRelation(CampId, ni.GetCampId())) { ++friendCt; } DestroyEntity(ni); } TryAllKilledOrAllDied(enemyCt > 0, friendCt > 0); } }