Example #1
0
        public static void CreateNewLevel(WorldInfo world)
        {
            NewLevelForm newLevelForm = new NewLevelForm();
            newLevelForm.StartPosition = FormStartPosition.CenterParent;
            newLevelForm.Owner = ReubenController.MainWindow;

            DialogResult result = newLevelForm.ShowDialog(world);
            if (result == DialogResult.OK)
            {
                ProjectController.LevelManager.CreateNewLevel(newLevelForm.LevelName, newLevelForm.LevelType, newLevelForm.LevelLayout, newLevelForm.SelectedWorld);
            }
        }
Example #2
0
        public bool AddWorld(WorldInfo wi)
        {
            if (worldLookup.ContainsKey(wi.WorldGuid)) return false;

            wi.Ordinal = Worlds.Count - 1;
            Worlds.Insert(Worlds.Count - 1, wi);
            worldLookup.Add(wi.WorldGuid, wi);
            if (WorldAdded != null)
            {
                WorldAdded(this, new TEventArgs<WorldInfo>(wi));
            }
            return true;
        }
Example #3
0
        public static void CreateNewWorld()
        {
            InputForm iForm = new InputForm();
            iForm.StartPosition = FormStartPosition.CenterParent;
            iForm.Owner = ReubenController.MainWindow;

            string name = iForm.GetInput("Please enter a world name.");
            if (name != null)
            {
                WorldInfo wi = new WorldInfo();
                wi.WorldGuid = Guid.NewGuid();
                wi.Name = name;
                ProjectController.WorldManager.AddWorld(wi);
            }
        }
Example #4
0
        public void RemoveWorld(WorldInfo wi)
        {
            Worlds.Remove(wi);
            worldLookup.Remove(wi.WorldGuid);

            if (File.Exists(string.Format("{0}{1}{2}.map", ProjectController.WorldDirectory, Path.DirectorySeparatorChar, wi.WorldGuid)))
            {
                File.Delete(string.Format("{0}{1}{2}.map", ProjectController.WorldDirectory, Path.DirectorySeparatorChar, wi.WorldGuid));
            }

            int worldIndex = 0;
            foreach (var w in Worlds)
            {
                if (!w.IsNoWorld)
                {
                    w.Ordinal = worldIndex++;
                }
            }
        }
Example #5
0
        public void New(WorldInfo wi)
        {
            Guid = wi.WorldGuid;
            Length = 1;
            Palette = 0;
            GraphicsBank = 0x16;
            for (int i = 0; i < 0x10; i++)
            {
                for (int j = 0; j < 0x40; j++)
                {
                    LevelData[j, i] = 0x02;
                }
            }

            for (int i = 0; i < 0x40; i++)
            {
                LevelData[i, 0x10] = 0x4E;
                LevelData[i, 0x1A] = 0x4F;
            }
        }
Example #6
0
 private void AddWorld(WorldInfo wi)
 {
     TreeNode nextNode = new TreeNode();
     nextNode.Text = wi.Name;
     nextNode.Tag = wi;
     WorldToNodes.Add(wi.WorldGuid, nextNode);
     NodesToWorlds.Add(nextNode, wi);
     projectNode.Nodes.Insert(projectNode.Nodes.Count - 1, nextNode);
     ToolStripMenuItem nextMenu = new ToolStripMenuItem(wi.Name);
     nextMenu.Tag = wi;
     MnuMoveTo.DropDownItems.Add(nextMenu);
     nextMenu.Click += new EventHandler(MoveLevelTo_Clicked);
 }
Example #7
0
        public bool CreateNewLevel(string name, LevelType levelType, LevelLayout layout, WorldInfo worldinfo)
        {
            Level l = new Level();

            l.LevelLayout = layout;
            l.Palette     = levelType.InGameID;
            switch (levelType.InGameID)
            {
            case 1:
                l.GraphicsBank = 0x08;
                l.ClearValue   = 0x90;
                break;

            case 2:
                l.GraphicsBank = 0x10;
                l.ClearValue   = 0x90;
                break;

            case 3:
                l.GraphicsBank = 0x6C;
                l.ClearValue   = 0x90;
                break;

            case 4:
                l.GraphicsBank = 0x06;
                l.ClearValue   = 0x90;
                break;

            case 5:
                l.GraphicsBank = 0x58;
                l.ClearValue   = 0x90;
                break;

            case 6:
                l.GraphicsBank = 0x58;
                l.ClearValue   = 0x90;
                break;

            case 7:
                l.GraphicsBank = 0x5C;
                l.ClearValue   = 0x90;
                break;

            case 8:
                l.GraphicsBank = 0x3E;
                l.ClearValue   = 0x80;
                break;

            case 9:
                l.GraphicsBank = 0x30;
                l.ClearValue   = 0x90;
                break;

            case 10:
                l.GraphicsBank = 0x34;
                l.ClearValue   = 0x90;
                break;


            case 11:
                l.GraphicsBank = 0x6E;
                l.ClearValue   = 0x90;
                break;


            case 12:
                l.GraphicsBank = 0x18;
                l.ClearValue   = 0x90;
                break;


            case 13:
                l.GraphicsBank = 0x38;
                l.ClearValue   = 0x90;
                break;

            case 14:
                l.GraphicsBank = 0x1C;
                l.ClearValue   = 0x90;
                break;
            }

            l.Guid              = Guid.NewGuid();
            l.Length            = 0x0A;
            l.Type              = levelType.InGameID;
            l.Music             = 0x00;
            l.Time              = 300;
            l.PaletteEffect     = 0;
            l.InvincibleEnemies = false;
            l.VineBlocked       = false;
            l.XStart            = 0x00;
            l.YStart            = 0x14;

            for (int j = 0; j < l.Height; j++)
            {
                for (int i = 0; i < l.Width; i++)
                {
                    l.LevelData[i, j] = (byte)l.ClearValue;
                }
            }

            LevelInfo li = new LevelInfo()
            {
                Name      = name,
                LevelGuid = l.Guid,
                WorldGuid = worldinfo.WorldGuid,
                LevelType = l.Type,
                Layout    = l.LevelLayout
            };

            Levels.Add(li);
            levelLookup.Add(l.Guid, li);

            if (l.Save())
            {
                if (LevelAdded != null)
                {
                    LevelAdded(this, new TEventArgs <LevelInfo>(li));
                }
            }
            return(true);
        }
