public MapSection[][] GenerateFirstMap()
        {
            //map coordinates:



            const int mapHeight = 5;
            const int mapLength = 10;
            var       map       = new MapSection[mapHeight][];

            for (int i = 0; i < mapHeight; i++)
            {
                map[i] = new MapSection[mapLength];
                for (int j = 0; j < mapLength; j++)
                {
                    map[i][j] = new NormalSquare(i, j);
                }
            }

            AddCoordinates(map);



            var mapSquares = new List <MapSection>();

            var squareNumber = 1;
            var counter      = 0;
            var bonusCounter = 0;

            for (int i = 0; i < mapHeight; i++)
            {
                for (int j = 0; j < mapLength; j++)
                {
                    if (i == 0 && j == 0)
                    {
                        map[i][j] = new StartSquare(i, j);
                    }
                    else if (i == map.Length - 1 && j == map[i].Length - 1)
                    {
                        map[i][j] = new FinishSquare(i, j);
                    }
                    else if (bonusCounter > 6)
                    {
                        if ((counter / 2 + bonusCounter) % 2 == 0)
                        {
                            map[i][j] = new BonusSquare(i, j);
                        }
                        else
                        {
                            map[i][j] = new MysterySquare(i, j);
                        }
                        bonusCounter = 0;
                    }
                    else if (counter > 5 && (bonusCounter + 1) % 2 == 0)
                    {
                        map[i][j] = new GoForwardSquare(i, j);
                        counter   = 1;
                    }
                    else if (counter > 5)
                    {
                        map[i][j] = new GoBackSquare(i, j);
                        counter   = 1;
                    }
                    else
                    {
                        map[i][j] = new NormalSquare(i, j);
                    }

                    map[i][j].Number = squareNumber; squareNumber++;
                    counter++;
                    bonusCounter++;

                    AddCoordinates(map);
                    mapSquares.Add(map[i][j]);

                    if (squareNumber == 51)
                    {
                        break;
                    }
                }
            }


            var json = Serializer.ExportFirstMapCoordinates(mapSquares);

            Console.WriteLine(json);

            return(map);
        }
Пример #2
0
        public MapSection[][] GenerateMap()
        {
            //fill a basic level with different squares
            const int mapHeight = 10;
            const int mapLength = mapHeight;
            var       map       = new MapSection[mapHeight][];

            var squareNumber = 1;
            //The start square and end square will be added right under the for's
            var counter      = 0;
            var bonusCounter = 0;

            for (int i = 0; i < mapHeight; i++)
            {
                map[i] = new MapSection[mapLength];
                for (int j = 0; j < mapLength; j++)
                {
                    if (bonusCounter == 7 && counter != 5)
                    {
                        var rnd = new Random();
                        if (rnd.Next(0, 10) % 2 == 0)
                        {
                            map[i][j] = new MysterySquare(i, j);

                            bonusCounter++;
                        }
                        else
                        {
                            map[i][j] = new BonusSquare(i, j);
                            bonusCounter++;
                        }
                        map[i][j].Number = squareNumber; squareNumber++;
                        bonusCounter     = 0;
                        counter++;
                    }
                    else if (counter == 5)
                    {
                        var rnd = new Random();
                        if (rnd.Next(0, 4) % 2 == 0)
                        {
                            map[i][j] = new GoForwardSquare(i, j);

                            counter++;
                        }
                        else
                        {
                            map[i][j] = new GoBackSquare(i, j);
                            counter++;
                        }
                        counter          = 0;
                        map[i][j].Number = squareNumber; squareNumber++;
                    }
                    else
                    {
                        map[i][j]        = new NormalSquare(i, j);
                        map[i][j].Number = squareNumber; squareNumber++;
                        counter++;
                        bonusCounter++;
                    }
                }
            }

            //this is the start square, can be different then 0,0 -> depends on the map
            map[0][0]        = new StartSquare(0, 0);
            map[0][0].Number = 1;

            //this is the final square, who goes there first wins the game -> again depends on the map
            map[mapHeight - 1][mapLength - 1]        = new FinishSquare(mapHeight - 1, mapLength - 1);
            map[mapHeight - 1][mapLength - 1].Number = 100;

            return(map);
        }
        public static List <MapSection> GetMapPath()
        {
            //Used for the map path service

            const int mapHeight = 5;
            const int mapLength = 10;
            var       map       = new MapSection[mapHeight][];

            for (int i = 0; i < mapHeight; i++)
            {
                map[i] = new MapSection[mapLength];
                for (int j = 0; j < mapLength; j++)
                {
                    map[i][j] = new NormalSquare(i, j);
                }
            }

            AddCoordinates(map);



            var mapSquares = new List <MapSection>();

            var squareNumber = 1;
            var counter      = 0;
            var bonusCounter = 0;

            for (int i = 0; i < mapHeight; i++)
            {
                for (int j = 0; j < mapLength; j++)
                {
                    if (i == 0 && j == 0)
                    {
                        map[i][j] = new StartSquare(i, j);
                    }
                    else if (i == map.Length - 1 && j == map[i].Length - 1)
                    {
                        map[i][j] = new FinishSquare(i, j);
                    }
                    else if (bonusCounter > 6)
                    {
                        if ((counter / 2 + bonusCounter) % 2 == 0)
                        {
                            map[i][j] = new BonusSquare(i, j);
                        }
                        else
                        {
                            map[i][j] = new MysterySquare(i, j);
                        }
                        bonusCounter = 0;
                    }
                    else if (counter > 5 && (bonusCounter + 1) % 2 == 0)
                    {
                        map[i][j] = new GoForwardSquare(i, j);
                        counter   = 1;
                    }
                    else if (counter > 5)
                    {
                        map[i][j] = new GoBackSquare(i, j);
                        counter   = 1;
                    }
                    else
                    {
                        map[i][j] = new NormalSquare(i, j);
                    }

                    map[i][j].Number = squareNumber; squareNumber++;
                    counter++;
                    bonusCounter++;

                    AddCoordinates(map);
                    mapSquares.Add(map[i][j]);

                    if (squareNumber == 51)
                    {
                        break;
                    }
                }
            }

            return(mapSquares);
        }