コード例 #1
0
ファイル: Town.cs プロジェクト: sakseichek/homm
        public Town(int id, Image img)
        {
            _id = id;
            _image = img;

            Heroes.Core.Army army = new Heroes.Core.Army();
            army._id = (int)Heroes.Core.ArmyIdEnum.Pikeman;
            army._qty = 14;
            army._name = "Pikemen";
            base._armyAvKIds.Add(army._id, army);

            Heroes.Core.Army army1 = new Heroes.Core.Army();
            army1._id = (int)Heroes.Core.ArmyIdEnum.Archer;
            army1._qty = 9;
            army1._name = "Archer";
            base._armyAvKIds.Add(army1._id, army1);

            Heroes.Core.Army army2 = new Heroes.Core.Army();
            army2._id = (int)Heroes.Core.ArmyIdEnum.Griffin;
            army2._qty = 7;
            army2._name = "Griffin";
            base._armyAvKIds.Add(army2._id, army2);

            Heroes.Core.Army army3 = new Heroes.Core.Army();
            army3._id = (int)Heroes.Core.ArmyIdEnum.Swordman;
            army3._qty = 4;
            army3._name = "Swordman";
            base._armyAvKIds.Add(army3._id, army3);

            Heroes.Core.Army army4 = new Heroes.Core.Army();
            army4._id = (int)Heroes.Core.ArmyIdEnum.Monk;
            army4._qty = 3;
            army4._name = "Monk";
            base._armyAvKIds.Add(army4._id, army4);

            Heroes.Core.Army army5 = new Heroes.Core.Army();
            army5._id = (int)Heroes.Core.ArmyIdEnum.Cavalier;
            army5._qty = 2;
            army5._name = "Cavalier";
            base._armyAvKIds.Add(army5._id, army5);

            Heroes.Core.Army army6 = new Heroes.Core.Army();
            army6._id = (int)Heroes.Core.ArmyIdEnum.Angel;
            army6._qty = 1;
            army6._name = "Angel";
            base._armyAvKIds.Add(army6._id, army6);
        }
コード例 #2
0
ファイル: frmDuel.cs プロジェクト: sakseichek/homm
        private bool CaptureMine(int count, int level)
        {
            // Few 1-4
            // Several 5-9
            // Pack 10-19
            // Lots 20-49
            // Horde 50-99
            // Throng 100-249
            // Swarm 250-499
            // Zounds 500-999
            // Legion 1000+

            Heroes.Core.Monster monster = new Heroes.Core.Monster();
            monster._id = 1;

            Random rnd = new Random();

            int totalQty = 0;

            if (level == 2)
                totalQty = rnd.Next(20, 49);
            if (level == 3)
                totalQty = rnd.Next(50, 99);
            else
                totalQty = rnd.Next(10, 19);
            totalQty *= (count + 1);

            int slots = rnd.Next(1, 5);
            int qtyPerSlot = totalQty / slots;

            int[] slotNos = null;
            Heroes.Core.Army army = null;
            if (slots == 1)
            {
                slotNos = new int[] { 3 };
            }
            else if (slots == 2)
            {
                slotNos = new int[] { 2, 4 };
            }
            else if (slots == 3)
            {
                slotNos = new int[] { 0, 3, 6 };
            }
            else if (slots == 4)
            {
                slotNos = new int[] { 0, 2, 4, 6 };
            }
            else if (slots == 5)
            {
                slotNos = new int[] { 0, 2, 3, 4, 6 };
            }

            foreach (int slotNo in slotNos)
            {
                army = new Heroes.Core.Army();
                army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Pikeman]);
                army._qty = qtyPerSlot;
                army._slotNo = slotNo;
                monster._armyKSlots.Add(army._slotNo, army);
            }

            return Battle(_currentHero, monster);
        }
