protected void AddRolesEvent(AddRolesEventArgs e) { if (AddRoles != null) { AddRoles(this, e); } }
/// <summary> /// 添加角色(调试用) /// </summary> /// <param name="num"></param> void AddRoles(object sender, AddRolesEventArgs e) { int armorCode = 0, weaponCode = 0, rideCode = 0; for (int i = 0; i < e.Num; i++) { int tempCamp = Convert.ToInt32(((ComboBoxItem)comboBox32.SelectedItem).Tag); Camps camp = tempCamp == -1 ? (Camps)ObjectBase.RandomSeed.Next(4) : (Camps)tempCamp; Professions profession = Professions.Random; States state = States.Walking; TacticAIs tacticAI = TacticAIs.None; switch (e.Mode) { case 0: int tempProfession = Convert.ToInt32(((ComboBoxItem)comboBox33.SelectedItem).Tag); profession = tempProfession == -1 ? (Professions)ObjectBase.RandomSeed.Next(4) : (Professions)tempProfession; int tempState = Convert.ToInt32(((ComboBoxItem)comboBox34.SelectedItem).Tag); state = tempState == -1 ? (States)ObjectBase.RandomSeed.Next(1, 3) : (States)tempState; int tempTacticAI = Convert.ToInt32(((ComboBoxItem)comboBox35.SelectedItem).Tag); tacticAI = tempTacticAI == -1 ? (TacticAIs)ObjectBase.RandomSeed.Next(1, 5) : (TacticAIs)tempTacticAI; break; case 1: case 2: profession = e.Profession; state = e.State; tacticAI = e.TacticAI; break; } int tempSpaceLayer = Convert.ToInt32(((ComboBoxItem)comboBox29.SelectedItem).Tag); SpaceLayers spaceLayer = tempSpaceLayer == -1 ? (SpaceLayers)ObjectBase.RandomSeed.Next(2) : (SpaceLayers)tempSpaceLayer; int tempActionAI = Convert.ToInt32(((ComboBoxItem)comboBox36.SelectedItem).Tag); ActionAIs actionAI = tempActionAI == -1 ? (ActionAIs)ObjectBase.RandomSeed.Next(0, 4) : (ActionAIs)tempActionAI; Directions direction = (Directions)ObjectBase.RandomSeed.Next(8); Dictionary<int, int> learnedMagic = new Dictionary<int, int>(); switch (profession) { case Professions.Warrior: armorCode = ObjectBase.RandomSeed.Next(7, 9); weaponCode = ObjectBase.RandomSeed.Next(7, 9); if (state == States.Riding) { rideCode = ObjectBase.RandomSeed.Next(7, 9); } for (int j = 0; j < 4; j++) { learnedMagic.Add(j, ObjectBase.RandomSeed.Next(1, 4)); } learnedMagic.Add(18, ObjectBase.RandomSeed.Next(1, 4)); learnedMagic.Add(23, ObjectBase.RandomSeed.Next(1, 4)); break; case Professions.Taoist: armorCode = ObjectBase.RandomSeed.Next(9, 11); weaponCode = ObjectBase.RandomSeed.Next(9, 11); if (state == States.Riding) { rideCode = ObjectBase.RandomSeed.Next(9, 11); } for (int j = 4; j < 10; j++) { learnedMagic.Add(j, ObjectBase.RandomSeed.Next(1, 4)); } learnedMagic.Add(18, ObjectBase.RandomSeed.Next(1, 4)); learnedMagic.Add(24, ObjectBase.RandomSeed.Next(1, 4)); break; case Professions.Archer: armorCode = ObjectBase.RandomSeed.Next(1, 3); weaponCode = ObjectBase.RandomSeed.Next(1, 3); if (state == States.Riding) { rideCode = ObjectBase.RandomSeed.Next(1, 3); } for (int j = 10; j < 15; j++) { learnedMagic.Add(j, ObjectBase.RandomSeed.Next(1, 4)); } learnedMagic.Add(18, ObjectBase.RandomSeed.Next(1, 4)); learnedMagic.Add(20, ObjectBase.RandomSeed.Next(1, 4)); learnedMagic.Add(21, ObjectBase.RandomSeed.Next(1, 4)); learnedMagic.Add(24, ObjectBase.RandomSeed.Next(1, 4)); break; case Professions.Assassin: armorCode = ObjectBase.RandomSeed.Next(5, 7); weaponCode = ObjectBase.RandomSeed.Next(5, 7); if (state == States.Riding) { rideCode = ObjectBase.RandomSeed.Next(5, 7); } for (int j = 15; j < 18; j++) { learnedMagic.Add(j, ObjectBase.RandomSeed.Next(1, 4)); } learnedMagic.Add(18, ObjectBase.RandomSeed.Next(1, 4)); learnedMagic.Add(23, ObjectBase.RandomSeed.Next(1, 4)); break; } Hero player = new Hero(terrain) { ID = countRole++, Code = 0, FullName = string.Format("英雄[{0}号]", countRole), LearnedMagic = learnedMagic, Profession = profession, ArmorCode = armorCode, WeaponCode = weaponCode, RideCode = rideCode, Direction = direction, State = state, Camp = e.Mode == 0 ? camp: Camps.KindHearted, TacticAI = tacticAI, ActionAI = actionAI, LifeMax = ObjectBase.RandomSeed.Next(40670, 43000), Life = ObjectBase.RandomSeed.Next(1800, 40000), ATK = ObjectBase.RandomSeed.Next(1300, 1600), DEF = ObjectBase.RandomSeed.Next(600, 900), MAG = ObjectBase.RandomSeed.Next(400, 500), DEX = ObjectBase.RandomSeed.Next(0, 30), }; player.AttachID = player.ID; player.Disposed += role_Disposed; player.ActionTrigger += role_ShadowSync; player.IntervalTrigger += role_TacticDecide; player.ActionTrigger += role_ActionDecide; player.DoAttack += role_DoAttack; player.DoCasting += role_DoCasting; player.PositionChanged += role_PositionChanged; player.LifeChanged += role_LifeChanged; GetFreeCoordinate(space.Code); switch (e.Mode) { case 0: case 2: player.Coordinate = coordinate; break; case 1: player.Coordinate = new Point(ObjectBase.RandomSeed.Next((int)leader.Coordinate.X - 10, (int)leader.Coordinate.X + 10), ObjectBase.RandomSeed.Next((int)leader.Coordinate.Y - 10, (int)leader.Coordinate.Y + 10)); break; } player.SpaceLayer = spaceLayer; if (player.SpaceLayer == SpaceLayers.Sky) { space.SetShadowScale(player, 0.4); } space.SetSpriteVisible(player, player.InSight(leader)); space.AddRole(player); } textBlock6.Text = string.Format("[场景中共{0}个角色]", space.AllRoles().Count); }