Beispiel #1
0
        public static Level Load( string levelName )
        {
            var temp = new Level() { Name = levelName };
            temp = DiskStorage.LoadFromDisk<Level>( temp.FilePath );

            return temp;
        }
Beispiel #2
0
        public LevelEditorForm( Level level )
        {
            InitializeComponent();

            EditLevel( level );

            ux_LayerList.ItemCheck += ( sender, args ) => {
                var name = (string)ux_LayerList.Items[ args.Index ];
                if( name == "Collision" )
                    ux_LevelEditor.Level.CollisionLayer.Alpha = args.NewValue == CheckState.Checked ? 255f : 0f;
                else
                    ux_LevelEditor.Level.MapLayers.First( ml => ml.Name == name ).Alpha = args.NewValue == CheckState.Checked ? 255f : 0f;

            };
            ux_LayerList.SelectedIndexChanged += ( sender, args ) => {
                var item = ux_LayerList.SelectedItem;
            };

            ux_LevelEntityList.ItemCheck += ( sender, args ) => {
                var entity = (GameObject)ux_LevelEntityList.SelectedItem;

                if( entity != null )
                    entity.IsAlive = args.NewValue == CheckState.Checked;
            };

            ux_LevelEntityList.DoubleClick += UxLevelEntityListOnDoubleClick;

            ux_LevelEditor.MouseDown += UxLevelEditorOnMouseDown;
            ux_LevelEditor.MouseMove += UxLevelEditorOnMouseMove;
            ux_LevelEditor.KeyDown += UxLevelEditorOnKeyDown;

            KeyDown += UxLevelEditorOnKeyDown;

            ux_LevelEditor.MouseWheel += UxLevelEditorOnMouseWheel;

            // setup status bar controls
            AddZoomControlsToStatusBar( ux_StatusBar );

            Text = Path.GetFileName( level.FilePath );

            Project.OnChange += ( sender, args ) => UpdateUserInterface();

            LostFocus += ( sender, args ) => {
                ( (AppContainer)MdiParent ).ux_AddEntity.Visible = false;
            };

            GotFocus += ( sender, args ) => {
                ( (AppContainer)MdiParent ).ux_AddEntity.Visible = true;
                UpdateUserInterface();
            };
        }
Beispiel #3
0
        public LevelTabPage( Level level )
        {
            Editor = new LevelEditorControl()
            {
                Name = "Editor",
                Level = level,
                Dock = DockStyle.Fill
            };

            Level = level;

            level.OnDataChanged += ( sender, args ) => Text = level.Name + "*";
            level.OnPersisted += ( sender, args ) => Text = level.Name;
        }
Beispiel #4
0
 public CollisionMap( Level level )
 {
     MapData = level.CollisionLayer.MapData;
     TileSize = level.CollisionLayer.TileSize;
 }
Beispiel #5
0
        private void ux_AddLevel_Click( object sender, EventArgs e )
        {
            var result = ux_SaveLevelDialog.ShowDialog();
            if( result == DialogResult.OK )
            {
                var fileName = ux_SaveLevelDialog.FileName;
                var level = new Level()
                {
                    FilePath = fileName,
                    Name = Path.GetFileNameWithoutExtension( fileName )
                };

                Project.Levels.Add( level );
                UpdateUserInterface();
            }
        }
Beispiel #6
0
 private void UpdateLevelControl( Level level = null )
 {
     ux_LevelEditor.Level = level;
 }
Beispiel #7
0
        private void EditLevel( Level level )
        {
            if( ux_LevelEditor.Level != null )
            {
                var result = MessageBox.Show( "Do you want to save changes to the current level?", "Save Changes?", MessageBoxButtons.YesNoCancel );
                if( result == DialogResult.Yes )
                {
                    ux_LevelEditor.Level.Save();
                }

                if( result == DialogResult.Cancel )
                {
                    return;
                }
            }

            ux_LevelEditor.Level = level;

            RefreshLevelEntityList();

            RefreshLayerList();

            SelectCurrentLevel();
        }
Beispiel #8
0
 private void EditLevel(Level level)
 {
     OpenChild(new LevelEditorForm(level));
 }