• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# InventorySlot类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中InventorySlot的典型用法代码示例。如果您正苦于以下问题:C# InventorySlot类的具体用法?C# InventorySlot怎么用?C# InventorySlot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InventorySlot类属于命名空间,在下文中一共展示了InventorySlot类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetSlotPosition

 protected Rectangle GetSlotPosition(InventorySlot slot)
 {
     switch (slot)
     {
         case InventorySlot.Head:
             return new Rectangle(48, 8, 34, 34);
         case InventorySlot.Necklace:
             return new Rectangle(8, 30, 34, 34);
         case InventorySlot.Backpack:
             return new Rectangle(88, 30, 34, 34);
         case InventorySlot.Armor:
             return new Rectangle(48, 50, 34, 34);
         case InventorySlot.Right:
             return new Rectangle(88, 70, 34, 34);
         case InventorySlot.Left:
             return new Rectangle(8, 70, 34, 34);
         case InventorySlot.Legs:
             return new Rectangle(48, 90, 34, 34);
         case InventorySlot.Feet:
             return new Rectangle(48, 130, 34, 34);
         case InventorySlot.Ring:
             return new Rectangle(8, 110, 34, 34);
         case InventorySlot.Ammo:
             return new Rectangle(88, 110, 34, 34);
     }
     return new Rectangle();
 }
开发者ID:hjnilsson,项目名称:sharptibiaclient,代码行数:27,代码来源:InventoryPanel.cs


示例2: UseShortcutSlotItem

    /// <summary>
    /// Utilise le consommable ou équipe l'arme du slot de raccourci envoyé en paramètres
    /// </summary>
    /// <param name="slot"></param>
    public void UseShortcutSlotItem(InventorySlot slot)
    {
        if (slot.IsEmpty)
            return;

        if (slot.Item.Type.Equals(ItemType.weapon))             // S'il s'agit d'une arme, on l'équipe
        {
            if (Inventory.leftHand.IsEmpty)
                Inventory.MoveOrMergeItem(slot, Inventory.leftHand, false);
            else
                Inventory.ExchangeItems(slot, Inventory.leftHand);

            LoadPlayingShortcutsSlots();
            return;
        }

        if (isBoostActive || !slot.Item.Type.Equals(ItemType.consumable))
            return;

        Inventory.UseConsumable(slot.Item, ref boostTimer, false);
        isBoostActive = true;

        boostItem = slot.Item;      // conservation pour enlever les bonus à la fin du temps de boost
        slot.Amount--;
        if (slot.Amount <= 0)       // On en enlève un en quantité, et supprime s'il s'agissait du dernier
        {
            slot.IsEmpty = true;
            slot.Item = new Item();
        }

        LoadPlayingShortcutsSlots();
    }
开发者ID:CalvoR,项目名称:2016_3A_Unity_Calvo_GodVSMan,代码行数:36,代码来源:gvmUI_PlayingShortcuts.cs


示例3: CreateNewSplittedResource

    ResourceItem CreateNewSplittedResource(InventorySlot slotScript, int times = -1)
    {
        int id = this._splitSlot._inventoryRef._itemInfoList[this._splitSlot._slotNum - 1]._itemInfo._uniqueItemID;
        ResourceItem resource = slotScript._inventoryRef._itemContainerObject.GetComponent<ItemContainer>().GetItem(id).GetComponent<ResourceItem>();
        int firstPopID = resource.PopStack();
        int splitCount = 0;
        if (times == -1)
        {
            splitCount = this._splitCount - 1;
        }
        else
        {
            splitCount = times - 1;
        }
        GameObject splitResource = this._splitSlot._inventoryRef._itemContainerObject.GetComponent<ItemContainer>().GetItem(firstPopID);
        ResourceItem splitResourceScript = splitResource.GetComponent<ResourceItem>();
        splitResourceScript.MaintainStack();

        for (int i = 0; i < splitCount; i++)
        {
            int idToAdd = this._splitSlot._inventoryRef._itemContainerObject.GetComponent<ItemContainer>().GetItem(resource.PopStack()).GetComponent<ResourceItem>()._uniqueItemID;
            splitResourceScript.AddToStack(idToAdd);
        }
        return splitResourceScript;
    }
