Exemple #1
0
    void CreateGranary(GranaryData granaryData)
    {
        Quaternion rotation   = Quaternion.LookRotation(Util.CoordsToVector3(granaryData.buildingData.loc.front.coords) - Util.CoordsToVector3(granaryData.buildingData.loc.coords), Vector3.up);
        Granary    storehouse = Instantiate(granaryObj, Util.CoordsToVector3(granaryData.buildingData.loc.coords), rotation, this.transform).GetComponent <Granary>();

        storehouse.Initialize(granaryData);
    }
Exemple #2
0
    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);
    }
Exemple #3
0
    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();
    }
Exemple #4
0
    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;
    }
    protected void SlotStructureTransfer(ItemInput droppedItem, SlotInput otherSlot, Dictionary <string, Item> InventoryAdd, int numSlots,
                                         List <GameObject> slotsContainer, List <GameObject> itemsContainer, Dictionary <string, Item> InventoryRemove)
    {
        SlotCraftTransfer(droppedItem, otherSlot, InventoryAdd, numSlots,
                          slotsContainer, itemsContainer, InventoryRemove);
        //Granary
        if (Pd.CurrentTile.Structure.Value.GetComponent <StructureData>() is GranaryData &&
            InventoryRemove == Pd.GetInventory())
        {
            GranaryData gD = (GranaryData)Pd.CurrentTile.Structure.Value.GetComponent <StructureData>();

            /*foreach (GameObject g in itemsContainer) {
             *  if (g.gameObject == null) {
             *      itemsContainer.Remove(g);
             *  }
             * }*/
            GameObject asdf = itemsContainer.Find(g => g.gameObject && g.GetComponent <ItemInput>().Item.GetName().Equals(droppedItem.Item.GetName()));
            if (!(asdf.GetComponent <ItemInput>().Item is Food))
            {
                return;
            }
            gD.StartCoroutine(gD.MutliplyItem(asdf.gameObject.transform.parent.GetComponent <SlotInput>()));
        }
        //Torch
        if (!(Pd.CurrentTile.Structure.Value.GetComponent <StructureData>() is GranaryData) &&
            InventoryRemove == Pd.GetInventory() && droppedItem.Item.GetName().Equals(Global.ItemNames[ItemList.Torch]))
        {
            Pd.FOWStructures.Add(Pd.CurrentTile.Structure.Value);
            Debug.Log("hello");
        }
        else if (!(Pd.CurrentTile.Structure.Value.GetComponent <StructureData>() is GranaryData) &&
                 !(InventoryRemove == Pd.GetInventory()) && droppedItem.Item.GetName().Equals(Global.ItemNames[ItemList.Torch]))
        {
            Pd.FOWStructures.Remove(Pd.CurrentTile.Structure.Value);
        }
    }