Beispiel #1
0
 private void AddLevel(LevelInfo info)
 {
     TreeNode worldNode = WorldToNodes[info.WorldGuid];
     TreeNode nextLevelNode = new TreeNode();
     nextLevelNode.Tag = info;
     nextLevelNode.Text = info.Name;
     NodesToLevels.Add(nextLevelNode, info);
     LevelToNodes.Add(info.LevelGuid, nextLevelNode);
     worldNode.Nodes.Add(nextLevelNode);
     worldNode.Expand();
 }
Beispiel #2
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;
        }
Beispiel #3
0
 public bool Load(LevelInfo li)
 {
     return Load(ProjectController.LevelDirectory + @"\" + li.LevelGuid + ".lvl");
 }
Beispiel #4
0
        public void RemoveLevel(LevelInfo li)
        {
            Levels.Remove(li);
            levelLookup.Remove(li.LevelGuid);

            if (File.Exists(string.Format("{0}{1}{2}.lvl", ProjectController.LevelDirectory, Path.DirectorySeparatorChar, li.LevelGuid)))
            {
                File.Delete(string.Format("{0}{1}{2}.lvl", ProjectController.LevelDirectory, Path.DirectorySeparatorChar, li.LevelGuid));
            }
        }
Beispiel #5
0
        public bool LoadFromElement(XElement e)
        {
            Levels.Clear();
            levelLookup.Clear();
            Default();
            foreach (var l in e.Elements("level"))
            {
                LevelInfo li = new LevelInfo();
                li.LoadFromElement(l);
                Levels.Add(li);
                levelLookup.Add(li.LevelGuid, li);
            }

            return true;
        }
Beispiel #6
0
        public bool AddLevel(LevelInfo li)
        {
            if(levelLookup.ContainsKey(li.LevelGuid)) return false;

            Levels.Add(li);
            levelLookup.Add(li.LevelGuid, li);
            if (LevelAdded != null)
            {
                LevelAdded(this, new TEventArgs<LevelInfo>(li));
            }

            return true;
        }
 public static void CloseLevelEditor(LevelInfo li)
 {
     if (editorTable.ContainsKey(li.LevelGuid))
     {
         editorTable[li.LevelGuid].Close();
     }
 }
        public static void ImportLevel()
        {
            OpenFileDialog OFD = new OpenFileDialog();
            OFD.DefaultExt = "lvl";
            DialogResult result = OFD.ShowDialog();
            OFD.Dispose();

            if (result == DialogResult.OK)
            {
                Level level = new Level();
                level.Load(OFD.FileName);
                LevelInfo li = new LevelInfo();
                li.LevelGuid = level.Guid;
                li.WorldGuid = ProjectController.WorldManager.Worlds[0].WorldGuid;
                li.Name = "Imported Level";
                li.LevelType = level.Type;
                if (!ProjectController.LevelManager.AddLevel(li))
                {
                    MessageBox.Show("Could not import level. Make sure the level does not already exist.");
                }
                else
                {
                    level.Save();
                }
            }
        }
        public static void EditLevel(LevelInfo li)
        {
            if (editorTable.ContainsKey(li.LevelGuid))
            {
                editorTable[li.LevelGuid].Activate();
                return;
            }

            Level l = new Level();
            l.Load(li);
            LevelEditor le = new LevelEditor();
            le.MdiParent = MainWindow;
            le.EditLevel(l);
            le.FormClosed += new FormClosedEventHandler(le_FormClosed);
            le.Activated += new EventHandler(le_Activated);
            ActiveEditor = le;
            editorTable.Add(li.LevelGuid, le);
            MainWindow.HideProjectview();
        }
Beispiel #10
0
 public bool Load(LevelInfo li)
 {
     return(Load(ProjectController.LevelDirectory + @"\" + li.LevelGuid + ".lvl"));
 }