开发者ID:TenorioDan,项目名称:TenorioTieuGame,代码行数:25,代码来源:ResourceSplit.cs


示例4: DropInventoryItem

 public static PacketWriter DropInventoryItem(InventorySlot slot, byte amount)
 {
     var pw = GetWriter(ClientPacketID.DropInventoryItem);
     pw.Write(slot);
     pw.Write(amount);
     return pw;
 }
开发者ID:Furt,项目名称:netgore,代码行数:7,代码来源:ClientPacket.cs


示例5: HUDInventory

        public HUDInventory()
        {
            InventorySlot.Width = InventorySlot.Size / Engine.Singleton.Camera.AspectRatio;
            Slots = new InventorySlot[SlotsCount];
            for (int i = 0; i < SlotsCount; i++)
                Slots[i] = new InventorySlot(SlotsSpacing, SlotsSpacing + i * (InventorySlot.Size + SlotsSpacing));

            SelectQuad = Engine.Singleton.Labeler.NewSimpleQuad("HighlightMaterial", SlotsSpacing, SlotsSpacing, InventorySlot.Width, InventorySlot.Size, new ColourValue(1, 1, 1), 4);

            DescriptionBg = Engine.Singleton.Labeler.NewSimpleQuad("QuadMaterial", 0.2f, 0.5f, 0.6f, 0.45f, ColourValue.White, 1);
            SelectedPicture = Engine.Singleton.Labeler.NewSimpleQuad("QuadMaterial",
                0.21f,
                0.58f,
                0.3f / Engine.Singleton.Camera.AspectRatio,
                0.3f, ColourValue.White, 2);
            DescriptionLabel = Engine.Singleton.Labeler.NewTextLabel("Primitive", 0.03f, new ColourValue(0.7f, 0.4f, 0), new ColourValue(1, 1.0f, 0.6f), 2);
            DescriptionLabel.SetPosition(0.45f, 0.51f);

            GoldBg = Engine.Singleton.Labeler.NewSimpleQuad("QuadMaterial", 0.7f, 0.1f, 0.2f, 0.1f, new ColourValue(1, 1, 1), 1);
            GoldLabel = Engine.Singleton.Labeler.NewTextLabel("Primitive", 0.05f, new ColourValue(0.7f, 0.4f, 0), new ColourValue(1, 1.0f, 0.6f), 2);
            GoldLabel.SetPosition(0.71f, 0.13f);

            InventoryBg = Engine.Singleton.Labeler.NewSimpleQuad("InventoryBgMaterial", 0.01f, 0.01f, 0.98f, 0.98f, new ColourValue(1, 1, 1), 0);
            CharacterPicture = Engine.Singleton.Labeler.NewSimpleQuad("Default", 0.4f, 0.1f, 0.2f / Engine.Singleton.Camera.AspectRatio, 0.2f, new ColourValue(1, 1, 1), 1);

            IsVisible = false;
        }
开发者ID:janPierdolnikParda,项目名称:RPG,代码行数:27,代码来源:HUDInventory.cs


示例6: RemoveItem

 public void RemoveItem(InventorySlot iS)
 {
     if (iS != null)
     {
         iS.UnHighlight();
         iS.m_currentHeldItem = null;
     }
 }
开发者ID:Dunnings,项目名称:ProceduralJam,代码行数:8,代码来源:InventoryManager.cs


