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.
81 lines
2.8 KiB
81 lines
2.8 KiB
using System; |
|
using Ability; |
|
using TMPro; |
|
using JetBrains.Annotations; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
namespace Special |
|
{ |
|
[Serializable] |
|
public class Ability |
|
{ |
|
public InGameAbType AbType; |
|
public Sprite Sprite; |
|
} |
|
|
|
public class AbilityItem : MonoBehaviour |
|
{ |
|
[SerializeField] private Image _icon; |
|
[SerializeField] private Button _button; |
|
[SerializeField] private GameObject _title; |
|
|
|
private Ability _abInfo; |
|
|
|
public void Create(Ability abInfo, RectTransform rect, bool interactable) |
|
{ |
|
var item = Instantiate(this, rect); |
|
item.Repaint(abInfo, interactable); |
|
} |
|
|
|
private void Repaint(Ability abInfo, bool interactable) |
|
{ |
|
_button.enabled = interactable; |
|
_abInfo = abInfo; |
|
_icon.sprite = abInfo.Sprite; |
|
if (_title) |
|
{ |
|
string titleStr = ""; |
|
if (abInfo.AbType == InGameAbType.HEAL) |
|
titleStr = GlobalsVar.gGameTextMng.GetGameText(35); |
|
else if (abInfo.AbType == InGameAbType.ADD_HEALTH) |
|
titleStr = GlobalsVar.gGameTextMng.GetGameText(36); |
|
else if (abInfo.AbType == InGameAbType.ADD_MINOR_DAMAGE) |
|
titleStr = GlobalsVar.gGameTextMng.GetGameText(37); |
|
else if (abInfo.AbType == InGameAbType.ADD_MINOR_SPEED) |
|
titleStr = GlobalsVar.gGameTextMng.GetGameText(38); |
|
else if (abInfo.AbType == InGameAbType.DECAY) |
|
titleStr = string.Format(GlobalsVar.gGameTextMng.GetGameText(46), 100); |
|
else if (abInfo.AbType == InGameAbType.ADD_DAMAGE) |
|
titleStr = GlobalsVar.gGameTextMng.GetGameText(47); |
|
else if (abInfo.AbType == InGameAbType.ADD_ATTACK_SPEED) |
|
titleStr = GlobalsVar.gGameTextMng.GetGameText(48); |
|
else if (abInfo.AbType == InGameAbType.ADD_BULLET_PARALLEL) |
|
titleStr = GlobalsVar.gGameTextMng.GetGameText(49); |
|
else if (abInfo.AbType == InGameAbType.ADD_BULLET_AFTER) |
|
titleStr = GlobalsVar.gGameTextMng.GetGameText(49); |
|
|
|
_title.GetComponent<TextMeshProUGUI>().text = titleStr; |
|
} |
|
} |
|
|
|
[UsedImplicitly] |
|
public void Click() |
|
{ |
|
if (_abInfo.AbType == InGameAbType.HEAL || _abInfo.AbType == InGameAbType.ADD_HEALTH) |
|
SoundsManager.Instance.PlaySound("heal"); |
|
|
|
if (GlobalsVar.gBoard) |
|
{ |
|
GameBoard gameBoard = GlobalsVar.gBoard as GameBoard; |
|
if (gameBoard != null) |
|
{ |
|
gameBoard.MainCharacter.AddAbility(_abInfo.AbType); |
|
|
|
GameObject dlgObj = gameBoard.GetDialogByType(DialogType.ANGEL); |
|
dlgObj.GetComponent<AngelHelp>().HideDialog(); |
|
} |
|
} |
|
} |
|
} |
|
}
|
|
|