public override void Update() { var gameDataModel = (OverwatchDataModel)DataModel; var colors = MmfReader.GetColorArray(); if (colors == null) { return; } var bitmap = new Bitmap(22, 6); using (var g = Graphics.FromImage(bitmap)) { for (var y = 0; y < 6; y++) { for (var x = 0; x < 22; x++) { g.DrawRectangle(new Pen(ColorHelpers.ToDrawingColor(colors[y, x])), y, x, 1, 1); } } } _events.PublishOnUIThread(new ChangeBitmap(bitmap)); // Determine general game state gameDataModel.Status = colors[0, 0].Equals(Color.FromRgb(55, 30, 0)) ? OverwatchStatus.InMainMenu : OverwatchStatus.Unkown; if (gameDataModel.Status == OverwatchStatus.InMainMenu) { return; } // If ingame, look for a character var characterMatch = OverwatchCharacters.FirstOrDefault(c => c.Color == colors[0, 0]); if (characterMatch.OverwatchCharacter == OverwatchCharacter.None) { return; } gameDataModel.Status = OverwatchStatus.InGame; gameDataModel.Character = characterMatch.OverwatchCharacter; // Ability1 is ready when LShift is lid gameDataModel.Ability1Ready = colors[4, 1].Equals(Color.FromRgb(4, 141, 144)); // Ability2 is ready when E is lid gameDataModel.Ability2Ready = colors[2, 4].Equals(Color.FromRgb(4, 141, 144)); // Ultimate is ready when Q is blinking gameDataModel.UltimateReady = !characterMatch.Color.Equals(colors[2, 2]); }
private CharacterColor?ParseCharacter(OverwatchDataModel gameDataModel, Color[,] colors) { var characterMatch = OverwatchCharacters.FirstOrDefault(c => c.Color == colors[0, 20]); // If a new character was chosen, let the other methods know if (characterMatch.Character != gameDataModel.Character) { _characterChange = DateTime.Now; } // If no character was found, this method shouldn't continue if (characterMatch.Character == OverwatchCharacter.None) { return(characterMatch); } // If WASD isn't orange (any of them will do), player is in character select _stickyStatus.Value = ControlsShown(colors) ? OverwatchStatus.InGame : OverwatchStatus.InCharacterSelect; // Update the datamodel gameDataModel.Character = characterMatch.Character; return(characterMatch); }