示例7: OnBeginDrag

	public void OnBeginDrag (PointerEventData eventData)
	{
		homeSlot = GetComponentInParent<InventorySlot> ();
		transform.SetParent (GetComponentInParent<Canvas> ().transform);
		GameManager.InventoryManager.Select (gameObject);
		GameManager.TakeTag (HasTag);
		GameManager.GiveTag (HoldTag);
		GetComponent<CanvasGroup> ().blocksRaycasts = false;
	}
开发者ID:imann24,项目名称:cs327-bestmobilegameever,代码行数:9,代码来源:InventoryItem.cs


示例8: PlaceItemInSlot

 public void PlaceItemInSlot(InventoryItem iI, InventorySlot iS)
 {
     iI.transform.position = iS.transform.position;
     iI.InventorySlot = iS;
     iS.m_currentHeldItem = iI;
     if (QuestManager.Instance.IsThisItemRequired(iI.gameObject))
     {
         iS.Highlight();
         QuestManager.Instance.PickedUpObject();
     }
 }
开发者ID:Dunnings,项目名称:ProceduralJam,代码行数:11,代码来源:InventoryManager.cs


示例9: Update

        /// <summary>
        /// Updates the client with the changes that have been made to the UserInventory.
        /// </summary>
        public void Update()
        {
            // Don't actually grab the PacketWriter from the pool until we know we will need it
            PacketWriter pw = null;

            try
            {
                // Loop through all slots
                for (var slot = 0; slot < GameData.MaxInventorySize; slot++)
                {
                    // Skip unchanged slots
                    if (!_slotChanged[slot])
                        continue;

                    // Get the item in the slot
                    var invSlot = new InventorySlot(slot);
                    var item = UserInventory[invSlot];

                    // Get the values to send, which depends on if the slot is empty (item == null) or not
                    GrhIndex sendItemGraphic;
                    byte sendItemAmount;

                    if (item == null)
                    {
                        sendItemGraphic = GrhIndex.Invalid;
                        sendItemAmount = 0;
                    }
                    else
                    {
                        sendItemGraphic = item.GraphicIndex;
                        sendItemAmount = item.Amount;
                    }

                    // Grab the PacketWriter if we have not already, or clear it if we have
                    if (pw == null)
                        pw = ServerPacket.GetWriter();
                    else
                        pw.Reset();

                    // Pack the data and send it
                    ServerPacket.SetInventorySlot(pw, invSlot, sendItemGraphic, sendItemAmount);
                    OwnerUser.Send(pw, ServerMessageType.GUIItems);
                }
            }
            finally
            {
                // If we grabbed a PacketWriter, make sure we dispose of it!
                if (pw != null)
                    pw.Dispose();
            }

            // Changes complete
            _slotChanged.SetAll(false);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:57,代码来源:UserInventoryUpdater.cs


示例10: Read

        public override void Read(StreamHandler reader)
        {
            ContainerSlot = (InventorySlot)reader.ReadByte();
            Slot = (InventorySlot)reader.ReadByte();
            CastId = reader.ReadByte();
            SpellId = reader.ReadUInt32();
            ItemGuid = reader.ReadGuid();
            GlyphSlot = reader.ReadUInt32();
            UnkFlags = reader.ReadByte();

            TargetData.Read(reader);
        }
开发者ID:CarlosX,项目名称:Kamilla.Wow,代码行数:12,代码来源:UseItem.cs


示例11: InventoryChangeInfo

        public InventoryChangeInfo(ItemEntity item, ItemValueTracker oldValues, InventorySlot slot)
        {
            _slot = slot;
            _item = item;

            if (oldValues == null || oldValues.IsNull)
                _oldValues = null;
            else
                _oldValues = oldValues;

            Debug.Assert(_item != null || _oldValues != null,
                "item and oldValues can not both be null. " + "This would imply that the item changed from null to null.");
        }
开发者ID:wtfcolt,项目名称:game,代码行数:13,代码来源:InventoryChangeInfo.cs


示例12: Resize

    public void Resize( int size, InventorySlot c )
    {
        int cur = m_Slots.Count;
        if( size < cur )
            m_Slots.RemoveRange( size, cur - size );
        else if( size > cur )
        {
            if( size > m_Slots.Capacity )//this bit is purely an optimisation, to avoid multiple automatic capacity changes.
                m_Slots.Capacity = size;

            m_Slots.AddRange( Enumerable.Repeat( c, size - cur ) );
        }
    }
开发者ID:LogicalDragonGames,项目名称:Star_Bloom,代码行数:13,代码来源:Inventory.cs


示例13: ActivateSplit

 public void ActivateSplit(GameObject splitObj, Sprite sprite)
 {
     if (this._splitItem == null)
     {
         this._splitItem = splitObj;
         this._splitSlot = splitObj.transform.parent.GetComponent<InventorySlot>();
         this._splitItemSprite = sprite;
         this.transform.GetChild(0).GetComponent<Image>().sprite = this._splitItemSprite;
         this._splitSlotNum = this._splitItem.transform.parent.GetComponent<InventorySlot>()._slotNum;
         this.gameObject.SetActive(true);
     }
     this._splitCount++;
     this.transform.GetChild(0).GetChild(0).GetComponent<Text>().text = this._splitCount.ToString();
 }
开发者ID:TenorioDan,项目名称:TenorioTieuGame,代码行数:14,代码来源:ResourceSplit.cs


示例14: HandleDrop

    public void HandleDrop(InventorySlot slot)
    {
        if (Inventory == null)
        {
            Debug.LogError("AlchemyCircleUI has no Inventory reference");
            return;
        }

        if (Inventory.SelectedItem != null &&
            !HasItem(Inventory.SelectedItem.ID))
        {
            slot.Item = Inventory.SelectedItem;
            Inventory.SelectedItem = null;
        }
    }
开发者ID:JakeClark1129,项目名称:GlobalGameJamVancouver,代码行数:15,代码来源:AlchemyCircleUI.cs


示例15: MoveTo

	/// <summary>
	/// Moves the item to the specified slot. If that slot is full, tries to move to an unoccupied slot. If there aren't any, does nothing.
	/// </summary>
	/// <param name="slot">Slot.</param>
	public void MoveTo(InventorySlot slot){
		if (!slot.Contents) {
			homeSlot = slot;
			transform.SetParent (slot.transform);
			transform.position = slot.transform.position;
			GetComponent<CanvasGroup> ().blocksRaycasts = true;
			GameManager.GiveTag (HasTag);
			GameManager.InventoryManager.Deselect ();
		} else if (GameManager.InventoryManager.FirstEmptySlot) {
			MoveTo (GameManager.InventoryManager.FirstEmptySlot);
		} else {
			#if (DEBUG)
			Debug.Log("Cannot put " + gameObject.name + " into inventory. There are no empty slots.");
			#endif
		}
	}
开发者ID:imann24,项目名称:cs327-bestmobilegameever,代码行数:20,代码来源:InventoryItem.cs


示例16: Start

    public override void Start() {
        base.Start();
        new ValueTracker<InventorySlot>(v => inventorySlot = v, () => inventorySlot);
        new ValueTracker<bool>(v => {
            ghostForm = v;
            SetSemitransparent(ghostForm);
            if (thrower != null) {
                Extensions.IgnoreCollision(thrower, this, v);
            }
        }, () => ghostForm);
        new ValueTracker<Unit>(v => thrower = v, () => thrower);

        bool ghost = GetComponent<NotCollidePlayer>() != null;
        if (ghost) {
            GhostFor(FindObjectOfType<Unit>());
        } else {
            SetSemitransparent(false);
        }
    }
开发者ID:craus,项目名称:UnityTest,代码行数:19,代码来源:Item.cs


示例17:

        /// <summary>
        /// Gets an inventory item.
        /// </summary>
        /// <param name="slot">Index of the inventory item slot.</param>
        /// <returns>Item in the specified inventory slot, or null if the slot is empty or invalid</returns>
        public ItemEntity this[InventorySlot slot]
        {
            get
            {
                // Check for a valid index
                if (!slot.IsLegalValue())
                {
                    const string errmsg = "Tried to get invalid inventory slot `{0}`.";
                    if (log.IsErrorEnabled)
                        log.ErrorFormat(errmsg, slot);
                    Debug.Fail(string.Format(errmsg, slot));
                    return null;
                }

                // If the item has an amount of 0, return null
                var item = _buffer[(int)slot];
                if (item != null && item.Amount == 0)
                    return null;

                // Item is either null or valid
                return _buffer[(int)slot];
            }

            private set
            {
                // Check for a valid index
                if (!slot.IsLegalValue())
                {
                    const string errmsg = "Tried to set invalid inventory slot `{0}`.";
                    if (log.IsErrorEnabled)
                        log.ErrorFormat(errmsg, slot);
                    Debug.Fail(string.Format(errmsg, slot));
                    return;
                }

                _buffer[(int)slot] = value;
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:43,代码来源:Inventory.cs


示例18: Drop

        /// <summary>
        /// Drops an item from the inventory onto the ground. If the user has just one item in the given <paramref name="slot"/>,
        /// then it is dropped. If they have multiple items in the <paramref name="slot"/>, then they are presented with an
        /// <see cref="InputBox"/> so they can enter in how much to drop.
        /// </summary>
        /// <param name="slot">The slot of the item to drop.</param>
        /// <param name="guiManager">The <see cref="IGUIManager"/> to use to create the <see cref="InputBox"/> if it is needed.</param>
        public void Drop(InventorySlot slot, IGUIManager guiManager)
        {
            // Check for a valid item
            var item = this[slot];
            if (item == null)
                return;

            // Check the amount
            if (item.Amount > 1)
            {
                // Create an InputBox to ask how much to drop
                const string text = "Drop item";
                const string message = "How much of the item do you wish to drop?\n(Enter a value from 1 to {0})";

                var inBox = InputBox.CreateNumericInputBox(guiManager, text, string.Format(message, item.Amount));
                inBox.Tag = slot;
                inBox.OptionSelected += DropInputBox_OptionSelected;
            }
            else
            {
                // Auto-drop if there is just one of the item
                Drop(slot, 1);
            }
        }
开发者ID:Vizzini,项目名称:netgore,代码行数:31,代码来源:Inventory.cs


示例19: InventoryItemPB

            /// <summary>
            /// Initializes a new instance of the <see cref="InventoryItemPB"/> class.
            /// </summary>
            /// <param name="parent">The parent.</param>
            /// <param name="pos">The relative position of the control.</param>
            /// <param name="slot">The <see cref="InventorySlot"/>.</param>
            /// <exception cref="ArgumentNullException"><paramref name="parent" /> is <c>null</c>.</exception>
            public InventoryItemPB(InventoryForm parent, Vector2 pos, InventorySlot slot) : base(parent, pos, _itemSize)
            {
                if (parent == null)
                    throw new ArgumentNullException("parent");

                _slot = slot;
                Tooltip = _tooltipHandler;
            }
开发者ID:mateuscezar,项目名称:netgore,代码行数:15,代码来源:InventoryForm.cs


示例20: InvokeRequestUseItem

 /// <summary>
 /// Invokes the <see cref="RequestUseItem"/> event.
 /// </summary>
 /// <param name="slot">The <see cref="InventorySlot"/> to use.</param>
 public void InvokeRequestUseItem(InventorySlot slot)
 {
     if (RequestUseItem != null)
         RequestUseItem.Raise(this, EventArgsHelper.Create(slot));
 }
开发者ID:mateuscezar,项目名称:netgore,代码行数:9,代码来源:InventoryForm.cs



注:本文中的InventorySlot类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# InventoryType类代码示例发布时间:2022-05-24
下一篇:
C# InventoryManager类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap