public static bool CreateDynamicMap(ushort mapadd, ushort mapneed, uint ownerid)
 {
     bool addedmap = false;
     if (DMaps.MapOwner.Contains(Convert.ToInt32(ownerid)))
         return false;
     while (ServerBase.Kernel.Maps.ContainsKey(mapadd))
     {
         mapadd++;
     }
     FileStream FS = new FileStream(ServerBase.Constants.DataHolderPath + "GameMap.dat", FileMode.Open);
     BinaryReader BR = new BinaryReader(FS);
     uint MapCount = BR.ReadUInt32();
     for (uint i = 0; i < MapCount; i++)
     {
         ushort MapID = (ushort)BR.ReadUInt32();
         string Path = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadInt32()));
         if (mapneed == MapID)
         {
             ushort NewMapID = mapadd;
             Game.Map D = new Game.Map(NewMapID, Path);
             D.Owner = NewMapID;
             ServerBase.Kernel.Maps.Add(NewMapID, D);
             //ServerBase.Kernel.Maps.Add(NewMapID, mapneed);
             MapOwner.Add(Convert.ToInt32(ownerid), NewMapID);
             addedmap = true;
             break;
         }
         BR.ReadInt32();
     }
     BR.Close();
     FS.Close();
        // FS.Dispose();
     //BR.Dispose();
     return addedmap;
 }
Esempio n. 2
0
 public static void PostCreateHook(Game.Map self, Game.CreateWorldOptions options)
 {
     foreach (var mod in active_mods)
     {
         mod.PostWorldCreation(modSaveFile.GetDataFor(mod), self, options);
     }
 }
Esempio n. 3
0
 public void SetMap(Game.Map Map)
 {
     this.Map = Map;
     MapViewerTiles.SetMap(Map);
     MapViewerConnections.SetMap(Map);
     MapImageWidget.LoadLayers(Map);
     //MapViewerEvents.SetMap(Map);
     //MapViewerEncounters.SetMap(Map);
     //MapViewerProperties.SetMap(Map);
     //if (Submodes.SelectedIndex != -1) ActiveMapViewer.PositionMap();
 }
Esempio n. 4
0
        public void ReadyToPlay()
        {
            Screen = new Game.Screen(this);

            Inventory = new Game.ConquerStructures.Inventory(this);
            Equipment = new Game.ConquerStructures.Equipment(this);
            WarehouseOpen = false;
            WarehouseOpenTries = 0;
            TempPassword = "";
            Warehouses = new SafeDictionary<Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID, Conquer_Online_Server.Game.ConquerStructures.Warehouse>(20);
            Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.TwinCity, new Conquer_Online_Server.Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.TwinCity));
            Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.PhoenixCity, new Conquer_Online_Server.Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.PhoenixCity));
            Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.ApeCity, new Conquer_Online_Server.Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.ApeCity));
            Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.DesertCity, new Conquer_Online_Server.Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.DesertCity));
            Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.BirdCity, new Conquer_Online_Server.Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.BirdCity));
            Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.StoneCity, new Conquer_Online_Server.Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.StoneCity));
            Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.Market, new Conquer_Online_Server.Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.Market));
            Trade = new Game.ConquerStructures.Trade();
            ArenaStatistic = new ArenaStatistic(true);
            Prayers = new List<GameState>();
            map = null;
        }
