public void OnLoadTileset(Jazz2 jazz2)
        {
            jazz2.Read(jazz2.Address + 0x1F3884, out string levelName, 32);
            var levelIndex = Array.IndexOf(LevelOrder, levelName.ToLower());

            if (levelIndex >= 0 && levelIndex < LevelSettings.Count)
            {
                LevelSettings[levelIndex].OnLoadTilset(jazz2, rng);
            }
        }
        public void OnLoadLevel(Jazz2 jazz2)
        {
            jazz2.Read(jazz2.Address + 0x1F3884, out string levelName, 32);
            var levelIndex = Array.IndexOf(LevelOrder, levelName.ToLower());

            if (levelIndex >= 0 && levelIndex < LevelSettings.Count)
            {
                var nextLevel = levelIndex + 1 < LevelOrder.Length ? LevelOrder[levelIndex + 1] : "ending";
                jazz2.Write(jazz2.Address + 0x14D5D3, nextLevel, 32);
                LevelSettings[levelIndex].OnLoadLevel(jazz2, rng);
            }
        }
Пример #3
0
        public MainForm()
        {
            InitializeComponent();
            Text = ProductName + " " + ProductVersion;

            jazz2 = new Jazz2();
            jazz2.ProcessFound  += Jazz2_ProcessFound;
            jazz2.ProcessClosed += Jazz2_ProcessClosed;

            loopThread = new Thread(LoopProc);
            loopThread.Start();

            randomizerSettings = new RandomizerSettings();
            randomizerSettings.LevelSettings.Add(new LevelSettings()
            {
                LevelFilename = "carrot1.j2l", Bird = true, Jazz = true
            });
            randomizerSettings.LevelSettings.Add(new LevelSettings()
            {
                LevelFilename = "castle1n.j2l", Bird = true, Spaz = true
            });

            textBoxSeed.Text = new Random().Next().ToString("X8");
        }
Пример #4
0
        public void OnLoadTilset(Jazz2 jazz2, Random rng)
        {
            if (RandomizeColors)
            {
                if (bitShifts == null)
                {
                    bitShifts = Enumerable.Range(0, 3)
                                .Select(x => 8 * x)
                                .OrderBy(x => rng.Next())
                                .ToArray();
                }

                int[] colors = new int[256];
                jazz2.Read(jazz2.Address + 0x1607A0, colors);
                for (int i = 0; i < colors.Length; i++)
                {
                    var r = colors[i] & 0xFF;
                    var g = (colors[i] >> 8) & 0xFF;
                    var b = (colors[i] >> 16) & 0xFF;
                    colors[i] = r << bitShifts[0] | g << bitShifts[1] | b << bitShifts[2];
                }
                jazz2.Write(jazz2.Address + 0x1607A0, colors);
            }
        }
Пример #5
0
        public void OnLoadLevel(Jazz2 jazz2, Random rng)
        {
            jazz2.Read(jazz2.Address + 0x1191D4, out IntPtr eventsPointer);
            jazz2.Read(eventsPointer, out eventsPointer);

            if (events == null)
            {
                var characterCount = 0;
                var characters     = new int[5];
                if (Jazz)
                {
                    characters[characterCount++] = 55;
                }
                if (Spaz)
                {
                    characters[characterCount++] = 89;
                }
                if (Lori)
                {
                    characters[characterCount++] = 61;
                }
                if (Frog)
                {
                    characters[characterCount++] = 47;
                }
                if (Bird)
                {
                    characters[characterCount++] = 8;
                }
                character = characters[rng.Next(characterCount)];

                jazz2.Read(jazz2.Address + 0x10F14C, out int width);
                jazz2.Read(jazz2.Address + 0x1191AC, out int height);

                events = new int[width * height];
                jazz2.Read(eventsPointer, events);

                var eventLookups = new Dictionary <int, int>();
                for (int i = 0; i < events.Length; i++)
                {
                    var eventId    = events[i] & 0xFF;
                    var eventGroup = EventGroups.FirstOrDefault(x => x.EventsFrom.Any(y => y.EventId == eventId));
                    if (eventGroup != null)
                    {
                        if (eventGroup.RandomizeIndividually)
                        {
                            events[i] = eventGroup.EventsTo[rng.Next(eventGroup.EventsTo.Count)].EventId;
                        }
                        else
                        {
                            if (!eventLookups.TryGetValue(eventId, out int newEventId))
                            {
                                newEventId            = eventGroup.EventsTo[rng.Next(eventGroup.EventsTo.Count)].EventId;
                                eventLookups[eventId] = newEventId;
                            }
                            events[i] = newEventId;
                        }
                    }
                }
            }

            jazz2.Write(eventsPointer, events);
            jazz2.Write(jazz2.Address + 0x1C89E0, character);
            //jazz2.Write(jazz2.Address + 0x14D613, song, 32);
        }