Пример #1
0
        public bool ResetTimedEvent(uint eventId, TimePeriod timePeriod)
        {
            var search = _timedEventLists[_activeTimedEventList].FindIndex(e => e.GameEvent.Id == eventId);

            if (search >= 0)
            {
                _timedEventLists[_activeTimedEventList][search] =
                    new TimedGameEvent(timePeriod, _timedEventLists[_activeTimedEventList][search].GameEvent);
                return(true);
            }
            return(false);
        }
Пример #2
0
        public void AddOrResetTimedEvent(GameEvent gameEvent, TimePeriod timePeriod)
        {
            if (gameEvent.Id != default(uint))
            {
                // search for an item which matches the Id of the specified event
                var search = _timedEventLists[_activeTimedEventList].FindIndex(e => e.GameEvent.Id == gameEvent.Id);

                if (search >= 0)
                {
                    // event with Id already exists, so we reset its time period
                    _timedEventLists[_activeTimedEventList][search] =
                        new TimedGameEvent(timePeriod, _timedEventLists[_activeTimedEventList][search].GameEvent);
                    return;
                }
            }
            // input event does not have an Id, or it has an Id but does not exist in list.
            // In either case, we add it.
            _timedEventLists[_activeTimedEventList].Add(new TimedGameEvent(timePeriod, gameEvent));
        }