public static void TriggerEvent(string eventName, EventParam eventParam = default(EventParam)) { Action <EventParam> thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(eventParam); } }
private void Start() { EventParam currentParams = new EventParam(); currentParams.kills = _kills; currentParams.maxKills = _maxKills; EventManager.TriggerEvent("PlayerShowScore", currentParams); }
private void EnemyDie(EventParam eventParam) { _kills++; if (_kills >= _maxKills) { EventManager.TriggerEvent("PlayerEndGame"); } else { EventParam currentParams = new EventParam(); currentParams.kills = _kills; currentParams.maxKills = _maxKills; EventManager.TriggerEvent("PlayerShowScore", currentParams); } }
private void TurretShoot(EventParam eventParam) { if (eventParam.uniqueID == _uniqueID) { if (_secondShotCounter <= 0.0f) { _audioSource.Play(); _secondShotCounter = _timeBetweenShots - _timeBetweenCanonShots; Instantiate(_bullet, _secondShootPoint.position, _secondShootPoint.rotation); } if (_firstShotCounter <= 0.0f) { _audioSource.Play(); _firstShotCounter = _timeBetweenShots; Instantiate(_bullet, _firstShootPoint.position, _firstShootPoint.rotation); } } }
private void PlayerDie(EventParam eventParams) { Time.timeScale = 0.0f; _loseGameUI.SetActive(true); }
private void WinGame(EventParam eventParams) { Time.timeScale = 0.0f; _winGameUI.SetActive(true); }
private void PlayerShowScore(EventParam eventParam) { _score.text = $"Score: {eventParam.kills} / {eventParam.maxKills}"; }