Пример #1
0
        /// <summary>
        /// Adds an item to inventory
        /// </summary>
        /// <param name="itemID">The item ID to add</param>
        public void AddInventoryItem(uint?itemID)
        {
            var item = DataAccess.Get <EntityInanimate>(itemID, CacheType);

            if (item != null)
            {
                _inventory.AddEntity(CacheType == CacheType.Instance ? item.Instance : item.Prototype, item);
            }
        }
Пример #2
0
        /// <summary>
        /// Equips an item
        /// </summary>
        /// <param name="item">The item to equip</param>
        /// <param name="slot">The slot to equip the item at</param>
        /// <param name="swap">Whether to swap the items if the slot is already full</param>
        /// <returns>The items removed as part of the swap</returns>
        /// <exception cref="InvalidSlotException">The item was attempted to be equipped at a slot it cannot be equipped at</exception>
        /// <exception cref="SlotFullException">If swap was false, the slot was full</exception>
        public List <EntityInanimate> EquipItemAt(uint?itemID, ItemSlot slot, bool swap)
        {
            var item         = DataAccess.Get <EntityInanimate>(itemID, CacheType);
            var swappedItems = new List <EntityInanimate>();

            if (item == null)
            {
                return(swappedItems);
            }

            if (item.Slot != slot)
            {
                throw new InvalidSlotException();
            }

            var swapRequired = false;
            var itemsAtSlot  = GetItemsEquippedAt(slot);

            if (itemsAtSlot.Count >= Constants.MAX_EQUIPPED.AT(slot))
            {
                swapRequired = true;
            }

            if (!swapRequired)
            {
                _equipment.AddEntity(itemID, item);
            }
            else if (swapRequired && swap)
            {
                // TODO: Fix so this only removes the required number of items from the slots
                swappedItems = RemoveItemsAt(slot);
                _equipment.AddEntity(itemID, item);
            }
            else if (swapRequired && !swap)
            {
                if (swapRequired)
                {
                    throw new SlotFullException();
                }
            }

            return(swappedItems);
        }
Пример #3
0
        public static void AddLogoMenu(EntityContainer container)
        {
            var logoSize = new Size(600, 125);

            container.AddEntity(new Entity("menu-logo", "menu-logo",
                                           new Rect(Constants.ViewportRatioWidth / 2f - logoSize.Width / 2f, logoSize.Height, logoSize.Width,
                                                    logoSize.Height),
                                           new EntityState("default",
                                                           new TextureComponent(new TextureComponent.TextureData("default", 0f,
                                                                                                                 new TextureComponent.Frame(Constants.GameLogoFile))))));
        }
Пример #4
0
 void Start()
 {
     EntityContainer.AddEntity(this);
 }