private static void F()
        {
            //important shit
            Random      rand        = new Random();
            var         local       = new LocalLevels();
            GameManager gameManager = new GameManager();

            //random shit
            var gameModes = new List <GameMode> {
                GameMode.Cube, GameMode.Ship, GameMode.Ball, GameMode.Dird, GameMode.Robot, GameMode.Spider
            };
            var speedTypes = new List <SpeedType> {
                SpeedType.Yellow, SpeedType.Default, SpeedType.Green, SpeedType.Purple, SpeedType.Red
            };

            Level level    = new Level(local.GetLevel(levelName));
            byte  BGColorR = (byte)rand.Next(255); Console.WriteLine("R: " + BGColorR);
            byte  BGColorB = (byte)rand.Next(255); Console.WriteLine("B: " + BGColorB);
            byte  BGColorG = (byte)rand.Next(255); Console.WriteLine("G: " + BGColorG);

            level.AddColor(new Color(ColorType.Background, BGColorR, BGColorB, BGColorG));
            //Code doesnt work for rn, doesnt match bg color
            level.AddColor(new Color(ColorType.Ground, (byte)(BGColorR - (byte)rand.Next(40)), (byte)(BGColorB - (byte)rand.Next(40)), (byte)(BGColorG - (byte)rand.Next(40))));
            level.AddColor(new Color(ColorType.Ground2, (byte)(BGColorR - (byte)rand.Next(70)), (byte)(BGColorB - (byte)rand.Next(70)), (byte)(BGColorG - (byte)rand.Next(70))));

            byte[] randomInts  = { (byte)rand.Next(20), (byte)rand.Next(17), (byte)rand.Next(speedTypes.Count), (byte)rand.Next(gameModes.Count), (byte)rand.Next(12) };
            bool[] randomBools = { rand.Next(2) == 1, rand.Next(2) == 1, rand.Next(2) == 1 };

            level.Background    = randomInts[0];                Console.WriteLine("Background ID: " + randomInts[0]);
            level.Ground        = randomInts[1];                    Console.WriteLine("Ground ID: " + randomInts[1]);
            level.PlayerSpeed   = (SpeedType)randomInts[2];    Console.WriteLine("Player Speed: " + (SpeedType)randomInts[2]);
            level.GameMode      = (GameMode)randomInts[3];        Console.WriteLine("GameMode: " + (GameMode)randomInts[3]);
            level.Fonts         = randomInts[4];                     Console.WriteLine("Font ID: " + (randomInts[4]));
            level.kA17          = 0;
            level.TwoPlayerMode = (bool)randomBools[0];      Console.WriteLine("Two Player Mode: " + (randomBools[0]));
            level.Mini          = (bool)randomBools[1];               Console.WriteLine("Mini Player: " + (randomBools[1]));
            level.Dual          = (bool)randomBools[2];               Console.WriteLine("Dual Mode: " + (randomBools[2]));

            //Save the level.
            local.GetLevel(levelName).LevelString   = level.ToString();
            local.GetLevel(levelName).Description   = "Random Description";
            local.GetLevel(levelName).TotalJumps    = rand.Next(99999);
            local.GetLevel(levelName).TotalAttempts = rand.Next(99999);
            local.Save();
        }
