Exemplo n.º 1
0
 /// <summary>
 /// 创建基于地形以玩家主角为核心的场景空间
 /// </summary>
 /// <param name="terrain">地形</param>
 /// <param name="leader">玩家对象</param>
 public Space(Terrain terrain, Hero leader)
 {
     InitializeShadowComponent();
     InitializeMapComponent();
     InitializeWeatherComponent();
     this.terrain = terrain;
     this.Children.Add(music);
     this.Children.Add(space);
     this.AddRole(this.leader = leader);
 }
Exemplo n.º 2
0
 /// <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);
 }
Exemplo n.º 3
0
 void Start(object sender, EventArgs e)
 {
     loginManager.Completed -= Start;
     LayoutRoot.Children.Remove(loginManager);
     loginManager = null;
     Application.Current.Host.Content.Resized -= loginManager_Resized;
     InitializeMouseController();
     InitializeHUDController();
     InitializeConsole();
     EventHandler gameInitHandler = null;
     initializer.ResReady += gameInitHandler = (code0, e0) => {
         initializer.ResReady -= gameInitHandler;
         LayoutRoot.MouseMove += LayoutRoot_MouseMove;
         leader = new Hero(terrain) {
             ID = 19820920,
             AttachID = 19820920,
             Code = (int)code0,
             Profession = Professions.Warrior,
             Camp = Camps.Eval,
             LifeMax = 18750000,
             Life = 16780000,
             ATK = 2000,
             DEF = 550,
             MAG = 900,
             DEX = 50,
         };
         leaderInfo.UpdateLife(leader.Life, leader.LifeMax);
         leader.SightRange = 3000;
         leader.ActionTrigger += role_ShadowSync;
         leader.DoAttack += role_DoAttack;
         leader.DoCasting += role_DoCasting;
         leader.PositionChanged += role_PositionChanged;
         leader.LifeChanged += role_LifeChanged;
         leader.LifeChanged += delegate { leaderInfo.UpdateLife(leader.Life, leader.LifeMax); };
         space = new Space(terrain, leader) { Z = -10 };
         space.ChangeCompleted += space_ChangeCompleted;
         space.RoleAdded += space_RoleAdded;
         LayoutRoot.Children.Add(space);
         cursor.CursorType = CursorTypes.Normal;
         cursor.HeartStart();
         EventHandler spaceInitHandler = null;
         initializer.ResReady += spaceInitHandler = (code1, e1) => {
             initializer.ResReady -= spaceInitHandler;
             //初始化空间
             space.Code = (int)code1;
             comboBox0.SelectedIndex = 1; //走/骑
             //comboBox11.SelectedIndex = 5; //天气
             comboBox12.SelectedIndex = 6;
             //comboBox13.SelectedIndex = 3;
             comboBox15.SelectedIndex = 1; //追影
             //comboBox16.SelectedIndex = 3; //流光
             comboBox19.SelectedIndex = 1;
             //comboBox27.SelectedIndex = 2; //粒子
             comboBox37.SelectedIndex = 1; //地形
             comboBox38.SelectedIndex = 4; //右键技能等级
             comboBox39.SelectedIndex = 21; //右键技能
             button5.IsEnabled = false;
             slider15.Value = 10;
             GlobalMethod.SetTimeout(delegate {
                 AddRoles(null ,new AddRolesEventArgs() { Num = 20, Mode = 0 });
                 button5.IsEnabled = true;
             }, 2000);
         };
         initializer.spaceInit(spaceCode);
     };
     initializer.GameInit(leaderCode);
 }