Example #1
0
 /// <summary>
 /// 初始化角色层
 /// </summary>
 void InitializeRoleLayer(XElement root)
 {
     ClearAllRoles();
     //解析NPC配置(包含两部分配置,Info.xml和NPC.xml)
     IEnumerable<XElement> iNPC = root.Element("RoleLayer").Element("NPCs").Elements();
     for (int i = 0; i < iNPC.Count(); i++) {
         XElement xNPC = iNPC.ElementAt(i);
         XElement args = Infos["NPC"].DescendantsAndSelf("NPCs").Elements().Single(X => X.Attribute("ID").Value == xNPC.Attribute("ID").Value);
         NPC npc = new NPC(terrain) {
             ID = (int)args.Attribute("ID"),
             Code = (int)args.Attribute("Code"),
             ArmorCode = (int)args.Attribute("ArmorCode"),
             FullName = xNPC.Attribute("FullName").Value,
             Profession = Professions.NPC,
             DefaultDirection = (Directions)(int)xNPC.Attribute("Direction"),
             Direction = (Directions)(int)xNPC.Attribute("Direction"),
             State = States.Walking,
             Camp = Camps.None,
             LifeMax = 100,
             Life = 100,
             SpaceLayer = (SpaceLayers)(int)xNPC.Attribute("SpaceLayer"),
             Coordinate = new Point((double)xNPC.Attribute("X"), (double)xNPC.Attribute("Y")),
             TacticAI = TacticAIs.None,
             ActionAI = ActionAIs.Simple,
             FullNameColor = Colors.Magenta,
         };
         //加载说话内容
         IEnumerable<XElement> talks = args.DescendantsAndSelf("Talks").Elements();
         for (int j = 0; j < talks.Count(); j++) {
             npc.AddTalk(new Talk() { Content = talks.ElementAt(j).Attribute("Value").Value, Duration = (int)talks.ElementAt(j).Attribute("Duration") });
         }
         //加载剧情内容
         IEnumerable<XElement> dramas = args.DescendantsAndSelf("Dramas").Elements();
         for (int j = 0; j < dramas.Count(); j++) {
             npc.AddDrama((int)dramas.ElementAt(j).Attribute("Avatar"), string.Format("{0}:{1}", dramas.ElementAt(j).Attribute("Name").Value, dramas.ElementAt(j).Attribute("Content").Value));
         }
         SetSpriteVisible(npc, npc.InSight(leader));
         AddRole(npc, new RoleAddedEventArgs() {
             RegisterDisposedEvent = (bool)args.Attribute("RegisterDisposedEvent"),
             RegisterIntervalTriggerEvent = (bool)args.Attribute("RegisterIntervalTriggerEvent"),
             RegisterActionTriggerEvent = (bool)args.Attribute("RegisterActionTriggerEvent"),
             RegisterDoAttackEvent = (bool)args.Attribute("RegisterDoAttackEvent"),
             RegisterDoCastingEvent = (bool)args.Attribute("RegisterDoCastingEvent"),
             RegisterPositionChangedEvent = (bool)args.Attribute("RegisterPositionChangedEvent"),
             RegisterLifeChangedEvent = (bool)args.Attribute("RegisterLifeChangedEvent"),
         });
     }
 }
