Exemple #1
0
    public void UpdateItem(int slot)
    {
        slot = -1;

        for (int i = 0; i < hotbar.displayedSlots.Count; i++)
        {
            HotbarSlot hSlot = hotbar.displayedSlots[i];

            if (hSlot.selected)
            {
                slot = hSlot.inventorySlot;
                break;
            }
        }

        if (slot == -1)
        {
            return;
        }

        for (int i = 0; i < handHelds.Length; i++)
        {
            if (hotbar.inventory.contents.TryGetValue(slot, out ItemStack itemStack))
            {
                handHelds[i].ActivateItem(itemStack);
            }
            else
            {
                handHelds[i].gameObject.SetActive(false);
            }
        }
    }
Exemple #2
0
    private void DropSelectedItem()
    {
        HotbarSlot slot = hotbarSlots[curSelectedSlot - 1];
        Item       i    = slot.GetItem();

        if (i != null)
        {
            int itemAmount = slot.amount;


            for (int j = 0; j < itemAmount; j++)
            {
                ItemDataBase.instance.SpawnItem(slot.item.id, dropArea.position);
            }

            slot.gameObject.transform.GetChild(0).GetComponent <Image>().enabled = false;
            slot.amount = 0;
            curItem     = null;
            if (slot.item.stackable)
            {
                slot.transform.GetChild(2).GetComponent <TextMeshProUGUI>().text = "";
            }
            slot.item = null;
        }
    }
Exemple #3
0
    public bool ContainsItem(int id, int amount)
    {
        // First, check if the item requested exists in the database
        Item item = ItemDataBase.instance.GetItemFromList(id);

        if (item != null)
        {
            // Item exists in database
            // Search through the hotbar and find the last index of the item
            for (int i = 0; i < hotbarSlots.Count; i++)
            {
                HotbarSlot slot = hotbarSlots[i];
                if (item == slot.GetItem())
                {
                    // Item exists, check if the amount there is the same as requested
                    if (slot.amount >= amount)
                    {
                        return(true);
                    }
                }
            }
        }

        return(false);
    }
Exemple #4
0
    public override void OnDrop(PointerEventData eventData)
    {
        ItemDragHandler itemDragHandler = eventData.pointerDrag.GetComponent <ItemDragHandler>();

        if (itemDragHandler == null)
        {
            return;
        }

        InventorySlot inventorySlot = itemDragHandler.ItemSlotUI as InventorySlot;

        if (inventorySlot != null)
        {
            SlotItem = inventorySlot.ItemSlot.item;
            return;
        }
        HotbarSlot hotbarSlot = itemDragHandler.ItemSlotUI as HotbarSlot;

        if (hotbarSlot != null)
        {
            HotbarItem oldItem = SlotItem;
            SlotItem            = hotbarSlot.SlotItem;
            hotbarSlot.SlotItem = oldItem;
            return;
        }
    }
Exemple #5
0
        public static SNOPower GetPowerForSlot(HotbarSlot slot)
        {
            if (slot == HotbarSlot.Invalid)
            {
                return(SNOPower.None);
            }

            return(Trinity.Hotbar[(int)slot]);
        }
Exemple #6
0
    private void PopulateSlots()
    {
        int diff = GetComponentsInChildren <HotbarSlot>().Length;

        for (int i = 0; i < _slotCount - diff; i++)
        {
            HotbarSlot slot = Instantiate(_hotbarSlotPrefab);
            slot.transform.SetParent(_slotContainer);
        }
    }
Exemple #7
0
        /// <summary>
        /// Returns the rune index for the given SNOPower. If rune can't be found returns -999
        /// </summary>
        /// <param name="power"></param>
        /// <returns></returns>
        private static int GetRuneIndexFromPower(SNOPower power)
        {
            int        runeIndex = -999;
            HotbarSlot slot      = GetHotbarSlotFromPower(power);

            if (slot != HotbarSlot.Invalid)
            {
                return(cPlayer.GetRuneIndexForSlot(slot));
            }

            return(runeIndex);
        }
Exemple #8
0
 private string ReturnSkillString(HotbarSlot slot)
 {
     try
     {
         return(String.Format("Skill: {0} HotbarSlot: {1} RuneIndex: {2}",
                              ZetaDia.CPlayer.GetPowerForSlot(slot), slot, ZetaDia.CPlayer.GetRuneIndexForSlot(slot)));
     }
     catch (Exception)
     {
         return("None");
     }
 }
 public HotbarSlot this[int i] {
     get {
         if (!jobSlots.ContainsKey(i))
         {
             jobSlots[i] = new HotbarSlot();
         }
         return(jobSlots[i]);
     }
     set {
         jobSlots[i] = value;
     }
 }
 public string GetHotbarSlotKeyMap(int hnum, int snum, int jnum)
 {
     if (hotbarData.rows.ContainsKey(hnum))
     {
         HotbarRow row = hotbarData[hnum];
         if (row.slots.ContainsKey(snum))
         {
             HotbarSlot slot = row[snum][jnum];
             return(slot.ToString());
         }
     }
     return(null);
 }
