예제 #1
0
 public ItemEvent(ItemEventType type, SmallItem item) :
     base(EventType.ItemEvent)
 {
     this.itemEventType = type;
     this.largeItem     = null;
     this.smallItem     = item;
 }
예제 #2
0
    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);
    }
예제 #3
0
 public TileEvent(TileEventType type, Board.Tile tile) :
     base(EventType.TileEvent)
 {
     this.tileEventType = type;
     this.tile          = tile;
     this.largeItem     = null;
     this.smallItem     = null;
 }
예제 #4
0
 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);
 }
예제 #5
0
    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;
    }
예제 #6
0
    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));
    }
예제 #7
0
 protected SmallItem(SmallItem other)
 {
     this.game = other.game;
     this.type = other.type;
 }
예제 #8
0
 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);
 }
예제 #9
0
 private void SendTileEvent(Events.TileEventType eventType, SmallItem item)
 {
     SendTileEvent(new Events.TileEvent(eventType, this, item));
 }