Esempio n. 5
0
        public void SetMap(Map Map)
        {
            this.MapData = Map;
            Cursor.SetPosition(21, 39);
            AutotileIndex       = -1;
            AutotileCombination = -1;
            TilesetIndex        = 0;
            TileStartX          = 0;
            TileStartY          = 0;
            TileEndX            = 0;
            TileEndY            = 0;
            for (int i = 0; i < this.AutotileContainers.Count; i++)
            {
                if (this.AutotileContainers[i] is CollapsibleContainer)
                {
                    (this.AutotileContainers[i] as CollapsibleContainer).Dispose();
                }
            }
            this.AutotileContainers.Clear();
            if (SingleAutotileContainer is CollapsibleContainer)
            {
                SingleAutotileContainer.Dispose();
            }
            SingleAutotileContainer = null;
            Bitmap singles = null;

            SingleAutotileCount = MapData.AutotileIDs.FindAll(id => Data.Autotiles[id].Format == AutotileFormat.Single).Count;
            if (SingleAutotileCount > 0)
            {
                SingleAutotileContainer = new CollapsibleContainer(MainStackPanel);
                SingleAutotileContainer.SetText("Single Autotiles");
                SingleAutotileContainer.SetMargin(0, 0, 0, 8);
                SingleAutotileContainer.OnCollapsedChanged += delegate(BaseEventArgs e) { UpdateCursor(); };
                singles = new Bitmap(263, 33 + 33 * (int)Math.Floor(SingleAutotileCount / 8d));
                singles.Unlock();
                SingleAutotileContainer.SetSize(MainContainer.Size.Width - 13, singles.Height + 23);
                PictureBox image = new PictureBox(SingleAutotileContainer);
                image.SetPosition(0, 23);
                image.Sprite.Bitmap = singles;
                image.SetSize(image.Sprite.Bitmap.Width, image.Sprite.Bitmap.Height);
            }
            int SingleIndex = 0;

            for (int i = 0; i < MapData.AutotileIDs.Count; i++)
            {
                int      autotileid = MapData.AutotileIDs[i];
                Autotile autotile   = Data.Autotiles[autotileid];
                if (autotile.Format == AutotileFormat.Single)
                {
                    int x = 33 * (SingleIndex % 8);
                    int y = 33 * (int)Math.Floor(SingleIndex / 8d);
                    singles.Build(x, y, autotile.AutotileBitmap, new Rect(0, 0, 32, 32));
                    AutotileContainers.Add(SingleIndex);
                    SingleIndex++;
                    continue;
                }
                CollapsibleContainer c = new CollapsibleContainer(MainStackPanel);
                c.SetText(autotile.Name);
                c.SetMargin(0, 0, 0, 8);
                c.OnCollapsedChanged += delegate(BaseEventArgs e) { UpdateCursor(); };
                c.SetSize(MainContainer.Size.Width - 13, 87);
                c.ObjectData = i;
                AutotileContainers.Add(c);
                PictureBox image = new PictureBox(c);
                image.SetPosition(0, 23);
                AutotileFormat f   = autotile.Format;
                Bitmap         bmp = new Bitmap(263, 64);
                bmp.Unlock();
                for (int j = 0; j < 4; j++)
                {
                    // Constructs a bitmap with the four corner autotile pieces.
                    int x = 0,
                        y = 0;
                    if (j == 0)
                    {
                        y = 32;
                    }
                    else if (j == 1)
                    {
                        x = (f == AutotileFormat.RMVX ? 32 : 64); y = 32;
                    }
                    else if (j == 2)
                    {
                        y = (f == AutotileFormat.RMVX ? 64 : 96);
                    }
                    else if (j == 3)
                    {
                        x = (f == AutotileFormat.RMVX ? 32 : 64); y = (f == AutotileFormat.RMVX ? 64 : 96);
                    }
                    bmp.Build(32 * (j % 2), 32 * (int)Math.Floor(j / 2d), autotile.AutotileBitmap, new Rect(x, y, 32, 32));
                }
                image.Sprite.Bitmap = bmp;
                image.SetSize(image.Sprite.Bitmap.Width, image.Sprite.Bitmap.Height);
                DrawQuickAutotiles(i);
                bmp.Lock();
            }
            if (singles != null)
            {
                singles.Lock();
            }
            for (int i = 0; i < this.TilesetContainers.Count; i++)
            {
                this.TilesetContainers[i].Dispose();
            }
            this.TilesetContainers.Clear();
            this.TilesetImages.Clear();
            for (int i = 0; i < MapData.TilesetIDs.Count; i++)
            {
                int     tilesetid      = MapData.TilesetIDs[i];
                Tileset tileset        = Data.Tilesets[tilesetid];
                CollapsibleContainer c = new CollapsibleContainer(MainStackPanel);
                c.SetText(tileset.Name);
                c.SetMargin(0, 0, 0, 8);
                c.OnCollapsedChanged += delegate(BaseEventArgs e) { UpdateCursor(); };
                c.SetSize(MainContainer.Size.Width - 13, tileset.TilesetListBitmap.Height + 23);
                TilesetContainers.Add(c);
                PictureBox image = new PictureBox(c);
                image.SetPosition(0, 23);
                image.Sprite.Bitmap        = tileset.TilesetListBitmap;
                image.Sprite.DestroyBitmap = false;
                image.SetSize(image.Sprite.Bitmap.Width, image.Sprite.Bitmap.Height);
                TilesetImages.Add(image);
            }
        }
