public void AddItem(InventoryType item) { GameObject invItem; if (UICanvas.Instance.player.inventoryList.ContainsKey(item)) { if (UICanvas.Instance.player.inventoryList[item] != 0) { UICanvas.Instance.player.inventoryList[item]++; InventoryItem inventoryItem = Resources.FindObjectsOfTypeAll <InventoryItem>().Where(x => x.itemType == item).First(); inventoryItem.itemCount.text = UICanvas.Instance.player.inventoryList[item].ToString(); if (UICanvas.Instance.player.inventoryList[item] == 3) { DoorController.Instance.OpenDoor(); } } } else { UICanvas.Instance.player.inventoryList[item] = 1; invItem = (GameObject)Instantiate(Resources.Load(item.ToString())); invItem.GetComponent <InventoryItem>().itemCount.text = UICanvas.Instance.player.inventoryList[item].ToString(); invItem.GetComponent <Transform>().SetParent(content); } }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); if (Optional.IsDefined(Kind)) { writer.WritePropertyName("kind"); writer.WriteStringValue(Kind); } writer.WritePropertyName("properties"); writer.WriteStartObject(); writer.WritePropertyName("inventoryType"); writer.WriteStringValue(InventoryType.ToString()); if (Optional.IsDefined(ManagedResourceId)) { writer.WritePropertyName("managedResourceId"); writer.WriteStringValue(ManagedResourceId); } if (Optional.IsDefined(MoRefId)) { writer.WritePropertyName("moRefId"); writer.WriteStringValue(MoRefId); } if (Optional.IsDefined(MoName)) { writer.WritePropertyName("moName"); writer.WriteStringValue(MoName); } writer.WriteEndObject(); writer.WriteEndObject(); }
void DisplayInventory() { DestroyInventoryChildren(); //Gotta start fresh foreach (OutfitVO o in _outfitDisplayList) { GameObject outfitButton = Instantiate(OutfitButtonPrefab, OutfitListContent.transform); OutfitButtonMediator outfitButtonMediator = outfitButton.GetComponent <OutfitButtonMediator>(); outfitButtonMediator.SetItem(o); outfitButtonMediator.SetInventoryOwner(InventoryOwner.ToString()); } //To Do: Make this actually populate the list, but we first need working accessories again (I mean, they used to, sort of work) /* * foreach (ItemVO i in _accessoryDisplayList) * { * GameObject outfitButton = Instantiate(OutfitButtonPrefab, OutfitListContent.transform); * OutfitButtonMediator outfitButtonMediator = outfitButton.GetComponent<OutfitButtonMediator>(); * outfitButtonMediator.SetItem(o); * outfitButtonMediator.SetInventoryOwner(InventoryOwner.ToString()); * }*/ if (InventoryOwner == InventoryType.Player || InventoryOwner == InventoryType.Loadout) { OutfitLimitText.text = _outfitDisplayList.Count + "/" + _inventorymodel.MaxOutfits; AccessoryLimitText.text = _accessoryDisplayList.Count + "/" + _inventorymodel.MaxAccessories; } }
private static string GetIconAttribute(InventoryType item) { var memberInfo = typeof(InventoryType).GetMember(item.ToString()).FirstOrDefault(); if (memberInfo != null) { return(memberInfo.CustomAttributes .Select(x => { var name = x.AttributeType.Name; var indexAttributeStr = name.IndexOf("Attribute"); return indexAttributeStr > 0 ? name.Substring(0, indexAttributeStr) : null; }) .FirstOrDefault()); } return(null); }
public void UpdateInventory(InventoryType item) { GameObject invItem; InventoryItem checkItem = content.GetComponentsInChildren <InventoryItem>().Where(x => x.itemType == item).FirstOrDefault(); if (checkItem != null) { Debug.Log("Adding " + item); InventoryItem inventoryItem = Resources.FindObjectsOfTypeAll <InventoryItem>().Where(x => x.itemType == item).First(); inventoryItem.itemCount.text = UICanvas.Instance.player.inventoryList[item].ToString(); } else { invItem = (GameObject)Instantiate(Resources.Load(item.ToString())); invItem.GetComponent <InventoryItem>().itemCount.text = UICanvas.Instance.player.inventoryList[item].ToString(); invItem.GetComponent <Transform>().SetParent(content); } }
public static void CreateInventoryLedger(S_FileInfo file, InventoryType type, int totalAmount, int inventoryAmount, string relateDetailInfoID, string targetUserID = "", string targetUserName = "", string detail = "") { DocConstEntities entities = FormulaHelper.GetEntities <DocConstEntities>(); var currentUser = FormulaHelper.GetUserInfo(); var InventoryLedger = new S_A_InventoryLedger { CarItemName = "", CreateDate = System.DateTime.Now, CreateUserID = currentUser.UserID, CreateUserName = currentUser.UserName, SpaceID = file.Space.ID, Type = type.ToString(), Detail = detail, CreateDept = currentUser.UserDeptNames, InventoryAmount = inventoryAmount, TotalAmount = totalAmount, RelateID = file.ID, RelateName = file.Name, RelateType = ListConfigType.File.ToString(), RelateDetailInfoID = relateDetailInfoID, TargetUserID = targetUserID, TargetUserName = targetUserName }; var qNum = int.Parse(string.IsNullOrEmpty(file.DataEntity.GetValue("Quantity")) ? "0" : file.DataEntity.GetValue("Quantity")) + totalAmount; file.DataEntity.SetValue("Quantity", qNum); var sNum = int.Parse(string.IsNullOrEmpty(file.DataEntity.GetValue("StorageNum")) ? "0" : file.DataEntity.GetValue("StorageNum")) + inventoryAmount; file.DataEntity.SetValue("StorageNum", sNum); if (qNum < 0 || sNum < 0) { throw new Formula.Exceptions.BusinessException("遗失份数大于库存,请重新填写"); } file.Save(false); entities.Set <S_A_InventoryLedger>().Add(InventoryLedger); entities.SaveChanges(); }
public static void CreateNewInventoryLedger(S_NodeInfo node, string detail = "", InventoryType type = InventoryType.StorageIn) { DocConstEntities entities = FormulaHelper.GetEntities <DocConstEntities>(); var currentUser = FormulaHelper.GetUserInfo(); var InventoryLedger = new S_A_InventoryLedger { SpaceID = node.Space.ID, RelateID = node.ID, RelateName = node.Name, RelateType = InventoryRelateType.Node.ToString(), RelateDetailInfoID = "", CarItemName = "", Type = type.ToString(), Detail = detail, CreateDept = currentUser.UserDeptNames, CreateDate = System.DateTime.Now, CreateUserID = currentUser.UserID, CreateUserName = currentUser.UserName, TargetUserID = "", TargetUserName = "" }; if (!string.IsNullOrEmpty(node.DataEntity.GetValue("Quantity"))) { var num = 0; if (int.TryParse(node.DataEntity.GetValue("Quantity"), out num)) { InventoryLedger.TotalAmount = num; InventoryLedger.InventoryAmount = num; } if (num == 0) { return; } } entities.Set <S_A_InventoryLedger>().Add(InventoryLedger); entities.SaveChanges(); }
private async Task OnPlayerInteract(PlayerInteractEventArgs e) { var item = e.Item; var block = e.Block; var server = e.Server as Server; var player = e.Player as Player; if (e.Cancel) { return; } if (block.HasValue) { if (e.BlockLocation is not Vector blockPosition) { return; } var interactedBlock = block.Value; player.LastClickedBlock = interactedBlock; var type = interactedBlock.Material; BaseContainer?container = type switch { Material.Anvil or Material.SmithingTable => new AnvilContainer(type.ToString().ToSnakeCase()) { Title = type == Material.Anvil ? "Anvil" : "Smithing Table" }, Material.EnchantingTable => new EnchantmentTable { BlockPosition = blockPosition }, Material.Dropper or Material.Dispenser => new Container(9) { Owner = player.Uuid, Title = type.ToString(), BlockPosition = blockPosition, Id = type is Material.Dropper ? "dropper" : "dispenser" }, Material.BrewingStand => new BrewingStand { BlockPosition = blockPosition }, Material.Hopper => new Container(5) { BlockPosition = blockPosition }, Material.CraftingTable => new CraftingTable(), Material.Loom => new Loom(), Material.CartographyTable => new CartographyTable(), Material.Stonecutter => new Stonecutter(), Material.Grindstone => new Grindstone(), _ => null }; //TODO check if container is cached if so get that container if (type == Material.Chest) // TODO check if chest its next to another single chest { container = new Container { Owner = player.Uuid, Title = "Chest", BlockPosition = blockPosition, Id = "chest" }; await player.OpenInventoryAsync(container); await player.client.QueuePacketAsync(new BlockAction { Position = blockPosition, ActionId = 1, ActionParam = 1, BlockType = interactedBlock.Id }); await player.SendSoundAsync(Sounds.BlockChestOpen, blockPosition.SoundPosition, SoundCategory.Blocks); } else if (type == Material.EnderChest) { container = new Container { Owner = player.Uuid, Title = "Ender Chest", Id = type.ToString().ToSnakeCase() }; await player.OpenInventoryAsync(container); await player.client.QueuePacketAsync(new BlockAction { Position = blockPosition, ActionId = 1, ActionParam = 1, BlockType = interactedBlock.Id }); await player.SendSoundAsync(Sounds.BlockEnderChestOpen, blockPosition.SoundPosition, SoundCategory.Blocks); } else if (type == Material.Furnace || type == Material.BlastFurnace || type == Material.Smoker) { InventoryType actualType = type switch { Material.Furnace => InventoryType.Furnace, Material.BlastFurnace => InventoryType.BlastFurnace, Material.Smoker => InventoryType.Smoker, _ => InventoryType.Furnace }; container = new SmeltingContainer(actualType, actualType.ToString().ToSnakeCase()) { BlockPosition = blockPosition, Title = actualType.ToString() }; } else if (type >= Material.ShulkerBox && type <= Material.BlackShulkerBox) { container = new Container // TODO shulker box functionality { Owner = player.Uuid, Title = "Shulker Box", BlockPosition = blockPosition, Id = "shulker_box" }; await player.client.QueuePacketAsync(new BlockAction { Position = blockPosition, ActionId = 1, ActionParam = 1, BlockType = interactedBlock.Id }); await player.SendSoundAsync(Sounds.BlockShulkerBoxOpen, blockPosition.SoundPosition, SoundCategory.Blocks); } else if (type == Material.Barrel) { container = new Container { //Owner = player.Uuid, Title = "Barrel", BlockPosition = blockPosition, Id = "Barrel" }; await player.SendSoundAsync(Sounds.BlockBarrelOpen, blockPosition.SoundPosition, SoundCategory.Blocks); } else if (type == Material.Lectern) { //TODO open lectern?? } if (container is IBlockEntity) { var tileEntity = await player.World.GetBlockEntityAsync(blockPosition); if (tileEntity == null) { tileEntity = new NbtCompound() { new NbtTag <string>("id", (container as IBlockEntity).Id), new NbtTag <int>("x", blockPosition.X), new NbtTag <int>("y", blockPosition.Y), new NbtTag <int>("z", blockPosition.Z), new NbtTag <string>("CustomName", container.Title.ToJson()) }; player.World.SetBlockEntity(blockPosition, tileEntity); } else if (tileEntity is NbtCompound dataCompound) { if (dataCompound.TryGetTag("Items", out var tag)) { var items = tag as NbtList; foreach (NbtCompound i in items) { var inventoryItem = i.ItemFromNbt(); container.SetItem(inventoryItem.Slot, inventoryItem); } } } } await player.OpenInventoryAsync(container); } else { //TODO check for other } }
public override string ToString() { return(string.Format("[InventoryType: {0} (0x{1:X2})]", InventoryType.ToString(), (byte)InventoryType)); }
/// <summary> /// Itemizerで鞄のアイテムを移動する /// </summary> /// <param name="iItemName">アイテム名</param> /// <param name="iInventoryType">倉庫タイプ</param> /// <returns>成功した場合Trueを返す</returns> public bool PutItem(string iItemName, InventoryType iInventoryType) { //移動元に指定のアイテムが存在するかチェック if (!IsExistItem(iItemName, InventoryType.Inventory)) return false; //移動先に空きがあるかチェック if (!IsInventoryFree(iInventoryType)) return false; //Itemizer実行 string scriptName = string.Format("{0}_{1}", MiscTool.GetAppAssemblyName(), fface.Player.Name); //string cmd = string.Format("input /puts \"{0}\" {1}", iItemName, iInventoryType.ToString()); //return ExecScript(cmd, scriptName); string cmd = string.Format("windower.send_command(\"input //puts {0} {1}\")", iItemName, iInventoryType.ToString().ToLower()); return ExecLua(cmd, scriptName); }
private void OpenInventory(Inventory inventory, InventoryType invType) { List <SO_Item> itemList = inventory.InventoryList; title.text = invType.ToString(); if (itemList != null) { if (myButtonList.Count != 0) { foreach (Transform child in itemGrid) { Destroy(child.gameObject); } myButtonList.Clear(); } if (invType != InventoryType.PLAYER && invType != InventoryType.ENEMY) { AddSwitchButton(invType, crtInventory); } crtInventory = inventory; foreach (SO_Item item in itemList) { AddButton(item); } switch (invType) { case InventoryType.CHEST: backInventory = inventory; firstInput += () => { TakeItem(selectedButton, inventory); }; secondInput += () => { TakeAllItems(inventory); }; break; case InventoryType.ENEMY: backInventory = inventory; firstInput += () => { TakeItem(selectedButton, inventory); }; secondInput += () => { TakeAllItems(inventory); }; break; case InventoryType.PLAYER: backInventory = inventory; firstInput += () => { playerEquipement.AskToEquip(selectedButton); }; secondInput += () => { DropItem(selectedButton); }; secondInput += () => { GameManager.Instance.Player.Inventory.Remove(selectedButton); }; secondInput += () => { AskToDestroyButton(); }; break; case InventoryType.SHOP: backInventory = inventory; firstInput += () => { BuyItem(selectedButton, inventory); }; break; case InventoryType.PLAYER_SHOP: firstInput += () => { SellItem(selectedButton); }; break; case InventoryType.PLAYER_STORE: firstInput += () => { backInventory.Receive(selectedButton); }; firstInput += () => { StockItem(selectedButton); }; break; default: break; } } }
/// <summary> /// アイテムを鞄から指定した場所へ移動する /// </summary> /// <param name="iItemName">アイテム名</param> /// <param name="iInventoryType">移動先</param> /// <returns>成功した場合Truwを返す</returns> private bool putItem(string iItemName, InventoryType iInventoryType) { if (control.GetInventoryCountByType(iInventoryType) >= control.GetInventoryMaxByType(iInventoryType)) return false; if (control.IsExistItem(iItemName, InventoryType.Inventory)) { control.PutItem(iItemName, iInventoryType); setMessage(string.Format("{0}を{1}に移動しました", iItemName, iInventoryType.ToString())); Thread.Sleep(1000); return true; } return false; }
/// <summary> /// 指定した場所へ魚を移動する /// </summary> /// <param name="iInventoryType"></param> /// <returns></returns> private bool putFish(InventoryType iInventoryType) { //short lastCnt = control.GetInventoryCountByType(InventoryType.Inventory); if (control.GetInventoryCountByType(iInventoryType) >= control.GetInventoryMaxByType(iInventoryType)) return false; List<FishDBFishModel> fishes = FishDB.SelectFishList(this.RodName, string.Empty, string.Empty); foreach (FishDBFishModel fish in fishes) { if (control.IsExistItem(fish.FishName, InventoryType.Inventory)) { control.PutItem(fish.FishName, iInventoryType); setMessage(string.Format("{0}を{1}に移動しました", fish.FishName, iInventoryType.ToString())); Thread.Sleep(1000); return true; } } return false; }
/// <summary> /// Itemizerで鞄のアイテムを移動する /// </summary> /// <param name="iItemName">アイテム名</param> /// <param name="iInventoryType">倉庫タイプ</param> /// <returns>成功した場合Trueを返す</returns> public bool PutItemizer(string iItemName, InventoryType iInventoryType) { //移動元に指定のアイテムが存在するかチェック if (!IsExistItem(iItemName, InventoryType.Inventory)) { return(false); } //移動先に空きがあるかチェック if (!IsInventoryFree(iInventoryType)) { return(false); } //Itemizer実行 string scriptName = string.Format("{0}_{1}", MiscTool.GetAppAssemblyName(), api.Player.Name); //string cmd = string.Format("input /puts \"{0}\" {1}", iItemName, iInventoryType.ToString()); //return ExecScript(cmd, scriptName); string cmd = string.Format("windower.send_command(\"input //puts {0} {1}\")", iItemName, iInventoryType.ToString().ToLower()); return(ExecLua(cmd, scriptName)); }
//要保证返回的字符串经UTF8编码后,长度小于或等于12个字节 public static string GetCommandName(this InventoryType type) { //TODO: 暂时返回枚举名称,未来可能会有枚举名称与命令名称不一致的情况,需要单独处理 return(type.ToString().ToLower()); }
protected override void OnFlowEnd(S_I_IdentifyApply entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { var state = IdentifyState.Identified.ToString(); var infoIDs = entity.S_I_IdentifyApply_DetailInfo.Select(a => a.IdentifyInfoID).ToArray(); this.BusinessEntities.Set <S_I_IdentifyInfo>().Where(a => infoIDs.Contains(a.ID)).Update(a => a.State = state); //添加鉴定记录 var IdentifyApplyDetails = entity.S_I_IdentifyApply_DetailInfo.Select(a => a).ToList(); InventoryType type = new InventoryType(); foreach (var IdentifyApplyDetail in IdentifyApplyDetails) { var identifyInfo = this.BusinessEntities.Set <S_I_IdentifyInfo>().FirstOrDefault(b => b.ID.Equals(IdentifyApplyDetail.IdentifyInfoID)); S_NodeInfo node = new S_NodeInfo(identifyInfo.NodeID, FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(b => b.ID.Equals(identifyInfo.SpaceID))); if (IdentifyApplyDetail.IdentifyResult.Equals(InventoryType.Destroy.ToString())) { type = InventoryType.Destroy; } else { type = InventoryType.ChangePeriod; } InventoryFO.CreateNewInventoryLedger(node, "鉴定结果为:" + EnumBaseHelper.GetEnumDescription(type.GetType(), type.ToString()), type); } }
public override string ToString() { return(string.Format("[InventoryType: {0} (0x{1:X2}), InventoryMarker: {2}, MaxSuIdRequested: {3}]", InventoryType.ToString(), (byte)InventoryType, InventoryMarker, MaxSuIdRequested)); }
protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { List <Dictionary <string, object> > lostReplenishList = null; List <Dictionary <string, object> > replenishList = new List <Dictionary <string, object> >(); S_NodeInfo nodeInfo = null; S_FileInfo fileInfo = null; //遗失登记 if (dic.ContainsKey("LostDetail")) { lostReplenishList = JsonHelper.ToList(dic["LostDetail"]); //遗失损毁数量校验 LostDamageVerifica(dic, lostReplenishList); } else { lostReplenishList = JsonHelper.ToList(dic["Detail"]);//补录 } if (lostReplenishList.Count <= 0) { throw new Formula.Exceptions.BusinessException("请添加内容之后,再保存!"); } var entities = Formula.FormulaHelper.GetEntities <DocConstEntities>(); InventoryType stateType = new InventoryType(); foreach (var lostReplenishDetail in lostReplenishList) { string relateID = lostReplenishDetail.ContainsKey("RelateDocID") ? lostReplenishDetail["RelateDocID"].ToString() : "";//文件或节点ID string spaceID = lostReplenishDetail.ContainsKey("SpaceID") ? lostReplenishDetail["SpaceID"].ToString() : ""; S_DOC_Space space = Formula.FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(spaceID)); string relateDocType = lostReplenishDetail.ContainsKey("RelateDocType") ? lostReplenishDetail["RelateDocType"].ToString() : "";//文件或结点 string state = ""; if (dic.ContainsKey("LostDetail")) { state = lostReplenishDetail.ContainsKey("LoseDamageState") ? lostReplenishDetail["LoseDamageState"].ToString() : "";//遗失损毁状态 } //遗失或损毁补录份数 #region 库存数量的增减 int LostReplenishCount = 0; int datilCount = 0;//补录份数可能为负数 if (state.Equals(InventoryType.Destroy.ToString()) || state.Equals(InventoryType.Lose.ToString())) { stateType = state.Equals(InventoryType.Destroy.ToString()) ? InventoryType.Destroy : InventoryType.Lose; LostReplenishCount = Convert.ToInt32(lostReplenishDetail["LoseCount"]); LostReplenishCount = -LostReplenishCount; } else { stateType = InventoryType.Replenish; LostReplenishCount = Convert.ToInt32(lostReplenishDetail["ReplenishCount"]); } datilCount = stateType == InventoryType.Replenish? LostReplenishCount:-LostReplenishCount; if (relateDocType == "Node") { nodeInfo = new S_NodeInfo(relateID, space); InventoryFO.CreateInventoryLedger(nodeInfo, stateType, LostReplenishCount, LostReplenishCount, "", "", "", EnumBaseHelper.GetEnumDescription(stateType.GetType(), stateType.ToString()) + "份数:" + datilCount + "份");//入库 } else { fileInfo = new S_FileInfo(relateID, space); InventoryFO.CreateInventoryLedger(fileInfo, stateType, LostReplenishCount, LostReplenishCount, "", "", "", EnumBaseHelper.GetEnumDescription(stateType.GetType(), stateType.ToString()) + "份数:" + datilCount + "份"); } #endregion if (dic.ContainsKey("LostDetail")) { AddLostDamage(dic, lostReplenishDetail, entities);//遗失 } else { AddReplenish(dic, lostReplenishDetail, entities, ref replenishList);//补录 } } if (dic.ContainsKey("Detail")) { dic["Detail"] = JsonHelper.ToJson(replenishList).ToString(); } entities.SaveChanges(); }