Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考
此代码仅为较上一P有所改变的代码
【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili
Parry_Skill.cs
using UnityEngine;
using UnityEngine.UI;
public class Parry_Skill : Skill
{
[Header("Perry")]
[SerializeField] private UI_SkillTreeSlot parryUnlockButton;
public bool parryUnlocked { get; private set; }
[Header("Restore Health")]
[SerializeField] private UI_SkillTreeSlot restoreUnlockButton;
[Range(0f, 1f)]
[SerializeField] private float restoreHealthPerentage;
public bool restoreUnlocked{ get; private set; }
[Header("Parry Mirage")]
[SerializeField] private UI_SkillTreeSlot parryWithUnlockButton;
public bool parryWithMirageUnlocked { get; private set; }
public override void UseSkill()
{
base.UseSkill();
if (restoreUnlocked)
{
int restoreAmount = Mathf.RoundToInt(player.stats.GetMaxHealthValue() * restoreHealthPerentage);
player.stats.IncreaseHealthBy(restoreAmount);
}
}
protected override void Start()
{
base.Start();
parryUnlockButton.GetComponent<Button>().onClick.AddListener(UnlockParry);
restoreUnlockButton.GetComponent<Button>().onClick.AddListener(UnlockParryRestore);
parryWithUnlockButton.GetComponent<Button>().onClick.AddListener(UnlockParryWithMirage);
}
private void UnlockParry()
{
Debug.Log(2);
if (parryUnlockButton.unlocked)
{
parryUnlocked = true;
}