Esempio n. 6
0
 public void SetMap(Game.Map Map)
 {
     EventMapImageWidget.LoadLayers(Map);
     MapViewer.SetMap(Map);
     EventListPanel.SetMap(Map);
 }
Esempio n. 7
0
 void InitialSetup()
 {
     Instance = this;
     Map      = new Game.Map();
 }
Esempio n. 8
0
 public static void PostGenerateMap(Game.Map self, Game.CreateWorldOptions options)
 {
     Instance.ModManager.OnPostGenerateMapEvent(new PostGenerateMapEventArgs(self, options));
 }
 public void ReadyToPlay()
 {
     try
     {
         Screen = new Game.Screen(this);
         Inventory = new Game.ConquerStructures.Inventory(this);
         Equipment = new Game.ConquerStructures.Equipment(this);
         WarehouseOpen = false;
         WarehouseOpenTries = 0;
         TempPassword = "";
         Warehouses = new SafeDictionary<PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID, PhoenixProject.Game.ConquerStructures.Warehouse>(20);
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.TwinCity, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.TwinCity));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.PhoenixCity, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.PhoenixCity));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.ApeCity, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.ApeCity));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.DesertCity, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.DesertCity));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.BirdCity, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.BirdCity));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.StoneCity, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.StoneCity));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.Market, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.Market));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.House, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.House));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.poker1, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.poker1));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.poker2, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.poker2));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.House2, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.House2));
         Trade = new Game.ConquerStructures.Trade();
         ArenaStatistic = new ArenaStatistic(true);
         Prayers = new List<GameState>();
         MagicDef = new List<GameState>();
         map = null;
     }
     catch (Exception e)
     {
         Program.SaveException(e);
     }
 }
Esempio n. 10
0
 public virtual void PostWorldCreation(ModSaveData data, Game.Map map, Game.CreateWorldOptions options)
 {
 }
