/// <summary> /// Spawn a construction site on the map and all assigned citizen begin to work. /// </summary> /// <param name="building">The building to be build.</param> /// <param name="position">The world position of the build spot.</param> /// <param name="player">The player that owns the building</param> /// <param name="citizen">The assigned citizen.</param> /// <returns>true if the player has enough resources and the construction has started.</returns> public bool Build(Building building, Vector3 position, Player player, Citizen citizen) { // Check if the player has enough resources. if (EnoughResources(player, building)) { // Remove the resource cost from the player resources. player.resources.RemoveResources(building.buildCost); GameObject construction; // Spawen a construction site according to the building size. if (building.constructionSiteSize == ConstructionSiteSize.Size4x4) { construction = (GameObject)Instantiate(Resources.Load("ConstructionSite4x4"), position, Quaternion.identity); } else { construction = (GameObject)Instantiate(Resources.Load("ConstructionSite8x8"), position, Quaternion.identity); } // Set the stats of the construction site. ConstructionSite constructionSite = construction.GetComponent <ConstructionSite>(); constructionSite.buildTimeLeft = building.buildTime; constructionSite.combatDefense = building.combatDefense; constructionSite.name = building.name + " Construction"; constructionSite.building = building.name; constructionSite.player = player; constructionSite.SetPlayerStats(); // Delegate the responsible citizen to the construction site. citizen.Build(construction); return(true); } return(false); }