Beispiel #1
0
        public void Update(float delta)
        {
            if (Mathf.Floor(TimeSinceStarted + delta) > Mathf.Floor(TimeSinceStarted))
            {
                SecondElapsed = true;
                OnSecondElapsed?.Invoke();
            }

            m_counter        -= delta;
            TimeSinceStarted += delta;
            if (m_counter < 0)
            {
                CounterFinished = true;
                OnCounterFinished?.Invoke();
                m_counter = m_counterSet;
            }
        }
Beispiel #2
0
        public HangmanGame(HangmanDifficulty diff)
        {
            if (diff == null)
            {
                throw new HangmanException("Game Difficulty must not be null.");
            }
            _difficulty   = diff;
            IsGameStarted = false;

            _timer.Elapsed += (sender, args) =>
            {
                if (IsGameStarted)
                {
                    CheckGameState();
                    OnSecondElapsed?.Invoke(_lastGameState);
                }
            };
        }