Example #1
0
        public void FreezeScene(QuickGameScene scene)
        {
            var mapObjects = scene.SolidLayer.CollidableObjects.OfType <IEditorPlaceable>().ToArray();

            foreach (var mo in mapObjects)
            {
                FrozenObject.Create(mo, scene);
            }
            scene.SolidLayer.Cleanup();
        }
Example #2
0
        void IUpdateable.Update(TimeSpan elapsedInFrame)
        {
            Cursor.UpdateCursor(MouseInput.MousePosition, elapsedInFrame);

            if (MouseInput.GetButtonPressed(GameKeys.PlaceObject))
            {
                var obj = GetObjectUnderCursor();
                if (obj != null)
                {
                    obj.Remove();
                }
                else
                {
                    if (ClipboardItem != null)
                    {
                        FreezeScene(Scene);

                        var newItem = ClipboardItem.CreateItem();
                        newItem.Position.Center = Cursor.Position.Center;
                        FrozenObject.Create(newItem, Scene);
                    }
                }
            }
            else if (MouseInput.GetButtonPressed(GameKeys.CopyObject))
            {
                var obj = GetObjectUnderCursor();
                if (obj != null)
                {
                    ClipboardItem = new EditorItem {
                        ItemType = obj.EditorType, Editor = this
                    };
                }
            }

            if (!Menu.Visible && !ItemSelector.Visible && KeyboardInput.GetButtonPressed(GameKeys.EditorMenu))
            {
                Menu.Visible = true;
            }
        }
Example #3
0
        protected override void OnOptionSelected(LiveEditor editor)
        {
            var playerPos = Scene.Player.Position.Center;

            foreach (var objectInThisScene in Scene.SolidLayer.CollidableObjects.OfType <IEditorPlaceable>())
            {
                objectInThisScene.Remove();
            }

            Scene.SolidLayer.Cleanup();

            var reloadedScene = Engine.Instance.SceneLoader.LoadScene(Scene.ID, forceReload: true) as QuickGameScene;
            var newObjects    = reloadedScene.SolidLayer.CollidableObjects.OfType <IEditorPlaceable>().ToArray().Select(p => FrozenObject.Create(p, Scene)).ToArray();

            Engine.Instance.Scene  = Scene;
            QuickGameScene.Current = Scene;

            editor.Menu.Visible = false;
        }