Esempio n. 11
0
        public static void ImportMaps()
        {
            Setup();
            OpenFileDialog of = new OpenFileDialog();

            of.SetFilter(new FileFilter("RPG Maker XP Map", "rxdata"));
            of.SetTitle("Pick map(s)");
            of.SetAllowMultiple(true);
            object        ret   = of.Show();
            List <string> Files = new List <string>();

            if (ret is string)
            {
                Files.Add(ret as string);
            }
            else if (ret is List <string> )
            {
                Files = ret as List <string>;
            }
            else
            {
                return;  // No files picked
            }
            for (int i = 0; i < Files.Count; i++)
            {
                while (Files[i].Contains('\\'))
                {
                    Files[i] = Files[i].Replace('\\', '/');
                }
            }
            string[] folders = Files[0].Split('/');
            string   parent  = "";
            string   root    = "";

            for (int i = 0; i < folders.Length - 1; i++)
            {
                parent += folders[i];
                if (i != folders.Length - 2)
                {
                    root += folders[i];
                }
                if (i != folders.Length - 2)
                {
                    parent += '/';
                }
                if (i != folders.Length - 3)
                {
                    root += '/';
                }
            }
            List <string> Names = new List <string>();

            foreach (string f in Files)
            {
                string[] l = f.Split('/').Last().Split('.');
                string   n = "";
                for (int i = 0; i < l.Length - 1; i++)
                {
                    n += l[i];
                    if (i != l.Length - 2)
                    {
                        n += '.';
                    }
                }
                Names.Add(n);
            }
            // Load MapInfos.rxdata
            IntPtr infofile = Ruby.Funcall(Ruby.GetConst(Ruby.Object.Class, "File"), "open", Ruby.String.ToPtr(parent + "/MapInfos.rxdata"), Ruby.String.ToPtr("rb"));
            IntPtr infos    = Ruby.Funcall(Ruby.GetConst(Ruby.Object.Class, "Marshal"), "load", infofile);

            Ruby.Pin(infos);
            IntPtr keys = Ruby.Funcall(infos, "keys");

            Ruby.Pin(keys);
            Ruby.Funcall(infofile, "close");
            // Load Tilesets.rxdata
            IntPtr tilesetfile = Ruby.Funcall(Ruby.GetConst(Ruby.Object.Class, "File"), "open", Ruby.String.ToPtr(parent + "/Tilesets.rxdata"), Ruby.String.ToPtr("rb"));
            IntPtr tilesets    = Ruby.Funcall(Ruby.GetConst(Ruby.Object.Class, "Marshal"), "load", tilesetfile);

            Ruby.Pin(tilesets);
            Ruby.Funcall(tilesetfile, "close");
            Action <int> ImportMap = null;

            ImportMap = delegate(int MapIndex)
            {
                // Convert rxdata (Ruby) to mkd (C#)
                string MapName = Names[MapIndex];
                string file    = Files[MapIndex];
                while (file.Contains('\\'))
                {
                    file = file.Replace('\\', '/');
                }
                // Load Map.rxdata
                IntPtr f   = Ruby.Funcall(Ruby.GetConst(Ruby.Object.Class, "File"), "open", Ruby.String.ToPtr(file), Ruby.String.ToPtr("rb"));
                IntPtr map = Ruby.Funcall(Ruby.GetConst(Ruby.Object.Class, "Marshal"), "load", f);
                Ruby.Pin(map);
                Ruby.Funcall(f, "close");
                int id = Convert.ToInt32(file.Substring(file.Length - 10, 3));
                // Link Map with its MapInfo
                IntPtr info = IntPtr.Zero;
                for (int i = 0; i < Ruby.Array.Length(keys); i++)
                {
                    if (Ruby.Array.Get(keys, i) == Ruby.Integer.ToPtr(id))
                    {
                        info = Ruby.Funcall(infos, "[]", Ruby.Array.Get(keys, i));
                    }
                }
                if (info == IntPtr.Zero)
                {
                    throw new Exception($"No MapInfo could be found for map ({MapName}).");
                }
                Game.Map data = new Game.Map();
                data.ID          = Editor.GetFreeMapID();
                data.DisplayName = MapInfo.Name(info);
                data.DevName     = data.DisplayName;
                data.Width       = Map.Width(map);
                data.Height      = Map.Height(map);
                IntPtr tileset = Ruby.Array.Get(tilesets, Map.TilesetID(map));
                Ruby.Pin(tileset);
                string       tilesetname = Tileset.Name(tileset);
                Action       cont        = null;
                Game.Tileset existing    = Data.Tilesets.Find(t => t != null && (t.Name == tilesetname || t.GraphicName == tilesetname));
                bool         exist       = existing != null;
                string       message     = $"Importing Map ({MapName})...\n\n";
                if (exist)
                {
                    message += "The tileset of the imported map has the same name as an already-defined tileset in " +
                               $"the database ({existing.Name}).\n" +
                               "Would you like to use this tileset, choose a different one, or import it?";
                }
                else
                {
                    message += $"No tilesets similar to the one used in the imported map ({Tileset.Name(tileset)}) could be found.\n" +
                               "Would you like to pick an existing tileset, or import it?";
                }
                List <string> Options = new List <string>();
                if (exist)
                {
                    Options.Add("Use this");
                }
                Options.Add("Pick other");
                Options.Add("Import it");
                MessageBox box = new MessageBox("Importing Map", message, Options);
                box.OnButtonPressed += delegate(BaseEventArgs e)
                {
                    if (Options[box.Result] == "Use this") // Use the matched tileset
                    {
                        data.TilesetIDs = new List <int>()
                        {
                            existing.ID
                        };
                        cont();
                    }
                    else if (Options[box.Result] == "Pick other") // Pick other tileset
                    {
                        TilesetPicker picker = new TilesetPicker(null);
                        picker.OnClosed += delegate(BaseEventArgs e)
                        {
                            if (picker.ChosenTilesetID > 0) // Chose tileset
                            {
                                data.TilesetIDs = new List <int>()
                                {
                                    picker.ChosenTilesetID
                                };
                                cont();
                            }
                            else // Didn't pick tileset; cancel importing
                            {
                                data = null;
                                Ruby.Unpin(tileset);
                                Ruby.Unpin(map);
                                MessageBox b = new MessageBox("Warning", $"Importing Map ({MapName})...\n\nAs no tileset was chosen, this map will not be imported.", IconType.Warning);
                                b.OnButtonPressed += delegate(BaseEventArgs e)
                                {
                                    if (MapIndex < Files.Count - 1)
                                    {
                                        ImportMap(MapIndex + 1);
                                    }
                                };
                            }
                        };
                    }
                    else if (Options[box.Result] == "Import it") // Import the tileset
                    {
                        string filename = root + "/Graphics/Tilesets/" + Tileset.TilesetName(tileset) + ".png";
                        if (!File.Exists(filename)) // Graphic doesn't exist
                        {
                            MessageBox b = new MessageBox("Error", $"Importing Map ({MapName})...\n\nThe tileset graphic could not be found. The tileset cannot be imported, and thus this map will not be imported.", IconType.Error);
                            b.OnButtonPressed += delegate(BaseEventArgs e)
                            {
                                if (MapIndex < Files.Count - 1)
                                {
                                    ImportMap(MapIndex + 1);
                                }
                            };
                        }
                        else // Graphic does exist
                        {
                            Bitmap bmp = new Bitmap(filename);
                            int    pw  = bmp.Width / 32 * 33;
                            int    ph  = bmp.Height / 32 * 33;
                            if (pw > Graphics.MaxTextureSize.Width || ph > Graphics.MaxTextureSize.Height)
                            {
                                MessageBox b = new MessageBox("Error",
                                                              $"Importing Map ({MapName})...\n\n" +
                                                              $"The formatted tileset will exceed the maximum texture size ({Graphics.MaxTextureSize.Width},{Graphics.MaxTextureSize.Height}).\n" +
                                                              "This map will not be imported."
                                                              );
                                b.OnButtonPressed += delegate(BaseEventArgs e)
                                {
                                    if (MapIndex < Files.Count - 1)
                                    {
                                        ImportMap(MapIndex + 1);
                                    }
                                };
                            }
                            else
                            {
                                string destination = Data.ProjectPath + "/gfx/tilesets/";
                                string name        = Tileset.TilesetName(tileset);
                                if (File.Exists(destination + Tileset.TilesetName(tileset) + ".png"))
                                {
                                    int i = 0;
                                    do
                                    {
                                        i++;
                                    } while (File.Exists(destination + Tileset.TilesetName(tileset) + " (" + i.ToString() + ").png"));
                                    destination += Tileset.TilesetName(tileset) + " (" + i.ToString() + ").png";
                                    name        += " (" + i.ToString() + ")";
                                }
                                else
                                {
                                    destination += Tileset.TilesetName(tileset) + ".png";
                                }
                                File.Copy(filename, destination);
                                Game.Tileset set = new Game.Tileset();
                                set.Name        = Tileset.Name(tileset);
                                set.GraphicName = name;
                                set.ID          = Editor.GetFreeTilesetID();
                                int tilecount = 8 * bmp.Height / 32;
                                set.Passabilities = new List <Passability>();
                                set.Priorities    = new List <int?>();
                                set.Tags          = new List <int?>();
                                for (int i = 0; i < tilecount; i++)
                                {
                                    set.Passabilities.Add(Passability.All);
                                    set.Priorities.Add(0);
                                    set.Tags.Add(null);
                                }
                                Data.Tilesets[set.ID] = set;
                                set.CreateBitmap();
                                if (Editor.MainWindow.DatabaseWidget != null)
                                {
                                    Editor.MainWindow.DatabaseWidget.DBDataList.RefreshList();
                                }
                                data.TilesetIDs = new List <int>()
                                {
                                    set.ID
                                };
                                cont();
                            }
                        }
                    }
                };
                // Called whenever a choice has been made for tileset importing.
                cont = new Action(delegate()
                {
                    if (data.TilesetIDs == null || data.TilesetIDs.Count == 0) // Should not be reachable
                    {
                        throw new Exception("Cannot continue without a tileset.");
                    }

                    data.Layers = new List <Layer>();

                    bool RemovedAutotiles = false;
                    bool RemovedEvents    = Ruby.Integer.FromPtr(Ruby.Funcall(Map.Events(map), "length")) > 0;

                    IntPtr Tiles    = Map.Data(map);
                    int XSize       = Table.XSize(Tiles);
                    int YSize       = Table.YSize(Tiles);
                    int ZSize       = Table.ZSize(Tiles);
                    IntPtr tiledata = Table.Data(Tiles);
                    for (int z = 0; z < ZSize; z++)
                    {
                        Layer layer = new Layer($"Layer {z + 1}");
                        for (int y = 0; y < YSize; y++)
                        {
                            for (int x = 0; x < XSize; x++)
                            {
                                int idx    = x + y * XSize + z * XSize * YSize;
                                int tileid = (int)Ruby.Integer.FromPtr(Ruby.Array.Get(tiledata, idx));
                                if (tileid < 384)
                                {
                                    RemovedAutotiles = true;
                                }
                                if (tileid == 0)
                                {
                                    layer.Tiles.Add(null);
                                }
                                else
                                {
                                    layer.Tiles.Add(new TileData()
                                    {
                                        TileType = TileType.Tileset, Index = 0, ID = tileid - 384
                                    });
                                }
                            }
                        }
                        data.Layers.Add(layer);
                    }

                    Ruby.Unpin(map);
                    Ruby.Unpin(tileset);

                    Editor.AddMap(data);

                    if (MapIndex < Files.Count - 1)
                    {
                        ImportMap(MapIndex + 1);
                    }
                    else
                    {
                        string Title = "Warning";
                        string Msg   = "";
                        if (Files.Count > 1)
                        {
                            Msg = "The maps were imported successfully";
                        }
                        else
                        {
                            Msg = "The map was imported successfully";
                        }
                        if (RemovedEvents && RemovedAutotiles)
                        {
                            Msg += ", but all events and autotiles have been deleted as these have not yet been implemented in RPG Studio MK.";
                        }
                        else if (RemovedEvents)
                        {
                            Msg += ", but all events have been deleted as these have not yet been implemented in RPG Studio MK.";
                        }
                        else if (RemovedAutotiles)
                        {
                            Msg += ", but all autotiles have been deleted as these have not yet been implemented in RPG Studio MK.";
                        }
                        else
                        {
                            Title = "Success";
                            Msg  += ".";
                        }
                        List <string> options = new List <string>();
                        if (Editor.ProjectSettings.LastMode != "MAPPING")
                        {
                            options.Add("Go to Map");
                        }
                        options.Add("OK");
                        MessageBox box       = new MessageBox(Title, Msg, options, IconType.Info);
                        box.OnButtonPressed += delegate(BaseEventArgs e)
                        {
                            if (options[box.Result] == "Go to Map") // Go to map
                            {
                                Editor.SetMode("MAPPING");
                                Editor.MainWindow.MapWidget.MapSelectPanel.SetMap(data);
                            }
                        };
                        Ruby.Unpin(keys);
                        Ruby.Unpin(infos);
                        Ruby.Unpin(tileset);
                        Cleanup();
                    }
                });
            };
            ImportMap(0);
        }
Esempio n. 12
0
 public Player()
     : base(MapObjects.Player)
 {
     Map = new Game.Map();
 }