Пример #1
0
 public void SetMinion(MinionTemplate template, MinionSlot setSlot = MinionSlot.NUM_MINION_SLOTS)
 {
     slot = setSlot;
     if (template == null)
     {
         background.sprite = emptyBackground;
         title.text        = "";
         desc.text         = "";
         health.text       = "";
     }
     else
     {
         background.sprite = elementalBackgrounds [(int)template.element];
         title.text        = LocalizationManager.GetLoc(template.unlocName);
         desc.text         = LocalizationManager.GetLoc(template.unlocDesc);
         if (template.GetSlotType() == MinionSlotType.SUPPORT)
         {
             health.text = "-";
         }
         else
         {
             string hpString = LocalizationManager.GetLoc("HP");
             health.text = string.Format(hpString, Mathf.FloorToInt(template.fMaxHealth));
         }
     }
 }
Пример #2
0
    void OnGUI()
    {
        // Set up drag-drop cursor
        Vector3 v = GUIUtility.ScreenToGUIPoint(Event.current.mousePosition);

        dragDrop.rectTransform.position = new Vector3(v.x, Screen.height - v.y, v.z);
        dragDrop.enabled = (dragDropSelection != null);
        if (dragDropSelection != null)
        {
            dragDrop.sprite = dragDropSelection.icon;
        }

        // Listen for events
        if (Event.current.isMouse)
        {
            switch (Event.current.type)
            {
            case EventType.MouseDown:
            {
                Debug.Assert(dragDropSelection == null, "How can we be clicking when we already have a selection?");
                if (hoveringOverPoolEntry != null && hoveringOverPoolEntry.bAvailable)
                {
                    dragDropSelection = hoveringOverPoolEntry.template;
                    foreach (MinionIcon icon in minionIcons)
                    {
                        icon.SetSlotDroppable(dragDropSelection.GetSlotType() == icon.index.GetSlotType());
                    }
                    Core.GetAudioManager().PlayPickupMinion();
                }
                break;
            }

            case EventType.MouseUp:
            {
                if (dragDropSelection != null)
                {
                    if (hoveringOverMinion == MinionSlot.NUM_MINION_SLOTS)
                    {
                        // Meh, do nothing. It returns to the pool automatically
                    }
                    else
                    {
                        if (hoveringOverMinion.GetSlotType() == dragDropSelection.GetSlotType())
                        {
                            currentRoster.SetMinion(hoveringOverMinion, dragDropSelection);
                            Core.GetAudioManager().PlayDropMinion();
                            UpdateMinionIcons();
                            SetComparisonType(currentlyComparing);
                        }
                        else
                        {
                            Core.GetAudioManager().PlayGUIReject();
                        }
                    }

                    //hoverBlock.SetMinion(null);
                    dragDropSelection = null;
                    foreach (MinionIcon icon in minionIcons)
                    {
                        icon.SetSlotDroppable(true);
                    }
                }
                break;
            }
            }
        }
    }
Пример #3
0
    public void ApplyFilters(Filters filters)
    {
        bool bElementalFilterActive = filters.IsAnyElementalFilterActive();
        bool bSlotTypeFilterActive  = filters.IsAnySlotTypeFilterActive();

        int index = 0;

        foreach (MinionPoolGUIEntry entry in allEntries)
        {
            MinionTemplate template = entry.template;
            bool           bAllowed = (!bElementalFilterActive || filters.abElementalFilters [(int)template.element]) &&
                                      (!bSlotTypeFilterActive || filters.abSlotTypeFilters [(int)template.GetSlotType()]) &&
                                      (entry.bAvailable || filters.bShowLocked) &&
                                      (!filters.bShowNewOnly || entry.bNew);
            if (bAllowed)
            {
                entry.SetIndex(index);
                index++;
            }
            else
            {
                entry.SetIndex(-1);
            }
        }

        int numRows = (index + 5) / 6;

        contentBox.sizeDelta = new Vector2(contentBox.sizeDelta.x, 128.0f * numRows + 16.0f);
        ScrollbarValueChanged();
    }