private void AddTree(GameplayController controller) { for (int i = 0; i < mapSize; i++) { for (int j = 0; j < mapSize; j++) { if (rnd.Next(0, 15) > 5)// параметр лесистости { MapObject newObject = null; if (newMap.mapArray[i][j].Terrain is Forest) { newObject = new ForestTree(); } if (newMap.mapArray[i][j].Terrain is Swamp) { newObject = new SwampTree(); } if (newMap.mapArray[i][j].Terrain is Field) { newObject = new FieldTree(); } if (newObject != null) { newObject.SetBehavior(new RandomDecisionMaker()); newMap.mapArray[i][j].listOfObjects.Add(newObject); controller.AddObject(newObject); newObject.CoordinateX = i; newObject.CoordinateY = j; } } } } }
public Map AutoCreator(int mapSize, GameplayController controller) { this.mapSize = mapSize; newMap = new Map(mapSize); notWaterTile = 0; while (notWaterTile < mapSize * mapSize * 6 / 7)//цифры изменить на что { this.CreateObject(new Field()); this.CreateObject(new Forest()); this.CreateObject(new Swamp()); } this.RemoveIsolatedTwoTileGroup(); this.DeleteSingleTile(); this.AddTree(controller); return newMap; }
static void Main(string[] args) { var test = new GameplayController(); test.StartGame(); Console.ReadKey(); }