void Awake() { renderer = GetComponent <Renderer>(); showMoveDialog = EventRegistry.GetEvent <ETowerType>("showMoveDialog"); EventRegistry.RegisterAction <bool>("moveTransaction", MoveTransaction); toDestroy = false; }
void Start() { dialogSystem = transform.Find("Dialog")?.GetComponent <DialogSystem>(); cashDisplay = transform.Find("WalletBG/Cash")?.GetComponent <Text>(); // Register events and callbacks createTower = EventRegistry.GetEvent <ETowerType>("createTower"); cancelTowerCreation = EventRegistry.GetEvent("cancelTowerCreation"); EventRegistry.RegisterAction <ETowerType>("showUpgradeDialog", ShowUpgradeDialog); }
public IEnumerator UIShowsUpOnUpgradeClick() { TDEvent <ETowerType> showUpgradeDialog = EventRegistry.GetEvent <ETowerType>("showUpgradeDialog"); showUpgradeDialog.Invoke(ETowerType.Base); GameObject dialogBox = GameObject.Find("UIManager").transform.Find("WalletUI/Dialog").gameObject; yield return(null); Assert.True(dialogBox.activeSelf); }
public IEnumerator CashDeductedUponAction() { GameObject walletUI = GameObject.Find("UIManager").transform.Find("WalletUI").gameObject; int originalCash = GameState.CurrentCash; TDEvent <ETowerType> showMoveDialog = EventRegistry.GetEvent <ETowerType>("showMoveDialog"); showMoveDialog.Invoke(ETowerType.Base); walletUI.GetComponent <WalletUISystem>().OnOKClickMove(); yield return(null); Assert.AreNotEqual(originalCash, GameState.CurrentCash); }
public IEnumerator UIButtonTextDependsOnConfig() { TDEvent <ETowerType> showMoveDialog = EventRegistry.GetEvent <ETowerType>("showMoveDialog"); showMoveDialog.Invoke(ETowerType.Base); GameObject dialogBox = GameObject.Find("UIManager").transform.Find("WalletUI/Dialog").gameObject; GameObject okButtonText = dialogBox.transform.Find("OKButton/Text").gameObject; yield return(null); Assert.AreEqual("Move", okButtonText.GetComponent <Text>().text); }
void Start() { // Initialize private fields mainCamera = Camera.main; player = GameObject.Find("Player"); // Show mouse in game Cursor.visible = true; // Register events and callbacks showMenu = EventRegistry.GetEvent <GameObject, Type>("showMenu"); hideMenu = EventRegistry.GetEvent("hideMenu"); }
public IEnumerator UIGoesAwayOnCancelClick() { TDEvent <ETowerType> showMoveDialog = EventRegistry.GetEvent <ETowerType>("showMoveDialog"); showMoveDialog.Invoke(ETowerType.Base); GameObject dialogBox = GameObject.Find("UIManager").transform.Find("WalletUI/Dialog").gameObject; yield return(null); dialogBox.GetComponent <DialogSystem>().CancelClicked(); yield return(null); Assert.False(dialogBox.activeSelf); }
/// <summary> /// Registers a zero argument callback for an event. Creates the event if it doesn't exist. /// </summary> /// <param name="name">Name of the event</param> /// <param name="callback">Callback to register</param> /// <returns>True if successfully registered</returns> public static bool RegisterAction(string name, UnityAction callback) { TDEvent ev = GetEvent(name); if (ev == null) { Debug.LogError("Failed to register callback. Type mismatch."); return(false); } else { ev?.AddListener(callback); return(true); } }
public static TDEvent <TParam1, TParam2, TParam3> GetEvent <TParam1, TParam2, TParam3>(string name) { TDEvent <TParam1, TParam2, TParam3> ev; if (container.ContainsKey(name)) { container.TryGetValue(name, out ev); } else { ev = new TDEvent <TParam1, TParam2, TParam3>(); container.Add(name, ev); } return(ev); }
public static TDEvent <TParam> GetEvent <TParam>(string name) { TDEvent <TParam> ev; if (container.ContainsKey(name)) { container.TryGetValue(name, out ev); } else { Debug.LogWarning("No event found. Creating a new event."); ev = new TDEvent <TParam>(); container.Add(name, ev); } return(ev); }
void Start() { // Initialize private fields GameObject image = GameObject.Find("UpgradeUI/Image"); for (int i = 1; i < image.transform.childCount; i++) { upgradeButtons.Add(image.transform.GetChild(i).gameObject); } // Hide canvas Hide(); // Register events and callbacks showUpgradeDialog = EventRegistry.GetEvent <ETowerType>("showUpgradeDialog"); EventRegistry.RegisterAction <ETowerType>("createTower", CreateTower); EventRegistry.RegisterAction("cancelTowerCreation", CancelTowerCreation); }
void Start() { a = EventRegistry.GetEvent <string, int>("test"); }