コード例 #3
0
ファイル: frmDuel.cs プロジェクト: sakseichek/homm
        private void CreatePlayer(int id)
        {
            Heroes.Core.Player player = new Heroes.Core.Player();
            player._id = id;
            player._wood = 20;
            player._mercury = 10;
            player._ore = 20;
            player._sulfur = 10;
            player._crystal = 10;
            player._gem = 10;
            player._gold = 20000;
            _players.Add(player);

            Random rnd = new Random();

            // hero
            Heroes.Core.Hero hero = (Heroes.Core.Hero)Heroes.Core.Setting._heros[id];
            hero._playerId = player._id;
            hero._player = player;
            hero._level = 1;
            hero._experience = rnd.Next(45, 99);
            hero.CalculateMaxSpellPoint();
            hero._spellPointLeft = hero._maxSpellPoint;
            hero._movementPoint = 1;
            hero._movementPointLeft = hero._movementPoint;
            player._heroes.Add(hero);

            // army
            {
                Heroes.Core.Army army = new Heroes.Core.Army();
                army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Pikeman]);
                army.AddAttribute(hero);
                army._heroId = hero._id;
                army._playerId = player._id;
                //army._qty = rnd.Next(20, 49);
                army._qty = rnd.Next(500, 999);
                army._slotNo = 1;
                hero._armyKSlots.Add(army._slotNo, army);

                army = new Heroes.Core.Army();
                army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Archer]);
                army.AddAttribute(hero);
                army._heroId = hero._id;
                army._playerId = player._id;
                //army._qty = rnd.Next(10, 19);
                army._qty = rnd.Next(500, 999);
                army._slotNo = 0;
                hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Griffin]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(10, 19);
                ////army._qty = rnd.Next(500, 999);
                //army._slotNo = 4;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Swordman]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(10, 19);
                ////army._qty = rnd.Next(500, 999);
                //army._slotNo = 5;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Cavalier]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(5, 9);
                ////army._qty = rnd.Next(500, 999);
                //army._slotNo = 2;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Monk]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(10, 19);
                ////army._qty = rnd.Next(500, 999);
                //army._slotNo = 6;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Angel]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(1, 4);
                ////army._qty = rnd.Next(500, 999);
                //army._slotNo = 3;
                //hero._armyKSlots.Add(army._slotNo, army);
            }

            // spells
            {
                Heroes.Core.Spell spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.MagicArrow]);
                spell.CalculateDamage(hero);
                hero._spells.Add(spell._id, spell);

                spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.Haste]);
                hero._spells.Add(spell._id, spell);
            }

            // castle
            {
                Heroes.Core.Town town = new Heroes.Core.Town();
                town._id = player._id;
                town._playerId = player._id;
                town._player = player;
                town._heroVisit = hero;
                player._castles.Add(town);

                // buildings
                {
                    Heroes.Core.Building building = new Heroes.Core.Building();
                    building.CopyFrom((Heroes.Core.Building)Heroes.Core.Setting._buildings[(int)Heroes.Core.BuildingIdEnum.VillageHall]);
                    town._buildingKIds.Add(building._id, building);

                    building = new Heroes.Core.Building();
                    building.CopyFrom((Heroes.Core.Building)Heroes.Core.Setting._buildings[(int)Heroes.Core.BuildingIdEnum.Tavern]);
                    town._buildingKIds.Add(building._id, building);

                    building = new Heroes.Core.Building();
                    building.CopyFrom((Heroes.Core.Building)Heroes.Core.Setting._buildings[(int)Heroes.Core.BuildingIdEnum.Fort]);
                    town._buildingKIds.Add(building._id, building);
                }
            }
        }
