public static string logStats() { updateFPSStats(); content = "PlayerNumberWinner, " + playerNumberWinner.ToString() + "\n" + "MinFPS, " + minFPS.ToString() + "\n" + "AvgFPS, " + avgFPS.ToString() + "\n" + "MaxFPS, " + maxFPS.ToString() + "\n" + "GameLength, " + gameLength.ToString() + "\n" + "player1GoldNodesGathered, " + playerXGoldNodesGathered[0].ToString() + "\n" + "player2GoldNodesGathered, " + playerXGoldNodesGathered[1].ToString() + "\n" + "player1EnemiesKilled, " + playerXEnemiesKilled[0].ToString() + "\n" + "player2EnemiesKilled, " + playerXEnemiesKilled[1].ToString() + "\n"; return(content); }
private void NumberBox_TextChanged(object sender, TextChangedEventArgs e) { int n = -1; bool worked = int.TryParse(NumberBox.Text, out n); if (!worked) { NumberBox.Text = TeamNumber.ToString(); } else if (ExistingTeams.Contains(n)) { NumberBox.BorderBrush = new SolidColorBrush(Colors.Red); NumberBox.ToolTip = "A team with that number already exists."; OKBtn.IsEnabled = false; } else { TeamNumber = n; NumberBox.BorderBrush = new SolidColorBrush(GRAY_BORDER); NumberBox.ToolTip = null; if (TeamName.Trim() != "") { OKBtn.IsEnabled = true; NameBox.BorderBrush = new SolidColorBrush(GRAY_BORDER); NameBox.ToolTip = null; } else { OKBtn.IsEnabled = false; NameBox.BorderBrush = new SolidColorBrush(Colors.Red); NameBox.ToolTip = "You must specify a name."; } } }
/// <summary> /// チーム設定の作成 /// </summary> /// <returns></returns> public TeamSetting CreateTeamSetting(TeamNumber teamNumber) { // チーム番号に即したデータを読み込む string text = Resources.Resource.ResourceManager.GetString(teamNumber.ToString()); TeamSetting teamSetting = null; int basicValue = 0; StringReader reader = new StringReader(text); string line; int lineCount = 0; while ((line = reader.ReadLine()) != null) { if (lineCount == 0) { // 1行目:チーム設定を取得 string[] teamSettingString = line.Split(TextSeparator); basicValue = int.Parse(teamSettingString[0]); string initialName = teamSettingString[1]; string teamName = teamSettingString[2]; teamSetting = new TeamSetting(teamName, initialName, teamNumber); } else if (lineCount == 1) { // 2行目:何もしない } else if (lineCount >= 20) { // 20行目:最大で18人分(LineCountが19)までしか読み込まない break; } else { // 3行目~19行目:能力値の取得 string[] memberSettingString = line.Split(TextSeparator); if (memberSettingString[0] == string.Empty) { // 1列目が空文字であればそれ以上のメンバ無しとみなして取得終了 break; } int columnIndex = 1; Player player = new Player(); DefensePosition defensePosition = (DefensePosition)System.Enum.Parse(typeof(DefensePosition), memberSettingString[columnIndex], true); columnIndex++; player.Name = memberSettingString[columnIndex]; columnIndex++; player.Grade = int.Parse(memberSettingString[columnIndex]); columnIndex++; if (memberSettingString[columnIndex] != string.Empty) { player.IsLeftThrow = bool.Parse(memberSettingString[columnIndex]); } columnIndex++; if (memberSettingString[columnIndex] != string.Empty) { player.IsLeftBox = bool.Parse(memberSettingString[columnIndex]); } columnIndex++; player.BreedType = (BreedType)System.Enum.Parse(typeof(BreedType), memberSettingString[columnIndex], true); columnIndex++; player.FielderAbility.Meet = int.Parse(memberSettingString[columnIndex]) + basicValue; columnIndex++; player.FielderAbility.Power = int.Parse(memberSettingString[columnIndex]) + basicValue; columnIndex++; player.FielderAbility.Run = int.Parse(memberSettingString[columnIndex]) + basicValue; columnIndex++; player.FielderAbility.Defense = int.Parse(memberSettingString[columnIndex]) + basicValue; columnIndex++; player.FielderAbility.Wisdom = int.Parse(memberSettingString[columnIndex]) + basicValue; columnIndex++; columnIndex++;// [計]列はスキップ // 守備適正は未記入であれば守備位置と同じものを設定 if (memberSettingString[columnIndex] != string.Empty) { player.FielderAbility.DefenseType = (DefenseType)System.Enum.Parse(typeof(DefenseType), memberSettingString[columnIndex], true); } else { player.FielderAbility.DefenseType = DefensePositionHelper.ConvertDefenseType(defensePosition); } columnIndex++; // 起用は未記入であればNomalとする UseKind useKind; if (memberSettingString[columnIndex] != string.Empty) { useKind = (UseKind)System.Enum.Parse(typeof(UseKind), memberSettingString[columnIndex], true); } else { useKind = UseKind.Normal; } columnIndex++; // 特殊能力 if (memberSettingString[columnIndex] != string.Empty) { player.FielderAbility.SpecialFilederAbility = SpecialAbilityHelper.GetSpecialFielderAbility(memberSettingString[columnIndex]); } columnIndex++; if (memberSettingString[columnIndex] != string.Empty) { // 投手能力が設定されている場合 player.PitcherAbility.Fastball = int.Parse(memberSettingString[columnIndex]) + basicValue; columnIndex++; player.PitcherAbility.Breakingball = int.Parse(memberSettingString[columnIndex]) + basicValue; columnIndex++; player.PitcherAbility.Control = int.Parse(memberSettingString[columnIndex]) + basicValue; columnIndex++; player.PitcherAbility.Stamina = int.Parse(memberSettingString[columnIndex]) + basicValue; columnIndex++; columnIndex++;// [計]列はスキップ if (memberSettingString[columnIndex] != string.Empty) { player.PitcherAbility.PitchingStyle = (PitchingStyle)System.Enum.Parse(typeof(PitchingStyle), memberSettingString[columnIndex], true); } columnIndex++; // 投手の特殊能力 if (memberSettingString[columnIndex] != string.Empty) { player.PitcherAbility.SpecialPitcherAbility = SpecialAbilityHelper.GetSpecialPitcherAbility(memberSettingString[columnIndex]); } } else { // 投手能力が未設定の場合 const int nothingValue = 0; player.PitcherAbility.Fastball = nothingValue; player.PitcherAbility.Breakingball = nothingValue; player.PitcherAbility.Control = nothingValue; player.PitcherAbility.Stamina = nothingValue; player.PitcherAbility.SpecialPitcherAbility = SpecialPitcherAbility.Nothing; } // メンバの作成 GameMember member = new GameMember(player, defensePosition); member.UseKind = useKind; teamSetting.DefaultGameMembers.Add(member); } lineCount++; } // デフォルトのメンバ設定を元にメンバ設定を作成 teamSetting.CreateCurrentMembersFromDefault(); // チーム設定のチェック(よくある設定ミスをチェック) CheckTeamSetting(teamSetting); return teamSetting; }