public ItemEvent(ItemEventType type, SmallItem item) : base(EventType.ItemEvent) { this.itemEventType = type; this.largeItem = null; this.smallItem = item; }
public SmallItem CreateSmallItem(string type) { // Look up if we have a custom prototype for this item type. If we do, // clone that prototype for our new item. SmallItem item; SmallItem proto; if (smallItemTypes.TryGetValue(type, out proto)) { item = proto.Clone(); } else { // This type doesn't have it's own prototype, so we'll just use the // generic base type instead. item = new SmallItem(game, type); } // Store the item in our database for future lookups and add it to our // indexes. smallItems.Add(item); UpdateIndexes(type, item); // And done. Return the item! return(item); }
public TileEvent(TileEventType type, Board.Tile tile) : base(EventType.TileEvent) { this.tileEventType = type; this.tile = tile; this.largeItem = null; this.smallItem = null; }
public void AddSmallItem(SmallItem item) { if (HasLargeItem() && smallItems.Count >= largeItem.SurfaceCapacity) { Debug.LogError(this + " can not take any more small items."); return; } smallItems.Add(item); SendTileEvent(Events.TileEventType.SmallItemAdded, item); }
private void UpdateCollection(float deltaTime) { // TODO: Pull inventory component from container. Item.Chest chest = targetContainer as Item.Chest; foreach (string itemType in GetMissingItemTypes()) { SmallItem item = chest.inventory.GetItemByType(itemType); if (item != null) { // TODO: Remove the item from the target container too. // chest.inventory.RemoveItemOfType(itemType); // TODO: Figure out better way of handling items than by reference. inventory.AddItem(new ItemReference(item)); } } // We're done with this container. targetContainer = null; }
void Start() { if (instance != null && instance != this) { Destroy(this); return; } instance = this; // TODO: Make board generation dynamic. game = new Game(50, 50); // TODO: Load the item database from configurations. game.itemDB.SetLargeItemProto("Chest", new Item.Chest(game)); // TODO: Make layout of board dynamic. // FIXME: Remove all this crap, just for debugging. Item.Chest chest = game.itemDB.CreateLargeItem("Chest") as Item.Chest; game.board.GetTile(0, 1).SetLargeItem(chest); SmallItem item = game.itemDB.CreateSmallItem("Wood"); chest.inventory.AddItem(new ItemReference(item)); }
protected SmallItem(SmallItem other) { this.game = other.game; this.type = other.type; }
public void Destroy(SmallItem item) { // Only need to remove the item from the main database. The indexes will // clean themselves on next access. smallItems.Remove(item); }
private void SendTileEvent(Events.TileEventType eventType, SmallItem item) { SendTileEvent(new Events.TileEvent(eventType, this, item)); }