예제 #1
0
 public void SaveEvent(StoredGameEvent storedGameEvent)
 {
     using (var db = new LiteDatabase(@"Save.db"))
     {
         var events = db.GetCollection <StoredGameEvent>(this._gameName);
         events.Insert(storedGameEvent);
     }
 }
예제 #2
0
        public async Task <StoredGameEvent> AddGameEvent <TEventData>(string description, TEventData gameEventData) where TEventData : IEventData
        {
            var eventTypeDataName = gameEventData.GetType().Name;
            var eventTypeName     = eventTypeDataName.Remove(eventTypeDataName.Length - 4);
            var eventType         = typeof(IEventData).Assembly.GetTypes().First(x => x.Name == eventTypeName);
            var @event            = (IRequest)Activator.CreateInstance(eventType, this, gameEventData);
            await _mediator.Send(@event);

            var storedGameEvent = new StoredGameEvent(description, eventTypeDataName, gameEventData);

            this._gameEvents.Add(storedGameEvent);
            this._stateSaver.SaveEvent(storedGameEvent);
            return(storedGameEvent);
        }