Example #8
0
        public bool CreateNewLevel(string name, LevelType levelType, LevelLayout layout, WorldInfo worldinfo)
        {
            Level l = new Level();
            l.LevelLayout = layout;
            l.Palette = levelType.InGameID;
            switch (levelType.InGameID)
            {
                case 1:
                    l.GraphicsBank = 0x08;
                    l.ClearValue = 0x90;
                    break;

                case 2:
                    l.GraphicsBank = 0x10;
                    l.ClearValue = 0x90;
                    break;

                case 3:
                    l.GraphicsBank = 0x6C;
                    l.ClearValue = 0x90;
                    break;

                case 4:
                    l.GraphicsBank = 0x06;
                    l.ClearValue = 0x90;
                    break;

                case 5:
                    l.GraphicsBank = 0x58;
                    l.ClearValue = 0x90;
                    break;

                case 6:
                    l.GraphicsBank = 0x58;
                    l.ClearValue = 0x90;
                    break;

                case 7:
                    l.GraphicsBank = 0x5C;
                    l.ClearValue = 0x90;
                    break;

                case 8:
                    l.GraphicsBank = 0x3E;
                    l.ClearValue = 0x80;
                    break;

                case 9:
                    l.GraphicsBank = 0x30;
                    l.ClearValue = 0x90;
                    break;

                case 10:
                    l.GraphicsBank = 0x34;
                    l.ClearValue = 0x90;
                    break;


                case 11:
                    l.GraphicsBank = 0x6E;
                    l.ClearValue = 0x90;
                    break;


                case 12:
                    l.GraphicsBank = 0x18;
                    l.ClearValue = 0x90;
                    break;


                case 13:
                    l.GraphicsBank = 0x38;
                    l.ClearValue = 0x90;
                    break;

                case 14:
                    l.GraphicsBank = 0x1C;
                    l.ClearValue = 0x90;
                    break;
            }

            l.Guid = Guid.NewGuid();
            l.Length = 0x0A;
            l.Type = levelType.InGameID;
            l.Music = 0x00;
            l.Time = 300;
            l.PaletteEffect = 0;
            l.InvincibleEnemies = false;
            l.VineBlocked = false;
            l.XStart = 0x00;
            l.YStart = 0x14;

            for(int j = 0; j < l.Height; j++)
            {
                for(int i = 0; i < l.Width; i++)
                {
                    l.LevelData[i, j] = (byte) l.ClearValue;
                }
            }

            LevelInfo li = new LevelInfo()
            {
                Name = name,
                LevelGuid = l.Guid,
                WorldGuid = worldinfo.WorldGuid,
                LevelType = l.Type,
                Layout = l.LevelLayout
            };

            Levels.Add(li);
            levelLookup.Add(l.Guid, li);

            if (l.Save())
            {

                if (LevelAdded != null) LevelAdded(this, new TEventArgs<LevelInfo>(li));
            }
            return true;
        }
Example #9
0
        public bool LoadFromElement(XElement e)
        {
            worldLookup.Clear();
            Worlds.Clear();

            foreach (var w in e.Elements("world"))
            {
                WorldInfo wi = new WorldInfo();
                wi.LoadFromElement(w);
                if (!wi.IsNoWorld)
                {
                    wi.Ordinal = Worlds.Count;
                }
                
                Worlds.Add(wi);
                worldLookup.Add(wi.WorldGuid, wi);
            }

            return true;
        }
Example #10
0
        public bool Load(WorldInfo li)
        {
            if (File.Exists(ProjectController.WorldDirectory + @"\" + li.WorldGuid + ".map"))
            {
                return Load(ProjectController.WorldDirectory + @"\" + li.WorldGuid + ".map");
            }

            return false;
        }
Example #11
0
 public static void CloseWorldEditor(WorldInfo wi)
 {
     if (editorTable.ContainsKey(wi.WorldGuid))
     {
         editorTable[wi.WorldGuid].Close();
     }
 }
Example #12
0
        public static void EditWorld(WorldInfo wi)
        {
            if (editorTable.ContainsKey(wi.WorldGuid))
            {
                editorTable[wi.WorldGuid].Activate();
                return;
            }

            World w = new World();

            if (!w.Load(wi))
            {
                w.New(wi);
            }

            WorldEditor we = new WorldEditor();
            we.MdiParent = MainWindow;
            we.EditWorld(w);
            we.FormClosed += new FormClosedEventHandler(le_FormClosed);
            we.Activated += new EventHandler(le_Activated);
            ActiveEditor = we;
            editorTable.Add(wi.WorldGuid, we);
            MainWindow.HideProjectview();
        }
Example #13
0
 public DialogResult ShowDialog(WorldInfo world)
 {
     CmbWorlds.SelectedItem = world;
     return this.ShowDialog();
 }