Created
June 6, 2019 19:51
-
-
Save pr00thmatic/5dd54c9038a2966987d3347242295839 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
public class BallVictoryTriggerer : MonoBehaviour { | |
void OnEnable () { | |
} | |
void OnDisable () { | |
GameManager.OnGameEndingTriggered -= Asdf; | |
} | |
void Update () { | |
if (Input.GetKeyDown(KeyCode.Space)) { | |
GameManager.OnGameEndingTriggered += Asdf; | |
print("bola avisándole a game manager"); | |
GameManager.TriggerVictory(); | |
} | |
} | |
public void Asdf (GameMode mode) { | |
print(mode + "!!!!!!"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
public class GameManager : MonoBehaviour { | |
public static GameManager instance; | |
public static event Action<GameMode> OnGameEndingTriggered; | |
void Awake () { | |
if (instance != null && instance != this) { | |
Destroy(this); | |
return; | |
} | |
} | |
public static void TriggerVictory () { | |
if (OnGameEndingTriggered != null) { | |
print("game manager disparando el evento"); | |
OnGameEndingTriggered(GameMode.Victory); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
public class UIManager : MonoBehaviour { | |
void OnEnable () { | |
GameManager.OnGameEndingTriggered += Avisar; | |
} | |
void OnDisable () { | |
GameManager.OnGameEndingTriggered -= Avisar; | |
} | |
public void Avisar (GameMode gameMode) { | |
print(gameMode); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment