public void onClickAskUI() { unShowAskUI(); if (bagUI1.IsOKAskUI) { GameItem item1 = bagUI0.getItem(); GameItem item2 = bagUI1.getItem(); short id = GameUserData.instance.getAlchemyItem(item1.ID, item2.ID); GameAlchemyUIBag.Item item = null; if (bagUI0.Selection > bagUI1.Selection) { item = bagUI0.removeItem(); bagUI1.removeItem(); } else { bagUI1.removeItem(); item = bagUI0.removeItem(); } if (item.type == GameAlchemyUIType.User) { GameUnitBase unit = GameUserData.instance.getUnitBase(item.userID); unit.addItem(id); } else { GameUserData.instance.addItem(id); } bagUI0.addItems(); bagUI1.addItems(); bagUI0.select(0); showAlchemy(false); } else { } }
public void onClickAskUI() { if (shopUI.Enabled) { shopUI.unShowAskUI(); if (shopUI.IsOKAskUI) { // buy GameItem item = shopUI.getItem(); if (item == null) { return; } switch (bagUI.Type) { case GameItemBagUI.GameItemBagUIType.User: { GameUnitBase unit = GameUserData.instance.getUnitBase(bagUI.UserID); unit.addItem(item.ID); GameUserData.instance.addGold(-item.Price); bagUI.setItems(unit.Items); bagUI.updateItems(); bagUI.enable(false); shopUI.updateItems(); shopUI.select(shopUI.Selection); updateText(); } break; case GameItemBagUI.GameItemBagUIType.Bag: { GameUserData.instance.addItem(item.ID); GameUserData.instance.addGold(-item.Price); bagUI.setItems(GameUserData.instance.ItemBag); bagUI.updateItems(); bagUI.enable(false); shopUI.updateItems(); shopUI.select(shopUI.Selection); updateText(); } break; } } } else { bagUI.unShowAskUI(); if (bagUI.IsOKAskUI) { // sell GameItem item = bagUI.getItem(); int itemSlot = bagUI.getItemSlot(); switch (bagUI.Type) { case GameItemBagUI.GameItemBagUIType.User: { GameUnitBase unit = GameUserData.instance.getUnitBase(bagUI.UserID); unit.removeItem(itemSlot); GameUserData.instance.addGold(item.Price / 2); bagUI.setItems(unit.Items); bagUI.updateItems(); bagUI.select(bagUI.Selection - 1); updateText(); } break; case GameItemBagUI.GameItemBagUIType.Bag: { GameUserData.instance.removeItem(itemSlot); GameUserData.instance.addGold(item.Price / 2); bagUI.setItems(GameUserData.instance.ItemBag); bagUI.updateItems(); bagUI.select(bagUI.Selection - 1); updateText(); } break; } } } if (GameEquipInfoUI.instance.IsShow) { GameEquipInfoUI.instance.unShowFade(); } }
public void onClickItemAskUI() { int selection = GameDefine.INVALID_ID; GameItemBagUI.GameItemBagUIType uiType = GameItemBagUI.GameItemBagUIType.Count; int itemSlot = GameDefine.INVALID_ID; if (bagUI0.Enabled) { if (bagUI0.IsEnabledItemAskUI) { selection = bagUI0.SelectionItemAskUI; uiType = bagUI0.Type; itemSlot = bagUI0.getItemSlot(); if (uiType == GameItemBagUI.GameItemBagUIType.User) { GameUnitBase unit0 = GameUserData.instance.getUnitBase(bagUI0.UserID); switch (selection) { case 0: { if (bagUI1.Type == GameItemBagUI.GameItemBagUIType.Bag) { short itemID = unit0.Items[itemSlot]; unit0.removeItem(itemSlot); GameUserData.instance.addItem(itemID); } else { GameUnitBase unit1 = GameUserData.instance.getUnitBase(bagUI1.UserID); short itemID = unit0.Items[itemSlot]; unit0.removeItem(itemSlot); unit1.addItem(itemID); } } break; case 1: { if (unit0.AccessorySlot == itemSlot) { unit0.Accessory = GameDefine.INVALID_ID; } else { short itemID = unit0.Items[itemSlot]; GameItem item = GameItemData.instance.getData(unit0.Items[itemSlot]); switch (item.ItemType) { case GameItemType.Weapon: unit0.Weapon = itemID; break; case GameItemType.Armor: unit0.Armor = itemID; break; case GameItemType.Accessory: unit0.Accessory = itemID; break; } } } break; case 2: { showAskUI(false); } break; } } else { switch (selection) { case 0: { GameUnitBase unit1 = GameUserData.instance.getUnitBase(bagUI1.UserID); short itemID = GameUserData.instance.ItemBag[itemSlot]; GameUserData.instance.removeItem(itemSlot); unit1.addItem(itemID); } break; case 2: { showAskUI(false); } break; } } if (bagUI0.Type == GameItemBagUI.GameItemBagUIType.User) { bagUI0.setItems(GameUserData.instance.getUnitBase(bagUI0.UserID).Items); } else { bagUI0.setItems(GameUserData.instance.ItemBag); } if (bagUI1.Type == GameItemBagUI.GameItemBagUIType.User) { bagUI1.setItems(GameUserData.instance.getUnitBase(bagUI1.UserID).Items); } else { bagUI1.setItems(GameUserData.instance.ItemBag); } bagUI0.unshowItemAskUI(); bagUI0.updateItems(); bagUI1.updateItems(); bagUI1.enable(false); bagUI0.select(bagUI0.Selection); } } else { if (bagUI1.IsEnabledItemAskUI) { selection = bagUI1.SelectionItemAskUI; uiType = bagUI1.Type; itemSlot = bagUI1.getItemSlot(); if (uiType == GameItemBagUI.GameItemBagUIType.User) { GameUnitBase unit1 = GameUserData.instance.getUnitBase(bagUI1.UserID); switch (selection) { case 0: { if (bagUI0.Type == GameItemBagUI.GameItemBagUIType.Bag) { short itemID = unit1.Items[itemSlot]; unit1.removeItem(itemSlot); GameUserData.instance.addItem(itemID); } else { GameUnitBase unit0 = GameUserData.instance.getUnitBase(bagUI0.UserID); short itemID = unit1.Items[itemSlot]; unit1.removeItem(itemSlot); unit0.addItem(itemID); } } break; case 1: { if (unit1.AccessorySlot == itemSlot) { unit1.Accessory = GameDefine.INVALID_ID; } else { short itemID = unit1.Items[itemSlot]; GameItem item = GameItemData.instance.getData(unit1.Items[itemSlot]); switch (item.ItemType) { case GameItemType.Weapon: unit1.Weapon = itemID; break; case GameItemType.Armor: unit1.Armor = itemID; break; case GameItemType.Accessory: unit1.Accessory = itemID; break; } } } break; case 2: { showAskUI(false); } break; } } else { switch (selection) { case 0: { GameUnitBase unit0 = GameUserData.instance.getUnitBase(bagUI0.UserID); short itemID = GameUserData.instance.ItemBag[itemSlot]; GameUserData.instance.removeItem(itemSlot); unit0.addItem(itemID); } break; case 2: { showAskUI(false); } break; } } if (bagUI0.Type == GameItemBagUI.GameItemBagUIType.User) { bagUI0.setItems(GameUserData.instance.getUnitBase(bagUI0.UserID).Items); } else { bagUI0.setItems(GameUserData.instance.ItemBag); } if (bagUI1.Type == GameItemBagUI.GameItemBagUIType.User) { bagUI1.setItems(GameUserData.instance.getUnitBase(bagUI1.UserID).Items); } else { bagUI1.setItems(GameUserData.instance.ItemBag); } bagUI1.unshowItemAskUI(); bagUI1.updateItems(); bagUI0.updateItems(); bagUI0.enable(false); bagUI1.select(bagUI1.Selection); } } if (GameEquipInfoUI.instance.IsShow) { GameEquipInfoUI.instance.unShowFade(); } }
public void giveItem(int slot, GameUnitBase unit) { unit.addItem(Items[slot]); removeItem(slot); }