void OnGUI() { GUILayout.BeginArea( new Rect((Screen.width - width) / 2.0f, 0, width, height), GUI.skin.box ); GUI.Label( new Rect(5, 3, 100, 25), String.Format("Villagers: {0} / {1}", villagerCount, SpawnVillagers.TotalVillagerCapacity()), CurrentCountSkin() ); GUI.Label(new Rect(width - 150, 3, 150, 25), String.Format("Currently {0}", HutBuilding.CurrentStateDescriptor())); GUI.Label( new Rect(5, 28, 100, 25), String.Format("Orcs: {0} / {1}", Ork.AllOrks().Count(), Fort.TotalOrkCapacity()) ); GUI.Label( new Rect(width - 150, 28, 150, 25), String.Format("Time until next fort: {0}s", SpawnForts.TimeUntilNextSpawn()) ); GUI.Label( new Rect((width / 2f) - 35, 50, 80, 25), String.Format("Time: {0}", ProgressTracker.FormattedPlaytime()) ); GUILayout.EndArea(); }
void WaitForCapacity() { if (Villager.AllVillagers().Count() > villagersToBuild && SpawnVillagers.AtVillagerCapacity()) { currentState = BuildState.LookingForLocation; } }
void AttemptSpawn() { timeSinceLastSpawn += Time.deltaTime; if (!canSpawn || timeSinceLastSpawn < spawnRate) { return; } SpawnVillagers.AttemptSpawnVillager(); timeSinceLastSpawn = 0f; }
private void PlaceBuildingOnFreePlainsTile() { // place building into a tile on the grid int tileXIndex = (int)(buildingToDrag.transform.position.x / tileOffset); int tileZIndex = (int)(buildingToDrag.transform.position.z / tileOffset); string tileTag = tileLayoutScript.getTileTag(tileXIndex, tileZIndex); if (tileTag == null || buildingToDrag.tag == "DestroyThis") { Destroy(buildingToDrag); buildingToDrag = null; StopDraggingBuidling(); return; } // drop the building down onto a free plains tile if (tileTag.Equals("PlainsTile")) { if (!buildingToDrag.tag.Equals("VillageCenter")) { // if village center exists - village center stores resources if (resourceCounterScript != null) { if (buildingToDrag.name.Contains("House")) { buildingToDrag.tag = "Home"; SpawnVillagers script = GameObject.Find("VillagerSpawner").GetComponent <SpawnVillagers>(); int villagerNum = 0; if (script == null || script.villagers?.Any() != true) { villagerNum = 0; } else { villagerNum = script.getVillagerList().Count; } Text foodCount = GameObject.Find("FarmFoodCount").GetComponent <Text>(); int currFoodCount = int.Parse(foodCount.text); if (currFoodCount < 5 * villagerNum + 5) { StartCoroutine(GameObject.Find("Hints").GetComponent <DisplayHints>().DisplayHint("NotEnoughFood", 4)); } } else if (buildingToDrag.name.Contains("Tavern")) { buildingToDrag.tag = "Tavern"; } else if (buildingToDrag.name.Contains("Fort")) { buildingToDrag.tag = "Fort"; } else if (buildingToDrag.name.Contains("Farm")) { buildingToDrag.tag = "Farm"; // if this is the first farm in the game if (GameObject.FindGameObjectsWithTag("Farm").Length == 1) { StartCoroutine(GameObject.Find("Hints").GetComponent <DisplayHints>().DisplayHint("FarmFunctionHint", 5)); // BuildHousesHint will be delayed StartCoroutine(GameObject.Find("Hints").GetComponent <DisplayHints>().DisplayHint("BuildHousesHint", 5)); } GameObject.Find("BuildMenuDropDown").GetComponent <DisableDropdownOptions>().DisplayFullMenu(); } PayThePrice(); } else { StartCoroutine(GameObject.Find("Hints").GetComponent <DisplayHints>().DisplayHint("NotEnoughHint", 4)); Destroy(buildingToDrag); return; } } else { // if this is the first village center if (GameObject.FindGameObjectsWithTag("VillageCenter").Length == 1) { StartCoroutine(GameObject.Find("Hints").GetComponent <DisplayHints>().DisplayHint("BuildFarmsHint", 5)); GameObject.Find("BuildMenuDropDown").GetComponent <DisableDropdownOptions>().DisplayBiggerMenu(); } else { PayThePrice(); } } buildingToDrag.transform.position = new Vector3(tileXIndex * tileOffset + centerOffset, 0, tileZIndex * tileOffset + centerOffset); tileLayoutScript.setTileTag(tileXIndex, tileZIndex, "PlainsTileWithBuilding"); buildingToDrag.GetComponent <ShowBuildingPlacementOnMap>().MakeRadicalInvisible(); buildingToDrag = null; StopDraggingBuidling(); } else { // continue dragging the building draggingNewBuilding = true; } }