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; } } }
private void cmdMercury_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 level = 0; if (cmdWood.Equals(btn)) { mineType = (int)Heroes.Core.MineTypeEnum.Wood; level = 1; } else if (cmdOre.Equals(btn)) { mineType = (int)Heroes.Core.MineTypeEnum.Ore; level = 1; } else if (cmdMercury.Equals(btn)) { mineType = (int)Heroes.Core.MineTypeEnum.Mercury; level = 2; } else if (cmdSulfur.Equals(btn)) { mineType = (int)Heroes.Core.MineTypeEnum.Sulfur; level = 2; } else if (cmdCrystal.Equals(btn)) { mineType = (int)Heroes.Core.MineTypeEnum.Crystal; level = 2; } else if (cmdGem.Equals(btn)) { mineType = (int)Heroes.Core.MineTypeEnum.Gem; level = 2; } else if (cmdGold.Equals(btn)) { mineType = (int)Heroes.Core.MineTypeEnum.Gold; level = 3; } else return; this._currentHero._movementPointLeft -= 1; ArrayList mines = _currentPlayer._mineKTypes[mineType]; if (!CaptureMine(mines.Count, level)) return; Heroes.Core.Mine mine = new Heroes.Core.Mine(); mine.CopyFrom((Heroes.Core.Mine)Heroes.Core.Setting._mineTypes[mineType]); mines.Add(mine); }
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); }