コード例 #4
0
ファイル: GameSetting.cs プロジェクト: sakseichek/homm
        public static void ConvertBattleToNetwork(Heroes.Core.Player attackPlayerMap, Heroes.Core.Hero attackHeroMap, Hashtable attackArmiesMap,
            Heroes.Core.Player defendPlayerMap, Heroes.Core.Hero defendHeroMap, Heroes.Core.Town defendCastleMap, Hashtable defendArmiesMap,
            out Heroes.Core.Player attackPlayer, out Heroes.Core.Hero attackHero, out Hashtable attackArmies,
            out Heroes.Core.Player defendPlayer, out Heroes.Core.Hero defendHero, out Heroes.Core.Town defendCastle, out Hashtable defendArmies)
        {
            attackPlayer = null;
            attackHero = null;
            attackArmies = new Hashtable();
            defendPlayer = null;
            defendHero = null;
            defendCastle = null;
            defendArmies = new Hashtable();

            if (attackArmiesMap != null)
            {
                foreach (Heroes.Core.Army armyMap in attackArmiesMap.Values)
                {
                    Heroes.Core.Army army = new Heroes.Core.Army();
                    army._id = armyMap._id;
                    army._qty = armyMap._qty;
                    army._slotNo = armyMap._slotNo;
                    attackArmies.Add(army._slotNo, army);
                }
            }

            if (attackPlayerMap != null)
            {
                attackPlayer = new Heroes.Core.Player();
                attackPlayer._id = attackPlayerMap._id;
            }

            if (attackHeroMap != null)
            {
                attackHero = new Heroes.Core.Hero();
                attackHero._id = attackHeroMap._id;
                attackHero._player = attackPlayer;
                attackHero._armyKSlots = attackArmies;
            }

            if (defendArmiesMap != null)
            {
                foreach (Heroes.Core.Army armyMap in defendArmiesMap.Values)
                {
                    Heroes.Core.Army army = new Heroes.Core.Army();
                    army._id = armyMap._id;
                    army._qty = armyMap._qty;
                    army._slotNo = armyMap._slotNo;
                    defendArmies.Add(army._slotNo, army);
                }
            }

            if (defendPlayerMap != null)
            {
                defendPlayer = new Heroes.Core.Player();
                defendPlayer._id = defendPlayerMap._id;
            }

            if (defendHeroMap != null)
            {
                defendHero = new Heroes.Core.Hero();
                defendHero._id = defendHeroMap._id;
                defendHero._player = defendPlayer;
                defendHero._armyKSlots = defendArmies;
            }

            // castle
        }
コード例 #5
0
ファイル: BattleEngine.cs プロジェクト: sakseichek/homm
 public ViewingArmyInfoEventArg(Heroes.Core.Army army, Heroes.Core.Battle.frmArmyInfo frmArmyInfo)
 {
     _army = army;
     _frmArmyInfo = frmArmyInfo;
 }
コード例 #6
0
ファイル: GameSetting.cs プロジェクト: sakseichek/homm
        public static void ConvertMapToNetwork(ArrayList mapPlayers, ArrayList mapMines, Heroes.Core.Map.Cell[,] mapCells,
            out ArrayList players, out Hashtable heroCells)
        {
            players = new ArrayList();
            heroCells = new Hashtable();

            // copy players and heroes
            foreach (Heroes.Core.Map.Player player in mapPlayers)
            {
                Heroes.Core.Player player2 = new Heroes.Core.Player();
                player2._id = player._id;
                player2._gold = player._gold;
                players.Add(player2);

                foreach (Heroes.Core.Map.Hero hero in player._heroes)
                {
                    Heroes.Core.Hero hero2 = new Heroes.Core.Hero();
                    hero2._id = hero._id;
                    hero2._player = player2;
                    player2._heroes.Add(hero2);

                    // cell in map
                    if (hero._cell != null)
                    {
                        GameCell cell = new GameCell(hero._cell._row, hero._cell._col);
                        heroCells.Add(hero2._id, cell);
                    }

                    foreach (Heroes.Core.Army army in hero._armyKSlots.Values)
                    {
                        Heroes.Core.Army army2 = new Heroes.Core.Army();
                        army2._id = army._id;
                        army2._slotNo = army._slotNo;
                        army2._qty = army._qty;

                        hero2._armyKSlots.Add(army2._slotNo, army2);
                    }
                }
            }

            // copy Towns
            int index = 0;
            foreach (Heroes.Core.Map.Player player in mapPlayers)
            {
                Heroes.Core.Player player2 = (Heroes.Core.Player)players[index];

                foreach (Heroes.Core.Map.Town town in player._castles)
                {
                    Heroes.Core.Town town2 = new Heroes.Core.Town();
                    town2._id = town._id;
                    town2._player = player2;
                    player2._castles.Add(town2);

                    foreach (Heroes.Core.Army army in town._armyAvKIds.Values)
                    {
                        Heroes.Core.Army army2 = new Heroes.Core.Army();
                        army2._id = army._id;
                        army2._qty = army._qty;

                        town2._armyAvKIds.Add(army2._id, army2);
                    }

                    foreach (Heroes.Core.Army army in town._armyInCastleKSlots.Values)
                    {
                        Heroes.Core.Army army2 = new Heroes.Core.Army();
                        army2._id = army._id;
                        army2._slotNo = army._slotNo;
                        army2._qty = army._qty;

                        town2._armyInCastleKSlots.Add(army2._id, army2);
                    }

                    if (town._heroVisit != null)
                    {
                        int indexPlayer = mapPlayers.IndexOf(town._heroVisit._player);
                        Heroes.Core.Map.Player playerVisit = (Heroes.Core.Map.Player)mapPlayers[indexPlayer];
                        int indexHero = playerVisit._heroes.IndexOf(town._heroVisit);

                        Heroes.Core.Player playerVisit2 = (Heroes.Core.Player)players[indexPlayer];
                        Heroes.Core.Hero heroVisit2 = (Heroes.Core.Hero)playerVisit2._heroes[indexHero];
                        town2._heroVisit = heroVisit2;
                    }
                }

                index += 1;
            }

            // copy mines
            foreach (Heroes.Core.Map.Mine mine in mapMines)
            {
                Heroes.Core.Mine mine2 = new Heroes.Core.Mine(mine._id);

                if (mine._player != null)
                {
                    // get player
                    Heroes.Core.Player player2 = GameSetting.FindPlayer(mine._player._id, players);
                    mine2._player = player2;
                    player2._mineKTypes[(int)Heroes.Core.MineTypeEnum.Gold].Add(mine2);
                }
                else
                {
                    mine2._player = null;
                }
            }
        }
