Exemplo n.º 1
0
        public static void TriggerEvent(string eventName, EventParam eventParam = default(EventParam))
        {
            Action <EventParam> thisEvent = null;

            if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
            {
                thisEvent.Invoke(eventParam);
            }
        }
Exemplo n.º 2
0
        private void Start()
        {
            EventParam currentParams = new EventParam();

            currentParams.kills    = _kills;
            currentParams.maxKills = _maxKills;

            EventManager.TriggerEvent("PlayerShowScore", currentParams);
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        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);
                }
            }
        }
Exemplo n.º 5
0
 private void PlayerDie(EventParam eventParams)
 {
     Time.timeScale = 0.0f;
     _loseGameUI.SetActive(true);
 }
Exemplo n.º 6
0
 private void WinGame(EventParam eventParams)
 {
     Time.timeScale = 0.0f;
     _winGameUI.SetActive(true);
 }
Exemplo n.º 7
0
 private void PlayerShowScore(EventParam eventParam)
 {
     _score.text = $"Score: {eventParam.kills} / {eventParam.maxKills}";
 }