public void DeselectAbility()
 {
     abilitiyMenu.abilities[abilities[menuIndex.Get()].description.id].saveInfo.isSelected = false;
     abilities[menuIndex.Get()]         = new Ability.AbilitySettings();
     abilities[menuIndex.Get()].texture = nullAbilityTexture;
     selectedImage = new BlinkTexture(nullAbilityTexture, blinkControl);
 }
 public void DeselectAbility(int index)
 {
     abilities[index]         = new Ability.AbilitySettings();
     abilities[index].texture = nullAbilityTexture;
     if (index == menuIndex.Get())
     {
         selectedImage = new BlinkTexture(nullAbilityTexture, blinkControl);
     }
 }
    public void DeselectAbility()
    {
        if (menuIndex.Get() >= numberOfSlots)
        {
            return;
        }

        abilities.Remove(abilities[menuIndex.Get()]);
        if (abilities.Count != 0)
        {
            menuIndex.Set(0);
            selectedImage = new BlinkTexture(abilities[0].texture, blinkControl);
        }
    }
    public override void Update()
    {
        int before = menuIndex.Get();

        base.Update();

        if (before != menuIndex.Get())
        {
            if (elements.Count > 0)
            {
                selectedImage = new BlinkTexture(elements[menuIndex.Get()].texture, blinkControl);
            }
        }

        selectedImage.Update();
        elementImage.AdjustToSquare();
    }
    public void Init(List <Ability.AbilitySettings> elements)
    {
        base.Init(new CircularIndex(elements.Count), new CircularIndex(backgrounds.Length));
        this.elements = elements;

        styleTitle                  = new GUIStyle();
        styleTitle.alignment        = TextAnchor.MiddleCenter;
        styleTitle.fontSize         = fontSize;
        styleTitle.font             = font;
        styleTitle.wordWrap         = true;
        styleTitle.normal.textColor = Color.white;

        if (elements.Count > 0)
        {
            selectedImage = new BlinkTexture(elements[0].texture, blinkControl);
        }
    }
    public bool ChangeSelectedAbility(Ability.AbilitySettings ability)
    {
        //Debug.Log("Eq length: " + abilities.Length);
        int i;

        for (i = 0; i < numActiveAbilities; i++)
        {
            //Debug.Log(abilities[i].json.id + " --> " + ability.json.id);
            if (abilities[i].description.id == ability.description.id)
            {
                break;
            }
        }

        int addIndex = menuIndex.Get();

        if (numOfSlotsAvailable == 2)
        {
            addIndex = menuIndex.IndexMovedBy(-1);
        }

        if (i < numActiveAbilities)
        {
            //Debug.Log("Found at: " + i);
            if (i == addIndex)
            {
                abilitiyMenu.abilities[abilities[addIndex].description.id].saveInfo.isSelected = false;
                DeselectAbility(i);
                return(false);
            }
            else
            {
                abilities[i] = abilities[addIndex];
            }
        }
        else
        {
            abilitiyMenu.abilities[abilities[addIndex].description.id].saveInfo.isSelected = false;
        }

        abilities[addIndex] = ability;
        abilitiyMenu.abilities[ability.description.id].saveInfo.isSelected     = true;
        abilitiyMenu.abilities[ability.description.id].saveInfo.selectLocation = (Options)addIndex;
        selectedImage = new BlinkTexture(ability.texture, blinkControl);
        return(true);
    }
    /// <summary>
    /// Function to make to control of movement and resizing operations also to change the selected element.
    /// Should be called in Update() of Monobehavior always that menu will be displayed
    /// </summary>
    public void Update(int selectedWeapon)
    {
        if (uiManager.mode != UIManager.Mode.PAUSED)
        {
            menuArea.centerPosition = gameManager.getCurrentCamera().GetTargetPosition();
        }

        int before = menuIndex.Get();

        base.Update();

        if (before != menuIndex.Get())
        {
            selectedImage = new BlinkTexture(weapons.GetWeapon((Commandments.Weapon)menuIndex.Get()).elementActivated, blinkControl);
        }

        selectedImage.Update();
    }
    /// <summary>
    /// Function to make to control of movement and resizing operations also to change the selected element.
    /// Should be called in Update() of Monobehavior always that menu will be displayed
    /// </summary>
    public override void Update()
    {
        int before = menuIndex.Get();

        base.Update();

        if (before != menuIndex.Get())
        {
            selectedImage = new BlinkTexture(abilities[menuIndex.Get()].texture, blinkControl);
        }

        selectedImage.Update();

        if (adjustToSquare)
        {
            menuArea.AdjustToSquare();
        }
    }
    public bool SelectAbility(Ability.AbilitySettings ability)
    {
        if ((abilities.Count == numberOfSlots) && (!ability.saveInfo.isSelected))
        {
            return(false);
        }

        int i;

        for (i = 0; i < abilities.Count; i++)
        {
            if (abilities[i].description.id == ability.description.id)
            {
                break;
            }
        }

        if (i < abilities.Count)
        {
            abilities.Remove(abilities[i]);
            abilitiyMenu.abilities[ability.description.id].saveInfo.isSelected = false;
            if (abilities.Count != 0)
            {
                menuIndex.Set(0);
                selectedImage = new BlinkTexture(abilities[0].texture, blinkControl);
            }
            return(true);
        }

        abilitiyMenu.abilities[ability.description.id].saveInfo.isSelected = true;


        if (abilities.Count >= numberOfSlots)
        {
            return(false);
        }

        abilities.Add(ability);
        if (abilities.Count == 1)
        {
            selectedImage = new BlinkTexture(ability.texture, blinkControl);
        }
        return(true);
    }
    public virtual void Init()
    {
        base.Init(new CircularIndex(maxSlots));
        abilitiyMenu       = UIManager.GetInstance().ability;
        verticalSeparation = false;
        selectedImage      = new BlinkTexture(nullAbilityTexture, blinkControl);

        abilities = new List <Ability.AbilitySettings>();


        foreach (var pair in abilitiyMenu.abilities)
        {
            if (!pair.Value.isActivatable)
            {
                if ((pair.Value.saveInfo.obtained) && (pair.Value.saveInfo.isSelected))
                {
                    SelectAbility(pair.Value);
                }
            }
        }
    }
    public virtual void Init(ref Ability.AbilityDictionary abilities)
    {
        this.abilities = abilities;
        abilitiyMenu   = UIManager.GetInstance().ability;
        activeList     = new List <Ability.AbilitySettings>();

        foreach (KeyValuePair <Ability.AbilityId, Ability.AbilitySettings> pair in abilities)
        {
            if (isSelectable(pair.Value))
            {
                activeList.Add(pair.Value);
            }
        }
        base.Init(new CircularIndex(rows), new CircularIndex(columns));
        selectedBorderBlinked = new BlinkTexture(selectedBorder, blinkControl);
        Update();

        lastRow    = rowIndex.OffsetCopy(0);
        lastColumn = columnIndex.OffsetCopy(0);
        ChangeSelection();
    }
    /// <summary>
    /// Function to initialize some internal properties. Should be called in Start()
    /// </summary>
    public void Init()
    {
        base.Init(new CircularIndex(numActiveAbilities));

        elementBorder.SetParent(menuArea);
        elementContent.SetParent(menuArea);

        gameManager  = GameManager.GetInstance();
        uiManager    = UIManager.GetInstance();
        abilitiyMenu = uiManager.ability;


        abilities = new Ability.AbilitySettings[numActiveAbilities];
        for (int i = 0; i < numActiveAbilities; i++)
        {
            abilities[i]         = new Ability.AbilitySettings();
            abilities[i].texture = nullAbilityTexture;
        }

        foreach (var pair in abilitiyMenu.abilities)
        {
            if (pair.Value.isActivatable)
            {
                if ((pair.Value.saveInfo.obtained) && (pair.Value.saveInfo.isSelected))
                {
                    menuIndex.Set((int)pair.Value.saveInfo.selectLocation);
                    ChangeSelectedAbility(pair.Value);
                }
            }
        }
        menuIndex.Set(0);

        selectedImage = new BlinkTexture(abilities[0].texture, blinkControl);
        if (adjustToSquare)
        {
            menuArea.AdjustToSquare();
        }
    }
    public override void Update()
    {
        int before = menuIndex.Get();

        base.Update();
        if (menuIndex.Get() >= abilities.Count)
        {
            if (before == 0)
            {
                menuIndex.Set(abilities.Count - 1);
            }
            else
            {
                menuIndex.Set(0);
            }
        }

        if (before != menuIndex.Get())
        {
            selectedImage = new BlinkTexture(abilities[menuIndex.Get()].texture, blinkControl);
        }
        selectedImage.Update();
    }
    /// <summary>
    /// Function to initialize some internal properties. Should be called in Start()
    /// </summary>
    public void Init(int weaponsSize, Commandments.Weapon selectedWeapon)
    {
        base.Init(new CircularIndex(weaponsSize));

        gameManager = GameManager.GetInstance();
        uiManager   = UIManager.GetInstance();
        weapons     = uiManager.weapon;

        elementContent.SetParent(onPlay);

        if (weaponsSize > 0)
        {
            selectedImage = new BlinkTexture(weapons.GetWeapon(selectedWeapon).elementActivated, blinkControl);
            menuIndex.Set(selectedWeapon.toInt());
        }

        onPlay.AdjustToSquare();
        onPause.AdjustToSquare();

        weaponPauseBGArea.SetParent(onPause);
        weaponPauseArea.SetParent(weaponPauseBGArea);
        pauseBG.SetParent(onPause);
    }
 public void ChangeWeaponIndex(Commandments.Weapon weapon)
 {
     menuIndex.Set(weapon.toInt());
     selectedImage = new BlinkTexture(weapons.GetWeapon(weapon).elementActivated, blinkControl);
 }