Esempio n. 1
0
 void PickUpHaulableItem()
 {
     item = CurrTile.haulableItem;//GiveItem();
     //Debug.Log(CurrTile.haulableItem);
     CurrTile.haulableItem.OnRemoved(CurrTile.haulableItem);
     // Debug.Log("Picked up thingo, item is now: " + item.Contents);
 }
    public Sprite GetSpriteForHaulableItem(HaulableItem item)
    {
        string spriteName = item.ObjectType;


        //TODO: Implement sprite manager class and fetch the sprite through there
        //return SpriteManager.current.GetSprite("Fixture", spriteName);
        Debug.Log("FSC:: GetSpriteForItem - " + spriteName);
        return(SpriteManager.current.GetSprite("HaulableItems", spriteName));
    }
Esempio n. 3
0
    public void OnHaulableItemRemoved(HaulableItem item)
    {
        if (item != haulableItem)
        {
            Debug.Log("OnHaulableItemRemoved:: Trying to remove item from tile that isnt there");
            return;
        }

        haulableItem = null;
    }
Esempio n. 4
0
    static public HaulableItem CreatePrototype(string objectType, Content content, int stackSize = 0, int requiredStackSize = 0)
    {
        HaulableItem item = new HaulableItem();

        item.ObjectType        = objectType;
        item.StackSize         = stackSize;
        item.RequiredStackSize = requiredStackSize;
        item.content           = content;

        return(item);
    }
    void OnHaulableItemChanged(HaulableItem item)
    {
        if (!haulableGameObjectMap.ContainsKey(item))
        {
            Debug.LogError("Trying to change visuals of a fixture not in the list? ");
            return;
        }

        GameObject fixt_go = haulableGameObjectMap [item];

        fixt_go.GetComponent <SpriteRenderer> ().sprite = GetSpriteForHaulableItem(item);
    }
    void OnHaulableItemRemoved(HaulableItem item)
    {
        if (!haulableGameObjectMap.ContainsKey(item))
        {
            Debug.LogError("Trying to remove an item not in the list? ");
            return;
        }

        GameObject fixt_go = haulableGameObjectMap [item];

        Destroy(fixt_go);
        haulableGameObjectMap.Remove(item);
        world.HaulableItems.Remove(item);
    }
Esempio n. 7
0
    public bool AssignHaulableItem(HaulableItem item)
    {
        if (item == null)
        {
            haulableItem = null;
            return(true);
        }

        if (haulableItem != null)
        {
            Debug.LogError("Trying to put a haulableItem where there is one");
            return(false);
        }

        haulableItem = item;
        haulableItem.RegisterOnRemoved(OnHaulableItemRemoved);
        return(true);
    }
Esempio n. 8
0
    static public HaulableItem PlaceHaulableItem(HaulableItem proto, Tile t)
    {
        HaulableItem item = new HaulableItem();

        item.ObjectType        = proto.ObjectType;
        item.StackSize         = proto.StackSize;
        item.RequiredStackSize = proto.RequiredStackSize;
        item.content           = proto.content;

        item.Tile = t;

        if (!t.AssignHaulableItem(item))
        {
            Debug.LogError("HI::PlaceHaulableItem - Couldnt place haulableItem");
            return(null);
        }

        return(item);
    }
Esempio n. 9
0
    public void PlaceHaulableItem(string objType, Tile tile)
    {
        if (!HaulableItemPrototypes.ContainsKey(objType))
        {
            Debug.LogError("HaulableItemPrototypes does not contain a definition for: " + objType);
            return;
        }

        HaulableItem obj = HaulableItem.PlaceHaulableItem(HaulableItemPrototypes[objType], tile);

        if (obj == null)
        {
            Debug.LogError("World:PlaceHaulableItem returned a null object");
            return;
        }

        HaulableItems.Add(obj);
        if (onHaulableItemCreated != null)
        {
            onHaulableItemCreated(obj);
        }
    }
    public void OnHaulableItemCreated(HaulableItem item)
    {
        Debug.Log("Item is being created");
        GameObject item_go = new GameObject();

        //Add data and UI to map
        haulableGameObjectMap.Add(item, item_go);

        //Set up general info about the GO
        item_go.name = item.ObjectType + "_" + item.Tile.X + "_" + item.Tile.Y;
        item_go.transform.position = new Vector3(item.Tile.X, item.Tile.Y);
        item_go.transform.SetParent(this.transform, true);

        SpriteRenderer sr = item_go.AddComponent <SpriteRenderer> ();

        sr.sprite           = GetSpriteForHaulableItem(item);
        sr.sortingLayerName = "Fixture";



        //TODO: Implement these
        //item.RegisterOnChanged (OnFixtureChanged);
        item.RegisterOnRemoved(OnHaulableItemRemoved);
    }
Esempio n. 11
0
    private GameObject itemToHaulGamobject;                                                 // gameobject ref

    public HaulingJob(GameObject itemToHaulGamobject, HaulableItem itemToHaul) : base(itemToHaulGamobject.transform.position)
    {
        this.itemToHaulGamobject = itemToHaulGamobject;
        this.itemToHaul          = itemToHaul;
        CalculateHaulingData();
    }
Esempio n. 12
0
    void CreateHaulableItemPrototypes()
    {
        HaulableItemPrototypes = new Dictionary <string, HaulableItem>();

        HaulableItemPrototypes.Add("boxofbooks", HaulableItem.CreatePrototype("boxofbooks", new Content("books", 10, 10), 1));
    }
Esempio n. 13
0
 public void OnRemoved(HaulableItem item)
 {
     onItemRemoved(item);
 }