public void Creep(CommandOrientation orientation) { _segment.Creep(orientation); if (_owner.Body.IsCover(_segment.Poisition)) { throw new SelfCrashedException("crashed oneself"); } }
public Snake(SnakeHead head, SnakeBody body, CommandOrientation command) { _head = head; _body = body; _command = command; _head.SetOwner(this); _body.SetOwner(this); }
public void Creep(CommandOrientation orientation) { var node = _segments.First; while (node.Next != null) { node.Value.Poisition = node.Next.Value.Poisition; node = node.Next; } }
private bool IsIdenticalDimension(CommandOrientation a, CommandOrientation b) { if (a is IHorizontalOrientation && b is IHorizontalOrientation) { return(true); } if (a is IVerticalOrientation && b is IVerticalOrientation) { return(true); } return(false); }
public void InterviewCommand(CommandOrientation command) { var adjacentCommand = _model.Snake.Command; if (_requests.Count > 0) { adjacentCommand = _requests.Peek(); } if (this.IsIdenticalDimension(command, adjacentCommand)) { return; } _requests.Enqueue(command); }
public void InterviewCommand(CommandOrientation command) { if (command is CommandUp) { if (_model.Tetromino.CanTransform(_model.TetrominoContext)) { _model.Tetromino.Transform(); } } else if (command is CommandLeft) { if (_model.Tetromino.BeHold(_model.LeftTetrominoContext)) { _model.ActiveColumnIndex--; } } else if (command is CommandRight) { if (_model.Tetromino.BeHold(_model.RightTetrominoContext)) { _model.ActiveColumnIndex++; } } else if (command is CommandDown) { this.TimerElapsedCore(); } else if (command is CommandBlank) { while (_model.Tetromino.BeHold(_model.DownTetrominoContext)) { _model.ActiveRowIndex--; } this.TimerElapsedCore(); } _view.RenderScence(_model); }
public void Creep(CommandOrientation orientation) { orientation.Execute(ref _poisition); }