예제 #1
0
 void Awake()
 {
     player          = GameObject.FindGameObjectWithTag("Player");
     playerAbilities = player.GetComponent <PlayerAbilities>();
     abilityImage    = this.gameObject.GetComponent <Image>();
     selectedAbility = GameObject.Find("SelectedAbility").GetComponent <UIAbility>();
 }
예제 #2
0
    public static UIAbility CreateAbilityUI(string key)
    {
        uiAbilityPrefab = (uiAbilityPrefab) ? uiAbilityPrefab : Resources.Load <GameObject>(PrefabFileDir.UI_ABILITY_RESOURCE_PATH); //
        UIAbility newAbility = GameObject.Instantiate(uiAbilityPrefab, UILinks.instance.abilityGridParent).GetComponent <UIAbility>();

        newAbility.Initialize(key);
        return(newAbility);
        //The above line is creating an object from a prefab, then getting the component from it caleld UIAbility, and returning it, remember this is a static function.
    }
예제 #3
0
    UILinks ui;  //still the same ui links. just a shortcut for less typing

    public void Initialize(PlayerController _player)
    {
        ui     = UILinks.instance;
        player = _player;
        for (int i = 0; i < player.stats.abilities.Count; i++)
        {
            UIAbility.CreateAbilityUI(player.stats.abilities[i].ToString());
        }
    }
예제 #4
0
    public void Load()
    {
        foreach (DamageType domain in m_domains)
        {
            GameObject domainObject = Instantiate(m_domainPrefab, m_contentParent);
            domainObject.transform.Find("Icon").GetComponent <Image>().sprite = domain.m_icon;

            Transform contentParent = domainObject.transform.Find("Scroll View").GetChild(0).GetChild(0);

            List <AbilityWrapper> sortedDomainAbilities = new List <AbilityWrapper>(m_entity.m_abilities.FindAll(a => a.GetAbility().m_domain == domain.m_name));
            sortedDomainAbilities.Sort(new AbilityComparer());
            sortedDomainAbilities.Reverse();

            foreach (AbilityWrapper wrapper in sortedDomainAbilities)
            {
                GameObject      abilityObject = Instantiate(m_abilityPrefab, contentParent);
                Image           abilityIcon   = abilityObject.GetComponent <Image>();
                TextMeshProUGUI trainingLevel = abilityObject.GetComponentInChildren <TextMeshProUGUI>();
                Ability         ability       = wrapper.GetAbility();

                abilityIcon.sprite = ability.m_icon;
                trainingLevel.text = wrapper.TrainingLevel.ToString();

                if (!wrapper.Learned)
                {
                    trainingLevel.text = "";
                    abilityIcon.color  = new Color(1, 1, 1, m_nonLearnedAlpha / 255f);
                }

                UIAbility uiAbility = abilityObject.GetComponent <UIAbility>();

                uiAbility.m_ability = wrapper;
                uiAbility.m_loader  = this;
                uiAbility.Init();

                m_loadedAbilities.Add(uiAbility);
            }
        }
    }