public void Awake() { _items = new InventoryEntry[maxSize]; onItemChangedCallback += checkFull; onSizeChangedCallback += checkFull; checkFull(); }
internal virtual void ReplaceWithFake(int type) { if (real && item.stack > 0) { // Main.player[Main.myPlayer].QuickSpawnItem(RecipeBrowserWindow.lookupItemSlot.item.type, RecipeBrowserWindow.lookupItemSlot.item.stack); Player player = Main.player[Main.myPlayer]; item.position = player.Center; Item item2 = player.GetItem(player.whoAmI, item, false, true); if (item2.stack > 0) { int num = Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, item2.type, item2.stack, false, (int)item.prefix, true, false); Main.item[num].newAndShiny = false; if (Main.netMode == 1) { NetMessage.SendData(21, -1, -1, null, num, 1f, 0f, 0f, 0, 0, 0); } } item = new Item(); } item.SetDefaults(type); real = type == 0; backgroundTexture = real ? defaultBackgroundTexture : backgroundTextureFake; OnItemChanged?.Invoke(); }
public override void Click(UIMouseEvent evt) { Player player = Main.LocalPlayer; if (player.itemAnimation == 0 && player.itemTime == 0) { if (real) { Item item = Main.mouseItem.Clone(); Main.mouseItem = this.item.Clone(); if (Main.mouseItem.type > 0) { Main.playerInventory = true; } this.item = item.Clone(); } else { item = Main.mouseItem.Clone(); Main.mouseItem.SetDefaults(0); real = true; } if (item.type == 0) { real = true; } OnItemChanged?.Invoke(); } backgroundTexture = real ? defaultBackgroundTexture : backgroundTextureFake; }
public int space = 10; // Amount of item spaces //void Start() //{ // if (inventoryType == InventoryType.NULL) // Debug.LogError("inventory type of " + name + " is null"); // else if (inventoryType == InventoryType.Player) // { // UI = UIController.instance.inventoryUI.GetComponent<UIforInventory>(); // SetInventoryToUI(); // } // else if (inventoryType == InventoryType.Trader) // { // UI = UIController.instance.tradeUI.GetComponentInChildren<UIforInventory>(); // if (UI.inventory == null) // SetInventoryToUI(); // } //} //public void SetInventoryToUI() //{ // if (inventoryType == InventoryType.Player) // { // UIController.instance.playerInventory = this; // } // else if (inventoryType == InventoryType.Trader) // { // UIController.instance.traderInventory = this; // } // UI.inventory = this; // onItemChangedCallback += UI.UpdateUI; // UI.UpdateUI(); //} public void SetInventoryToUI() { if (inventoryType == InventoryType.NULL) { Debug.LogError("inventory type of " + name + " is null"); } else if (inventoryType == InventoryType.Player) { UI = UIController.instance.inventoryUI.GetComponent <UIforInventory>(); UIController.instance.playerInventory = this; } else if (inventoryType == InventoryType.Trader) { UI = UIController.instance.tradeUI.GetComponentInChildren <UIforInventory>(); UIController.instance.traderInventory = this; } else if (inventoryType == InventoryType.Loot) { UI = UIController.instance.lootUI.GetComponentInChildren <UIforInventory>(); UIController.instance.lootInventory = this; } UI.inventory = this; onItemChangedCallback += UI.UpdateUI; UI.UpdateUI(); }
internal virtual void ReplaceWithFake(int type) { if (real && item.stack > 0) { // Main.player[Main.myPlayer].QuickSpawnItem(RecipeBrowserWindow.lookupItemSlot.item.type, RecipeBrowserWindow.lookupItemSlot.item.stack); Player player = Main.player[Main.myPlayer]; item.position = player.Center; Item item2 = player.GetItem(player.whoAmI, item, false, true); if (item2.stack > 0) { int num = Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, item2.type, item2.stack, false, (int)item.prefix, true, false); Main.item[num].newAndShiny = false; if (Main.netMode == 1) { NetMessage.SendData(21, -1, -1, null, num, 1f, 0f, 0f, 0, 0, 0); } else { // TODO: Detect PreSaveAndQuit only. RecipeBrowser.instance.Logger.Warn("RecipeBrowser: You left an item in the recipe browser with a full inventory and have lost the item: " + item2.Name); } } item = new Item(); } item.SetDefaults(type); real = type == 0; backgroundTexture = real ? defaultBackgroundTexture : backgroundTextureFake; OnItemChanged?.Invoke(); }
void Start() { space_count = 0; slots = new Item[space]; items_count = new int[space]; //Unequips items when items changed onItemChangedCallback += RefreshEquippedItem; }
public void Move(int sourceIndex, int destIndex) { var destItem = _items[destIndex]; _items[destIndex] = _items[sourceIndex]; _items[sourceIndex] = destItem; OnItemChanged?.Invoke(destIndex); OnItemChanged?.Invoke(sourceIndex); }
public void Move(int sourceSlot, int destinationSlot) { var destinationItem = _items[destinationSlot]; _items[destinationSlot] = _items[sourceSlot]; _items[sourceSlot] = destinationItem; OnItemChanged?.Invoke(destinationSlot); OnItemChanged?.Invoke(sourceSlot); }
public Item UseItem(int index) { if (index < slots.Count) { Item item = slots[index]; slots.Remove(slots[index]); OnItemChanged?.Invoke(this, EventArgs.Empty); return(item); } return(Item.Null); }
public void AddItem(Item item) { if (slots.Count < Capacity) { slots.Add(item); OnItemChanged?.Invoke(this, EventArgs.Empty); } else { OnInventoryFull?.Invoke(this, EventArgs.Empty); } }
public void Init() { equipmentManager = GameController.instance.playerManager.equipmentManager; equipmentManager.onItemUnequip += AddAfterUnequip; equipmentManager.onItemEquip += Remove; onItemUse = null; onLoot = null; onItemsChangedCallback = null; onLootEnd = null; defaultItemGameObject = Resources.Load <GameObject>("Equipments/EmptyItem"); }
public void SellEquipmentItem(Item item) { goldAmount += item.GetPrice(); //reset index firstEmptyItemIndex = Math.Min(selectedItemIndex, firstEmptyItemIndex); //destroy itemList[selectedItemIndex] = null; OnItemChanged?.Invoke(this, new OnItemChangedArgs { index = selectedItemIndex }); selectedItemIndex = -1; }
public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath) { var follower = users[indexPath.Row]; var cell = (FollowerCollectionViewCell)collectionView.DequeueReusableCell(FollowerCollectionViewCell.Key, indexPath); cell.UpdateCell(userId, follower.Id, follower.ImagePath, follower.Username, follower.UserTag); cell.DataContext.OnFollowAction = () => { OnItemChanged?.Invoke(this, EventArgs.Empty); }; return(cell); }
public void SetItem(Item item) { if (_ghostItemGameObject != null) { Destroy(_ghostItemGameObject); } _currentItem = item; if (item != null) { CreateGhost(item); } OnItemChanged?.Invoke(_currentItem); }
public void SetItem(Item item) { //Unsubrscribe from old item if (currentItem != null) { currentItem.OnItemChanged -= CurrentItem_OnItemChanged; } currentItem = item; //Subscribe to new item if (currentItem != null) { currentItem.OnItemChanged += CurrentItem_OnItemChanged; } OnItemChanged?.Invoke(item); }
public void SetItem(GameObject item) { if (_ghostRenderer != null) { Destroy(_ghostItem); } _currentItem = item; _ghostItem = Instantiate(item); _ghostRenderer = _ghostItem.GetComponentInChildren <Renderer>(); _ghostRenderer.material = _ghostMaterial; _ghostRenderer.enabled = false; OnItemChanged?.Invoke(item.name); }
/// <summary> /// Returns the overflowing amount. /// </summary> public int ModifyAmount(int amount) { if (TryGetInformation(out ItemSO info) && info.IsStackable) { this.amount += amount; int overflow = this.amount - info.MaxStack; if (overflow < 0) { overflow = 0; } this.amount -= overflow; OnItemChanged?.Invoke(this); return(overflow); } Debug.Log($"{itemName} is missing an SO"); return(amount); }
// Use this for initialization void Start() { inventory = Inventory.instance; onItemChangedCallback += UpdateUI; boxCollider = GetComponent <BoxCollider>(); boxCollider.size = initialBoxSize; //Debug.Log(boxCollider.size); 000이 뜨는데 왜이러는건지? bagCanvas.SetActive(false); isBagCalled = false; slots = itemsParents.GetComponentsInChildren <InventorySlot>(); audioSource = GetComponent <AudioSource>(); currentCanvasLocalPosition = transform.localPosition; currentCanvasLocalRotation = transform.localRotation; }
public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath) { var post = posts[indexPath.Row]; var postAuthor = userReads.Get(post.UserId); var cell = (FeedCollectionViewCell)collectionView.DequeueReusableCell(FeedCollectionViewCell.Key, indexPath); cell.UpdateCell(post.Id, userId, postAuthor.Id, postAuthor.ImagePath, postAuthor.UserTag, post.ImagePath, post.Description, post.Likes, post.UsesURL); cell.DataContext.DeleteItemAction = () => { OnItemChanged?.Invoke(this, EventArgs.Empty); }; cell.DataContext.LikeAction = () => { OnItemChanged?.Invoke(this, EventArgs.Empty); }; return(cell); }
protected void OnSelectChanged(UIChangeEventArgs e) { //nao sei pq, mas nao funciona se eu deixo o value=@eItem Console.WriteLine("alterou combo item"); SelectedValue = ConverterHelper.TryChangeType <ValueType>(e.Value, out var value) ? value : default; SelectedValueChanged?.Invoke(SelectedValue); if (IsFirstItemNull && e.Value == null) { OnItemChanged?.Invoke(null); return; } if (Items != null) { foreach (object obj in Items) { var valor = ReflectionHelper.GetPropertyValue(obj, ValueField); if (!valor.Equals(e.Value)) { continue; } OnItemChanged?.Invoke(obj); break; } } else if (ComboItems != null) { foreach (EComboBoxItem item in ComboItems) { if (item.Value != e.Value as string) { continue; } OnItemChanged?.Invoke(item); break; } } }
public void SellStackableItem(Item item, int amount) { IStackableItem stackableItem = item as IStackableItem; int originalAmount = stackableItem.GetAmount(); if (originalAmount == amount) { goldAmount += stackableItem.GetTotalPrice(); //update index firstEmptyItemIndex = Math.Min(selectedItemIndex, firstEmptyItemIndex); //update link if (null != stackableItem.GetPrevSameItem()) { IStackableItem prevStameItem = stackableItem.GetPrevSameItem(); prevStameItem.SetNextSameItem(stackableItem.GetNextSameItem()); } if (null != stackableItem.GetNextSameItem()) { IStackableItem nextSameItem = stackableItem.GetNextSameItem(); nextSameItem.SetPrevSameItem(stackableItem.GetPrevSameItem()); } //destory itemList[selectedItemIndex] = null; OnItemChanged?.Invoke(this, new OnItemChangedArgs { index = selectedItemIndex }); selectedItemIndex = -1; } else { goldAmount += stackableItem.GetTotalPrice(); stackableItem.SetAmount(originalAmount - amount); } }
/// <summary> /// Assigns an item to the slot. /// </summary> public void SetItem(InventoryItem item) { Item = item; OnItemChanged?.Invoke(item); }
public void SetItemNumber(GItem item, float number) { item.CurrentAmount = (int)number; OnItemChanged.Invoke(item); }
public void SetArmorStats(Quipment quipment) { quipmentArmor = quipment.defenceMof; totalArmor += quipmentArmor; OnItemChanged?.Invoke(this, EventArgs.Empty); }
public void SetWeaponStats(Weapon weapon) { weapomAttack = weapon.damageMod; totalDamage += weapomAttack; OnItemChanged?.Invoke(this, EventArgs.Empty); }
public void InvokeItemChanged() => OnItemChanged?.Invoke();
private void NetListOnOnItemChanged(UIComponent component, NetTypeItemEventArgs value) { OnItemChanged?.Invoke(this, value); }
private void CurrentItem_OnItemChanged(Item item) { OnItemChanged?.Invoke(item); }
private void ItemChanged(SyncList <Item> .Operation op, int itemIndex) { OnItemChanged?.Invoke(op, itemIndex); }
protected virtual void InvokeOnItemCellChanged(PackageItemChangedInfo changedInfo) { OnItemChanged?.Invoke(changedInfo); }