Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
        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);
                }
            }
        }
Esempio n. 3
0
 protected virtual void OnGettingArtifact(GettingArtifactEventArg e)
 {
     if (GettingArtifact != null)
     {
         //Invokes the delegates.
         GettingArtifact(e);
     }
 }