Exemplo n.º 1
0
        private void OnTurned(object sender, TurnedEventArgs eventArgs)
        {
            _lastStepSource.Dispose();
            _lastStepSource = null;

            if (Field.IsEnd())
            {
                IsEnded = true;
                OnWin(CurrentStepPlayer);
            }

            Turned?.Invoke(sender, eventArgs);
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
 public void Turn(Lane.Direction newDirection)
 {
     direction = newDirection;
     Turned?.Invoke(this, new EventArgs());
     //change lane
 }
Exemplo n.º 5
0
 protected virtual void OnTurn(PotentiometerTurn Event)
 {
     Turned?.Invoke(this, Event);
 }
Exemplo n.º 6
0
 protected virtual void OnTurn(EncoderTurn Event)
 {
     Turned?.Invoke(this, Event);
 }