Topic: Training Mode - Show Damage and Refill Health
Since the next UFE update is a few months away, thought I'd post this in case anyone else was wanting to get their training modes a little more fleshed out.
This is just a simple implementation of refilling health, with the time delay exposed under the Training Mode checkbox. I recommend testing what delay works best for your game as each game will feel different, especially when considering wake up times.
In GlobalInfo.cs, after line:
public bool trainingMode; // NOT COMPLETE
add:
public float updateHealthInSeconds = 3;
In GlobalEditorWindow.cs, after line:
globalInfo.trainingMode = EditorGUILayout.Toggle("Training Mode", globalInfo.trainingMode);
add:
if (globalInfo.trainingMode) {
globalInfo.updateHealthInSeconds = EditorGUILayout.FloatField("Update Health Time:", globalInfo.updateHealthInSeconds);
}
Then in ControlsScript.cs
above:
void Start () {
add:
private float trainingTimeToHealthFull;
private bool trainingCanUpdateHealth = false;
… then, just under:
void Update() {
add:
if (UFE.config.trainingMode) {
if (trainingCanUpdateHealth && Time.timeSinceLevelLoad >= trainingTimeToHealthFull) {
myInfo.currentLifePoints = myInfo.lifePoints;
trainingCanUpdateHealth = false;
}
}
… and finally replace the whole private bool DamageMe(float damage) method with:
private bool DamageMe(float damage){
if (UFE.config.trainingMode) {
trainingTimeToHealthFull = Time.timeSinceLevelLoad + UFE.config.updateHealthInSeconds;
trainingCanUpdateHealth = true;
} else {
if (myInfo.currentLifePoints <= 0 || opInfo.currentLifePoints <= 0) return true;
}
if (UFE.GetTimer() <= 0 && UFE.config.roundOptions.hasTimer) return true;
myInfo.currentLifePoints -= damage;
UFE.SetLifePoints(myInfo.currentLifePoints, myInfo);
if (myInfo.currentLifePoints <= 0 && !UFE.config.trainingMode){
UFE.PlaySound(myInfo.deathSound);
UFE.PauseTimer();
if (UFE.config.roundOptions.slowMotionKO){
Time.timeScale = Time.timeScale * .2f;
Invoke("ReturnTimeScale", .4f); // Low timer to account for the slowmotion
}else{
Invoke("EndRound", 3);
}
return true;
}
return false;
}
Careful with that last one, there are two DamageMe methods, make sure you replace DamageMe(float damage) and not DamageMe(float damage, bool doesntKill)!!