示例#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);
            }
        }
        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}";
 }