예제 #1
0
파일: frmMap.cs 프로젝트: sakseichek/homm
 public StartingBattleEventArg(Heroes.Core.Hero attackHero, Heroes.Core.Hero defendHero, Heroes.Core.Monster monster, Heroes.Core.Town defendCastle)
 {
     _attackHero = attackHero;
     _defendHero = defendHero;
     _monster = monster;
     _defendCastle = defendCastle;
     _victory = 0;
 }
예제 #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
        public BattleCommander(Heroes.Core.Player attackPlayer, Heroes.Core.Hero attackHero, 
            Heroes.Core.Player defendPlayer, Heroes.Core.Hero defendHero, Heroes.Core.Monster monster, bool quickCombat)
        {
            _battleTerrain = new BattleTerrain();

            _attackPlayer = attackPlayer;
            _defendPlayer = defendPlayer;

            {
                _attackHeroOriginal = attackHero;

                _attackHero = new Heroes.Core.Battle.Heros.Hero();
                _attackHero.CopyFrom(attackHero);
                _attackHero._armySide = Heroes.Core.Battle.Characters.ArmySideEnum.Attacker;
                _attackHero._spells = attackHero._spells;

                foreach (Heroes.Core.Army army in attackHero._armyKSlots.Values)
                {
                    Heroes.Core.Battle.Armies.Army army2 = new Heroes.Core.Battle.Armies.Army();
                    army2.CopyFrom(army);
                    army2._armySide = Heroes.Core.Battle.Characters.ArmySideEnum.Attacker;

                    army2._qtyLeft = army2._qty;
                    army2._healthRemain = army2._health;
                    army2._shotRemain = army2._noOfShot;
                    army2._retaliateRemain = army2._noOfRetaliate;

                    army2._cell = GetCell(army2._armySide, army2._slotNo, army2._isBig);
                    army2._cell._character = army2;

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

                _attackArmies = _attackHero._armyKSlots;
            }

            _defendHeroOriginal = null;
            _defendHero = null;
            if (defendHero != null)
            {
                _defendHeroOriginal = defendHero;

                _defendHero = new Heroes.Core.Battle.Heros.Hero();
                _defendHero.CopyFrom(defendHero);
                _defendHero._armySide = Heroes.Core.Battle.Characters.ArmySideEnum.Defender;
                _defendHero._spells = attackHero._spells;

                foreach (Heroes.Core.Army army in defendHero._armyKSlots.Values)
                {
                    Heroes.Core.Battle.Armies.Army army2 = new Heroes.Core.Battle.Armies.Army();
                    army2.CopyFrom(army);
                    army2._armySide = Heroes.Core.Battle.Characters.ArmySideEnum.Defender;

                    army2._qtyLeft = army2._qty;
                    army2._healthRemain = army2._health;
                    army2._shotRemain = army2._noOfShot;
                    army2._retaliateRemain = army2._noOfRetaliate;

                    army2._cell = GetCell(army2._armySide, army2._slotNo, army2._isBig);
                    army2._cell._character = army2;

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

                _defendArmies = _defendHero._armyKSlots;
            }

            _monsterOriginal = null;
            _monster = null;
            if (monster != null)
            {
                _monsterOriginal = monster;

                _monster = new Heroes.Core.Battle.Quick.Monster();
                _monster.CopyFrom(monster);
                _monster._armySide = Heroes.Core.Battle.Characters.ArmySideEnum.Defender;

                foreach (Heroes.Core.Army army in monster._armyKSlots.Values)
                {
                    Heroes.Core.Battle.Armies.Army army2 = new Heroes.Core.Battle.Armies.Army();
                    army2.CopyFrom(army);
                    army2._armySide = Heroes.Core.Battle.Characters.ArmySideEnum.Defender;

                    army2._qtyLeft = army2._qty;
                    army2._healthRemain = army2._health;
                    army2._shotRemain = army2._noOfShot;
                    army2._retaliateRemain = army2._noOfRetaliate;

                    army2._cell = GetCell(army2._armySide, army2._slotNo, army2._isBig);
                    army2._cell._character = army2;

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

                _defendArmies = _monster._armyKSlots;
            }

            _heroes = new Hashtable();
            _heroes.Add(_attackHero._id, _attackHero);
            if (_defendHero != null) _heroes.Add(_defendHero._id, _defendHero);

            _armies = new ArrayList();
            foreach (Heroes.Core.Army army in _attackArmies.Values)
            {
                _armies.Add(army);
            }
            foreach (Heroes.Core.Army army in _defendArmies.Values)
            {
                _armies.Add(army);
            }

            BattleEngine.SortBySpeed(_armies);

            _quickCombat = quickCombat;

            _turn = new Turn(_armies, _attackHero, _attackArmies, _defendHero, _monster, _defendArmies);
        }
예제 #4
0
        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;
        }
예제 #5
0
        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;
        }
예제 #6
0
 public StartingBattleEventArg(Heroes.Core.Hero attackHero, Heroes.Core.Hero defendHero, Heroes.Core.Monster monster)
 {
     _attackHero = attackHero;
     _defendHero = defendHero;
     _monster = monster;
     _success = false;
 }