Ejemplo n.º 1
0
        public void AddSnakeToMap(MapManager mm)
        {
            SnakePart snakeTail = snakeParts.First();

            mm.PlaceItemOnTile(mm.GetCenterTile(), snakeTail);

            for (LinkedListNode <SnakePart> currentNode = snakeParts.First; currentNode != null;)
            {
                LinkedListNode <SnakePart> nextNode = currentNode.Next;
                if (nextNode != null)
                {
                    Tile tile = mm.GetTileInFrontOfSnakePart(currentNode.Value);
                    mm.PlaceItemOnTile(tile, nextNode.Value);
                }
                currentNode = nextNode;
            }
        }
Ejemplo n.º 2
0
        public Tile GetTileInFrontOfSnakePart(SnakePart snakePart)
        {
            Direction partDirection = snakePart.GetSnakeDirection().GetCurrentDirection();

            switch (partDirection)
            {
            case Direction.Up:
                return(FindUpwardsNeighbourToTile(GetTileWithItem(snakePart)));

            case Direction.Down:
                return(FindDownwardsNeighbourToTile(GetTileWithItem(snakePart)));

            case Direction.Left:
                return(FindLeftNeighbourToTile(GetTileWithItem(snakePart)));

            case Direction.Right:
                return(FindRightNeighbourToTile(GetTileWithItem(snakePart)));

            default:
                return(FindRightNeighbourToTile(GetTileWithItem(snakePart)));
            }
        }
Ejemplo n.º 3
0
        public Tile GetTileBehindSnakePart(SnakePart snakePart)
        {
            Direction oppositeOfPartDirection = snakePart.GetSnakeDirection().GetOppositeDirection();

            switch (oppositeOfPartDirection)
            {
            case Direction.Up:
                return(FindUpwardsNeighbourToTile(GetTileWithItem(snakePart)));

            case Direction.Down:
                return(FindDownwardsNeighbourToTile(GetTileWithItem(snakePart)));

            case Direction.Left:
                return(FindLeftNeighbourToTile(GetTileWithItem(snakePart)));

            case Direction.Right:
                return(FindRightNeighbourToTile(GetTileWithItem(snakePart)));

            default:
                return(FindRightNeighbourToTile(GetTileWithItem(snakePart)));
            }
        }