private void RegistInventory() { for (int i = 0; i < mSlotList.Length; i++) { RectTransform tr = mSlotList[i].GetComponent <RectTransform>(); GridLayoutGroup grid = mSlotList[i].GetComponent <GridLayoutGroup>(); Vector2 cellSize = grid.cellSize; Vector2 spacing = grid.spacing; InvenSlot[] slots = mSlotList[i].GetComponentsInChildren <InvenSlot>(); int tX = (int)Mathf.Round((tr.sizeDelta.x / (cellSize.x + spacing.x))); int tY = (int)Mathf.Round((tr.sizeDelta.y / (cellSize.y + spacing.y))); for (int y = 0; y < tY; y++) { List <InvenSlot> lTemp = new List <InvenSlot>(); for (int x = 0; x < tX; x++) { InvenSlot temp = slots[(y * tX) + x]; temp.Init(); lTemp.Add(temp); } Slots.Add(lTemp); } } }
private void ChangeSlot(InvenSlot _invenSlot) { if (!_invenSlot.Item) { SetAlpha(0f); return; } Item = _invenSlot.Item; mItemImg.sprite = Item.Sprite; Count = _invenSlot.Count; MaxCount = Item.Kind == Items.ITEM_KIND.RESOURCE ? 99 : 1; SetAlpha(1f); }
public override List <Items> GetItems() { Items mCraftItem = GetComponentInParent <CraftLine>().CurItem; if (!mCraftItem) { return(null); } List <Items> tList = new List <Items>(); Items.ItemRecipe[] recipe = mCraftItem.Recipe; for (int i = 0; i < recipe.Length; i++) { List <Items> temp = new List <Items>(); if (recipe[i].Recipe.Length > slotId) { Items.ITEM_DETAILTYPE type = recipe[i].Recipe[slotId]; List <Items> ttemp = Inventory.GetInvenItemList(type); if (ttemp != null) { temp.AddRange(ttemp); } } if (recipe[i].SpecialRecipe.Length > slotId) { InvenSlot tSlot = Inventory.GetInvenSlot(recipe[i].SpecialRecipe[slotId]); if (tSlot) { temp.Add(tSlot.Item); } } if (temp.Count != 0) { tList.AddRange(temp); } } if (tList.Count == 0) { return(null); } return(tList); }
private void SwapSlot() { Items temp = Item; int tCount = Count; InvenSlot _dragging = DragSlot.instance.mDragSlot; ChangeSlot(_dragging); if (!temp) { _dragging.ClearSlot(); } else { _dragging.ChangeSlot(temp, tCount); } }
public void OnPointerDown(PointerEventData eventData) { InvenSlot slot = Inventory.GetInvenSlot(mWantItem); if (!slot) { mGaugeBar.fillAmount -= 0.2f; return; } IncreaseHandler(slot.Item); if (guestDoHandler != null) { guestDoHandler(); } StartCoroutine(PlayEndAudioCoroutine(mBuyClip, 0.5f)); }
static public void StoreItem(Items _item) { for (int y = 0; y < Slots.Count; y++) { for (int x = 0; x < Slots[y].Count; x++) { InvenSlot temp = Slots[y][x]; if (!temp.Item) { temp.AddItem(_item); return; } else if (temp.Item.ItemName == _item.ItemName && temp.MaxCount > temp.Count) { temp.AddItem(_item); return; } } } }
static public bool UseItem(Items _item) { for (int y = Slots.Count - 1; y >= 0; y--) { for (int x = Slots[y].Count - 1; x >= 0; x--) { InvenSlot temp = Slots[y][x]; if (!temp.Item) { continue; } if (temp.Item.ItemName == _item.ItemName) { temp.UseItem(); return(true); } } } return(false); }
public bool AddItemInSlot(ItemObject item) { int slotCount = AllSlot.Count; for (int i = 0; i < slotCount; i++) { InvenSlot slot = AllSlot[i].GetComponent <InvenSlot>(); if (slot.IsSlotEmpty()) { continue; } if (slot.ItemReturn().type == item.type && slot.ItemMax(item)) { slot.AddItem(item); Debug.Log("Add item success"); return(true); } } for (int i = 0; i < slotCount; i++) { InvenSlot slot = AllSlot[i].GetComponent <InvenSlot>(); if (!slot.IsSlotEmpty()) { continue; } slot.AddItem(item); Debug.Log("Add item success"); return(true); } Debug.Log("Add item fails"); return(false); }
static public InvenSlot GetInvenSlot(Items item) { InvenSlot slots = null; for (int y = Slots.Count - 1; y >= 0; y--) { for (int x = Slots[y].Count - 1; x >= 0; x--) { if (!Slots[y][x].Item) { continue; } if (Slots[y][x].Item.ItemName != item.ItemName) { continue; } slots = Slots[y][x]; break; } } return(slots); }
private void SetItem( sITEM sitem, int iSlot) { if( 0 > iSlot || m_ItemList.Length <= iSlot) { Debug.LogError( "Inventory::SetItem() [m_ItemList.Length <= iSlot] [ index : " + iSlot); return; } if( null == sitem) { Debug.LogError("Inventory::SetItem()[null == sitem ] "); } if ( 0 == sitem.nItemTableIdx) { if( null != m_ItemList[ iSlot ]) m_ItemList[ iSlot ].Clear(); } else { if( null == m_ItemList[ iSlot ]) { m_ItemList[ iSlot ] = new InvenSlot( new RealItem( sitem, iSlot)); } else { if( null == m_ItemList[ iSlot ]) { Debug.LogError("Inventory::SetItem()[null == m_ItemList[ iSlot ] ] slot: " + iSlot ); } m_ItemList[ iSlot ].SetItem( sitem, iSlot); } } #region -GameGuide_Item AsGameGuideManager.Instance.CheckUp( eGameGuideType.Item, sitem.nItemTableIdx); #endregion SetExpireItem( iSlot, GetRealItemInSlot( iSlot ) ); }
public void InnerClassTest() { InvenSlot NewInvenSlot = new InvenSlot(); NewInvenSlot.Select(this); }
public void InnerClassTest() { InvenSlot NewSlot = new InvenSlot(); }