/// <summary> /// ユニット種類リストボックスの項目描画処理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnTypeListBoxDrawItem(object sender, DrawItemEventArgs e) { // 項目がなければ何もしない if (e.Index == -1) { return; } // 背景を描画する e.DrawBackground(); // 項目の文字列を描画する Brush brush; if ((e.State & DrawItemState.Selected) != DrawItemState.Selected) { // 変更ありの項目は文字色を変更する Country country = Countries.Tags[countryListBox.SelectedIndex]; UnitNameType type = UnitNames.Types[e.Index]; brush = UnitNames.IsDirty(country, type) ? new SolidBrush(Color.Red) : new SolidBrush(SystemColors.WindowText); } else { brush = new SolidBrush(SystemColors.HighlightText); } string s = typeListBox.Items[e.Index].ToString(); e.Graphics.DrawString(s, e.Font, brush, e.Bounds); brush.Dispose(); // フォーカスを描画する e.DrawFocusRectangle(); }
/// <summary> /// フォーム読み込み時の処理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnFormLoad(object sender, EventArgs e) { // 国家データを初期化する Countries.Init(); // ユニット名データを初期化する UnitNames.Init(); // 文字列定義ファイルを読み込む Config.Load(); // 国家リストボックスを初期化する InitCountryListBox(); // ユニット種類リストボックスを初期化する InitTypeListBox(); // 履歴を初期化する InitHistory(); // オプション設定を初期化する InitOption(); // ユニット名定義ファイルを読み込む UnitNames.Load(); // データ読み込み後の処理 OnFileLoaded(); }
/// <summary> /// ユニット名リストを更新する /// </summary> private void UpdateNameList() { nameTextBox.Clear(); // 選択中の国家がなければ戻る if (countryListBox.SelectedIndex < 0) { return; } Country country = Countries.Tags[countryListBox.SelectedIndex]; // 選択中のユニット名種類がなければ戻る if (typeListBox.SelectedIndex < 0) { return; } UnitNameType type = UnitNames.Types[typeListBox.SelectedIndex]; // ユニット名を順に追加する StringBuilder sb = new StringBuilder(); foreach (string name in UnitNames.GetNames(country, type)) { sb.AppendLine(name); } nameTextBox.Text = sb.ToString(); }
public int GetDecimalPlaces() { if (UnitNames.Count() > 0) { return(UnitNames.Keys.Max()); } throw new NullReferenceException(); }
public BaseUnit Create(UnitNames name, params object[] constructorArgs) { switch (name) { case UnitNames.StoneGolem: return(_instantiator.Instantiate <BaseUnit>(constructorArgs)); } Assert.That(false); return(null); }
/// <summary> /// 補間ボタン押下時の処理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnInterpolateButtonClick(object sender, EventArgs e) { Log.Info("[UnitName] Interpolate"); if (allCountryCheckBox.Checked) { if (allUnitTypeCheckBox.Checked) { // 全てのユニット名を補間する UnitNames.InterpolateAll(); } else { // ユニット名種類リストボックスの選択項目がなければ戻る if (typeListBox.SelectedIndex < 0) { return; } // 全ての国のユニット名を補間する UnitNames.InterpolateAllCountries(UnitNames.Types[typeListBox.SelectedIndex]); } } else { // 国家リストボックスの選択項目がなければ戻る if (countryListBox.SelectedIndex < 0) { return; } if (allUnitTypeCheckBox.Checked) { // 全てのユニット名種類のユニット名を補間する UnitNames.InterpolateAllTypes(Countries.Tags[countryListBox.SelectedIndex]); } else { // ユニット名種類リストボックスの選択項目がなければ戻る if (typeListBox.SelectedIndex < 0) { return; } // ユニット名を補間する UnitNames.Interpolate(Countries.Tags[countryListBox.SelectedIndex], UnitNames.Types[typeListBox.SelectedIndex]); } } // ユニット名リストの表示を更新する UpdateNameList(); // 編集済みフラグが更新されるため表示を更新する countryListBox.Refresh(); typeListBox.Refresh(); }
public static GameObject CreateUnit(UnitNames name) { var unitObject = CreateUnit(); Debug.Log(string.Format(UnitSettingPathFormat, name)); var unitSetting = Resources.Load<UnitSetting>(string.Format(UnitSettingPathFormat, name)); ObjectSpriteSetter.SetSprite(unitObject, unitSetting.Sprite); ObjectAnimatorControllerSetter.SetAniamtorController(unitObject, unitSetting.AnimatorController); return unitObject; }
public List <UnitNames> GetUnitName(string text) { List <UnitNames> listproduct = new List <UnitNames>(); DataTable data = DataProvider.Instance.ExcuteQuery("EXEC GetUnitName @text ", new object[] { text }); foreach (DataRow item in data.Rows) { UnitNames list = new UnitNames(item); listproduct.Add(list); } return(listproduct); }
private string GetDefenderSquadInfo(Island island, int squadCountCount, UnitNames unitNames, int pad) { List <long> sc = new List <long>(); StringBuilder sb = new StringBuilder(); // Sort the islands with squads so that they display nicely. List <long> squadPlans = new List <long>(); for (int c = 0; c < island.SquadPlans.Count; c++) { squadPlans.Add(island.SquadPlans[c][0]); } squadPlans.Sort(); sb.AppendLine("<pre>"); // Add in all tiles with squads on them for (int j = 0; j < squadCountCount; j++) { sc = island.SquadCounts[j]; int tileNumber = Convert.ToInt32(squadPlans[j]); // Convert.ToInt32(island.SquadPlans[j][0]); // List blockers & bunkers & features (terrain) string defenses = island.Defenses; string features = island.Features; char defense = defenses[tileNumber]; char feature = features[tileNumber]; string blocker = GetBlockerFromChar(defense); string bunkers = GetBunkersFromChar(defense); string terrain = GetTerrainFromChar(feature); sb.AppendLine(" Squad #" + (j + 1).ToString() + " on tile " + tileNumber.ToString() + " ==> " + terrain + " with " + blocker + " and " + bunkers); sb.AppendLine(" " + unitNames.Riflemen.PadRight(pad) + " = " + sc[0].ToString().PadLeft(12, ' ')); sb.AppendLine(" " + unitNames.MachineGunners.PadRight(pad) + " = " + sc[1].ToString().PadLeft(12, ' ')); sb.AppendLine(" " + unitNames.Bazookamen.PadRight(pad) + " = " + sc[2].ToString().PadLeft(12, ' ')); sb.AppendLine(" " + unitNames.LightTanks.PadRight(pad) + " = " + sc[3].ToString().PadLeft(12, ' ')); sb.AppendLine(" " + unitNames.MediumTanks.PadRight(pad) + " = " + sc[4].ToString().PadLeft(12, ' ')); sb.AppendLine(" " + unitNames.HeavyTanks.PadRight(pad) + " = " + sc[5].ToString().PadLeft(12, ' ')); sb.AppendLine(" " + unitNames.LightFighters.PadRight(pad) + " = " + sc[6].ToString().PadLeft(12, ' ')); sb.AppendLine(" " + unitNames.MediumFighters.PadRight(pad) + " = " + sc[7].ToString().PadLeft(12, ' ')); sb.AppendLine(" " + unitNames.Bombers.PadRight(pad) + " = " + sc[8].ToString().PadLeft(12, ' ')); } // Add in all the tiles with no squad on them sb.AppendLine(GetDefenderNoSquadInfo(island)); sb.AppendLine("</pre>"); return(sb.ToString()); }
/// <summary> /// 編集済みかどうかを取得する /// </summary> /// <returns>編集済みならばtrueを返す</returns> public static bool IsDirty() { return(Misc.IsDirty() || Config.IsDirty() || Leaders.IsDirty() || Ministers.IsDirty() || Teams.IsDirty() || Provinces.IsDirty() || Techs.IsDirty() || Units.IsDirty() || CorpsNames.IsDirty() || UnitNames.IsDirty() || RandomLeaders.IsDirty() || Scenarios.IsDirty()); }
/// <summary> /// データを保存する /// </summary> private static void SaveFiles() { if (!Misc.Save()) { return; } if (!Config.Save()) { return; } if (!Leaders.Save()) { return; } if (!Ministers.Save()) { return; } if (!Teams.Save()) { return; } if (!Provinces.Save()) { return; } if (!Techs.Save()) { return; } if (!Units.Save()) { return; } if (!CorpsNames.Save()) { return; } if (!UnitNames.Save()) { return; } if (!RandomLeaders.Save()) { return; } Scenarios.Save(); }
/// <summary> /// 追加ボタン押下時の処理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnAddButtonClick(object sender, EventArgs e) { // 選択中の国家がなければ戻る if (countryListBox.SelectedIndex < 0) { return; } Country country = Countries.Tags[countryListBox.SelectedIndex]; // 選択中のユニット名種類がなければ戻る if (typeListBox.SelectedIndex < 0) { return; } UnitNameType type = UnitNames.Types[typeListBox.SelectedIndex]; string prefix = prefixComboBox.Text; string suffix = suffixComboBox.Text; int start = (int)startNumericUpDown.Value; int end = (int)endNumericUpDown.Value; Log.Info("[UnitName] Add: {0}-{1} {2} {3} [{4}] <{5}>", start, end, prefix, suffix, Config.GetText(UnitNames.TypeNames[(int)type]), Countries.Strings[(int)country]); // ユニット名を一括追加する UnitNames.AddSequential(prefix, suffix, start, end, country, type); // ユニット名リストの表示を更新する UpdateNameList(); // 編集済みフラグが更新されるため国家リストボックスの表示を更新する countryListBox.Refresh(); typeListBox.Refresh(); // 履歴を更新する _prefixHistory.Add(prefix); _suffixHistory.Add(suffix); HoI2EditorController.Settings.UnitNameEditor.PrefixHistory = _prefixHistory.Get().ToList(); HoI2EditorController.Settings.UnitNameEditor.SuffixHistory = _suffixHistory.Get().ToList(); // 履歴コンボボックスを更新する UpdateAddHistory(); }
public void SummonUnit(UnitNames unitName, Vector2Int coordinates) { int unitCost = unitCollection[UnitNames.BARBARIAN].cost; if (mana >= unitCost) { mana -= unitCost; GameObject newUnit = Instantiate(unitCollection[UnitNames.BARBARIAN].prefab); newUnit.transform.localScale = grid.transform.localScale; newUnit.GetComponent <Unit>().SetCoordinates(coordinates.x, coordinates.y); newUnit.tag = "Player"; onManaChanged.Invoke(mana); } else { FindObjectOfType <UIManager>().ShowInsufficientMana(); } }
/// <summary> /// ファイルの再読み込みを要求する /// </summary> public static void RequestReload() { Misc.RequestReload(); Config.RequestReload(); Leaders.RequestReload(); Ministers.RequestReload(); Teams.RequestReload(); Techs.RequestReload(); Units.RequestReload(); Provinces.RequestReload(); CorpsNames.RequestReload(); UnitNames.RequestReload(); RandomLeaders.RequestReload(); Scenarios.RequestReload(); Maps.RequestReload(); SaveCanceled = false; Log.Verbose("Request to reload"); }
/// <summary> /// ユニット名リスト変更時の処理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnNameTextBoxValidated(object sender, EventArgs e) { // 選択中の国家がなければ戻る if (countryListBox.SelectedIndex < 0) { return; } Country country = Countries.Tags[countryListBox.SelectedIndex]; // 選択中のユニット名種類がなければ戻る if (typeListBox.SelectedIndex < 0) { return; } UnitNameType type = UnitNames.Types[typeListBox.SelectedIndex]; // ユニット名リストを更新する UnitNames.SetNames(nameTextBox.Lines.Where(line => !string.IsNullOrEmpty(line)).ToList(), country, type); // 編集済みフラグが更新されるため国家リストボックスの表示を更新する countryListBox.Refresh(); typeListBox.Refresh(); }
/// <summary> /// データを再読み込みする /// </summary> public static void Reload() { Log.Info("Reload"); // データを再読み込みする Misc.Reload(); Config.Reload(); Leaders.Reload(); Ministers.Reload(); Teams.Reload(); Provinces.Reload(); Techs.Reload(); Units.Reload(); CorpsNames.Reload(); UnitNames.Reload(); RandomLeaders.Reload(); Scenarios.Reload(); // データ読み込み後の更新処理呼び出し OnFileLoaded(); SaveCanceled = false; }
/// <summary> /// 置換ボタン押下時の処理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnReplaceButtonClick(object sender, EventArgs e) { string to = toComboBox.Text; string with = withComboBox.Text; Log.Info("[UnitName] Replace: {0} -> {1}", to, with); if (allCountryCheckBox.Checked) { if (allUnitTypeCheckBox.Checked) { // 全てのユニット名を置換する UnitNames.ReplaceAll(to, with, regexCheckBox.Checked); } else { // ユニット名種類リストボックスの選択項目がなければ戻る if (typeListBox.SelectedIndex < 0) { return; } // 全ての国のユニット名を置換する UnitNames.ReplaceAllCountries(to, with, UnitNames.Types[typeListBox.SelectedIndex], regexCheckBox.Checked); } } else { // 国家リストボックスの選択項目がなければ戻る if (countryListBox.SelectedIndex < 0) { return; } if (allUnitTypeCheckBox.Checked) { // 全てのユニット名種類のユニット名を置換する UnitNames.ReplaceAllTypes(to, with, Countries.Tags[countryListBox.SelectedIndex], regexCheckBox.Checked); } else { // ユニット名種類リストボックスの選択項目がなければ戻る if (typeListBox.SelectedIndex < 0) { return; } // ユニット名を置換する UnitNames.Replace(to, with, Countries.Tags[countryListBox.SelectedIndex], UnitNames.Types[typeListBox.SelectedIndex], regexCheckBox.Checked); } } // ユニット名リストの表示を更新する UpdateNameList(); // 編集済みフラグが更新されるため国家リストボックスの表示を更新する countryListBox.Refresh(); typeListBox.Refresh(); // 履歴を更新する _toHistory.Add(to); _withHistory.Add(with); HoI2EditorController.Settings.UnitNameEditor.ToHistory = _toHistory.Get().ToList(); HoI2EditorController.Settings.UnitNameEditor.WithHistory = _withHistory.Get().ToList(); // 履歴コンボボックスを更新する UpdateReplaceHistory(); }
public UnitBlueprint this[UnitNames name] { get { return(blueprintDict[name]); } }
private void cbxPlayers_SelectedIndexChanged(object sender, EventArgs e) { // skip 1 time if (skip) { skip = false; return; } // Old code that used curl //GspRoot gsp = GetGsp(); // Get GSP without using curl string json = GetJsonRpcResponse(getCurrentState); Application.DoEvents(); GspRoot gsp = GetGspFromJson(json); SortedDictionary <string, Player> players = new SortedDictionary <string, Player>(gsp.Result.Gamestate.Players); // get ComboBox from sender ComboBox comboBox = (ComboBox)sender; // get selected KVP KeyValuePair <string, Player> selectedEntry = (KeyValuePair <string, Player>)comboBox.SelectedItem; // get selected Key string name = selectedEntry.Key; Player player = players[name]; StringBuilder sb = new StringBuilder(); // set up header sb.AppendLine(GetHeader()); // Set up navigation //sb.AppendLine(GetFloatingMenu()); // no need for a menu // Set up sb with basic CSS sb.AppendLine(GetCSS()); IslesOfWar.UnitNames unitNames = new UnitNames(); int pad = 20; // used to pad names & stuff // Should do TOTAL combat units at the top here sb.AppendLine(GetTotalCombatUnits(player, name, pad, gsp)); // Next, available combat units sb.AppendLine(GetPlayerCombatUnits(player)); // resources // Get resources for player. IslesOfWar.ResourceNames resourceNames = new ResourceNames(); sb.AppendLine("<h2>PLAYER RESOURCES FOR " + name + "</h2>"); sb.AppendLine(); sb.AppendLine(GetPlayerResources(player, resourceNames)); // islands & defences sb.AppendLine("<p></p>"); sb.AppendLine("<h2>ISLANDS AND THEIR DEFENSES</h2>"); sb.AppendLine(GetIslandNumbering()); // What islands have what resources or defenses? Let's ignore resources for now as it's a bunch of arrays - just do defenses. sb.AppendLine("<p></p>"); sb.AppendLine("<h3>###PLAYERISLANDCOUNT###</h3>"); // place holder to replace Dictionary <string, Island> islands = gsp.Result.Gamestate.Islands; sb.AppendLine("<p></p>"); Dictionary <string, int> playerIslandCount = new Dictionary <string, int>(); int islandCount = 0; foreach (var isle in islands) { if (isle.Value.Owner != name) { continue; } string hexName = isle.Key; Island island = isle.Value; sb.AppendLine("<pre>" + island.Owner + " owns " + hexName + "</pre>"); // Add in if there's a player attacking it sb.AppendLine(GetAttackingPlayer(hexName, players)); // This adds in all islands with squads deployed. if (island.SquadCounts != null && island.SquadPlans != null) { // Add in defenses for each island int squadPlanCount = island.SquadPlans.Count; int squadCountCount = island.SquadCounts.Count; sb.AppendLine(GetDefenderSquadInfo(island, squadCountCount, unitNames, pad)); } else { // Add in for islands with no squads sb.AppendLine("<pre>"); sb.AppendLine(GetDefenderNoSquadInfo(island)); sb.AppendLine("</pre>"); } // There are 12 hexes per island. Each one can have a squad. if (playerIslandCount.Keys.Contains <string>(island.Owner)) { playerIslandCount[island.Owner]++; islandCount++; } else { playerIslandCount.Add(island.Owner, 1); islandCount++; } } // island counts sb.AppendLine("<p></p>"); sb.Replace("###PLAYERISLANDCOUNT###", name + " OWNS " + islandCount.ToString() + " ISLANDS"); sb.AppendLine(GetFooter()); webBrowser1.DocumentText = sb.ToString(); // "<pre>" + sb.ToString() + "</pre>"; }
private void btnGetGameState_Click(object sender, EventArgs e) { // This is old code that used curl. //string s = Blah("getcurrentstate.bat"); //Application.DoEvents(); //GspRoot gsp = GetGsp(); // Get GSP without using curl string json = GetJsonRpcResponse(getCurrentState); Application.DoEvents(); GspRoot gsp = GetGspFromJson(json); Dictionary <string, Player> playersU = gsp.Result.Gamestate.Players; SortedDictionary <string, Player> players = new SortedDictionary <string, Player>(playersU); PopulatePlayerDropDown(gsp); StringBuilder sb = new StringBuilder(); // set up header sb.AppendLine(GetHeader()); // Set up navigation sb.AppendLine(GetFloatingMenu()); // Set up sb with basic CSS sb.AppendLine(GetCSS()); IslesOfWar.UnitNames unitNames = new UnitNames(); int pad = 20; // used to pad names & stuff // Some basic overview stats first sb.AppendLine("<p>Player count = " + players.Count.ToString() + "</p>"); sb.AppendLine("<p>Island count = " + gsp.Result.Gamestate.Islands.Count.ToString() + "</p>"); sb.AppendLine("<p></p>"); // Display resource pools. sb.AppendLine("<h1><a id=\"Pools\"></a>POOLS</h1>"); sb.AppendLine("<pre>Oil: ".PadRight(16) + gsp.Result.Gamestate.ResourcePools[0].ToString("n0").PadLeft(20) + "</pre>"); sb.AppendLine("<pre>Metal: ".PadRight(16) + gsp.Result.Gamestate.ResourcePools[1].ToString("n0").PadLeft(20) + "</pre>"); sb.AppendLine("<pre>Concrete: ".PadRight(16) + gsp.Result.Gamestate.ResourcePools[2].ToString("n0").PadLeft(20) + "</pre>"); sb.AppendLine("<pre>Warbux: ".PadRight(16) + gsp.Result.Gamestate.WarbucksPool.ToString("n0").PadLeft(20) + "</pre>"); // Get combat unit numbers for each player. sb.AppendLine("<h1><a id=\"PlayerCombatUnits\"></a>PLAYER COMBAT UNITS</h1>"); sb.AppendLine("<p></p>"); foreach (var p in players) { string name = p.Key; Player player = p.Value; sb.AppendLine("<h1>" + name + "</h1>"); // TOTAL units sb.AppendLine(GetTotalCombatUnits(player, name, pad, gsp)); // AVAILABLE units sb.AppendLine(GetPlayerCombatUnits(player)); } // End getting combat units for each player. // Get resources for each player. IslesOfWar.ResourceNames resourceNames = new ResourceNames(); sb.AppendLine("<p></p>"); sb.AppendLine("<h1><a id=\"PlayerResources\"></a>PLAYER RESOURCES</h1>"); sb.AppendLine("<p></p>"); foreach (var p in players) { string name = p.Key; Player player = p.Value; sb.AppendLine("<h2>" + name + "</h2>"); sb.AppendLine(GetPlayerResources(player, resourceNames)); } // What islands have what resources or defenses? Let's ignore resources for now as it's a bunch of arrays - just do defenses. Dictionary <string, Island> islands = gsp.Result.Gamestate.Islands; sb.AppendLine("<p></p>"); sb.AppendLine("<h1><a id=\"IslandsAndTheirDefenses\"></a>ISLANDS AND THEIR DEFENSES</h1>"); sb.AppendLine("<p></p>"); sb.AppendLine(GetIslandNumbering()); sb.AppendLine("<p></p>"); Dictionary <string, int> playerIslandCount = new Dictionary <string, int>(); int islandCount = 0; foreach (var isle in islands) { string hexName = isle.Key; Island island = isle.Value; sb.AppendLine("<pre>" + island.Owner + " owns " + hexName + "</pre>"); // Add in if there's a player attacking it sb.AppendLine(GetAttackingPlayer(hexName, players)); if (island.SquadCounts != null && island.SquadPlans != null) { // Add in defenses for each island int squadPlanCount = island.SquadPlans.Count; int squadCountCount = island.SquadCounts.Count; sb.AppendLine(GetDefenderSquadInfo(island, squadCountCount, unitNames, pad)); } else { // Add in for islands with no squads sb.AppendLine("<pre>"); sb.AppendLine(GetDefenderNoSquadInfo(island)); sb.AppendLine("</pre>"); } // There are 12 hexes per island. Each one can have a squad. if (playerIslandCount.Keys.Contains <string>(island.Owner)) { playerIslandCount[island.Owner]++; islandCount++; } else { playerIslandCount.Add(island.Owner, 1); islandCount++; } } // Islands targeted for attack. sb.AppendLine("<p></p>"); sb.AppendLine("<h1><a id=\"IslandsTargetedForAttack\"></a>ISLANDS TARGETED FOR ATTACK</h1>"); sb.AppendLine(GetIslandsTargetedForAttack(players, islands)); // How many islands each player has sb.AppendLine("<p></p>"); sb.AppendLine("<h1><a id=\"HowManyIslands\"></a>HOW MANY ISLANDS DOES EACH PLAYER OWN?</h1>"); sb.AppendLine("<h2>" + islandCount.ToString() + " ISLANDS TOTAL</h2>"); sb.AppendLine("<p></p><pre>"); // Sort by player name var l = playerIslandCount.OrderBy(key => key.Key); var dic = l.ToDictionary((keyItem) => keyItem.Key, (valueItem) => valueItem.Value); playerIslandCount = dic; foreach (var v in playerIslandCount) { sb.AppendLine("" + v.Key + " owns " + v.Value.ToString() + " islands"); } sb.AppendLine("</pre>"); sb.AppendLine(GetFooter()); string newtext = sb.ToString(); wbBrowser.DocumentText = newtext; // "<pre>" + newtext + "</pre>"; }
private string GetPlayerCombatUnits(Player player) { IslesOfWar.UnitNames unitNames = new UnitNames(); List <long> units = player.Units; int i = 0; int pad = 20; // used to pad names & stuff StringBuilder sb = new StringBuilder(); sb.AppendLine("<h2>UNITS AVAILABLE TO DEPLOY</h2>"); sb.AppendLine("<p></p><pre>"); foreach (long unitCount in units) { sb.Append(" "); switch (i) { case 0: sb.Append(unitNames.Riflemen.PadRight(pad, ' ')); break; case 1: sb.Append(unitNames.MachineGunners.PadRight(pad, ' ')); break; case 2: sb.Append(unitNames.Bazookamen.PadRight(pad, ' ')); break; case 3: sb.Append(unitNames.LightTanks.PadRight(pad, ' ')); break; case 4: sb.Append(unitNames.MediumTanks.PadRight(pad, ' ')); break; case 5: sb.Append(unitNames.HeavyTanks.PadRight(pad, ' ')); break; case 6: sb.Append(unitNames.LightFighters.PadRight(pad, ' ')); break; case 7: sb.Append(unitNames.MediumFighters.PadRight(pad, ' ')); break; case 8: sb.Append(unitNames.Bombers.PadRight(pad, ' ')); break; default: sb.Append("Unknown"); break; } i++; sb.Append("=" + string.Format("{0:n0}", unitCount).ToString().PadLeft(12, ' ') + Environment.NewLine); } sb.AppendLine("</pre>"); return(sb.ToString()); }
private string GetTotalCombatUnits(Player player, string name, int pad, GspRoot gsp) { long riflemen, machinegunners, bazookamen, lighttanks, mediumtanks, heavytanks, lightfighters, mediumfighters, bombers; riflemen = 0; machinegunners = 0; bazookamen = 0; lighttanks = 0; mediumtanks = 0; heavytanks = 0; lightfighters = 0; mediumfighters = 0; bombers = 0; // get all free units counted riflemen += player.Units[0]; machinegunners += player.Units[1]; bazookamen += player.Units[2]; lighttanks += player.Units[3]; mediumtanks += player.Units[4]; heavytanks += player.Units[5]; lightfighters += player.Units[6]; mediumfighters += player.Units[7]; bombers += player.Units[8]; // get all islands into a dictionary Dictionary <string, Island> dic = gsp.Result.Gamestate.Islands; foreach (var isle in dic) { if (isle.Value.Owner == name) { if (isle.Value.SquadCounts == null) { continue; } foreach (List <long> v in isle.Value.SquadCounts) { riflemen += v[0]; machinegunners += v[1]; bazookamen += v[2]; lighttanks += v[3]; mediumtanks += v[4]; heavytanks += v[5]; lightfighters += v[6]; mediumfighters += v[7]; bombers += v[8]; } } } // assemble string of TOTAL units - free and deployed StringBuilder sb = new StringBuilder(); IslesOfWar.UnitNames unitNames = new UnitNames(); sb.AppendLine("<h2>TOTAL COMBAT UNITS FOR " + name + "</h2>"); sb.AppendLine("<p></p>"); sb.Append("<pre> " + unitNames.Riflemen.PadRight(pad, ' ')); sb.Append("=" + string.Format("{0:n0}", riflemen).ToString().PadLeft(12, ' ') + "</pre>" + Environment.NewLine); sb.Append("<pre> " + unitNames.MachineGunners.PadRight(pad, ' ')); sb.Append("=" + string.Format("{0:n0}", machinegunners).ToString().PadLeft(12, ' ') + "</pre>" + Environment.NewLine); sb.Append("<pre> " + unitNames.Bazookamen.PadRight(pad, ' ')); sb.Append("=" + string.Format("{0:n0}", bazookamen).ToString().PadLeft(12, ' ') + "</pre>" + Environment.NewLine); sb.Append("<pre> " + unitNames.LightTanks.PadRight(pad, ' ')); sb.Append("=" + string.Format("{0:n0}", lighttanks).ToString().PadLeft(12, ' ') + "</pre>" + Environment.NewLine); sb.Append("<pre> " + unitNames.MediumTanks.PadRight(pad, ' ')); sb.Append("=" + string.Format("{0:n0}", mediumtanks).ToString().PadLeft(12, ' ') + "</pre>" + Environment.NewLine); sb.Append("<pre> " + unitNames.HeavyTanks.PadRight(pad, ' ')); sb.Append("=" + string.Format("{0:n0}", heavytanks).ToString().PadLeft(12, ' ') + "</pre>" + Environment.NewLine); sb.Append("<pre> " + unitNames.LightFighters.PadRight(pad, ' ')); sb.Append("=" + string.Format("{0:n0}", lightfighters).ToString().PadLeft(12, ' ') + "</pre>" + Environment.NewLine); sb.Append("<pre> " + unitNames.MediumFighters.PadRight(pad, ' ')); sb.Append("=" + string.Format("{0:n0}", mediumfighters).ToString().PadLeft(12, ' ') + "</pre>" + Environment.NewLine); sb.Append("<pre> " + unitNames.Bombers.PadRight(pad, ' ')); sb.Append("=" + string.Format("{0:n0}", bombers).ToString().PadLeft(12, ' ') + "</pre>" + Environment.NewLine); return(sb.ToString()); }
public void Initialize(UnitNames unitName, int health) { unitNameText.text = unitName.ToString(); hpText.text = health + "/" + health; }