public DialogResult ShowDialog(Heroes.Core.Town town, Building buildingPurArmy) { _town = town; _building = buildingPurArmy; this.lblCost.Text = _building._gold.ToString(); this.txtQty.Text = _building._armyQty.ToString(); this.lblAv.Text = this.txtQty.Text; int amt = Heroes.Core.Army.CalculateAmt(_building._armyQty, _building._gold); lblAmt.Text = amt.ToString(); return this.ShowDialog(); }
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; }
public VisitingCastleEventArg(Heroes.Core.Town castle) { _castle = castle; }
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); } } }
public static void ResetAll() { if (_frmBattle != null) { _frmBattle.Close(); _frmBattle = null; } if (_frmMap != null) { _frmMap.Close(); _frmMap = null; } if (_frmGame != null) { _frmGame.Close(); _frmGame = null; } _isServer = false; _me = null; _server = null; _players.Clear(); _currentPlayer = null; _isNeedToStartGame = false; _isGameStarted = false; _isInitialized = false; _isAllPlayerInitialized = false; _needToRunNextPlayer = false; _isNeedToStartBattle = false; _amIBattle = false; _isBattleStarted = false; _attackPlayer = null; _attackHero = null; _attackArmies = null; _defendPlayer = null; _defendHero = null; _defendCastle = null; _defendArmies = null; _victory = 0; _isBattleEnded = false; _attackCommands.Clear(); _defendCommands.Clear(); }
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; } } }
public CastleView() { InitializeComponent(); _town = null; }
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); } } }