コード例 #7
0
ファイル: frmDuelNetwork.cs プロジェクト: sakseichek/homm
        private void InitPlayer(Heroes.Core.Player player, int startingHeroId)
        {
            player._wood = 20;
            player._mercury = 10;
            player._ore = 20;
            player._sulfur = 10;
            player._crystal = 10;
            player._gem = 10;
            player._gold = 20000;

            //player._wood = 10;
            //player._mercury = 0;
            //player._ore = 10;
            //player._sulfur = 0;
            //player._crystal = 0;
            //player._gem = 0;
            //player._gold = 10000;

            Random rnd = new Random();

            // hero
            Heroes.Core.Hero hero = (Heroes.Core.Hero)Heroes.Core.Setting._heros[startingHeroId];
            hero._playerId = player._id;
            hero._player = player;
            hero._level = 1;
            hero._experience = rnd.Next(45, 99);
            //hero._movementPoint = 1;
            hero._movementPoint = 2;
            hero._movementPointLeft = hero._movementPoint;
            player._heroes.Add(hero);

            // army
            {
                Heroes.Core.Army army = new Heroes.Core.Army();
                army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Pikeman]);
                army._heroId = hero._id;
                army._playerId = player._id;
                army._qty = rnd.Next(20, 49);
                //army._qty = rnd.Next(500, 999);
                army._slotNo = 1;
                hero._armyKSlots.Add(army._slotNo, army);

                army = new Heroes.Core.Army();
                army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Archer]);
                army._heroId = hero._id;
                army._playerId = player._id;
                army._qty = rnd.Next(10, 19);
                //army._qty = rnd.Next(500, 999);
                army._slotNo = 0;
                hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.RoyalGiffin]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(10, 19);
                //army._slotNo = 4;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Crusader]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(10, 19);
                //army._slotNo = 5;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Champion]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(5, 9);
                //army._slotNo = 2;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Zealot]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(10, 19);
                //army._slotNo = 6;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Archangel]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(1, 4);
                //army._slotNo = 3;
                //hero._armyKSlots.Add(army._slotNo, army);
            }

            // spells
            {
                Heroes.Core.Spell spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.MagicArrow]);
                hero._spells.Add(spell._id, spell);

                spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.IceBolt]);
                hero._spells.Add(spell._id, spell);

                spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.MeteorShower]);
                hero._spells.Add(spell._id, spell);

                spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.LightningBolt]);
                hero._spells.Add(spell._id, spell);

                spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.Implosion]);
                hero._spells.Add(spell._id, spell);

                spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.FireBall]);
                hero._spells.Add(spell._id, spell);

                spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.Inferno]);
                hero._spells.Add(spell._id, spell);
            }

            // artifacts
            //for (int i = 0; i < 20; i++)
            {
                GettingArtifactEventArg e2 = new GettingArtifactEventArg(Heroes.Core.Heros.ArtifactLevelEnum.Treasure);
                OnGettingArtifact(e2);

                if (e2._artifact != null)
                {
                    hero.AddArtifacts(e2._artifact);
                }
            }

            hero.CalculateAll();
            hero._spellPointLeft = hero._maxSpellPoint;

            // castle
            {
                Heroes.Core.Town town = new Heroes.Core.Town();
                town._id = player._id;
                town._playerId = player._id;
                town._player = player;
                town._heroVisit = hero;
                player._castles.Add(town);

                // buildings
                {
                    Heroes.Core.Building building = new Heroes.Core.Building();
                    building.CopyFrom((Heroes.Core.Building)Heroes.Core.Setting._buildings[(int)Heroes.Core.BuildingIdEnum.VillageHall]);
                    town._buildingKIds.Add(building._id, building);

                    building = new Heroes.Core.Building();
                    building.CopyFrom((Heroes.Core.Building)Heroes.Core.Setting._buildings[(int)Heroes.Core.BuildingIdEnum.Tavern]);
                    town._buildingKIds.Add(building._id, building);

                    building = new Heroes.Core.Building();
                    building.CopyFrom((Heroes.Core.Building)Heroes.Core.Setting._buildings[(int)Heroes.Core.BuildingIdEnum.Fort]);
                    town._buildingKIds.Add(building._id, building);
                }
            }
        }
