You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.6 KiB
95 lines
2.6 KiB
using UnityEngine; |
|
using UnityEngine.UI; |
|
using Ability; |
|
using TMPro; |
|
|
|
public class MainAbilityIcon : MonoBehaviour |
|
{ |
|
[SerializeField] MainAbilityType m_type; |
|
[SerializeField] int m_weight; |
|
Image m_image; |
|
[SerializeField] TextMeshProUGUI m_lvlUpLabel; |
|
[SerializeField] Sprite m_unactiveSprite; |
|
Sprite m_activeSprite; |
|
|
|
GameObject m_icon; |
|
|
|
bool m_isActive = false; |
|
|
|
//----------------------------------------------------------------------------------------- |
|
public int Weight |
|
{ |
|
get { return m_weight; } |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
public bool IsActive |
|
{ |
|
get { return m_isActive; } |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
public MainAbilityType Type |
|
{ |
|
get { return m_type; } |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
void Start () |
|
{ |
|
|
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
public void Init() |
|
{ |
|
m_image = GetComponent<Image>(); |
|
m_activeSprite = m_image.sprite; |
|
m_icon = transform.Find("icon").gameObject; |
|
|
|
InitTextLabels(); |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
void InitTextLabels() |
|
{ |
|
Transform nameTrans = transform.Find("name"); |
|
if (nameTrans) |
|
nameTrans.GetComponent<TextMeshProUGUI>().text = CommonFunctions.GetMainAbilityNameStr(m_type); |
|
else |
|
CommonFunctions.myassert(false); |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
public void SetLvlUp(int lvlUp) |
|
{ |
|
if (m_lvlUpLabel) |
|
m_lvlUpLabel.text = lvlUp.ToString(); |
|
else |
|
CommonFunctions.myassert(false); |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
public void SetActiveState() |
|
{ |
|
bool isActive = GlobalsVar.gMainAbilities.GetAbilityActiveByType(m_type); |
|
m_isActive = isActive; |
|
|
|
if (isActive) |
|
{ |
|
m_image.sprite = m_activeSprite; |
|
m_icon.GetComponent<Image>().material = null; |
|
} |
|
else |
|
{ |
|
m_image.sprite = m_unactiveSprite; |
|
m_icon.GetComponent<Image>().material = GlobalsVar.gGrayscaleMaterial; |
|
} |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
void Update () |
|
{ |
|
|
|
} |
|
}
|
|
|