Example #1
0
    public void Init(Pawn pawn)
    {
        pawnIcon.Init(pawn);
        // Get Hero data
        HeroData heroData = DataManager.GetHeroData(pawn.type);
        // Initialize the hero's power up info
        HeroPowerUpListData powerUpListData = DataManager.GetPowerUpListData(pawn.type);
        int numPowerUpsUnlocked             = HeroPowerUpListData.GetNumPowerUpsUnlocked(pawn.level);

        for (int i = 0; i < HeroPowerUpListData.powerUpUnlockLevels.Length; i++)
        {
            // If the hero has unlocked this powerUp
            bool            locked        = i >= numPowerUpsUnlocked;
            int             unlockedLevel = HeroPowerUpListData.powerUpUnlockLevels[i];
            HeroPowerUpData data          = powerUpListData.powerUps[i].GetComponent <HeroPowerUp>().data;
            // Get the key for NewFeatureIndicator
            string newKey = GetViewedPowerKey(i);
            heroPowerUpInfoIcons[i].GetComponent <HeroPowerUpInfoIcon>().Init(data, locked, newKey, unlockedLevel);
            heroPowerUpInfoIcons[i].GetComponent <ScrollingTextOption>().scrollingText = infoText;
        }
        // Reset MidPanel Menu
        midPanelTabToggleGroup.SetAllTogglesOff();
        // Due to some stupid bug we have to wait one frame before initializing the scroll view
        StartCoroutine(ForcePosAfter1Frame());
        // Initialize the scrolling text to display info about the hero
        infoText.defaultText = heroData.heroDescription;
        infoText.SetToDefaultText();
        // Initialize NewFeatureIndicator
        newTextPowers.RegisterKey(HasPlayerViewedPowersTabKey);
        newTextAbilities.RegisterKey(HasPlayerViewedAbilitiesTabKey);
        newAbility[0].RegisterKey(GetViewedAbilityKey('0'));
        newAbility[1].RegisterKey(GetViewedAbilityKey('1'));
        newSpecial.RegisterKey(GetViewedAbilityKey('S'));

        // Initialize Abilities Panel
        abilityIcon1.GetComponent <Image>().sprite                   = heroData.abilityIcons[0];
        abilityIcon2.GetComponent <Image>().sprite                   = heroData.abilityIcons[1];
        specialAbilityIcon.GetComponent <Image>().sprite             = heroData.specialAbilityIcon;
        abilityIcon1.GetComponent <ScrollingTextOption>().text       = heroData.ability1Description;
        abilityIcon2.GetComponent <ScrollingTextOption>().text       = heroData.ability2Description;
        specialAbilityIcon.GetComponent <ScrollingTextOption>().text = heroData.specialDescription;
        abilityIcon1.GetComponent <Toggle>().isOn       = false;
        abilityIcon2.GetComponent <Toggle>().isOn       = false;
        specialAbilityIcon.GetComponent <Toggle>().isOn = false;
    }
Example #2
0
    public void Init(HeroPowerUpData data, bool locked, string key, int unlockLevel = 0)
    {
        // Init variables
        this.key    = key;
        this.data   = data;
        icon.sprite = data.icon;

        if (locked)
        {
            newPowerUp.gameObject.SetActive(false);
            icon.color = Color.gray;
            scrollingTextOption.text = string.Format("LOCKED: Unlocked at level {0}", unlockLevel);
        }
        else
        {
            newPowerUp.RegisterKey(key);                // Only indicate that the powerup is new if it has been unlocked
            icon.color = Color.white;
            scrollingTextOption.text = data.description;
            toggle.onValueChanged.AddListener(SetViewedPower);
        }
    }