I am still really new to programming and I am having a hard time getting this problem fixed. In the game, Lerpz starts with 4 lives. I want it so when he picks up one of the heart icons, if he is at full health, he gets an extra life. The code works when he is not at full health by adding one point to his overall health, but I can't figure out how to add more lives. I have attempted some things, but like I said, I don't know much about programming.
Do I have to add something to the Pickup script or the ThirdPersonStatus script? Also, what do I add?
The part of the Pickup script that mentions health:
function ApplyPickup (playerStatus : ThirdPersonStatus)
{
// A switch...case statement may seem overkill for this, but it makes adding new pickup types trivial.
switch (pickupType)
{
case PickupType.Health:
playerStatus.AddHealth(amount);
break;
case PickupType.FuelCell:
playerStatus.FoundItem(amount);
break;
}
return true;
}
Part of the ThirdPersonStatus that deals with health/lives:
function AddLife (powerUp : int)
{
lives += powerUp;
health = maxHealth;
}
function AddHealth (powerUp : int)
{
health += powerUp;
if (health>maxHealth) // We can only show six segments in our HUD.
{
health=maxHealth;
}
}
Thanks for the help!