Пример #1
0
 int GetTileForTail(SnakeBodyPart newTail)
 {
     if (newTail.CurrentTile > 4)
     {
         return(newTail.PreviousDirection + 8);
     }
     return(newTail.CurrentTile + 8);
 }
Пример #2
0
        internal void Move(Vector2 newPosition, int previousHeadDirection)
        {
            SnakeBodyPart newFirstPart = bodyParts.Last();
            SnakeBodyPart newTail      = newFirstPart.Next;

            newFirstPart.Position          = newPosition;
            newFirstPart.PreviousDirection = HeadDirection;
            newFirstPart.CurrentTile       = GetTileForFirstBodyPart(previousHeadDirection);
            newTail.CurrentTile            = GetTileForTail(newTail);
            bodyParts.Insert(0, newFirstPart);
            bodyParts.RemoveAt(Length);
        }
Пример #3
0
        internal void Grow(Vector2 newPosition, int previousHeadDirection)
        {
            SnakeBodyPart firstPart = bodyParts.First();
            SnakeBodyPart tail      = bodyParts.Last();
            SnakeBodyPart newPart   = new SnakeBodyPart(snakeBodySprite)
            {
                Position          = newPosition,
                CurrentTile       = GetTileForFirstBodyPart(previousHeadDirection),
                PreviousDirection = HeadDirection,
                Next = tail
            };

            firstPart.Next = newPart;
            bodyParts.Insert(0, newPart);
        }