Here is what I did to have a K.O.-text and soundfile in our game.
Maybe it's not the best way, but it works
At first open up "GlobalInfo.CS" to create a variable for the K.O.-text and K.O.-soundfile:
after
public string timeOver = "Time Over";
public string perfect = "Perfect!";
public string rematch = "Rematch";
public string quit = "Quit";
add this:
public string kotext = "K.O.";
next edit in the same file:
after:
public AudioClip firstHit;
public AudioClip counterHit;
public AudioClip parry;
public AudioClip timeOver;
add this:
public AudioClip kosound;
...
Now go to your UFE.config file and select GUI-options -> Screens -> Battle GUI (open)
Assign a soundfile to the new AudioClip-field:
Open up "GlobalEditorWindow.cs":
after:
globalInfo.languages[i].rematch = EditorGUILayout.TextField("Rematch:", globalInfo.languages[i].rematch);
globalInfo.languages[i].quit = EditorGUILayout.TextField("Quit:", globalInfo.languages[i].quit);
add this:
globalInfo.languages[i].kotext = EditorGUILayout.TextField("K.O.:", globalInfo.languages[i].kotext);
Now you can set the text-string for the K.O.-message by changing the setting in the UFE.config:
Next edit the UFE.cs-file:
after:
public static GameObject gameEngine{get; protected set;}
public static bool gameRunning{get; protected set;}
public static bool synchronizedRandomSeed{get; protected set;}
add this:
public static bool koflag = 0;
Next edit the ControlScript.cs:
after this:
if (myInfo.currentLifePoints == 0){
UFE.PlaySound(myInfo.deathSound);
add this:
This will set the K.O.-flag to "true" if someone gets knocked out.
Now open your DefaultBattleGUI.cs
After:
public override void DoFixedUpdate (){
base.DoFixedUpdate ();
if (this.isRunning){
AbstractInputController p1InputController = UFE.GetPlayer1Controller();
AbstractInputController p2InputController = UFE.GetPlayer2Controller();
float deltaTime = Time.fixedDeltaTime;
Add:
//**************** K.O.-text and sound *************************
if (UFE.koflag == true)
{
UFE.koflag = false;
UFE.PlaySound(this.announcer.kosound);
this.OnNewAlert(UFE.config.selectedLanguage.kotext, null);
}
If you want to add your custom K.O.-animation/text you can also spawn it in the code snippet above.
Finally add after:
protected override void OnRoundBegin(int roundNumber){
base.OnRoundBegin(roundNumber);
This:
Here is a quick video how it looks ingame:
[media]https://youtu.be/IIMKLyAb-64[/media]
Good luck, I hope it works for you