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)); }
public void OnHaulableItemRemoved(HaulableItem item) { if (item != haulableItem) { Debug.Log("OnHaulableItemRemoved:: Trying to remove item from tile that isnt there"); return; } haulableItem = null; }
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); }
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); }
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); }
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); }
private GameObject itemToHaulGamobject; // gameobject ref public HaulingJob(GameObject itemToHaulGamobject, HaulableItem itemToHaul) : base(itemToHaulGamobject.transform.position) { this.itemToHaulGamobject = itemToHaulGamobject; this.itemToHaul = itemToHaul; CalculateHaulingData(); }
void CreateHaulableItemPrototypes() { HaulableItemPrototypes = new Dictionary <string, HaulableItem>(); HaulableItemPrototypes.Add("boxofbooks", HaulableItem.CreatePrototype("boxofbooks", new Content("books", 10, 10), 1)); }
public void OnRemoved(HaulableItem item) { onItemRemoved(item); }