function OnEnable () {
Regenerate ();
}
function Regenerate () {
if (regenerateSpeed > 0.0f) {
while (enabled) {
if (Time.time > lastDamageTime + 3) {
health += regenerateSpeed;
yield;
if (health >= maxHealth) {
health = maxHealth;
enabled = false;
}
}
yield WaitForSeconds (1.0f);
}
}
}
时间: 2024-10-13 20:09:40