Ejemplo n.º 1
0
 public void Creep(CommandOrientation orientation)
 {
     _segment.Creep(orientation);
     if (_owner.Body.IsCover(_segment.Poisition))
     {
         throw new SelfCrashedException("crashed oneself");
     }
 }
Ejemplo n.º 2
0
        public Snake(SnakeHead head, SnakeBody body, CommandOrientation command)
        {
            _head    = head;
            _body    = body;
            _command = command;

            _head.SetOwner(this);
            _body.SetOwner(this);
        }
Ejemplo n.º 3
0
        public void Creep(CommandOrientation orientation)
        {
            var node = _segments.First;

            while (node.Next != null)
            {
                node.Value.Poisition = node.Next.Value.Poisition;
                node = node.Next;
            }
        }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
 public void Creep(CommandOrientation orientation)
 {
     orientation.Execute(ref _poisition);
 }