protected override int getPos(byte enumFlag) { int index = 0; ExistFlag flag = (ExistFlag)Enum.ToObject(typeof(ExistFlag), enumFlag); switch (flag) { case ExistFlag.Hostile_Hero_ATK_Self_Hero: index = 0; break; case ExistFlag.Hostile_Summoner_ATK_Self_Hero: index = 1; break; case ExistFlag.Hostile_Minion_ATK_Self_Hero: index = 2; break; case ExistFlag.Hostile_Minion: index = 3; break; case ExistFlag.Hostile_Summoner: index = 4; break; case ExistFlag.Hostile_Hero: index = 5; break; } return(index); }
ExistFlag LifeNpcType2ExistFlag(LifeNPCType type, BuildNPCType bldType) { ExistFlag flag = ExistFlag.None; switch (type) { case LifeNPCType.Hero: flag = ExistFlag.Hero; break; case LifeNPCType.Build: switch (bldType) { case BuildNPCType.Tower: flag = ExistFlag.Tower; break; case BuildNPCType.Barrank: case BuildNPCType.Base: flag = ExistFlag.Building; break; } break; case LifeNPCType.Soldier: flag = ExistFlag.minion; break; case LifeNPCType.Summon: flag = ExistFlag.Summoner; break; } return(flag); }
protected override int getPos(byte enumFlag) { int i = 0; ExistFlag flag = (ExistFlag)Enum.ToObject(typeof(ExistFlag), enumFlag); switch (flag) { case ExistFlag.Hero: i = 0; break; case ExistFlag.Summoner: i = 1; break; case ExistFlag.minion: i = 2; break; case ExistFlag.Tower: i = 3; break; case ExistFlag.Building: i = 4; break; } return(i); }
/// 1.英雄 > 召唤兽 > 小兵 > 防御塔 > 建筑 (英雄使用) public void SortByPriority(IEnumerable <ServerNPC> unPriority, WarServerNpcMgr npcMgr, List <List <ServerNPC> > HasPriority) { //已经排好序的 if (HasPriority == null) { HasPriority = new List <List <ServerNPC> >(); } else { HasPriority.Clear(); } for (int i = 0; i < 5; ++i) { HasPriority.Add(null); } foreach (ServerNPC npc in unPriority) { NPCConfigData cfg = npc.data.configData; ExistFlag totest = LifeNpcType2ExistFlag(cfg.type, cfg.bldType); /// /// 如果属于不关心的类型,则丢弃 /// if (totest == ExistFlag.None) { continue; } base.addNpcByPriority(npc, (byte)totest, HasPriority); } }
ExistFlag NPCToFlag(ServerNPC npc, WarServerNpcMgr npcMgr, LifeNPCType type) { ExistFlag tar1 = ExistFlag.None; ExistFlag tar2 = ExistFlag.None; switch (type) { case LifeNPCType.Hero: tar1 = ExistFlag.Hostile_Hero; tar2 = ExistFlag.Hostile_Hero_ATK_Self_Hero; break; case LifeNPCType.Summon: tar1 = ExistFlag.Hostile_Summoner; tar2 = ExistFlag.Hostile_Summoner_ATK_Self_Hero; break; case LifeNPCType.Soldier: tar1 = ExistFlag.Hostile_Minion; tar2 = ExistFlag.Hostile_Minion_ATK_Self_Hero; break; } ExistFlag toTest = ExistFlag.None; //没有攻击过的目标 if (npc.TargetID == -1) { toTest = tar1; } else { ServerNPC targetNpc = npcMgr.GetNPCByUniqueID(npc.TargetID); if (targetNpc != null) { /// /// 发现目标是Hero,则会判定为攻击了英雄 /// NPCConfigData tarCfg = targetNpc.data.configData; if (tarCfg.type.check(LifeNPCType.Hero)) { toTest = tar2; } else { toTest = tar1; } } else { toTest = tar1; } } return(toTest); }
public void SortByPriority(IEnumerable <ServerNPC> unPriority, WarServerNpcMgr npcMgr, List <List <ServerNPC> > HasPriority) { //已经排好序的 if (HasPriority == null) { HasPriority = new List <List <ServerNPC> >(); } else { HasPriority.Clear(); } for (int i = 0; i < 8; ++i) { HasPriority.Add(null); } foreach (ServerNPC npc in unPriority) { ExistFlag toTest = ExistFlag.None; /// /// 挑选出关心的 敌方英雄,敌方召唤物, 敌方小兵 /// NPCConfigData cfg = npc.data.configData; bool careHero = cfg.type.check(LifeNPCType.Hero); bool careSummoner = cfg.type.check(LifeNPCType.Summon); bool careMinion = cfg.type.check(LifeNPCType.Soldier); bool careBuilding = cfg.type.check(LifeNPCType.Build); bool care = careHero || careSummoner || careMinion || careBuilding; if (care == false) { continue; } if (careHero) { toTest = NPCToFlag(npc, npcMgr, LifeNPCType.Hero); } if (careSummoner) { toTest = NPCToFlag(npc, npcMgr, LifeNPCType.Summon); } if (careMinion) { toTest = NPCToFlag(npc, npcMgr, LifeNPCType.Soldier); } if (careBuilding) { toTest = NPCToFlag(npc, npcMgr, LifeNPCType.Build); } base.addNpcByPriority(npc, (byte)toTest, HasPriority); } }
ExistFlag toExistType(ServerNPC npc, WarServerNpcMgr npcMgr) { NPCConfigData cfg = npc.data.configData; ExistFlag flag = LifeNpcType2ExistFlag(cfg.type, cfg.bldType); if (flag == ExistFlag.Hero) { if (npc.TargetID != -1) { ServerNPC npcTar = npcMgr.GetNPCByUniqueID(npc.TargetID); if (npcTar != null) { flag = ExistFlag.HeroTar; } } } return(flag); }
public void SortByPriority(IEnumerable <ServerNPC> unPriority, WarServerNpcMgr npcMgr, List <List <ServerNPC> > HasPriority) { //已经排好序的 if (HasPriority == null) { HasPriority = new List <List <ServerNPC> >(); } else { HasPriority.Clear(); } for (int i = 0; i < 6; ++i) { HasPriority.Add(null); } foreach (ServerNPC npc in unPriority) { ExistFlag toTest = toExistType(npc, npcMgr); base.addNpcByPriority(npc, (byte)toTest, HasPriority); } }