Exemple #11
0
 private string ReturnSkillString(HotbarSlot slot)
 {
     try
     {
         SNOPower power = ZetaDia.CPlayer.GetPowerForSlot(slot);
         PowerManager.CanCastFlags castflags;
         bool cancast = Zeta.Bot.PowerManager.CanCast(power, out castflags);
         return(String.Format("Skill: {0} HotbarSlot: {1} RuneIndex: {2}\r\n" +
                              "CanCast: {3} CanCastFlags: {4}",
                              power, slot, ZetaDia.CPlayer.GetRuneIndexForSlot(slot), cancast, castflags));
     }
     catch (Exception)
     {
         return("None");
     }
 }
        private HotbarSlot ParseSection(BinaryReader stream)
        {
            byte       xor = 0x31;
            HotbarSlot ac  = new HotbarSlot {
                action = XorTools.ReadXorByte(stream, xor),
                flag   = XorTools.ReadXorByte(stream, xor),
                unk1   = XorTools.ReadXorByte(stream, xor),
                unk2   = XorTools.ReadXorByte(stream, xor),
                job    = XorTools.ReadXorByte(stream, xor),
                hotbar = XorTools.ReadXorByte(stream, xor),
                slot   = XorTools.ReadXorByte(stream, xor),
                type   = XorTools.ReadXorByte(stream, xor),
            };

            return(ac);
        }
        /// <summary>
        ///     Gets an ActiveSkill from an equipped Power
        /// </summary>
        /// <param name="power"></param>
        /// <returns></returns>
        public static ActiveSkill GetSkillFromPower(SNOPower power)
        {
            if (!HeroClass.ActiveSkills.Any(s => s == power))
            {
                return(new ActiveSkill());
            }

            HotbarSlot slot      = HeroClass.GetSlotFromPower(power);
            int        runeIndex = HeroClass.GetRuneIndexFromSlot(slot);

            return(new ActiveSkill
            {
                Power = power,
                RuneIndex = runeIndex,
                Slot = slot
            });
        }
        /// <summary>
        ///     Creates an ActiveSkill from a HotbarSlot
        /// </summary>
        /// <param name="slot"></param>
        /// <returns></returns>
        public static ActiveSkill GetSkillFromSlot(HotbarSlot slot)
        {
            SNOPower power = HeroClass.GetPowerFromSlot(slot);

            if (power == SNOPower.None)
            {
                return(new ActiveSkill());
            }

            int runeIndex = HeroClass.GetRuneIndexFromSlot(slot);

            return(new ActiveSkill
            {
                Power = power,
                RuneIndex = runeIndex,
                Slot = slot
            });
        }
Exemple #15
0
    public override void OnDrop(PointerEventData eventData)
    {
        //Get the item drag handler
        ItemDragHandler itemDragHandler = eventData.pointerDrag.GetComponent <ItemDragHandler>();

        //If the item drag handler is null
        if (itemDragHandler == null)
        {
            //Ignore the rest of the function
            return;
        }

        //Check if the item you dropped is an inventory item
        InventorySlot inventorySlot = itemDragHandler.ItemSlotUI as InventorySlot;

        //If the item is an inventory slot
        if (inventorySlot != null)
        {
            //Set the slot item to be the inventory item
            SlotItem = inventorySlot.ItemSlot.inventoryItem;

            //Exit the function
            return;
        }

        //Check if the item you dropped is a Hotbar item
        HotbarSlot hotbarSlot = itemDragHandler.ItemSlotUI as HotbarSlot;

        //If the item is a hotbar slot
        if (hotbarSlot != null)
        {
            //Store the old item
            HotbarItem oldItem = SlotItem;

            //Set the slot as the new item
            SlotItem = hotbarSlot.SlotItem;

            //Set the hotbar slot item to the old item
            hotbarSlot.SlotItem = oldItem;

            //Exit the function
            return;
        }
    }
 protected override bool ParseDat(BinaryReader stream)
 {
     hotbarData.Clear();
     if (base.ParseDat(stream))
     {
         stream.BaseStream.Seek(0x10, SeekOrigin.Begin);
         while (stream.BaseStream.Position < header.dataSize)
         {
             HotbarSlot ac = ParseSection(stream);
             if (ac.job <= 0x23)
             {
                 if (ac.type == 0x1D)
                 {
                     //Console.WriteLine(string.Format("{0} ({1}): {2} {3}", ac.ToString(), ac.job, ac.action, ac.type));
                 }
                 hotbarData[ac.hotbar][ac.slot][ac.job] = ac;
             }
         }
     }
     return(true);
 }
 public void ReadFromStream(IPacketCodec content)
 {
     Slot = content.ReadEnum <HotbarSlot>();
 }
 /// <summary> Constructor. </summary>
 /// <remarks> Nesox, 2013-10-02. </remarks>
 /// <param name="slot"> The slot. </param>
 public HotbarPower(HotbarSlot slot)
 {
     Power     = ZetaDia.CPlayer.GetPowerForSlot(slot);
     RuneIndex = ZetaDia.CPlayer.GetRuneIndexForSlot(slot);
 }
