178 lines
6.2 KiB
C#
178 lines
6.2 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Improved_Health_Bars.Scripts
|
|
{
|
|
public class ButtonsTriggerScript : MonoBehaviour
|
|
{
|
|
|
|
public Button minorDmgBtn;
|
|
public Button majorDmgBtn;
|
|
public Button fatalDmgBtn;
|
|
public Button recoverFullHpBtn;
|
|
public Button recoverHalfHpBtn;
|
|
public Button recoverThirtyBtn;
|
|
public Button useHealSkillBtn;
|
|
public Button openNaturalHealBtn;
|
|
public Button closeNaturalHealBtn;
|
|
public Button recoverFiftyManaBtn;
|
|
public Button openNaturalManaBtn;
|
|
public Button closeNaturalManaBtn;
|
|
public Button emptyAllBtn;
|
|
public Button recoverAllBtn;
|
|
public Button openDotDmgBtn;
|
|
public Button closeDotDmgBtn;
|
|
public GameObject health1;
|
|
public GameObject health2;
|
|
public GameObject health3;
|
|
private HealthScript hp1hs;
|
|
private HealthScript hp2hs;
|
|
private HealthScript hp3hs;
|
|
private ManaScript mp1hs;
|
|
private ManaScript mp2hs;
|
|
private ManaScript mp3hs;
|
|
|
|
void Start()
|
|
{
|
|
hp1hs = health1.GetComponent<HealthScript>();
|
|
hp2hs = health2.GetComponent<HealthScript>();
|
|
hp3hs = health3.GetComponent<HealthScript>();
|
|
mp1hs = health1.GetComponent<ManaScript>();
|
|
mp2hs = health2.GetComponent<ManaScript>();
|
|
mp3hs = health3.GetComponent<ManaScript>();
|
|
minorDmgBtn.onClick.AddListener(delegate
|
|
{
|
|
hp1hs.DamageHealth(Random.Range(5, 11));
|
|
hp2hs.DamageHealth(Random.Range(5, 11));
|
|
hp3hs.DamageHealth(Random.Range(5, 11));
|
|
});
|
|
majorDmgBtn.onClick.AddListener(delegate
|
|
{
|
|
hp1hs.DamageHealth(Random.Range(50, 101));
|
|
hp2hs.DamageHealth(Random.Range(50, 101));
|
|
hp3hs.DamageHealth(Random.Range(50, 101));
|
|
});
|
|
fatalDmgBtn.onClick.AddListener(delegate
|
|
{
|
|
hp1hs.DamageHealth(hp1hs.maxHP);
|
|
hp2hs.DamageHealth(hp2hs.maxHP);
|
|
hp3hs.DamageHealth(hp3hs.maxHP);
|
|
});
|
|
recoverFullHpBtn.onClick.AddListener(delegate
|
|
{
|
|
hp1hs.RestoreHealth(hp1hs.maxHP);
|
|
hp2hs.RestoreHealth(hp2hs.maxHP);
|
|
hp3hs.RestoreHealth(hp3hs.maxHP);
|
|
});
|
|
recoverHalfHpBtn.onClick.AddListener(delegate
|
|
{
|
|
hp1hs.RestoreHealth(hp1hs.maxHP * 0.5f);
|
|
hp2hs.RestoreHealth(hp2hs.maxHP * 0.5f);
|
|
hp3hs.RestoreHealth(hp3hs.maxHP * 0.5f);
|
|
});
|
|
recoverThirtyBtn.onClick.AddListener(delegate
|
|
{
|
|
hp1hs.RestoreHealth(30);
|
|
hp2hs.RestoreHealth(30);
|
|
hp3hs.RestoreHealth(30);
|
|
});
|
|
useHealSkillBtn.onClick.AddListener(delegate
|
|
{
|
|
if (mp1hs.currentMana >= 20)
|
|
{
|
|
hp1hs.RestoreHealth(25);
|
|
mp1hs.DamageMana(20);
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("You Don't Have Enough Mana");
|
|
}
|
|
|
|
if (mp2hs.currentMana >= 20)
|
|
{
|
|
hp2hs.RestoreHealth(25);
|
|
mp2hs.DamageMana(20);
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("You Don't Have Enough Mana");
|
|
}
|
|
|
|
if (mp3hs.currentMana >= 20)
|
|
{
|
|
hp3hs.RestoreHealth(25);
|
|
mp3hs.DamageMana(20);
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("You Don't Have Enough Mana");
|
|
}
|
|
});
|
|
openNaturalHealBtn.onClick.AddListener(delegate
|
|
{
|
|
// you can set natural healing amounts from health script
|
|
hp1hs.SetNaturalHealing();
|
|
hp2hs.SetNaturalHealing();
|
|
hp3hs.SetNaturalHealing();
|
|
});
|
|
closeNaturalHealBtn.onClick.AddListener(delegate
|
|
{
|
|
hp1hs.StopNaturalHealing();
|
|
hp2hs.StopNaturalHealing();
|
|
hp3hs.StopNaturalHealing();
|
|
});
|
|
recoverFiftyManaBtn.onClick.AddListener(delegate
|
|
{
|
|
mp1hs.RestoreMana(50);
|
|
mp2hs.RestoreMana(50);
|
|
mp3hs.RestoreMana(50);
|
|
});
|
|
openNaturalManaBtn.onClick.AddListener(delegate
|
|
{
|
|
mp1hs.SetNaturalMana();
|
|
mp2hs.SetNaturalMana();
|
|
mp3hs.SetNaturalMana();
|
|
});
|
|
closeNaturalManaBtn.onClick.AddListener(delegate
|
|
{
|
|
mp1hs.StopNaturalMana();
|
|
mp2hs.StopNaturalMana();
|
|
mp3hs.StopNaturalMana();
|
|
});
|
|
emptyAllBtn.onClick.AddListener(delegate
|
|
{
|
|
hp1hs.DamageHealth(hp1hs.maxHP);
|
|
hp2hs.DamageHealth(hp2hs.maxHP);
|
|
hp3hs.DamageHealth(hp3hs.maxHP);
|
|
mp1hs.DamageMana(mp1hs.maxMana);
|
|
mp2hs.DamageMana(mp2hs.maxMana);
|
|
mp3hs.DamageMana(mp3hs.maxMana);
|
|
});
|
|
recoverAllBtn.onClick.AddListener(delegate
|
|
{
|
|
hp1hs.isDead = false;
|
|
hp2hs.isDead = false;
|
|
hp3hs.isDead = false;
|
|
hp1hs.RestoreHealth(hp1hs.maxHP);
|
|
hp2hs.RestoreHealth(hp2hs.maxHP);
|
|
hp3hs.RestoreHealth(hp3hs.maxHP);
|
|
mp1hs.RestoreMana(mp1hs.maxMana);
|
|
mp2hs.RestoreMana(mp2hs.maxMana);
|
|
mp3hs.RestoreMana(mp3hs.maxMana);
|
|
});
|
|
openDotDmgBtn.onClick.AddListener(delegate
|
|
{
|
|
hp1hs.SetDotDamage(3, 1, 5);
|
|
hp2hs.SetDotDamage(4, 2, 10);
|
|
hp3hs.SetDotDamage(7, 3, 15);
|
|
});
|
|
closeDotDmgBtn.onClick.AddListener(delegate
|
|
{
|
|
hp1hs.StopDotDmg();
|
|
hp2hs.StopDotDmg();
|
|
hp3hs.StopDotDmg();
|
|
});
|
|
}
|
|
|
|
}
|
|
} |