// Note, the client actually uses item id to determine type public static void WriteEquip(EquipSlot slot, Item item, PacketWriter pWriter) { pWriter.WriteLong(item.Id) .WriteLong(item.Id) .WriteUnicodeString(slot.ToString()) .WriteInt(1) .WriteItem(item); }
/* * On Click event for currently equipped item panel in the equipment panel */ private void EquipmentSlotItemClicked(EquipSlot slot) { Debug.Log("Equipment Slot Clicked: " + slot.ToString()); this.playerController.playerModel.Unequip(slot); playerController.UpdateUI(); UpdateEquipmentPanel(); ClearInventoryUI(); UpdateInventoryPanel(); }
public override string GetDescription() { string desc = Name + "\n"; desc += WeaponSubType + " - " + WeaponType + " - " + ItemRarity.ToString() + "\n"; desc += "Gold: " + Value + " - " + EquipSlot.ToString() + "\n"; desc += Description + "\n\n"; desc += ModPackage.GetStatInfo(); return(desc); }
public static Packet EquipItem(IFieldObject <Player> player, Item item, EquipSlot equipSlot) { return(PacketWriter.Of(SendOp.ITEM_PUT_ON) .WriteInt(player.ObjectId) .WriteInt(item.Id) .WriteLong(item.Uid) .WriteUnicodeString(equipSlot.ToString()) .WriteInt(item.Rarity) .WriteByte() .WriteItem(item)); }
public override string GetStatsString() { StringBuilder res = new StringBuilder(); if (Shields != null && Shields.MaxShields > 0) { res.Append($"\nShields: {Shields.MaxShields:F1} ({Shields.RechargeRate:F1}/s)"); } foreach (var key in DamageResistance.Keys.Union(DamageThreshold.Keys)) { float dr = DamageResistance.GetOrDefault(key, 0); float dt = DamageThreshold.GetOrDefault(key, 0); if (dr == 0 && dt == 0) { continue; } res.AppendFormat("\n{0}: {1:F1} ({2:F1})", key, dr, dt); } return($"<b>Armor: {Slot.ToString()}</b>\n" + base.GetStatsString() + res.ToString()); }
void UpdateEquipment(Actor a) { for (int i = 0; i < Enum.GetNames(typeof(EquipSlot)).Length; i++) { EquipSlot slot = (EquipSlot)i; Equipable e = a.data.GetEquipment((EquipSlot)i); if (e == null) { _equipmentItems[(int)slot].transform.Find("header").GetComponent <Text>().text = "Empty (" + slot.ToString() + ")"; _equipmentItems[(int)slot].GetComponent <GenericPointerHandler>().Initialize( null, null, null, null, null); } else { bool isEquipped = a.data.GetEquipment(e.slot) == e; _equipmentItems[(int)e.slot].transform.Find("header").GetComponent <Text>().text = isEquipped ? e.NameToString() : "Empty (" + e.slot.ToString() + ")"; if (isEquipped) { _equipmentItems[(int)e.slot].GetComponent <GenericPointerHandler>().Initialize( () => Tooltip.Open(e.ToTooltip()), null, null, null, () => Tooltip.Close()); } else { _equipmentItems[(int)e.slot].GetComponent <GenericPointerHandler>().Initialize( null, null, null, null, null); } } } }
private void RefreshView() { for (int i = 0; i < guiItems.Count; i++) { GameObject.Destroy(guiItems[i]); } guiItems.Clear(); UpdateStatusTexts(); var player = gameManager.playerObject.GetComponent <Creature>(); descriptionText.text = player.Inventory.Count == 0 ? "Your inventory is empty." : ""; // Instantiate items in inventory for (int i = 0; i < player.Inventory.Count; i++) { var obj = GameObject.Instantiate(gameManager.inventoryGuiItemPrefab); var backgroundImg = obj.GetComponent <UnityEngine.UI.Image>(); obj.transform.SetParent(inventoryCanvas.transform); obj.transform.localScale = Vector3.one; obj.GetComponent <RectTransform>().localPosition = new Vector3(170, 288 - i * 30f, 0); guiItems.Add(obj); InventoryItem invItem = player.Inventory[i]; Data.ItemData item = gameManager.GameData.ItemData[invItem.ItemKey]; obj.transform.GetChild(0).GetComponent <TMPro.TextMeshProUGUI>().text = "" + invItem.Count + "x " + System.Globalization.CultureInfo.InvariantCulture.TextInfo.ToTitleCase(item.Name); var itemHandler = obj.GetComponent <UIItemHandler>(); if (player.HasItemInSlot(invItem, EquipSlot.LeftHand)) { itemHandler.LeftHandImage.SetActive(true); } if (player.HasItemInSlot(invItem, EquipSlot.RightHand)) { itemHandler.RightHandImage.SetActive(true); } itemHandler.MouseEnter += delegate { backgroundImg.color = new Color(0.7f, 0.7f, 0.7f); ShowItemStats(item); highlightedItem = invItem; }; itemHandler.MouseExit += delegate { backgroundImg.color = new Color(1f, 1f, 1f); descriptionText.text = ""; highlightedItem = null; }; itemHandler.MouseClick += delegate(PointerEventData eventData) { EquipSlot slot = eventData.button == PointerEventData.InputButton.Left ? EquipSlot.LeftHand : EquipSlot.RightHand; if (player.HasItemInSlot(invItem, slot)) { gameManager.PlayerUnequip(slot); gameManager.MessageBuffer.AddMessage(Color.white, "You unequipped the " + gameManager.GameData.ItemData[invItem.ItemKey].Name.ToLower() + " from your " + slot.ToString().Replace("Hand", "").ToLower() + " hand."); } else { gameManager.PlayerEquip(invItem, slot); gameManager.MessageBuffer.AddMessage(Color.white, "You equipped the " + gameManager.GameData.ItemData[invItem.ItemKey].Name.ToLower() + " to your " + slot.ToString().Replace("Hand", "").ToLower() + " hand."); } RefreshView(); }; } }
/// TODO: Implement Broker /// TODO: Implement Craft /// TODO: Implement Dump /// TODO: Implement EQ2Ignore /// TODO: Implement InitCommands /// TODO: Implement ShowStats /// TODO: Implement Where /// <summary> /// Activates an item that is currently equipped. (The command /// activates an item in the same way as if you placed the item /// in your hotbar and clicked on it, or, if you right-click on /// an item and select 'use'.) /// </summary> /// <param name="slot">equipment slot</param> public static int Activate(EquipSlot slot) { Trace.WriteLine(String.Format("Extension:Activate({0})", slot)); return(LavishScript.ExecuteCommand(String.Format("Activate {0}", slot.ToString().ToLower()))); }
public void Equip(Item item) { EquipSlot slot = item.EquipSlot; Item oldEquip = EquippedItems[(int)slot]; if (oldEquip != null) { Unequip((int)slot); } EquippedItems[(int)slot] = item; RemoveItem(item); // Apply new effects item.Equip(this); Game.Instance.Message(string.Format("Equipped {0} in {1} slot.", item.Name, slot.ToString())); }
/// TODO: Implement Broker /// TODO: Implement Craft /// TODO: Implement Dump /// TODO: Implement EQ2Ignore /// TODO: Implement InitCommands /// TODO: Implement ShowStats /// TODO: Implement Where /// <summary> /// Activates an item that is currently equipped. (The command /// activates an item in the same way as if you placed the item /// in your hotbar and clicked on it, or, if you right-click on /// an item and select 'use'.) /// </summary> /// <param name="slot">equipment slot</param> public static int Activate(EquipSlot slot) { Trace.WriteLine(String.Format("Extension:Activate({0})", slot)); return LavishScript.ExecuteCommand(String.Format("Activate {0}", slot.ToString().ToLower())); }