Exemple #19
0
        private string ReturnSkillString(HotbarSlot slot)
        {
            try
            {

                return String.Format("Skill: {0} HotbarSlot: {1} RuneIndex: {2}",
                                ZetaDia.CPlayer.GetPowerForSlot(slot), slot, ZetaDia.CPlayer.GetRuneIndexForSlot(slot));
            }
            catch (Exception)
            {
                return "None";
            }
        }
Exemple #20
0
            internal HotbarSkill GetSkill(HotbarSlot slot)
            {
                HotbarSkill skill;

                return(_skillBySlot.TryGetValue(slot, out skill) ? skill : new HotbarSkill());
            }
Exemple #21
0
 public HotbarSkill(HotbarSlot slot, SNOPower power, int runeindex)
 {
     Slot = slot;
     Power = power;
     RuneIndex = runeindex;
 }
 internal HotbarSkill GetSkill(HotbarSlot slot)
 {
     HotbarSkill skill;
     return _skillBySlot.TryGetValue(slot, out skill) ? skill : new HotbarSkill();
 }
        //public void OpenRift(int level)
        //{
        //    ZetaDia.Me.OpenRift(level);
        //}

        public void SetActiveSkill(SNOPower power, int runeId, HotbarSlot slot)
        {
            ZetaDia.Me.SetActiveSkill(power, runeId, slot);
        }
Exemple #24
0
    public bool RemoveItemFromHotbar(int id, int amount)
    {
        bool       deleteItem = false;
        HotbarSlot slot       = null;

        // First, check if the item requested exists in the database
        Item item = ItemDataBase.instance.GetItemFromList(id);

        if (item != null)
        {
            for (int i = 0; i < hotbarSlots.Count; i++)
            {
                // Check if item exists in hotbar
                HotbarSlot s = hotbarSlots[i];
                if (s.item == item)
                {
                    // Set slot
                    slot = hotbarSlots[i];

                    // item exists, check if it is stackable
                    if (s.item.stackable)
                    {
                        s.amount -= amount;
                        if (s.amount <= 0)
                        {
                            deleteItem = true;
                        }
                    }
                    else
                    {
                        deleteItem = true;
                    }
                    break;
                }
            }

            if (deleteItem)
            {
                slot.gameObject.transform.GetChild(0).GetComponent <Image>().enabled = false;
                slot.amount = 0;
                if (slot == hotbarSlots[curSelectedSlot - 1])
                {
                    curItem = null;
                }
                if (slot.item.stackable)
                {
                    slot.transform.GetChild(2).GetComponent <TextMeshProUGUI>().text = "";
                }
                slot.item = null;
                return(true);
            }
            else
            {
                if (slot.item.stackable)
                {
                    slot.transform.GetChild(2).GetComponent <TextMeshProUGUI>().text = slot.amount.ToString();
                }
                return(true);
            }
        }

        return(false);
    }
 /// <summary>
 ///     Returns the rune index (integer) from a given Hotbar slot
 /// </summary>
 /// <param name="slot"></param>
 /// <returns></returns>
 internal static int GetRuneIndexFromSlot(HotbarSlot slot)
 {
     return(ZetaDia.CPlayer.GetRuneIndexForSlot(slot));
 }
 public ActiveSkill(SNOPower power, int runeIndex, HotbarSlot slot)
 {
     Power     = power;
     RuneIndex = runeIndex;
     Slot      = slot;
 }
Exemple #27
0
 public void setHotbarSlot(HotbarSlot hotbarSlot)
 {
     this.hotbarSlot = hotbarSlot;
 }
Exemple #28
0
 // Updates itemslot UI
 private void UpdateItemSlotUi(HotbarSlot hotbarSlot, ItemStack itemStack)
 {
     hotbarSlot.UpdateItemUi(itemStack);
 }
Exemple #29
0
 public HotbarSkill(HotbarSlot slot, SNOPower power, int runeindex)
 {
     Slot      = slot;
     Power     = power;
     RuneIndex = runeindex;
 }
 /// <summary>
 ///     Returns the current Power from a given Hotbar slot
 /// </summary>
 /// <param name="slot"></param>
 /// <returns></returns>
 internal static SNOPower GetPowerFromSlot(HotbarSlot slot)
 {
     return(ZetaDia.CPlayer.GetPowerForSlot(slot));
 }