public void UseItemServer(Items.ItemType currentType, int slotNumber) { Debug.Log("item Used"); for (int i = 0; i < itemDataScript.items.Count; i++) { if (itemDataScript.items[i].itemType == currentType) { if (myItems[slotNumber].stacks > 1) { AddRemoveItemStats(currentType, false); myItems[slotNumber].stacks--; playerStScript.UpdateGoldToClients(0); networkView.RPC("BuyItemResponse", uLink.RPCMode.Owner, currentType, true, slotNumber, myItems[slotNumber].stacks, "Item Purchased No stackable"); } else { AddRemoveItemStats(currentType, false); playerStScript.gold += itemDataScript.items[i].cost / 2; myItems[slotNumber].name = ""; myItems[slotNumber].desc = ""; myItems[slotNumber].stacks = 0; myItems[slotNumber].itemType = ItemDataClass.ItemType.Empty; playerStScript.UpdateGoldToClients(0); networkView.RPC("BuyItemResponse", uLink.RPCMode.Owner, Items.ItemType.Empty, true, slotNumber, myItems[slotNumber].stacks, "Item Purchased No stackable"); } } } }
public static void LoadItemTypes() { string[] ItemTypes = File.ReadAllLines("C:/db/itemtype.dat"); foreach (string itemData in ItemTypes) { string[] ItemType = itemData.Split(' '); Items.ItemType IT = new Items.ItemType(); IT.ID = uint.Parse(ItemType[0]); IT.Name = ItemType[1]; IT.ClassReq = byte.Parse(ItemType[2]); IT.ProfReq = byte.Parse(ItemType[3]); IT.LvlReq = byte.Parse(ItemType[4]); IT.SexReq = byte.Parse(ItemType[5]); IT.StrReq = ushort.Parse(ItemType[6]); IT.AgiReq = ushort.Parse(ItemType[7]); IT.Cost = uint.Parse(ItemType[12]); IT.MaxAttack = ushort.Parse(ItemType[14]); IT.MinAttack = ushort.Parse(ItemType[15]); IT.Defense = ushort.Parse(ItemType[16]); IT.AgiGive = byte.Parse(ItemType[17]); IT.Dodge = byte.Parse(ItemType[18]); IT.VitGive = ushort.Parse(ItemType[19]); IT.ManaGive = ushort.Parse(ItemType[20]); IT.MaxDurability = ushort.Parse(ItemType[22]); IT.MagicAttack = ushort.Parse(ItemType[29]); IT.MagicDefense = byte.Parse(ItemType[30]); IT.Range = byte.Parse(ItemType[31]); Kernel.ItemTypes.TryAdd(IT.ID, IT); } }
public static void AddResource(Quest theQuest, Items.ItemType type) { Item i = Items.getRandomType(theQuest.questRand, type); int s = ResourceQuantity(theQuest.questRand, i.minStackSize, i.maxStackSize); s += checkHerbalism(theQuest, i); //NotificationItem notify = new NotificationItem(theQuest.heroName, "Found: " + Main.ToTitleCase(i.name) + "\nAdded to your stocks", SpriteLoader.getSpriteForResource("items/" + i.name)); Main.instance.player.addItemToInventory(new ItemStack(i, s), theQuest, true); }
private void TryBuyItem(Items.ItemType itemType) { if (shopCustomer.TrySpendAmount(Items.GetCost(itemType))) { shopCustomer.BoughtItem(itemType); } else { Debug.Log("Cant buy item, not enough drops"); } }
private void CreateItemButton(Items.ItemType itemType, Sprite itemSprite, string itemName, int itemCost, int positionIndex) { Transform shopItemTransform = Instantiate(shopItemTemplate, container); shopItemTransform.gameObject.SetActive(true); RectTransform shopItemRectTransform = shopItemTransform.GetComponent <RectTransform>(); float shopItemHeight = 30f; shopItemRectTransform.anchoredPosition = new Vector2(0, -shopItemHeight * positionIndex); shopItemTransform.Find("Item").GetComponent <TextMeshProUGUI>().SetText(itemName); shopItemTransform.Find("Price").GetComponent <TextMeshProUGUI>().SetText(itemCost.ToString()); shopItemTransform.Find("Image").GetComponent <Image>().sprite = itemSprite; shopItemTransform.GetComponent <Button_UI>().ClickFunc = () => { TryBuyItem(itemType); }; }
public void BuyItemResponse(Items.ItemType currentType, bool value, int slotNumber, int stacks, string msj) { //IF THE PURCHASE WAS APROVED BY THE SERVER //ADD THE ITEM TO myItems LIST Debug.Log(currentType); if (value) { GetComponent <AudioSource>().PlayOneShot(buyClip); //PLAY BUY SOUND GetComponent <AudioSource>().PlayOneShot(buyClip); for (int i = 0; i < itemDataScript.items.Count; i++) { if (itemDataScript.items[i].itemType == currentType) { myItems[slotNumber].name = itemDataScript.items[i].name; myItems[slotNumber].itemType = itemDataScript.items[i].itemType; myItems[slotNumber].desc = itemDataScript.items[i].desc; myItems[slotNumber].stacks = stacks; if (networkView.isOwner == true) { //UPDATES THE UI WITH THE NEW ITEM PURCHASE ONLY IN THE OWNER NETWORKVIEW foreach (GameObject slotItem in mySlotItems) { ItemMySlot itemMyslotScript = slotItem.GetComponent <ItemMySlot>(); if (itemMyslotScript.slotNumber == slotNumber) { itemMyslotScript.item.name = itemDataScript.items[i].name; itemMyslotScript.item.desc = itemDataScript.items[i].desc; itemMyslotScript.item.itemType = itemDataScript.items[i].itemType; itemMyslotScript.item.itemSprite = itemDataScript.items[i].itemSprite; itemMyslotScript.item.stacks = stacks; return; } } } } } } }
public void SearchItem(Items.ItemType Type) { SearchItemType = Type; }
public async Task <Player []> GetPlayersWithItems(Items.ItemType type) { return(await repo.GetPlayersWithItemType(type)); }
public void BoughtItem(Items.ItemType itemType) { Debug.Log("Bought Item: " + itemType); }
private void AddRemoveItemStats(Items.ItemType item, bool adding) { Debug.Log(item); Debug.Log(adding); float addSusValue = 1; if (!adding) { addSusValue = -1; } switch (item) { case ItemDataClass.ItemType.Empty: break; case ItemDataClass.ItemType.HealthPotMini: if (!adding) { playerStScript.myHealth += 80; playerStScript.UpdateHealthClients(); } break; case ItemDataClass.ItemType.HealthPotBig: if (!adding) { playerStScript.myHealth += 150; playerStScript.UpdateHealthClients(); } break; case ItemDataClass.ItemType.ManaPotMini: if (!adding) { playerStScript.mana += 100; playerStScript.UpdateManaToClients(); } break; case ItemDataClass.ItemType.ManaPotBig: if (!adding) { playerStScript.mana += 200; playerStScript.UpdateManaToClients(); } break; case ItemDataClass.ItemType.SwordMini: playerStScript._adValueAdd += 20 * addSusValue; break; case ItemDataClass.ItemType.SwordBig: playerStScript._adValueAdd += 80 * addSusValue; playerStScript.attackRedAdd += 20 * addSusValue; break; case ItemDataClass.ItemType.ShieldMini: playerStScript.adResAdd += 15 * addSusValue; break; case ItemDataClass.ItemType.ShieldBig: playerStScript.adResAdd += 35 * addSusValue; playerStScript.maxHealth += 150 * addSusValue; playerStScript.UpdateHealthClients(); break; case ItemDataClass.ItemType.MagicMini: playerStScript._apValueAdd += 40 * addSusValue; break; case ItemDataClass.ItemType.MagicBig: playerStScript._apValueAdd += 95 * addSusValue; playerStScript.baseMana += 250 * addSusValue; playerStScript.UpdateManaToClients(); break; case ItemDataClass.ItemType.CloakMini: playerStScript.apResAdd += 10 * addSusValue; break; case ItemDataClass.ItemType.CloakBig: playerStScript.apResAdd += 20 * addSusValue; playerStScript.baseMana += 380 * addSusValue; playerStScript.UpdateManaToClients(); break; case ItemDataClass.ItemType.BootsMedium: playerStScript.speedAdd += 10 * addSusValue; break; case ItemDataClass.ItemType.BootsFast: playerStScript.speedAdd += 25 * addSusValue; break; } playerStScript.UpdateAdds(); }
public void BuyItemServer(Items.ItemType currentType) { for (int i = 0; i < itemDataScript.items.Count; i++) { if (itemDataScript.items[i].itemType == currentType) { //If the player has the money available if (itemDataScript.items[i].cost <= playerStScript.gold) { //If the item is not stackable if (itemDataScript.items[i].stacks == 0) { //Search the list to check if there any empty slotItem to place the new item for (int x = 0; x < myItems.Count; x++) { if (myItems[x].itemType == ItemDataClass.ItemType.Empty) { myItems[x].stacks++; myItems[x].itemType = itemDataScript.items[i].itemType; playerStScript.gold -= itemDataScript.items[i].cost; playerStScript.UpdateGoldToClients(0); networkView.RPC("BuyItemResponse", uLink.RPCMode.Owner, currentType, true, x, myItems[x].stacks, "Item Purchased No stackable"); AddRemoveItemStats(currentType, true); return; } } } else //If the item is stackable, add to a existing item if found { for (int x = 0; x < myItems.Count; x++) { //If the slot has not reached the maximun stacks availables if (myItems[x].itemType == itemDataScript.items[i].itemType && myItems[x].stacks < itemDataScript.items[i].stacks) { myItems[x].stacks++; myItems[x].itemType = itemDataScript.items[i].itemType; playerStScript.gold -= itemDataScript.items[i].cost; playerStScript.UpdateGoldToClients(0); networkView.RPC("BuyItemResponse", uLink.RPCMode.Owner, currentType, true, x, myItems[x].stacks, "Item Purchased Stackable"); AddRemoveItemStats(currentType, true); return; } } //If there is no stacks available, add the item to a new stack for (int x = 0; x < myItems.Count; x++) { if (myItems[x].itemType == ItemDataClass.ItemType.Empty) { myItems[x].stacks++; myItems[x].itemType = itemDataScript.items[i].itemType; playerStScript.gold -= itemDataScript.items[i].cost; playerStScript.UpdateGoldToClients(0); networkView.RPC("BuyItemResponse", uLink.RPCMode.Owner, currentType, true, x, myItems[x].stacks, "Item Purchased Stackable New Stack"); AddRemoveItemStats(currentType, true); Debug.Log("Item Added to a new stack"); return; } } networkView.RPC("BuyItemResponse", uLink.RPCMode.Owner, currentType, false, 0, 0, "No slots available"); } } else { networkView.RPC("BuyItemResponse", uLink.RPCMode.Owner, currentType, false, 0, 0, "Dont have enought money"); } } } }