Skip to content

Commit

Permalink
First phase (playable game) is finished; Next phase is ml-agents inte…
Browse files Browse the repository at this point in the history
…gration
  • Loading branch information
kori4r2 committed Nov 25, 2018
1 parent 2cbabdc commit 010b35f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Assets/Scripts/Battle/BattleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public static class BattleManager{
foreach(Button button in survivor.skillButtons) {
button.interactable = false;
}
GameObject message = Resources.Load("WinMessage") as GameObject;

GameObject message = GameObject.Instantiate(Resources.Load("WinMessage") as GameObject, GameObject.Find("Canvas").transform);
message.GetComponentInChildren<Text>().text += winningTeam;
ButtonFunctions.SetEndGame(message.GetComponent<Button>());
GameObject.Instantiate(message, GameObject.Find("Canvas").transform);
message.GetComponent<Button>().onClick.AddListener(ButtonFunctions.EndGame);
battleStarted = false;
}
public static void StartTurn() {
Expand Down
15 changes: 2 additions & 13 deletions Assets/Scripts/UI/ButtonFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using UnityEngine.UI;

public class ButtonFunctions : MonoBehaviour{
private Button endGameButton;
public void SkillPressed() {
// The name of each button gameobject must be the same as the name of the skill
// The ideal implementation would use IDs but let's keep it simple
Expand All @@ -17,19 +16,9 @@ public class ButtonFunctions : MonoBehaviour{
BattleManager.targetUnit = EventSystem.current.currentSelectedGameObject.GetComponentInParent<Unit>();
BattleManager.TargetSelected();
}
public static void SetEndGame(Button button) {
Debug.Log("Assigning button");
ButtonFunctions script = GameObject.Find("Main Camera").GetComponent<ButtonFunctions>();
script.endGameButton = button;
button.onClick.AddListener((UnityEngine.Events.UnityAction)script.EndGame);
}
public void EndGame() {
Debug.Log("Button was pressed");
endGameButton.GetComponentInChildren<Text>().text.Remove(17);
public static void EndGame() {
#if UNITY_EDITOR
// Application.Quit() does not work in the editor so
// UnityEditor.EditorApplication.isPlaying need to be set to false to end the game
UnityEditor.EditorApplication.Exit(0);
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
Expand Down

0 comments on commit 010b35f

Please sign in to comment.