private void Check(object o, EventArgs e) { Object_Side _D = _dragon.Check_struct; int D_t = _D.Top; int D_b = _D.Bottom; int D_l = _D.Left; int D_r = _D.Right; foreach (Obstacle O in Obstacles) { Object_Side _O = O.Check_struct; bool X_b = !(D_r <_O.Left || D_l> _O.Right); bool Y_b = !(D_t > _O.Bottom || D_b < _O.Top); if (X_b && Y_b) { DragonDie?.Invoke(); Stop(); } } _score += 1; if (_score % ScoreStandar == 0) { ScoreArriveStandar?.Invoke(); } GameStatusUpdate?.Invoke(_score); }
public IObservable <Unit> PostStatusUpdate(string gameId, GameStatusUpdate update) { var request = new RestRequest("Games/{id}/State", Method.POST) .AddUrlSegment("id", gameId) .AddBody <GameStatusUpdate>(update, _knownTypes); return(ExecuteRequest(request)); }
private GameStatusUpdate SetupStatusUpdate(GameStatus status) { GameStatusUpdate gameStatusUpdate = new GameStatusUpdate(status, null); _gameStatusRetrieverMock.Setup(retriever => retriever.GetCurrentStatus()) .Returns(gameStatusUpdate); return(gameStatusUpdate); }
private GameStatusUpdate SetupGameStatusFromImage(IImage image) { GameStatusUpdate status = new GameStatusUpdate(GameStatus.AcceptingMatch, new BitmapImage()); _gameImageProcessorMock.Setup(processor => processor.ProcessGameImage(image)) .Returns(status); return(status); }
public void TestInvokesUpdateMessages() { GameStatusUpdate expectedUpdate = SetupStatusUpdate(); SetupCaptureGameStatusUpdate(); AwakeThread(); Assert.Same(expectedUpdate, _gameStatusUpdate); }
public void UpdateGameStatus(string gameId, GameStatusUpdate update, HttpResponseMessage response) { var game = _gameManager.FindGame(new Guid(gameId)); if (game == null) { response.StatusCode = HttpStatusCode.NotFound; response.ReasonPhrase = "No game exists with Guid " + gameId; return; } game.ProcessUpdate(update); }
public void ProcessUpdate(GameStatusUpdate update) { _stateLock.EnterWriteLock(); try { _currentState.ProcessUpdate(update); } finally { _stateLock.ExitWriteLock(); } MarkAsActive(); }
public void UpdateGameStatus(GameStatusUpdate update) { if (_outputCommands.Count > 0) { string command = _outputCommands.First().GetOutput(this, update); if (command != null) { SendCommand(command); } if (_outputCommands.First().IsDone) { _outputCommands.Dequeue(); // If the command was null, send the status to the next command in the chain. if (command == null) { UpdateGameStatus(update); } } } }
public override string GetOutput(Player player, GameStatusUpdate update) { // don't bother sending new output until a room is parsed. if (update != GameStatusUpdate.RoomParsed) { return(null); } string direction = exitData.GetMovementCommand(player); if (destinationRoom == null && startingRoom == null) { // no source or destination assigned, so we're not verifying the location. // Simply return the movement command and be done. IsDone = true; return(direction); } else if (startingRoom != null && player.RoomDetectionState == Parsing.RoomDetectionState.HaveMatch && player.LastSeenRoom.Match.RoomNumber == startingRoom) { // we're in the starting room, return the direction. sentCommand = true; return(direction); } if (destinationRoom != null && player.RoomDetectionState == Parsing.RoomDetectionState.HaveMatch && player.LastSeenRoom.Match.RoomNumber == destinationRoom) { // we're at the destination. IsDone = true; return(null); } return(null); }
/// <summary> /// Retrieves a textual command that should be sent in response to a game status update. /// Null signifies that nothing should be sent. /// </summary> /// <param name="update"></param> /// <returns></returns> public abstract string GetOutput(Player player, GameStatusUpdate update);
private void SetupCaptureGameStatusUpdate() { _gameMonitor.GameUpdated += update => _gameStatusUpdate = update; }
public virtual void ProcessUpdate(GameStatusUpdate update) { }
public override string GetOutput(Player player, GameStatusUpdate update) { string direction = exitData.GetMovementCommand(player); if (update == GameStatusUpdate.RoomParsed && player.RoomDetectionState == Parsing.RoomDetectionState.HaveMatch && player.LastSeenRoom.Match.RoomNumber == startingRoom) { if (exitData.IsCurrentlyPassable(player.Model, player.LastSeenRoom)) { return(direction); } else { // barrier isn't passable, so commence with the suggested problem-solving method switch (requirements.Method) { case ExitMethod.UseItem: return(GetUseKey(player)); case ExitMethod.Bash: return(GetBash(player)); case ExitMethod.Pick: return(GetPick(player)); case ExitMethod.PickOrBash: if (player.Strength > player.Picklocks) { goto case ExitMethod.Bash; } else { goto case ExitMethod.Pick; } default: // should never get here, but hey, shit happens. throw new InvalidOperationException(); } } } else if (update == GameStatusUpdate.RoomParsed && player.RoomDetectionState == Parsing.RoomDetectionState.HaveMatch && player.LastSeenRoom.Match.RoomNumber == destinationRoom) { // we're at the destination. IsDone = true; return(null); } else if (update == GameStatusUpdate.BashFail) { return(GetBash(player)); } else if (update == GameStatusUpdate.BashSuccess) { return(direction); } else if (update == GameStatusUpdate.PickFail) { return(GetPick(player)); } else if (update == GameStatusUpdate.PickSuccess) { return(GetOpen(player)); } else if (update == GameStatusUpdate.DoorOpened) { return(direction); } return(null); }