Exemple #1
0
    public void DrawIfHotbarIsUpdated()
    {
        if (hasHotbarUpdated)
        {
            // Draw hotbar items
            for (int i = 0; i < hotbarSize; i++)
            {
                Structs.HotbarSlot hotbarSlot = hotbar[i];
                Spell ability = hotbarSlot.Ability;
                if (ability == null)
                {
                    continue;
                }

                hotbarSlot.UIRawImageComponent.texture = ability.IconTex;
            }

            // Draw selected hotbar border
            foreach (Structs.HotbarSlot slot in hotbar)
            {
                slot.UIImageComponent.color = unselectedColor;
            }

            GetCurrentSelectedSlot().UIImageComponent.color = selectedColor;
            hasHotbarUpdated = false;
        }
    }
Exemple #2
0
 public Hotbar()
 {
     Debug.Log("INITIALIZING HOTBAR");
     Debug.Log($"hotbarSize is {hotbarSize}");
     hotbar = new Structs.HotbarSlot[hotbarSize];
     for (int slot = 0; slot < hotbarSize; slot++)
     {
         // 0-index vs 1-index
         GameObject go = GameObject.Find($"Canvas/HotbarPanel/Slot{slot + 1}");
         hotbar[slot] = new Structs.HotbarSlot(slot, go);
         Debug.Log($"Inserting hotbar slot object: {hotbar[slot]}");
     }
 }