public bool CanDoAction(Human human, ref BuildingLocationData loc) { loc = human.FindUnoccupiedBuildingSpace(); if (loc != null) { return(true); } return(false); }
public GranaryData CreateGranaryData(BuildingLocationData loc) { GranaryData granaryData = new GranaryData(loc, "Granary " + (gameController.data.granaryData.Count + 1)); VoxelData voxelData = gameController.data.voxelData[loc.coords.x, loc.coords.y]; gameController.data.granaryData.Add(granaryData); voxelData.hasGranary = true; voxelData.occupied = true; voxelData.navigable = false; loc.front.claimed = true; foreach (Coords c in Util.GetAdjacent(voxelData.coords, false)) { gameController.data.voxelData[c.x, c.y].UpdateClaimed(gameController.data.voxelData); } return(granaryData); }
public override void Initialize(object granaryData) { if (granaryData == null) { BuildingLocationData loc = new BuildingLocationData(Util.Vector3ToCoords(transform.position), new Coords(1, 1), gameController.data.voxelData[(int)transform.position.x + (int)transform.forward.x, (int)transform.position.z + (int)transform.forward.z]); this.data = new GranaryData(loc, "Storehouse " + (gameController.data.granaryData.Count + 1)); VoxelData voxelData = gameController.data.voxelData[loc.coords.x, loc.coords.y]; gameController.data.granaryData.Add(this.data); voxelData.navigable = false; voxelData.occupied = true; voxelData.hasGranary = true; } else { this.data = (GranaryData)granaryData; } this.gameObject.name = data.name; UpdateDict(); }
public override IEnumerator PerformAction(Human human) { human.busy = true; //Find building location BuildingLocationData loc = null; if (!CanDoAction(human, ref loc)) { human.busy = false; yield break; } //Create data GranaryData granaryData = CreateGranaryData(loc); //Move to storehouse build location yield return(human.MoveTo(Util.CoordsToVector3(loc.coords))); //Build storehouse CreateGranary(granaryData); human.busy = false; }
public BuildingData(BuildingLocationData loc) { this.loc = loc; }
public GranaryData(BuildingLocationData loc, string name) { this.buildingData = new BuildingData(loc); this.name = name; }