예제 #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);
            }
        }
예제 #2
0
        private void Start()
        {
            EventParam currentParams = new EventParam();

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

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