public void ClearStatus() { Team1Score = 0; Team2Score = 0; Result = GameResult.None; GameEvents.Clear(); }
private async Task AsyncConvertUpdates() { Processor processor = new Processor(); processor.GameComplete += GameComplete; GameEvents.Clear(); GameEvents.SupressNotification = true; foreach (GameUpdateVm vm in m_updatesCv) { await processor.ProcessGameObject(vm.Update, vm.Update.timestamp); } GameEvents.SupressNotification = false; }
private async Task LoadEvents(string eventsFile) { GameEvents.Clear(); LoadSaveEnabled = false; EventsDisabled = true; Mouse.OverrideCursor = Cursors.Wait; await AsyncLoadEvents(eventsFile); Mouse.OverrideCursor = null; EventsDisabled = false; LoadSaveEnabled = true; OnPropertyChanged(nameof(FilteredEvents)); }
private async Task AsyncConvertUpdates() { Processor processor = new Processor(); GameEvents.Clear(); GameEvents.SupressNotification = true; foreach (GameUpdateVm vm in m_updatesCv) { GameEvent newEvent = processor.ProcessGame(vm.Update, vm.Update.timestamp); if (newEvent != null) { GameEvents.Add(new GameEventVm(newEvent, m_teamLookup)); } } GameEvents.SupressNotification = false; }
public override void OnInspectorGUI() { GameBlackboard gb = target as GameBlackboard; if (Application.isPlaying) { OnInspectorGuiEx(); return; } const float kFrameWidth = 80; const float kDeleteWidth = 17; GUILayout.BeginVertical("OL box NoExpand"); GUILayout.BeginHorizontal(); GUILayout.Label("Game Events", "OL Title"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Name", "OL Title"); GUILayout.Label("State", "OL Title", GUILayout.Width(kFrameWidth)); GUILayout.Label(GUIContent.none, "OL Title", GUILayout.Width(kDeleteWidth)); GUILayout.EndHorizontal(); GUIStyle gs = "OL TextField"; GameEvents events = gb.GameEvents; Dictionary <string, GameEvents.E_State> updatedEvents = new Dictionary <string, GameEvents.E_State>(); for (int i = 0; i < events.Count; i++) { EditorGUILayout.BeginHorizontal(); string key = EditorGUILayout.TextField(events.Names[i], gs, GUILayout.MinWidth(30)); GameEvents.E_State state = (GameEvents.E_State)EditorGUILayout.EnumPopup(events.GetState(events.Names[i]), GUILayout.Width(kFrameWidth)); if (GUILayout.Button(GUIContent.none, "OL Minus", GUILayout.Width(kDeleteWidth)) == false) { try { updatedEvents.Add(key, state); } catch { updatedEvents.Add(events.Names[i], events.GetState(events.Names[i])); } } EditorGUILayout.EndHorizontal(); } GUILayout.Space(5); GUILayout.BeginHorizontal(); if (GUILayout.Button(GUIContent.none, "OL Plus", GUILayout.Width(kDeleteWidth))) { updatedEvents.Add("_NewEvent" + events.Count, GameEvents.E_State.False); } if (GUI.changed || events.Count != updatedEvents.Count) { //gb.ClearAllGameEvents(); events.Clear(); foreach (KeyValuePair <string, GameEvents.E_State> pair in updatedEvents) { events.Add(pair.Key, pair.Value); } EditorUtility.SetDirty(gb); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
private void RunMainLoop() { var scope = Services.CreateScope(); DBContext = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>(); List <PlayerCharacter> playerCharacters; List <GameObject> visibleObjects; while (true) { try { if (BrowserHub.ConnectionList.Count == 0) { Thread.Sleep(1000); continue; } if (DateTime.Now - LastDBSave > TimeSpan.FromMinutes(1) && !DBContext.Database.IsInMemory()) { DBContext.SaveChanges(); DBContext.Database.CloseConnection(); DBContext.Dispose(); scope.Dispose(); scope = Services.CreateScope(); DBContext = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>(); LastDBSave = DateTime.Now; continue; } // TODO: Remove these dummy users later. while (DBContext.Characters.Count(x => !(x is PlayerCharacter)) < 5) { DBContext.Characters.Add(new Character() { Name = "TargetDummy" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10), XCoord = new Random().Next(-500, 500), YCoord = new Random().Next(-500, 500), Color = Utilities.GetRandomHexColor(), AnchorX = 0, AnchorY = 0, AnchorZ = "0", CoreEnergy = DBContext.PlayerCharacters.Any() ? DBContext.PlayerCharacters.Average(x => x.CoreEnergy) : 100 }); DBContext.SaveChanges(); } var delta = GetDelta(); ProcessInputQueue(); var activeCharacters = BrowserHub.ConnectionList.Values.Select(x => x.CharacterID); playerCharacters = DBContext.PlayerCharacters .Include(x => x.StatusEffects) .Where(x => x is PlayerCharacter && activeCharacters.Contains(x.ID)).ToList(); visibleObjects = GetAllVisibleObjects(playerCharacters); visibleObjects.ForEach(x => { if (IsExpired(x)) { return; } ApplyStatUpdates(x, delta); ApplyInputUpdates(x, delta); UpdatePositionsFromVelociy(x, delta); }); CheckForCollisions(visibleObjects.Where(x => x is ICollidable).Cast <ICollidable>()); SendUpdates(visibleObjects, BrowserHub.ConnectionList.Values.ToList()); visibleObjects.ForEach(x => { x.Modified = false; }); visibleObjects.Clear(); GameEvents.Clear(); } catch (DbUpdateConcurrencyException ex) { continue; } catch (Exception ex) { try { var error = new Error() { PathWhereOccurred = "Main Engine Loop", Message = ex.Message, StackTrace = ex.StackTrace, Source = ex.Source, Timestamp = DateTime.Now }; DBContext.Errors.Add(error); DBContext.SaveChanges(); if (DateTime.Now - LastEmailSent < TimeSpan.FromMinutes(1)) { continue; } LastEmailSent = DateTime.Now; EmailSender.SendEmail("*****@*****.**", "*****@*****.**", "After Server Error", JsonConvert.SerializeObject(error)); continue; } catch { continue; } } } }