コード例 #1
0
ファイル: frmMap.cs プロジェクト: sakseichek/homm
        private void Attack(Cell cell)
        {
            // confirmation message
            if (MessageBox.Show("Do you want to attack?", "Attack", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                != DialogResult.Yes) return;

            // minus movement point
            _currentHero._movementPointLeft -= 1;
            if (_currentHero._movementPointLeft == 0)
            {
                _currentHero._image = _currentPlayer._heroImage;
                Draw();
            }

            // start battle
            {
                // clone
                Heroes.Core.Hero attackHero = _currentHero;
                //Heroes.Core.Hero attackHero = new Heroes.Core.Hero();
                //attackHero.CopyFrom(_currentHero);

                Heroes.Core.Hero defendHero = cell._hero;
                //Heroes.Core.Hero defendHero = new Heroes.Core.Hero();
                //defendHero.CopyFrom(cell._hero);

                Heroes.Core.Monster monster = cell._monster;

                Heroes.Core.Town castle = cell._castle;

                StartingBattleEventArg eventArg = new StartingBattleEventArg(attackHero, defendHero, monster, castle);
                OnStartingBattle(eventArg);

                // set battle result
                if (!_isMultiPlayer)
                {
                    if (eventArg._victory == 1)
                    {
                        // attacker win

                        // remove defender
                        Heroes.Core.Player player = cell._hero._player;
                        player._heroes.Remove(cell._hero);
                        cell._hero = null;
                    }
                    else
                    {
                        // defender win

                        // remove attacker
                        Heroes.Core.Player player = _currentHero._player;
                        player._heroes.Remove(_currentHero);
                        cell._hero = null;
                    }

                    Draw();
                }
            }
        }
コード例 #2
0
ファイル: frmMap.cs プロジェクト: sakseichek/homm
 protected virtual void OnStartingBattle(StartingBattleEventArg e)
 {
     if (StartingBattle != null)
     {
         //Invokes the delegates.
         StartingBattle(e);
     }
 }
コード例 #3
0
ファイル: frmDuelNetwork.cs プロジェクト: sakseichek/homm
        private void cmdWood_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            if (this._currentHero._movementPointLeft <= 0)
            {
                MessageBox.Show("No more movement points.");
                return;
            }

            int mineType = 0;
            int[] armyLevels = null;
            if (cmdWood.Equals(btn))
            {
                mineType = (int)Heroes.Core.MineTypeEnum.Wood;
                armyLevels = new int[] { 1, 2 };
            }
            else if (cmdOre.Equals(btn))
            {
                mineType = (int)Heroes.Core.MineTypeEnum.Ore;
                armyLevels = new int[] { 1, 2 };
            }
            else if (cmdMercury.Equals(btn))
            {
                mineType = (int)Heroes.Core.MineTypeEnum.Mercury;
                armyLevels = new int[] { 3, 4 };
            }
            else if (cmdSulfur.Equals(btn))
            {
                mineType = (int)Heroes.Core.MineTypeEnum.Sulfur;
                armyLevels = new int[] { 3, 4 };
            }
            else if (cmdCrystal.Equals(btn))
            {
                mineType = (int)Heroes.Core.MineTypeEnum.Crystal;
                armyLevels = new int[] { 3, 4 };
            }
            else if (cmdGem.Equals(btn))
            {
                mineType = (int)Heroes.Core.MineTypeEnum.Gem;
                armyLevels = new int[] { 3, 4 };
            }
            else if (cmdGold.Equals(btn))
            {
                mineType = (int)Heroes.Core.MineTypeEnum.Gold;
                armyLevels = new int[] { 5, 6 };
            }
            else
                return;

            this._currentHero._movementPointLeft -= 1;

            ArrayList mines = _currentPlayer._mineKTypes[mineType];
            int count = mines.Count;
            count += 1;

            Heroes.Core.Monster monster = CreateMonster(armyLevels, 2, count);

            if (chkQuickCombat.Checked)
            {
                Heroes.Core.Battle.Quick.BattleCommander quickBattle = new Heroes.Core.Battle.Quick.BattleCommander(this._currentPlayer, this._currentHero,
                    null, null, monster, true);
                Heroes.Core.Battle.BattleSideEnum victory = quickBattle.Start();

                if (!ShowBattleResult(victory, this._currentPlayer._id,
                    quickBattle._attackHero, quickBattle._defendHero, quickBattle._monster)) return;
            }
            else
            {
                StartingBattleEventArg e2 = new StartingBattleEventArg(this._currentHero, null, monster);
                OnStartingBattle(e2);

                if (!e2._success) return;
            }

            Heroes.Core.Mine mine = new Heroes.Core.Mine();
            mine.CopyFrom((Heroes.Core.Mine)Heroes.Core.Setting._mineTypes[mineType]);
            mines.Add(mine);
        }