Beispiel #2
0
 public static void Invoke()
 {
     GeometryDashApi.RegisterBlockType(typeof(MyShakeTrigger), true);
     var levels = new LocalLevels();
     var level  = new Level(levels.GetLevel("Temp"));
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            Console.Title = "Art To Geometry Dash";
            Welcome();
            Console.Write("Image path.\nExample: C:\\images\\my.png\n> ");
            fileArt = Console.ReadLine().Replace("\"", "");
            Console.Clear();
            Console.Write("Width and height pixel (pixels). \n> ");
            pixelSize = int.Parse(Console.ReadLine());
            Console.Clear();
            Console.Write("Alpha color.\nExample 1: 255 255 255 (Cut close to white color)\nExample 2: A 245 (Cuts all pixels with little aplha.)\n> ");
            string[] al = Console.ReadLine().Split(' ');
            if (al[0] == "A" || al[0] == "А")
            {
                useAplhaChannel = true;
                alphaChannel    = byte.Parse(al[1]);
            }
            else
            {
                alpha    = new byte[3];
                alpha[0] = byte.Parse(al[0]);
                alpha[1] = byte.Parse(al[1]);
                alpha[2] = byte.Parse(al[2]);
            }
            Console.Clear();
            Console.Write("Color similarity ratio.\n0 - Exact color match\nThe higher the value, the less color will be used in the level.\nRecommended value: 10\n> ");
            userDistance = double.Parse(Console.ReadLine());
            Console.Clear();
            Console.Write("What ID to start creating the palette\n> ");
            colorStart = int.Parse(Console.ReadLine());
            Console.Clear();
            Console.Write("The size of the art in the level.\n1: 1 pixel = 1/4 block\nExample: 0,8\n> ");
            scale = float.Parse(Console.ReadLine());
            Console.Clear();
            Console.Write("Image coordinates in level.\n1 block = 30, 2 block = 60\nTemplate: X Y\nExample: 2000 0\nUsing coordinates far from 0 when adding a large image, otherwise the level may not open.\n> ");
            string[] coords = Console.ReadLine().Split(' ');
            coordX = float.Parse(coords[0]);
            coordY = float.Parse(coords[1]);
            Console.Clear();
            Console.Write("Layer for art.\n> ");
            EditorLayer = int.Parse(Console.ReadLine());
            Console.Clear();
            Console.Write("Add a color changing trigger?\n1 - Yes\n0 - No\n> ");
            string addtrgstr = Console.ReadLine();

            addTrigger = addtrgstr.ToLower() == "yes" || addtrgstr == "1" ? true : false;
            Console.Clear();
            Console.Write("The name of the level in which the art will be placed.\nRecomended use empty level.\nPossible level damage!\n> ");
            levelName = Console.ReadLine();
            Console.Write("Level revision.\n> ");
            levelRevision = int.Parse(Console.ReadLine());
            Console.Clear();

            Stopwatch sw = new Stopwatch();

            sw.Restart();

            Console.WriteLine("Loading level ...");
            localLevels = new LocalLevels();
            level       = new Level(localLevels.GetLevel(levelName, levelRevision));

            Console.WriteLine("Loading image ...");
            art = new Bitmap(fileArt);

            blockStart = level.CountBlock;

            Console.WriteLine("Creating art...");
            int currentColorID = colorStart;
            int startFor       = 0;

            if (pixelSize >= 2)
            {
                startFor = 1;
            }
            else if (pixelSize >= 4)
            {
                startFor = 2;
            }
            else if (pixelSize >= 8)
            {
                startFor = 4;
            }
            for (int x = startFor; x < art.Width; x += pixelSize)
            {
                for (int y = startFor; y < art.Height; y += pixelSize)
                {
                    System.Drawing.Color color = art.GetPixel(x, y);
                    int colorInt = BytesToInt(color.R, color.G, color.B);
                    if (useAplhaChannel)
                    {
                        if (color.A < alphaChannel)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (FindSimilar(color.R, color.G, color.B, alpha[0], alpha[1], alpha[2]))
                        {
                            continue;
                        }
                    }
                    if (!palette.ContainsKey(colorInt))
                    {
                        int?sim = FindSimilar(color.R, color.G, color.B);
                        if (sim == null)
                        {
                            level.AddColor(new GeometryDashAPI.Levels.Color((short)currentColorID, color.R, color.G, color.B));
                            palette.Add(colorInt, currentColorID);
                            if (addTrigger)
                            {
                                level.AddBlock(new PulseTrigger()
                                {
                                    TargetID  = currentColorID,
                                    Red       = color.R,
                                    Green     = color.G,
                                    Blue      = color.B,
                                    Hold      = 10f,
                                    PositionX = -15 + coordX,
                                    PositionY = 0 + coordY,
                                    EditorL   = (short)EditorLayer
                                });
                            }
                            currentColorID++;
                        }
                        else
                        {
                            colorInt = (int)sim;
                        }
                    }
                    DetailBlock block = new DetailBlock(917);
                    block.ColorDetail = (short)palette[colorInt];
                    block.Scale       = scale;
                    block.EditorL     = (short)EditorLayer;
                    block.PositionX   = (x / pixelSize * 7.5f * scale) + coordX;
                    block.PositionY   = ((art.Height - y) / pixelSize * 7.5f * scale) + coordY;
                    level.AddBlock(block);
                }
            }

            Console.WriteLine("Save...");
            localLevels.GetLevelByName(levelName).LevelString = level.ToString();
            localLevels.Save();

            sw.Stop();

            Console.Clear();
            Console.WriteLine($"Completed!\nUsed colors: {palette.Count}\nUsed blocks: {level.CountBlock - blockStart}\nElapsed time: {sw.ElapsedTicks} ticks ({sw.ElapsedMilliseconds} milliseconds)");
            Console.WriteLine("Press any button to continue.");
            Console.ReadKey();
        }