Ejemplo n.º 1
0
        private static void DrawSection(SectionBuildingDetails details)
        {
            string resourcePath;

            // pick image
            switch (details.section.SectionType)
            {
            case (SectionTypes.Finish):
                resourcePath = FINISH;
                break;

            case (SectionTypes.RightCorner):
            case (SectionTypes.LeftCorner):
                resourcePath = CORNER;
                break;

            case (SectionTypes.StartGrid):
                resourcePath = STARTGRID;
                break;

            case (SectionTypes.Straight):
                resourcePath = STRAIGHT;
                break;

            default:
                resourcePath = "";
                break;
            }
            int x = posX(details.x);
            int y = posY(details.y);

            g.DrawImage(ContentLoader.GetBitmapFromCache(resourcePath), x, y, tileWidth, tileHeight);
        }
Ejemplo n.º 2
0
        private static void ShiftPositions(List <SectionBuildingDetails> buildingDetails)
        {
            int offsetX = getLowestXValue(ref buildingDetails);
            int offsetY = getLowestYValue(ref buildingDetails);

            for (int i = 0; i < buildingDetails.Count; i++)
            {
                SectionBuildingDetails bd = buildingDetails[i];
                int real_x = buildingDetails[i].x + Math.Abs(offsetX);
                int real_y = buildingDetails[i].y + Math.Abs(offsetY);
                bd.x = real_x;
                bd.y = real_y;

                buildingDetails[i] = bd;
            }
        }
Ejemplo n.º 3
0
        private static void FillBuildingDetails(ref List <SectionBuildingDetails> buildingDetails, Model.Track t)
        {
            int x = 0;
            int y = 0;

            Heading current = Heading.South;
            Heading last    = current;

            foreach (Model.Section sec in Data.CurrentRace.Track.Sections)
            {
                var a = new SectionBuildingDetails()
                {
                    section = sec, x = x, y = y
                };
                // Determine its heading
                if (sec.SectionType == SectionTypes.LeftCorner)
                {
                    last = current;

                    if (current == Heading.West)
                    {
                        current = Heading.North;
                    }
                    else
                    {
                        current++;
                    }
                }
                if (sec.SectionType == SectionTypes.RightCorner)
                {
                    last = current;

                    if (current == Heading.North)
                    {
                        current = Heading.West;
                    }
                    else
                    {
                        current--;
                    }
                }

                a.direction     = current;
                a.lastDirection = last;

                buildingDetails.Add(a);

                // move postion values based on the direction
                switch (current)
                {
                case (Heading.North):
                    y++;
                    break;

                case (Heading.East):
                    x++;
                    break;

                case (Heading.South):
                    y--;
                    break;

                case (Heading.West):
                    x--;
                    break;
                }
            }
        }
Ejemplo n.º 4
0
 public void SetUp()
 {
     sectionDetails = new SectionBuildingDetails(new Section(SectionTypes.Finish), 1, 2, Direction.North);
 }
Ejemplo n.º 5
0
        private static void drawSection(SectionBuildingDetails details)
        {
            SectionTypes sectionType = details.section.SectionType;

            (int x, int y)pos = (details.x * SectionBuildingDetails.SIZE_X, details.y *SectionBuildingDetails.SIZE_Y);
            if (sectionType == SectionTypes.RightCorner || sectionType == SectionTypes.LeftCorner)
            {
                if (details.direction == Heading.East)
                {
                    if (details.lastDirection == Heading.Nord)
                    {
                        drawToConsole(_BottomLeftCorner, pos);
                    }

                    if (details.lastDirection == Heading.South)
                    {
                        drawToConsole(_TopLeftCorner, pos);
                    }
                }

                if (details.direction == Heading.Nord)
                {
                    if (details.lastDirection == Heading.East)
                    {
                        drawToConsole(_TopRightCorner, pos);
                    }

                    if (details.lastDirection == Heading.West)
                    {
                        drawToConsole(_TopLeftCorner, pos);
                    }
                }

                if (details.direction == Heading.South)
                {
                    if (details.lastDirection == Heading.East)
                    {
                        drawToConsole(_BottomRightCorner, pos);
                    }

                    if (details.lastDirection == Heading.West)
                    {
                        drawToConsole(_BottomLeftCorner, pos);
                    }
                }

                if (details.direction == Heading.West)
                {
                    if (details.lastDirection == Heading.Nord)
                    {
                        drawToConsole(_BottomRightCorner, pos);
                    }

                    if (details.lastDirection == Heading.South)
                    {
                        drawToConsole(_TopRightCorner, pos);
                    }
                }
            }

            switch (sectionType)
            {
            case SectionTypes.StartGrid:
                if (details.direction == Heading.Nord || details.direction == Heading.South)
                {
                    drawToConsole(_startGridVertical, pos);
                }
                else
                {
                    drawToConsole(_startGridHorizontal, pos);
                }
                break;

            case SectionTypes.Straight:
                if (details.direction == Heading.Nord || details.direction == Heading.South)
                {
                    drawToConsole(_straightVertical, pos);
                }
                else
                {
                    drawToConsole(_straightHorizontal, pos);
                }

                break;

            case SectionTypes.Finish:
                if (details.direction == Heading.Nord || details.direction == Heading.South)
                {
                    drawToConsole(_finishVertical, pos);
                }
                else
                {
                    drawToConsole(_finishHorizontal, pos);
                }

                break;
            }
        }