コード例 #4
0
ファイル: frmDuelNetwork.cs プロジェクト: sakseichek/homm
        private void cmdWarriorTomb_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            if (this._currentHero._movementPointLeft <= 0)
            {
                MessageBox.Show("No more movement points.");
                return;
            }

            int qtyIndex = 0;
            int tombIndex = 0;
            Heroes.Core.Heros.ArtifactLevelEnum artifactLevel = Heroes.Core.Heros.ArtifactLevelEnum.Treasure;
            int[] armyLevels = null;
            if (btn.Equals(cmdWarriorTomb))
            {
                qtyIndex = 2;
                tombIndex = 0;
                artifactLevel = Heroes.Core.Heros.ArtifactLevelEnum.Treasure;
                armyLevels = new int[] { 1, 2 };
            }
            else if (btn.Equals(cmdDwarvenTreasury))
            {
                qtyIndex = 2;
                tombIndex = 1;
                artifactLevel = Heroes.Core.Heros.ArtifactLevelEnum.Minor;
                armyLevels = new int[] { 3, 4 };
            }
            else if (btn.Equals(cmdGriffinConserv))
            {
                qtyIndex = 2;
                tombIndex = 2;
                artifactLevel = Heroes.Core.Heros.ArtifactLevelEnum.Major;
                armyLevels = new int[] { 5, 6 };
            }
            else if (btn.Equals(cmdDragonUtopia))
            {
                qtyIndex = 2;
                tombIndex = 3;
                artifactLevel = Heroes.Core.Heros.ArtifactLevelEnum.Relic;
                armyLevels = new int[] { 7 };
            }
            else
                return;

            int count = _artifactVisitCounts[tombIndex];
            count += 1;

            this._currentHero._movementPointLeft -= 1;

            Heroes.Core.Monster monster = CreateMonster(armyLevels, qtyIndex, count);

            if (chkQuickCombat.Checked)
            {
                Heroes.Core.Battle.Quick.BattleCommander quickBattle = new Heroes.Core.Battle.Quick.BattleCommander(this._currentPlayer, this._currentHero,
                    null, null, monster, true);
                Heroes.Core.Battle.BattleSideEnum victory = quickBattle.Start();

                if (!ShowBattleResult(victory, this._currentPlayer._id,
                    quickBattle._attackHero, quickBattle._defendHero, quickBattle._monster)) return;
            }
            else
            {
                StartingBattleEventArg e2 = new StartingBattleEventArg(this._currentHero, null, monster);
                OnStartingBattle(e2);

                if (!e2._success) return;
            }

            _artifactVisitCounts[tombIndex] = count;

            GettingArtifactEventArg e3 = new GettingArtifactEventArg(artifactLevel);
            OnGettingArtifact(e3);

            if (e3._artifact != null)
            {
                MessageBox.Show(string.Format("You get {0}.", e3._artifact._name));

                this._currentHero.AddArtifacts(e3._artifact);
                this._currentHero.CalculateAll();
            }
        }
コード例 #5
0
ファイル: frmDuelNetwork.cs プロジェクト: sakseichek/homm
        private void cmdSteal_Click(object sender, EventArgs e)
        {
            Heroes.Core.Hero hero = GetHero();
            if (hero == null) return;

            StartingBattleEventArg e2 = new StartingBattleEventArg(this._currentHero, hero, null);
            OnStartingBattle(e2);
        }
コード例 #6
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;
        }