Example #2
0
 ///<summary>进度检查(网络版中为所有玩家都要检测,目前单机只检测players[0]即主角)</summary>
 protected override void StepCheck(object sender, EventArgs e)
 {
     SetDescription(string.Format("Step {0}:  {1}", (int)Step, stepExplanation[Step]));
     switch (Step) {
         case Steps.于4个坐标处放置祭旗:
             if (TriggerOrgan[0] && TriggerOrgan[1] && TriggerOrgan[2] && TriggerOrgan[3]) {
                 Step = Steps.设置右键魔法为9级烈焰喷射;
             }
             break;
         case Steps.设置右键魔法为9级烈焰喷射:
             if (players[0].CurrentMagic.Level == 9 && players[0].CurrentMagic.Code == 4) {
                 Step = Steps.召唤王者英灵;
             }
             break;
         case Steps.召唤王者英灵:
             if (TriggerOrgan[4]) {
                 Step = Steps.干掉被魔化俯身的王者英灵;
                 Monster boss = new Monster(space.Terrain) {
                     ID = 3130000,
                     //AttachID = 4110000,
                     Code = 2,
                     FullName = "王者英灵(魔化俯身)",
                     LearnedMagic = new Dictionary<int, int>() { { 0, 6 }, { 1, 6 }, { 2, 6 }, { 3, 6 }, { 4, 6 }, { 5, 6 }, { 6, 6 }, { 7, 6 }, { 8, 6 }, { 9, 6 }, { 10, 6 }, { 11, 6 }, { 12, 6 }, { 13, 6 }, { 14, 6 }, { 15, 6 }, { 16, 6 }, { 17, 6 }, { 18, 6 } },
                     Profession = Professions.Monster,
                     ArmorCode = 17,
                     Direction = Directions.South,
                     State = States.Walking,
                     Camp = Camps.Eval,
                     TacticAI = TacticAIs.GoalLeader,
                     ActionAI = ActionAIs.Persistent,
                     LifeMax = 160000,
                     Life = 160000,
                     ATK = 17466,
                     DEF = 1500,
                     MAG = 500,
                     DEX = ObjectBase.RandomSeed.Next(0, 30),
                     Coordinate = new Point(46, 38)
                 };
                 space.AddRole(boss, new RoleAddedEventArgs() {
                     RegisterDisposedEvent = true,
                     RegisterIntervalTriggerEvent = true,
                     RegisterActionTriggerEvent = true,
                     RegisterDoAttackEvent = true,
                     RegisterDoCastingEvent = true,
                     RegisterPositionChangedEvent = true,
                     RegisterLifeChangedEvent = true,
                 });
                 space.MusicUri = "Boss";
             }
             break;
         case Steps.干掉被魔化俯身的王者英灵:
             if (space.AllRoles().Count == players.Count) {
                 Step = Steps.与王者英灵第一次交谈;
                 space.MusicUri = "101";
                 npc = new NPC(space.Terrain) {
                     ID = 3130001,
                     Code = 2,
                     ArmorCode = 17,
                     FullName ="王者英灵",
                     Profession = Professions.NPC,
                     DefaultDirection = Directions.West,
                     Direction = Directions.West,
                     State = States.Walking,
                     Camp = Camps.None,
                     LifeMax = 100,
                     Life = 100,
                     Coordinate = new Point(46, 38),
                     TacticAI = TacticAIs.None,
                     ActionAI = ActionAIs.Simple,
                     FullNameColor = Colors.Magenta,
                 };
                 //加载说话内容
                 XElement args = Infos["NPC"].DescendantsAndSelf("NPCs").Elements().Single(X => X.Attribute("ID").Value == "3130001");
                 IEnumerable<XElement> talks = args.DescendantsAndSelf("Talks").Elements();
                 for (int j = 0; j < talks.Count(); j++) {
                     npc.AddTalk(new Talk() { Content = talks.ElementAt(j).Attribute("Value").Value, Duration = (int)talks.ElementAt(j).Attribute("Duration") });
                 }
                 //加载剧情内容
                 IEnumerable<XElement> dramas = args.DescendantsAndSelf("Dramas").Elements();
                 for (int j = 0; j < dramas.Count(); j++) {
                     npc.AddDrama((int)dramas.ElementAt(j).Attribute("Avatar"), string.Format("{0}:{1}", dramas.ElementAt(j).Attribute("Name").Value, dramas.ElementAt(j).Attribute("Content").Value));
                 }
                 space.AddRole(npc, new RoleAddedEventArgs() {
                     RegisterDisposedEvent = (bool)args.Attribute("RegisterDisposedEvent"),
                     RegisterIntervalTriggerEvent = (bool)args.Attribute("RegisterIntervalTriggerEvent"),
                     RegisterActionTriggerEvent = (bool)args.Attribute("RegisterActionTriggerEvent"),
                     RegisterDoAttackEvent = (bool)args.Attribute("RegisterDoAttackEvent"),
                     RegisterDoCastingEvent = (bool)args.Attribute("RegisterDoCastingEvent"),
                     RegisterPositionChangedEvent = (bool)args.Attribute("RegisterPositionChangedEvent"),
                     RegisterLifeChangedEvent = (bool)args.Attribute("RegisterLifeChangedEvent"),
                 });
             }
             break;
         case Steps.与王者英灵第一次交谈:
             if (space.AllRoles().Count == players.Count) {
                 Exit("副本【神邸秘境】  战斗失败");
                 break;
             } else if (TriggerOrgan[5]) {
                 Step = Steps.跟随王者英灵走到秘境深处;
                 npc.CleartTalk(); npc.AddTalk(new Talk() { Content = "跟紧啦,小妹!", Duration = 8000 });
                 npc.TaskInfo.Content.Clear();
                 npc.MoveTo(space.Terrain.GetPositionFromCoordinate(new Point(20, 11)));
             }
             break;
         case Steps.跟随王者英灵走到秘境深处:
             if (space.AllRoles().Count == players.Count) {
                 Exit("副本【神邸秘境】  战斗失败");
                 break;
             } else if ((int)npc.Coordinate.X == 20 && (int)npc.Coordinate.Y == 11) {
                 if (Math.Abs(players[0].Coordinate.X - npc.Coordinate.X) <= 5 && Math.Abs(players[0].Coordinate.Y - npc.Coordinate.Y) <= 5) {
                     npc.DefaultDirection = npc.Direction = Directions.South;
                     npc.CleartTalk(); npc.AddTalk(new Talk() { Content = "赶紧啦,你准备好了没?", Duration = 8000 });
                     Step = Steps.设置右键魔法为5级冰咆哮;
                 }
             }
             break;
         case Steps.设置右键魔法为5级冰咆哮:
             if (space.AllRoles().Count == players.Count) {
                 Exit("副本【神邸秘境】  战斗失败");
                 break;
             } else if (players[0].CurrentMagic.Level == 5 && players[0].CurrentMagic.Code == 13) {
                 npc.TaskInfo.Avatar[0] = 5;
                 npc.TaskInfo.Content.Add("5秒后大量追杀者将至,请守护我至少40秒以开启【未来之门】");
                 Step = Steps.与王者英灵第二次交谈;
             }
             break;
         case Steps.与王者英灵第二次交谈:
             if (space.AllRoles().Count == players.Count) {
                 Exit("副本【神邸秘境】  战斗失败");
                 break;
             } else if (TriggerOrgan[6]) {
                 npc.TaskInfo.Content.Clear();
                 npc.CleartTalk(); npc.AddTalk(new Talk() { Content = "保护我40秒!我将耗尽我全身真气开启【未来之门】", Duration = 8000 });
                 StartCountdown(Steps.延迟5秒大量敌人来袭, 5);
                 space.MusicUri = "Boss";
             }
             break;
         case Steps.消灭所有残余敌人:
             if (space.AllRoles().Count == players.Count) {
                 Exit("副本【神邸秘境】  战斗失败");
                 break;
             } else if (space.AllRoles().Count == players.Count + 1) {
                 npc.CleartTalk(); npc.AddTalk(new Talk() { Content = "感谢您的崇高!是您拯救了世界!", Duration = 8000 });
                 Step = Steps.副本完成通过传送门离开秘境;
                 space.MusicUri = "101";
             }
             break;
     }
 }