/// <summary> /// Creates a new village and gives it to a player. /// </summary> /// <param name="id">Village id.</param> /// <param name="isMyVillage">MyVillage or not.</param> /// <returns>Returns the created village.</returns> public Village CreateVillage( int id, bool isMyVillage = false) { Village v = GetVillage(id); if (v != null) { return(v); } if (isMyVillage) { Logger.Trace("Creating a myvillage id:{0}", id); v = new MyVillage(id); } else { Logger.Trace("Creating a village id:{0}", id); v = new Village(id); } Villages.Add(id, v); if (VillageAdded != null) { VillageAdded.Invoke(v); } return(v); }
/// <summary> /// Adds a new village to player's villages. /// Fires a new village added event. /// </summary> /// <param name="id">Village id.</param> public void AddVillage(Village v) { if (Villages.ContainsKey(v.Id)) { return; } Villages.Add(v.Id, v); Logger.Trace("{0}, new village added to me.", this); if (VillageAdded != null) { VillageAdded.Invoke(v); } }