/* * public bool IsDead * { * get { return _isDead; } * set { _isDead = value; } * } */ #endregion #region Constructor /// <summary> /// Create a Player [Designated constructor] /// </summary> /// <param name="name">Name of the player</param> /// <param name="cannon">Represent the canon of the player</param> public BG_Player(string name, BG_Cannon cannon) { //this.Cannon = new BG_Cannon(); this.History = new List <BG_Hit>(); this.Name = name; this.IsPlaying = false; this.Cannon = cannon; }
public void UpdateValues(string msg) { // Check for seed string SeedRegex = "seed:([0-9]{1,})"; Match seedMatch = Regex.Match(msg, SeedRegex); // Check if we have a seed if (seedMatch.Value != String.Empty) { int levelSeed = int.Parse(seedMatch.Groups[1].Value); this.field = new BG_Field(MainForm.Width - 180, MainForm.Height - 24, levelSeed); } // Check for moving players string MoveRegex = "\\(([^,;.]+);([0-9]{1,3});([0-9]{1,3})\\)"; MatchCollection moveMatches = Regex.Matches(msg, MoveRegex); foreach (Match match in moveMatches) { string[] MoveValues = Regex.Split(match.Value, MoveRegex); string name = MoveValues[1]; int x = int.Parse(MoveValues[2]); int y = int.Parse(MoveValues[3]); BG_Cannon currentPlayerCannon = new BG_Cannon(Color.Red, new BG_Location(x, y)); BG_Player currentPlayer = new BG_Player(name, currentPlayerCannon); this.listPlayers.Add(currentPlayer); } // Check for new turn string newTurnRegex = "[^,.-]{1,};newturn"; Match newTurnMatch = Regex.Match(msg, newTurnRegex); // Check if we have to start a new turn if (newTurnMatch.Value == (this.Name + ";" + "newturn")) { // Start the turn } // Check for end turn string testStr = "endturn"; string endTurnRegex = "^endturn$"; Match endTurnMatch = Regex.Match(testStr, endTurnRegex); // Check if we have to start a new turn if (endTurnMatch.Value == "endturn") { // End the turn } }
// Designated constructor public BG_Hit(BG_Location location, BG_Cannon cannon) { this.Location = location; this.Cannon = cannon; }