private void OnTurned(object sender, TurnedEventArgs eventArgs) { _lastStepSource.Dispose(); _lastStepSource = null; if (Field.IsEnd()) { IsEnded = true; OnWin(CurrentStepPlayer); } Turned?.Invoke(sender, eventArgs); }
public Task ForceTurn(int x, int y, CancellationToken cancellationToken) { return(Task.Run(() => { if (!_canTurn || Field[x, y].State != CellState.Empty) { return; } Field.Turn(PlayerCellState, x, y); _canTurn = false; Turned?.Invoke(this, new TurnedEventArgs { CellState = PlayerCellState, X = x, Y = y }); }, cancellationToken)); }
public Task ForceTurn(int x, int y, CancellationToken cancellationToken) { if (!_canTurn || _bot.Field[x, y].State != CellState.Empty) { return(Task.FromResult(false)); } return(Task.Delay(Game.BotStepDelay, cancellationToken).ContinueWith(task => { _canTurn = false; _bot.Field.Turn(_bot.State, x, y); Turned?.Invoke(this, new TurnedEventArgs { CellState = PlayerCellState, X = x, Y = y }); }, cancellationToken)); }
public void Turn(Lane.Direction newDirection) { direction = newDirection; Turned?.Invoke(this, new EventArgs()); //change lane }
protected virtual void OnTurn(PotentiometerTurn Event) { Turned?.Invoke(this, Event); }
protected virtual void OnTurn(EncoderTurn Event) { Turned?.Invoke(this, Event); }