コード例 #8
0
ファイル: frmDuelNetwork.cs プロジェクト: sakseichek/homm
        private Heroes.Core.Monster CreateMonster(int[] armyLevels, int startingQtyIndex, int multiplier)
        {
            Heroes.Core.Monster monster = new Heroes.Core.Monster();
            monster._id = 1;

            Random rnd = new Random();

            // random monster level
            int levelIndex = rnd.Next(0, armyLevels.Length);
            int level = armyLevels[levelIndex];

            // create armyIds
            ArrayList ids = new ArrayList();
            Hashtable armies = Heroes.Core.Setting._armyKLevelKIds[level];
            foreach (int id in armies.Keys)
            {
                ids.Add(id);
            }

            int index = rnd.Next(0, ids.Count);
            int armyId = (int)ids[index];

            // random qty
            int totalQty = 0;
            {
                int qtyIndex = startingQtyIndex - levelIndex;   // less qty if higher level
                if (qtyIndex < 0) qtyIndex = 0;

                int minQty = 0;
                if (qtyIndex < _minQtys.Length) minQty = _minQtys[qtyIndex];
                else minQty = 99999;

                int maxQty = 0;
                if (qtyIndex < _minQtys.Length) maxQty = _maxQtys[qtyIndex];
                else maxQty = 99999;

                totalQty = rnd.Next(minQty, maxQty + 1);
                totalQty *= multiplier;
            }

            // random slot
            {
                int slots = 0;
                int qtyPerSlot = 0;

                // do until qty per slot is more than zero
                do
                {
                    slots = rnd.Next(1, 6);
                    qtyPerSlot = totalQty / slots;
                } while (qtyPerSlot <= 0);

                int[] slotNos = null;
                Heroes.Core.Army army = null;
                if (slots == 1)
                {
                    slotNos = new int[] { 3 };
                }
                else if (slots == 2)
                {
                    slotNos = new int[] { 2, 4 };
                }
                else if (slots == 3)
                {
                    slotNos = new int[] { 0, 3, 6 };
                }
                else if (slots == 4)
                {
                    slotNos = new int[] { 0, 2, 4, 6 };
                }
                else if (slots == 5)
                {
                    slotNos = new int[] { 0, 2, 3, 4, 6 };
                }

                foreach (int slotNo in slotNos)
                {
                    army = new Heroes.Core.Army();
                    army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[armyId]);
                    army._qty = qtyPerSlot;
                    army._slotNo = slotNo;
                    monster._armyKSlots.Add(army._slotNo, army);
                }
            }

            return monster;
        }
