예제 #1
0
    private void updatePage()
    {
        List <UIIconButton> buttons = new List <UIIconButton>();

        buttons.Add(centerButton);

        buttonMap = new Dictionary <UISelectable, Character>();

        foreach (Character character in PlacementController.charactersToPlace)
        {
            Character    c          = character;
            UIIconButton iconButton = Instantiate(iconButtonPrefab);
            iconButton.SetIconSprite(character.identity.icon);
            iconButton.transform.SetParent(iconButtonParent);
            iconButton.onClick.AddListener(() => click(c));

            buttons.Add(iconButton);
        }

        for (int i = 0; i < buttons.Count; i++)
        {
            buttons[i].neighborLeft  = buttons[NeverdawnUtility.RepeatIndex(i - 1, buttons.Count)];
            buttons[i].neighborRight = buttons[NeverdawnUtility.RepeatIndex(i + 1, buttons.Count)];
        }

        buttons[0].Select();
    }
예제 #2
0
    void Start()
    {
        buttons = new List <UIIconButton>();

        foreach (AbilityBase ability in combatItem.abilities)
        {
            UIAbilityIconButton button = Instantiate(UIFactory.uiAbilityButton);
            button.ability = ability;
            button.menu    = menu;
            button.label   = label;

            buttons.Add(button);
        }

        UIIconButton buttonCancel = Instantiate(UIFactory.uiIconButton);

        buttonCancel.SetIconSprite(iconCancel);
        buttonCancel.onSelect.AddListener(() => label.text = labelCancel);
        buttonCancel.onClick.AddListener(() => menu.GoBack());
        buttons.Add(buttonCancel);

        for (int i = 0; i < buttons.Count; i++)
        {
            buttons[i].transform.SetParent(buttonParent);
            buttons[i].neighborLeft  = buttons[NeverdawnUtility.RepeatIndex(i - 1, buttons.Count)];
            buttons[i].neighborRight = buttons[NeverdawnUtility.RepeatIndex(i + 1, buttons.Count)];
        }
    }
예제 #3
0
    void Start()
    {
        buttons = new List <UIIconButton>();

        if (character.mannequin)
        {
            foreach (CombatItem item in character.mannequin.GetEquippedCombatItems())
            {
                UICombatItemIconButton combatItemButton = Instantiate(UIFactory.uiCombatItemButton);
                combatItemButton.combatItem = item;
                combatItemButton.menu       = menu;
                combatItemButton.label      = label;
                buttons.Add(combatItemButton);
            }
        }

        if (character.unarmed)
        {
            UICombatItemIconButton combatItemButton = Instantiate(UIFactory.uiCombatItemButton);
            combatItemButton.combatItem  = character.unarmed;
            combatItemButton.menu        = menu;
            combatItemButton.label       = label;
            combatItemButton.customLabel = "Self";
            buttons.Add(combatItemButton);
        }

        if (includeWalk)
        {
            AbilityBase walkAbility = Instantiate(CombatController.walkAbility);
            walkAbility.Initialize(character.gameObject);

            UIAbilityIconButton walkButton = Instantiate(UIFactory.uiAbilityButton);
            walkButton.ability = walkAbility;
            walkButton.menu    = menu;
            walkButton.label   = label;
            buttons.Add(walkButton);
        }

        if (includeDoNothing)
        {
            UIIconButton buttonDoNothing = Instantiate(UIFactory.uiIconButton);
            buttonDoNothing.SetIconSprite(iconDoNothing);
            buttonDoNothing.onSelect.AddListener(() => label.text = labelDoNothing);
            buttonDoNothing.onClick.AddListener(() => doNothing());
            buttons.Add(buttonDoNothing);
        }

        for (int i = 0; i < buttons.Count; i++)
        {
            buttons[i].transform.SetParent(buttonParent);
            buttons[i].neighborLeft  = buttons[NeverdawnUtility.RepeatIndex(i - 1, buttons.Count)];
            buttons[i].neighborRight = buttons[NeverdawnUtility.RepeatIndex(i + 1, buttons.Count)];
        }
    }
예제 #4
0
    /// <summary>
    /// Draw the atlas and sprite selection fields.
    /// </summary>

    public override void OnInspectorGUI()
    {
        EditorGUIUtility.labelWidth = 80f;
        mButton = target as UIIconButton;

        UISprite sprite = EditorGUILayout.ObjectField("Icon Sprite", mButton.sprite, typeof(UISprite), true) as UISprite;
        UIButton button = EditorGUILayout.ObjectField("Button", mButton.button, typeof(UIButton), true) as UIButton;

        UIIconButton.UIIconButtonTypes type = (UIIconButton.UIIconButtonTypes)EditorGUILayout.EnumPopup("Icon", mButton.type);

        if (mButton.sprite != sprite || mButton.button != button || mButton.type != type)
        {
            mButton.sprite = sprite;
            mButton.button = button;
            mButton.type   = type;
        }
    }
    // Use this for initialization
    void Start()
    {
        GetComponent <SelectionControllerBase>().inputModule = avatarController.inputModule;

        character = avatarController.character;

        for (int i = 0; i < character.quickCastAbilities.Length; i++)
        {
            AbilityBase ability = character.quickCastAbilities[i];

            if (ability != null)
            {
                iconButtons[i].SetIconSprite(ability.icon);
            }

            int          k      = i;
            UIIconButton button = iconButtons[i];
            button.onSelect.AddListener(() => setIcon(button));
            button.onDeSelect.AddListener(() => resetIcon(k));
        }
    }
예제 #6
0
    // Use this for initialization
    void Start()
    {
        List <UIIconButton> buttons = new List <UIIconButton>();

        buttonMap = new Dictionary <UISelectable, Character>();

        foreach (Character character in possibleTargets)
        {
            UIIconButton iconButton = Instantiate(iconButtonPrefab);
            iconButton.SetIconSprite(character.identity.icon);
            iconButton.transform.SetParent(iconButtonParent);

            buttonMap.Add(iconButton, character);

            buttons.Add(iconButton);
        }

        selectionController.peripherals = buttons.ToArray();
        selectionController.center      = cancelButton;
        selectionController.inputModule = avatarController.inputModule;
    }
 private void setIcon(UIIconButton button)
 {
     button.SetIconSprite(ability.icon);
 }