示例#1
0
        public void Moving()
        {
            SnakeBlock tempNode = head;

            for (var i = 0; i < count; i++)
            {
                tempNode.Moving();
                tempNode = tempNode.Previous;
            }
        }
示例#2
0
        public void Turn(Direction direction)
        {
            SnakeBlock tempNode = head.Previous;
            Point      fixState = new Point(head.Position.X, head.Position.Y);

            head.ToTurn(fixState, direction);
            for (var i = 0; i < count - 1; i++)
            {
                tempNode.ToTurn(fixState, direction);
                tempNode = tempNode.Previous;
            }
        }
示例#3
0
        public void Draw()
        {
            spriteBatch.Begin();
            SnakeBlock tempNode = head;

            for (var i = 0; i <= count; i++)
            {
                spriteBatch.Draw(rectangleBlock, tempNode.ToRectangle(), tempNode.Color);
                tempNode = tempNode.Previous;
            }
            spriteBatch.End();
        }
示例#4
0
        public void Add(SnakeBlock snakeBlock)
        {
            SnakeBlock node = snakeBlock;

            if (head == null)
            {
                head          = node;
                head.Next     = node;
                head.Previous = node;
            }
            else
            {
                node.Previous      = head.Previous;
                node.Next          = head;
                head.Previous.Next = node;
                head.Previous      = node;
            }
            count++;
        }
示例#5
0
 public void Clear()
 {
     head  = null;
     count = 0;
     BeginInitialise();
 }