void Start() { // Establish instance. if (instance != null) { Debug.LogError("There is already a GameController"); } else { instance = this; } CalculateDaysTillNextHunter(); // Generate terrain TileController tc = new TileController(GRID_SIZE); tc.InitGrid(); foreach (List <Tile> gridX in tc.grid) { foreach (Tile t in gridX) { var terrainGameObject = Instantiate(terrainPrefab, t.location, Quaternion.identity); terrainGameObject.GetComponent <SpriteRenderer>().sprite = t.sprite; terrainGameObject.GetComponent <SpriteRenderer>().material.color = t.color; // Add marsh ponds if required if (t.isMarshy) { foreach (MarshSubTile m in t.marsh) { var marshGameObject = Instantiate(terrainPrefab, m.location, Quaternion.Euler(new Vector3(0, 0, (int)(m.rotation * 360)))); var sr = marshGameObject.GetComponent <SpriteRenderer>(); sr.sprite = m.sprite; sr.flipX = m.flipX; sr.flipY = m.flipY; sr.material.color = new Color(0.0f, 0.05f, 0.4f); } } } } // Init the animal types. AnimalType.InitAnimalTypes(); // Place some inital trees. for (int i = 0; i < 100; i++) { Vector3 c = Random.onUnitSphere; Vector2 coord = new Vector2(c.x, c.y); coord = coord.normalized * Mathf.Sqrt(Random.Range(0f, 1f)) * 10f; PlantController newPlant = CreatePlant(coord, PlantType.GetRandomPlantType()); newPlant.SetAge(Random.Range(1, newPlant.plantType.matureTime)); } // Place some initial animals. foreach (var animalType in AnimalType.animalTypes) { for (int i = 0; i < animalType.GetHabitability(trees, animals); i++) { SpawnAnimal(animalType); } } UIController.instance.OnCarbonChanged(); UIController.instance.OnWaterChanged(); }