コード例 #9
0
ファイル: frmDuelNetwork.cs プロジェクト: sakseichek/homm
        private bool CaptureMine(int count, int mineLevel)
        {
            Heroes.Core.Monster monster = new Heroes.Core.Monster();
            monster._id = 1;

            Random rnd = new Random();

            // random monster level
            int armyId = 0;
            int armyLevel = 0;
            {
                int[] armyIds = null;
                int[] armyLevels = null;

                if (mineLevel == 1)
                {
                    armyIds = new int[] { (int)Heroes.Core.ArmyIdEnum.Pikeman, (int)Heroes.Core.ArmyIdEnum.Halberdier,
                        (int)Heroes.Core.ArmyIdEnum.Archer, (int)Heroes.Core.ArmyIdEnum.Marksman };
                    armyLevels = new int[] { 1, 1, 2, 2 };
                }
                else if (mineLevel == 2)
                {
                    armyIds = new int[] {
                        (int)Heroes.Core.ArmyIdEnum.Griffin, (int)Heroes.Core.ArmyIdEnum.RoyalGiffin,
                        (int)Heroes.Core.ArmyIdEnum.Swordman, (int)Heroes.Core.ArmyIdEnum.Crusader };
                    armyLevels = new int[] { 3, 3, 4, 4 };
                }
                else if (mineLevel == 3)
                {
                    armyIds = new int[] { (int)Heroes.Core.ArmyIdEnum.Monk, (int)Heroes.Core.ArmyIdEnum.Zealot,
                        (int)Heroes.Core.ArmyIdEnum.Cavalier, (int)Heroes.Core.ArmyIdEnum.Champion,
                        (int)Heroes.Core.ArmyIdEnum.Angel, (int)Heroes.Core.ArmyIdEnum.Archangel };
                    armyLevels = new int[] { 5, 5, 6, 6, 7, 7 };
                }
                else
                {
                    armyIds = new int[] { (int)Heroes.Core.ArmyIdEnum.Pikeman };
                    armyLevels = new int[] { 1 };
                }

                int index = rnd.Next(0, armyIds.Length);
                armyId = armyIds[index];
                armyLevel = armyLevels[index];
            }

            // random qty
            int totalQty = 0;
            {
                int qtyIndex = 0;

                if (mineLevel == 2)
                    qtyIndex = count + 2 - armyLevel + 3;
                else if (mineLevel == 3)
                    qtyIndex = count + 2 - armyLevel + 5;
                else
                    qtyIndex = count + 2 - armyLevel + 1;

                if (qtyIndex < 0) qtyIndex = 0;

                int minQty = 0;
                if (qtyIndex < _minQtys.Length) minQty = _minQtys[qtyIndex];
                else minQty = 99999;

                int maxQty = 0;
                if (qtyIndex < _minQtys.Length) maxQty = _maxQtys[qtyIndex];
                else maxQty = 99999;

                totalQty = rnd.Next(minQty, maxQty);
            }

            // random slot
            {
                int slots = 0;
                int qtyPerSlot = 0;

                // do until qty per slot is more than zero
                do
                {
                    slots = rnd.Next(1, 6);
                    qtyPerSlot = totalQty / slots;
                } while (qtyPerSlot <= 0);

                int[] slotNos = null;
                Heroes.Core.Army army = null;
                if (slots == 1)
                {
                    slotNos = new int[] { 3 };
                }
                else if (slots == 2)
                {
                    slotNos = new int[] { 2, 4 };
                }
                else if (slots == 3)
                {
                    slotNos = new int[] { 0, 3, 6 };
                }
                else if (slots == 4)
                {
                    slotNos = new int[] { 0, 2, 4, 6 };
                }
                else if (slots == 5)
                {
                    slotNos = new int[] { 0, 2, 3, 4, 6 };
                }

                foreach (int slotNo in slotNos)
                {
                    army = new Heroes.Core.Army();
                    army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[armyId]);
                    army._qty = qtyPerSlot;
                    army._slotNo = slotNo;
                    monster._armyKSlots.Add(army._slotNo, army);
                }
            }

            StartingBattleEventArg e2 = new StartingBattleEventArg(this._currentHero, null, monster);
            OnStartingBattle(e2);

            return e2._success;
        }
コード例 #10
0
ファイル: frmDuelNetwork.cs プロジェクト: sakseichek/homm
        public void ResurrectHero(Heroes.Core.Hero hero)
        {
            hero._armyKSlots.Clear();

            {
                Heroes.Core.Army army = new Heroes.Core.Army();
                army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Pikeman]);
                army.AddAttribute(hero);
                army._heroId = hero._id;
                army._playerId = hero._playerId;
                army._qty = 1;
                army._slotNo = 0;
                hero._armyKSlots.Add(army._slotNo, army);
            }
        }