void ChangeTool() { if (CurrentToolController != null) { Destroy(CurrentToolController.gameObject); CurrentToolController = null; } if (Toolbar.Instance.SelectedSlot.ReferencedItemStack != null) { ItemBase selectedItem = Toolbar.Instance.SelectedSlot.ReferencedItemStack.ContainedItem; if (selectedItem as ItemTool == null) { CurrentTool = null; } else { CurrentTool = ItemSystem.Instance.GetItemClone(selectedItem.ID) as ItemTool; TimeBeforeHold = CurrentTool.UseInterval / 4; } } else { CurrentTool = null; } if (CurrentTool != null) { CurrentToolController = Instantiate(CurrentTool.Controller.gameObject, this.transform).GetComponent <ToolControllerBase>(); } if (OnSelectedToolChanged != null) { OnSelectedToolChanged(); } }
public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry) { PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0)); if (player == null) { queue.HandleError(entry, "Invalid player!"); return; } ItemAssetTag item = ItemAssetTag.For(entry.GetArgument(queue, 1)); if (item == null) { queue.HandleError(entry, "Invalid item!"); return; } byte amount = 1; if (entry.Arguments.Count > 2) { amount = (byte)Utilities.StringToUInt(entry.GetArgument(queue, 2)); } if (ItemTool.tryForceGiveItem(player.Internal.player, item.Internal.id, amount)) { if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully gave a " + TagParser.Escape(item.Internal.name) + "!"); } } else { queue.HandleError(entry, "Failed to give item (is the inventory full?)!"); } }
//====================================== private void showNowFlyWingProperty() { if (m_CurWantEquipFlyWingId == GlobeVar.INVALID_ID) { m_PropertyNameNow.text = ""; m_PropertyVlueNow.text = ""; return; } Tab_FlyWing curEquipFlyWingTab = TableManager.GetFlyWingByID(m_CurWantEquipFlyWingId, 0); if (curEquipFlyWingTab == null) { return; } if (curEquipFlyWingTab.ABSORBID <= (int)COMBATATTE.INVALID || curEquipFlyWingTab.ABSORBID >= (int)COMBATATTE.COMBATATTE_MAXNUM) { return; } string propertyName = ItemTool.ConvertAttrToString((COMBATATTE)curEquipFlyWingTab.ABSORBID); m_PropertyNameNow.text = propertyName; m_PropertyVlueNow.text = string.Format("+{0}", curEquipFlyWingTab.ABSORBVLUE); }
/// <summary> /// 显示其它分页 /// </summary> private void ShowBackPack_Other() { // 过滤物品 GameItemContainer BackPack = GameManager.gameManager.PlayerDataPool.BackPack; List <GameItem> itemlist1 = ItemTool.ItemFilter(BackPack, (int)ItemClass.STRENGTHEN, 0, m_QianKunDaiView.activeInHierarchy); List <GameItem> itemlist2 = ItemTool.ItemFilter(BackPack, (int)ItemClass.PRIZE, 0, m_QianKunDaiView.activeInHierarchy); List <GameItem> itemlist3 = ItemTool.ItemFilter(BackPack, (int)ItemClass.MEDIC, 0, m_QianKunDaiView.activeInHierarchy); List <GameItem> itemlist4 = ItemTool.ItemFilter(BackPack, (int)ItemClass.MISSION, 0, m_QianKunDaiView.activeInHierarchy); List <GameItem> itemlist5 = ItemTool.ItemFilter(BackPack, (int)ItemClass.MOUNT, 0, m_QianKunDaiView.activeInHierarchy); List <GameItem> itemlist6 = ItemTool.ItemFilter(BackPack, (int)ItemClass.FASHION, 0, m_QianKunDaiView.activeInHierarchy); itemlist1.AddRange(itemlist2); itemlist1.AddRange(itemlist3); itemlist1.AddRange(itemlist4); itemlist1.AddRange(itemlist5); itemlist1.AddRange(itemlist6); /*m_HaveItemMax = itemlist1.Count; * * int leftCount = m_HaveItemMax - m_ShowItemMin; * if (leftCount < MAX_SHOW_ITEM) * { * CurItemList = itemlist1.GetRange(m_ShowItemMin, leftCount); * } * else * { * CurItemList = itemlist1.GetRange(m_ShowItemMin, MAX_SHOW_ITEM); * }*/ CurItemList = itemlist1; // 显示物品 ShowBackPackItemList(itemlist1); }
private void OnConsumePerformed(Player instigatingPlayer, ItemConsumeableAsset consumeableAsset) { foreach (var leftover in Configuration.Instance.Leftovers.Where(x => x.Id == consumeableAsset.id)) { ItemTool.tryForceGiveItem(instigatingPlayer, leftover.LeftoverId, 1); } }
void GemSlotOnClick(int nItemID, ItemSlotLogic.SLOT_TYPE eItemType, string strSlotName) { Tab_GemAttr tabGemAttr = TableManager.GetGemAttrByID(nItemID, 0); if (tabGemAttr == null) { m_GemClickSlot = strSlotName; OpenGemView(); } else { if (m_GemTips.activeSelf && m_GemClickSlot == strSlotName) { m_GemTips.SetActive(false); m_GemNameLabel.text = ""; m_GemAttrLabel.text = ""; m_GemClickSlot = ""; } else { m_GemTips.SetActive(true); m_GemNameLabel.text = tabGemAttr.Name; m_GemAttrLabel.text = ItemTool.GetGemAttr(nItemID); m_GemClickSlot = strSlotName; } } }
void UpdateFellowInfo_Star(Fellow fellow) { if (fellow.GetFellowType() == (int)FELLOWTYPE.BABY) { m_StarAttr.SetActive(false); m_BabyFellowNotice.SetActive(true); //MoveButtonFun(true); } else { m_StarAttr.SetActive(true); m_BabyFellowNotice.SetActive(false); //MoveButtonFun(false); int nStarCount = fellow.StarLevel > 0 ? ((fellow.StarLevel - 1) % 12) + 1 : 0; for (int i = 0; i < m_StarPic.Length; i++) { if (i < nStarCount) { //m_StarPic[i].spriteName = FellowTool.GetChatFellowStarQualityPic(fellow.StarLevel); //m_StarPic[i].MakePixelPerfect(); // m_StarPic[i].gameObject.SetActive(true); m_StarPic[i].color = ItemTool.GetStarColorRGB(fellow.StarLevel); } else { // m_StarPic[i].gameObject.SetActive(false); m_StarPic[i].color = ItemTool.GetStarColorRGB(fellow.StarLevel - 12); } } } }
public override ItemStack[] getDrops(World world, BlockPos pos, int meta, ItemTool brokenWith) { if (brokenWith != null && brokenWith.toolType == EnumToolType.PICKAXE) { return(new ItemStack[] { new ItemStack(this.asItem(), meta) }); } return(null); }
public static bool ItemTool_SocketItem(ItemTool __instance, OWItemSocket socket) { var qsbObj = __instance._heldItem.GetWorldObject <IQSBItem>(); var socketId = socket.GetWorldObject <QSBItemSocket>().ObjectId; var itemId = qsbObj.ObjectId; QSBPlayerManager.LocalPlayer.HeldItem = null; new SocketItemMessage(SocketMessageType.Socket, socketId, itemId).Send(); return(true); }
private List <Data> GetDataListCommonItem_2() { List <Data> res = new List <Data>(); GameItemContainer EquipPack = GameManager.gameManager.PlayerDataPool.EquipPack; for (int index = 0; index < EquipPack.ContainerSize; ++index) { GameItem equip = EquipPack.GetItem(BackPackLogic.GetEquipSlotByIndex(index)); if (equip != null && equip.IsValid()) { Data data = new Data(); data.item = equip; res.Add(data); } } GameItemContainer BackPack = GameManager.gameManager.PlayerDataPool.BackPack; List <GameItem> itemall = ItemTool.ItemFilter(BackPack, 0, 0, false); for (int nIndex = 0; nIndex < GameItemContainer.MAXSIZE_BACKPACK; ++nIndex) { if (nIndex < BackPack.ContainerSize && nIndex < itemall.Count) { Data data = new Data(); data.item = itemall[nIndex]; res.Add(data); } } //道具显示比较特殊,22组为一个Item // int itemCount = MAX_COMMONITEM_COUNT; // int pageCount = 0; // if (res.Count % itemCount == 0) // { // pageCount = res.Count / itemCount; // } // else // { // pageCount = res.Count / itemCount + 1; // } // // res.Clear(); // // //看有多少页的数据 // for (int i = 0; i < pageCount; i++) // { // Data data = new Data(); // res.Add(data); // } return(res); }
void Awake() { _itemTool = FindObjectOfType <ItemTool>(); _itemTool.transform.localScale = 1.8f * Vector3.one; Hands.HoldObject(_itemTool.transform.Find("ItemSocket"), Hands.RightHand); Hands.HoldObject(_itemTool.transform.Find("ScrollSocket"), Hands.RightHand, new Vector3(-0.06f, -0.06f, -0.03f), Quaternion.Euler(354f, 104f, 194f)); Hands.HoldObject(_itemTool.transform.Find("SharedStoneSocket"), Hands.RightHand, new Vector3(-0.13f, -0.03f, 0f)); Hands.HoldObject(_itemTool.transform.Find("WarpCoreSocket"), Hands.RightHand, new Vector3(-0.1f, -0.01f, 0.03f), Quaternion.Euler(335f, 34f, 64f)); Hands.HoldObject(_itemTool.transform.Find("VesselCoreSocket"), Hands.RightHand, new Vector3(-0.07f, -0.03f, -0.01f), Quaternion.Euler(31.1f, 70.4f, 26f)); Hands.HoldObject(_itemTool.transform.Find("LanternSocket"), Hands.RightHand); }
public Player(Point location) : base("player.png", location, new Size(20, 40), 40, "Player") { registerHandlers(); hotbar = new Inventory(10); hotbar.addItem(ItemTool.createPickaxe(PickaxeType.PICKAXE_STARTING), 1); hotbar.addItem(new ItemBow(), 1); hotbar.addItem(new ItemSword(), 1); hotbar.addItem(BlockPrototype.torch, 50); hotbar.addItem(BlockPrototype.furnace, 1); hotbar.addItem(BlockPrototype.computer, 1); hotbar.addItem(BlockPrototype.glass, 50); }
/// <summary> /// 显示伙伴分页 /// </summary> private void ShowBackPack_Fellow() { // 过滤物品 GameItemContainer BackPack = GameManager.gameManager.PlayerDataPool.BackPack; List <GameItem> itemall = ItemTool.ItemFilter(BackPack, (int)ItemClass.FELLOW, 0, m_QianKunDaiView.activeInHierarchy); //m_HaveItemMax = itemall.Count; //List<GameItem> itemlist = ItemTool.ItemFilter(BackPack, (int)ItemClass.FELLOW, 0, m_QianKunDaiView.activeInHierarchy, m_ShowItemMin, MAX_SHOW_ITEM); CurItemList = itemall; // 显示物品 ShowBackPackItemList(itemall); }
public override ItemStack[] getDrops(World world, BlockPos pos, int meta, ItemTool brokenWith) { bool finished = meta < this.finishedMeta; int i = finished ? Random.Range(this.minDrop, this.maxDrop) : 1; Item item = finished ? this.produce : this.seed; ItemStack[] drops = new ItemStack[i]; for (int j = 0; j < i; j++) { drops[j] = new ItemStack(item, 0, 1); } return(drops); }
public void LoadItems() { var assets = Assets.find(EAssetType.ITEM).Cast <ItemAsset>().ToList(); foreach (ItemAsset asset in assets) { var ready = new ItemIconReady((icon) => { AddUnturnedIcon(asset.id, icon.EncodeToPNG()); }); ItemTool.getIcon(asset.id, 0, asset.quality, asset.getState(), asset, null, string.Empty, string.Empty, asset.size_x * 250, asset.size_y * 250, false, true, ready); } }
public override ItemStack[] getDrops(World world, BlockPos pos, int meta, ItemTool brokenWith) { int i = Random.Range(0, 40); if (i == 0) { return(new ItemStack[] { new ItemStack(Item.apple) }); } else if (i == 1) { return(new ItemStack[] { new ItemStack(Item.stick) }); } return(null); }
//过滤上架物品 private List <GameItem> FilterSelShenQiStuff(GameItemContainer Container) { List <GameItem> resultlist = new List <GameItem>(); for (int nIndex = 0; nIndex < Container.ContainerSize; ++nIndex) { GameItem item = Container.GetItem(nIndex); if (null != item && item.IsValid() && item.DataID == m_nNeedItemDataId) { resultlist.Add(item); } } return(ItemTool.ItemSort(resultlist)); }
public override void OnInspectorGUI() { DrawDefaultInspector(); ItemTool myScript = (ItemTool)target; if (GUILayout.Button("Create Item")) { myScript.AddItemToItemDB(); } if (GUILayout.Button("Destroy Item")) { myScript.RemoveItemFromItemDB(); } }
void ShowChooseGemInfo(GameItem item) { if (item.IsValid()) { m_EquipGemNameLabel.text = item.GetName(); m_EquipGemAttrLable.text = ItemTool.GetGemAttr(item.DataID); m_EquipGemLvLabel.text = GetGemLevelString(item.GetMinLevelRequire()); Tab_GemMount line = TableManager.GetGemMountByID((m_CurGemSlot + 1), 0); if (line != null) { //m_EquipGemCoinNum.text = string.Format("消耗金币:{0}", line.ConsumeNum); m_EquipGemCoinNum.text = StrDictionary.GetClientDictionaryString("#{2836}", line.ConsumeNum); } } }
public static bool ItemTool_DropItem(ItemTool __instance, RaycastHit hit, OWRigidbody targetRigidbody, IItemDropTarget customDropTarget) { Locator.GetPlayerAudioController().PlayDropItem(__instance._heldItem.GetItemType()); var hitGameObject = hit.collider.gameObject; var gameObject2 = hitGameObject; var sectorGroup = gameObject2.GetComponent <ISectorGroup>(); Sector sector = null; while (sectorGroup == null && gameObject2.transform.parent != null) { gameObject2 = gameObject2.transform.parent.gameObject; sectorGroup = gameObject2.GetComponent <ISectorGroup>(); } if (sectorGroup != null) { sector = sectorGroup.GetSector(); if (sector == null && sectorGroup is SectorCullGroup sectorCullGroup) { var controllingProxy = sectorCullGroup.GetControllingProxy(); if (controllingProxy != null) { sector = controllingProxy.GetSector(); } } } var parent = (customDropTarget == null) ? targetRigidbody.transform : customDropTarget.GetItemDropTargetTransform(hit.collider.gameObject); var IQSBItem = __instance._heldItem.GetWorldObject <IQSBItem>(); __instance._heldItem.DropItem(hit.point, hit.normal, parent, sector, customDropTarget); __instance._heldItem = null; QSBPlayerManager.LocalPlayer.HeldItem = null; Locator.GetToolModeSwapper().UnequipTool(); var parentSector = parent.GetComponentInChildren <Sector>(); if (parentSector != null) { var localPos = parentSector.transform.InverseTransformPoint(hit.point); IQSBItem.SendMessage(new DropItemMessage(localPos, hit.normal, parentSector)); return(false); } DebugLog.ToConsole($"Error - No sector found for rigidbody {targetRigidbody.name}!.", MessageType.Error); return(false); }
void UpdateFellowInfo_CurStar(Fellow fellow) { int nStarCount = fellow.StarLevel > 0 ? ((fellow.StarLevel - 1) % 12) + 1 : 0; for (int i = 0; i < m_CurStarPic.Length; i++) { if (i < nStarCount) { m_CurStarPic[i].color = ItemTool.GetStarColorRGB(fellow.StarLevel); } else { m_CurStarPic[i].color = ItemTool.GetStarColorRGB(fellow.StarLevel - 12); } } }
public override ItemStack[] getDrops(World world, BlockPos pos, int meta, ItemTool brokenWith) { ItemStack[] contents = ((TileEntityChest)world.getTileEntity(pos)).chestData.getRawItemArray(); List <ItemStack> list = new List <ItemStack>(); list.Add(new ItemStack(Block.chest)); foreach (ItemStack stack in contents) { if (stack != null) { list.Add(stack); } } return(list.ToArray()); }
public override ItemStack[] getDrops(World world, BlockPos pos, int meta, ItemTool brokenWith) { if (brokenWith != null && brokenWith.toolType == EnumToolType.PICKAXE) { if (this.droppedItem == null) { return(new ItemStack[] { new ItemStack(this) }); } else { return(new ItemStack[] { new ItemStack(this.droppedItem) }); } } else { return(null); } }
public override void Execute(PointBlankPlayer executor, string[] args) { ItemAsset item; if (!ushort.TryParse(args[0], out ushort id)) { ItemAsset[] items = Assets.find(EAssetType.ITEM) as ItemAsset[]; item = items.Where(a => a != null).OrderBy(a => a.itemName.Length).FirstOrDefault(a => a.itemName.ToLower().Contains(args[0].ToLower())); } else { item = Assets.find(EAssetType.ITEM, id) as ItemAsset; } if (item == null) { UnturnedChat.SendMessage(executor, Translations["Item_Invalid"], ConsoleColor.Red); return; } if (args.Length < 2 || !byte.TryParse(args[1], out byte amount)) { amount = 1; } if (args.Length < 3 || UnturnedPlayer.TryGetPlayer(args[2], out UnturnedPlayer ply)) { if (executor == null) { UnturnedChat.SendMessage(executor, Translations["Base_InvalidPlayer"], ConsoleColor.Red); return; } ply = (UnturnedPlayer)executor; } if (!ItemTool.tryForceGiveItem(ply.Player, item.id, amount)) { UnturnedChat.SendMessage(executor, Translations["Item_Fail"], ConsoleColor.Red); return; } UnturnedChat.SendMessage(executor, string.Format(Translations["Item_Give"], item.itemName, ply.PlayerName), ConsoleColor.Green); }
private void WriteGemDes() { for (int i = 0; i < (int)CONSTVALUE.GEM_SLOT_NUM; ++i) { Tab_CommonItem line = TableManager.GetCommonItemByID(m_GemSlotId[i], 0); if (line != null) { m_GemName[i].text = line.Name; m_GemdDes[i].text = ItemTool.GetGemAttr(m_GemSlotId[i]); m_GemLevel[i].text = line.CompondLevel.ToString(); } else { m_GemName[i].text = ""; m_GemdDes[i].text = ""; m_GemLevel[i].text = ""; } } }
void UpdateFellowInfo_CurStar(Fellow fellow) { int nStarCount = fellow.StarLevel > 0 ? ((fellow.StarLevel - 1) % 12) + 1 : 0; for (int i = 0; i < m_CurStarPic.Length; i++) { if (i < nStarCount) { //m_CurStarPic[i].spriteName = FellowTool.GetChatFellowStarQualityPic(fellow.StarLevel); //m_CurStarPic[i].MakePixelPerfect(); // m_CurStarPic[i].gameObject.SetActive(true); m_CurStarPic[i].color = ItemTool.GetStarColorRGB(fellow.StarLevel); } else { // m_CurStarPic[i].gameObject.SetActive(false); m_CurStarPic[i].color = ItemTool.GetStarColorRGB(fellow.StarLevel - 12); } } }
//过滤上架物品 private List <GameItem> FilterConsignSale(GameItemContainer Container, int nClass, int nSubClass = 0) { List <GameItem> resultlist = new List <GameItem>(); for (int nIndex = 0; nIndex < Container.ContainerSize; ++nIndex) { GameItem item = Container.GetItem(nIndex); if (null != item && item.IsValid()) { int itemclass = TableManager.GetCommonItemByID(item.DataID, 0).ClassID; int itemsubclass = TableManager.GetCommonItemByID(item.DataID, 0).SubClassID; if ((itemclass == nClass || nClass == 0) && (itemsubclass == nSubClass || nSubClass == 0) && isCanConsignSale(item)) { resultlist.Add(item); } } } return(ItemTool.ItemSort(resultlist)); }
/// <summary> /// 显示全部分页 /// </summary> private void ShowBackPack_All() { // 过滤物品 GameItemContainer BackPack = GameManager.gameManager.PlayerDataPool.BackPack; List <GameItem> itemall = ItemTool.ItemFilter(BackPack, 0, 0, m_QianKunDaiView.activeInHierarchy); //m_HaveItemMax = itemall.Count; /// 特殊处理 /// 驱虫剂(ID 44),在任务(33)未完成时,排到第一个位置上,便于引导可以引导正确的位置。 /// MissionState misState = (MissionState)GameManager.gameManager.MissionManager.GetMissionState(GlobeVar.QUCHONGJI_MISSION_ID); if (MissionState.Mission_Completed != misState) { int quChongjiIndex = -1; for (int i = 0; i < itemall.Count; i++) { GameItem item = itemall[i]; if (null != item && item.DataID == GlobeVar.QUCHONGJI_ID) { quChongjiIndex = i; break; } } if (itemall.Count > 0 && quChongjiIndex > 0 && quChongjiIndex < itemall.Count) { GameItem tempItem = itemall[0]; itemall[0] = itemall[quChongjiIndex]; itemall[quChongjiIndex] = tempItem; } } //List<GameItem> itemlist = ItemTool.ItemFilter(BackPack, 0, 0, m_QianKunDaiView.activeInHierarchy, m_ShowItemMin, MAX_SHOW_ITEM); if (null != itemall) { CurItemList = itemall; // 显示物品 ShowBackPackItemList(itemall); } }
void ShowUnEquipPage() { //m_Page_Help.gameObject.SetActive(false); m_Page_Equip.gameObject.SetActive(false); CloseEquip(); m_Page_UnEquip.gameObject.SetActive(true); m_GemHelpInfo.SetActive(false); if (m_CurGemSlot >= 0 && m_CurGemSlot < (int)CONSTVALUE.GEM_SLOT_NUM) { int gemId = m_GemSlotId[m_CurGemSlot]; if (gemId >= 0) { Tab_CommonItem line = TableManager.GetCommonItemByID(gemId, 0); if (line != null) { m_ChooseGem.InitInfo(ItemSlotLogic.SLOT_TYPE.TYPE_ITEM, gemId); m_ChooseGemNameLabel.text = line.Name; m_ChooseGemAttrLabel.text = ItemTool.GetGemAttr(gemId); } } } }
public void LoadItems() { UnturnedMarketplaceModule.Instance.Config.Reload(UnturnedMarketplaceModule.Instance); List <ushort> noIconItems = GetItemsWithNoIcons(); Debug.Log($"{noIconItems.Count} items do not have icons"); int num1 = 0; foreach (ushort itemId in noIconItems) { ItemAsset asset = Assets.find(EAssetType.ITEM, itemId) as ItemAsset; var ready = new ItemIconReady((icon) => { UploadUnturnedItemIcon(asset.id, icon.EncodeToPNG()); }); ItemTool.getIcon(asset.id, 0, asset.quality, asset.getState(), asset, null, string.Empty, string.Empty, asset.size_x * UnturnedMarketplaceModule.Instance.Config.IconSize, asset.size_y * UnturnedMarketplaceModule.Instance.Config.IconSize, false, true, ready); num1++; } }