Beispiel #1
0
        protected override ControlsContainer CreateUI()
        {
            _stateManager = DreamOfStarsCorePlugin._singularityAdapter.Container.GetInstance <IStateManager>();

            this.IsFullScreen = true;
            DockPanel root = new DockPanel()
            {
                Margin = new Border(5),
                Size   = new Size(200)
            };

            StackPanel stackV = new StackPanel()
            {
                Docking   = Dock.Right,
                Direction = Direction.UpToDown,
                Margin    = new Border(5),
                Size      = new Size(200)
            };

            MyButtons.CreateButtonInContainer("New Game", stackV, () => StartNewGame());
            var slotNumbers = _stateManager.GetSaveSlotsNumbers();

            foreach (var slot in slotNumbers)
            {
                MyButtons.CreateButtonInContainer($"Load Game Slot {slot}", stackV, () => LoadSelectedGameSlot(slot));
            }


            MyButtons.CreateButtonInContainer("Exit", stackV, () => DualityApp.Terminate());

            root.Add(stackV);
            root.ApplySkin(Skin.YAUI_DARK);
            return(root);
        }
        public void AfterTest(TestDetails details)
        {
            Console.WriteLine("----- Beginning Duality environment teardown -----");

            // Remove NUnit Console logs
            Log.RemoveGlobalOutput(this.consoleLogOutput);
            this.consoleLogOutput = null;

            if (this.dummyWindow != null)
            {
                ContentProvider.ClearContent();
                ContentProvider.DisposeDefaultContent();
                this.dummyWindow.Dispose();
                this.dummyWindow = null;
            }
            DualityApp.Terminate();
            Environment.CurrentDirectory = this.oldEnvDir;

            // Save local testing memory
            if (TestContext.CurrentContext.Result.Status == TestStatus.Passed && !System.Diagnostics.Debugger.IsAttached)
            {
                Serializer.WriteObject(TestHelper.LocalTestMemory, TestHelper.LocalTestMemoryFilePath, SerializeMethod.Xml);
            }

            Console.WriteLine("----- Duality environment teardown complete -----");
        }
Beispiel #3
0
        public void Dispose()
        {
            Console.WriteLine("----- Beginning Duality environment teardown -----");

            // Remove NUnit Console logs
            Logs.RemoveGlobalOutput(_consoleLogOutput);
            _consoleLogOutput = null;

            if (_dummyWindow != null)
            {
                ContentProvider.ClearContent();
                _dummyWindow.Dispose();
                _dummyWindow = null;
            }

            /*// Save local testing memory. As this uses Duality serializers,
             * // it needs to be done before terminating Duality.
             * if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed && !System.Diagnostics.Debugger.IsAttached)
             * {
             *      Serializer.WriteObject(TestHelper.LocalTestMemory, TestHelper.LocalTestMemoryFilePath, typeof(XmlSerializer));
             * }*/

            try
            {
                DualityApp.Terminate();
            }
            catch (BackendException)
            {
            }

            Environment.CurrentDirectory = _oldEnvDir;

            Console.WriteLine("----- Duality environment teardown complete -----");
        }
Beispiel #4
0
        private static void Main(string[] args)
        {
            // Override working directory
            Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            DualityApp.Init(DualityApp.ExecutionContext.Game, new DefaultAssemblyLoader(), args);

            ScreenMode newScreenMode;

            switch (Preferences.Get <int>("Screen", 0))
            {
            default:
            case 0: newScreenMode = ScreenMode.Window; break;

            case 1: newScreenMode = ScreenMode.FullWindow; break;
            }

            using (INativeWindow window = DualityApp.OpenWindow(new WindowOptions {
                Title = AssemblyTitle,
                RefreshMode = (args.Contains("/nv") ? RefreshMode.NoSync : (args.Contains("/mv") ? RefreshMode.ManualSync : RefreshMode.VSync)),
                Size = LevelRenderSetup.TargetSize,
                ScreenMode = newScreenMode
            })) {
                current = new App(window);
                current.ShowMainMenu();
                window.Run();
            }

            DualityApp.Terminate();

            // ToDo: Linux-specific workaround
            Environment.Exit(0);
        }
Beispiel #5
0
 void ICmpUpdatable.OnUpdate()
 {
     if (DualityApp.Keyboard.KeyHit(Key.Enter) || DualityApp.Keyboard.KeyHit(Key.Escape))
     {
         DualityApp.Terminate();
     }
 }
Beispiel #6
0
        protected override void OnContextLost(EventArgs e)
        {
            base.OnContextLost(e);

            // Reinitialize core
            DualityApp.Terminate();
            DualityApp.Init(DualityApp.ExecutionContext.Game, null, null);

            ContentResolver.Current.Init();

            viewportWidth  = Width;
            viewportHeight = Height;

            DualityApp.WindowSize = new Point2(viewportWidth, viewportHeight);
            INativeWindow window = DualityApp.OpenWindow(new WindowOptions());

            ContentResolver.Current.InitPostWindow();

            // Reinitialize input
            TouchButtons = null;

            InitializeInput();

            // Reinitialize the game
            current = new App(window);
            current.ShowMainMenu(false);
        }
Beispiel #7
0
 void CheckExit()
 {
     if (InputManager.IsButtonHit("Exit"))
     {
         DualityApp.Terminate();
     }
 }
Beispiel #8
0
        public void AfterTest(ITest details)
        {
            Console.WriteLine("----- Beginning Duality environment teardown -----");

            // Remove NUnit Console logs
            Logs.RemoveGlobalOutput(this.consoleLogOutput);
            this.consoleLogOutput = null;

            if (this.dummyWindow != null)
            {
                ContentProvider.ClearContent();
                this.dummyWindow.Dispose();
                this.dummyWindow = null;
            }

            // Save local testing memory. As this uses Duality serializers,
            // it needs to be done before terminating Duality.
            if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed && !System.Diagnostics.Debugger.IsAttached)
            {
                Serializer.WriteObject(TestHelper.LocalTestMemory, TestHelper.LocalTestMemoryFilePath, typeof(XmlSerializer));
            }

            DualityApp.Terminate();
            Environment.CurrentDirectory = this.oldEnvDir;

            Console.WriteLine("----- Duality environment teardown complete -----");
        }
Beispiel #9
0
 public override void OnUpdate()
 {
     if (ControlScheme.MenuActionHit(PlayerActions.Menu))
     {
         DualityApp.Terminate();
     }
 }
Beispiel #10
0
 void IEventHandler <ScriptEventArgs> .HandleEvent(object source, ScriptEventArgs data)
 {
     switch (data.Script)
     {
     case "MainMenu_Exit":
         DualityApp.Terminate();
         break;
     }
 }
Beispiel #11
0
        public override void OnUpdate()
        {
#if !PLATFORM_WASM
            if (ControlScheme.MenuActionHit(PlayerActions.Menu))
            {
                DualityApp.Terminate();
            }
#endif
        }
Beispiel #12
0
 private void OnAltF4Pressed(object sender, KeyboardKeyEventArgs e)
 {
     if (DualityApp.Keyboard.KeyPressed(Key.F4) &&
         (DualityApp.Keyboard.KeyPressed(Key.AltLeft) ||
          DualityApp.Keyboard.KeyPressed(Key.AltRight)
         ))
     {
         DualityApp.Terminate();
     }
 }
Beispiel #13
0
        private void CheckForAltF4Quit()
        {
            var kbd        = DualityApp.Keyboard;
            var altPressed = kbd.KeyPressed(Key.AltLeft) || kbd.KeyPressed(Key.AltRight);

            if (altPressed && kbd.KeyPressed(Key.F4))
            {
                DualityApp.Terminate();
            }
        }
Beispiel #14
0
        public override void OnInitialize(GUI gui)
        {
            Visible = true;
            Active  = true;
            var resSize = DualityApp.TargetViewSize.X / 2;

            var startGameBtn = new Button("Play")
            {
                Position        = new Vector2(resSize - 512 / 2f, 500),
                Size            = new Vector2(512, 65),
                TextSize        = 0.75f,
                BackgroundColor = ColorRgba.Black,
                MouseHoverColor = ColorRgba.DarkGrey,
                FocusValue      = 1,
            };

            startGameBtn.Clicked += (sender, args) =>
            {
                if (gameScene.IsAvailable)
                {
                    Scene.SwitchTo(gameScene);
                }
            };

            var howToPlayBtn = startGameBtn.DeepClone();

            howToPlayBtn.Position  += new Vector2(0, 100);
            howToPlayBtn.Text       = "How to Play";
            howToPlayBtn.FocusValue = 2;
            howToPlayBtn.Clicked   += (sender, args) =>
            {
                if (gameScene.IsAvailable)
                {
                    Scene.SwitchTo(HowToPlayScene);
                }
            };

            var exitBtn = howToPlayBtn.DeepClone();

            exitBtn.Position  += new Vector2(0, 100);
            exitBtn.Text       = "Exit";
            exitBtn.FocusValue = 3;
            exitBtn.Clicked   += (sender, args) =>
            {
                DualityApp.Terminate();
            };

            startGameBtn.Focused = true;

            Controls.Add(startGameBtn);
            Controls.Add(howToPlayBtn);
            Controls.Add(exitBtn);
            base.OnInitialize(gui);
        }
Beispiel #15
0
 private void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         Scene.Current.Dispose();
         Scene.Current = GameRes.Data.Scenes.GameScene_Scene.Res;
     }
     else if (e.Key == Key.Escape)
     {
         DualityApp.Terminate();
     }
 }
Beispiel #16
0
 void ICmpUpdatable.OnUpdate()
 {
     if (DualityApp.Keyboard.KeyHit(Key.Enter))
     {
         Scene.Current.DisposeLater();
         Scene.SwitchTo(this.startGameScene);
     }
     else if (DualityApp.Keyboard.KeyHit(Key.Escape))
     {
         DualityApp.Terminate();
     }
 }
Beispiel #17
0
        void IEventHandler <ScriptEventArgs> .HandleEvent(object source, ScriptEventArgs data)
        {
            switch (data.Script)
            {
            case "MainMenu_NewGame":
                Scene.SwitchTo(MainGameScene);
                break;

            case "MainMenu_Exit":
                DualityApp.Terminate();
                break;
            }
        }
Beispiel #18
0
        public void AfterTest(TestDetails details)
        {
            Console.WriteLine("----- Beginning Duality environment teardown -----");

            if (this.dummyWindow != null)
            {
                ContentProvider.ClearContent();
                ContentProvider.DisposeDefaultContent();
                this.dummyWindow.Dispose();
                this.dummyWindow = null;
            }
            DualityApp.Terminate();
            Environment.CurrentDirectory = this.oldEnvDir;

            Console.WriteLine("----- Duality environment teardown complete -----");
        }
Beispiel #19
0
        public void validateBallPosition()
        {
            //Obter da scene o objecto Ball
            GameObject theBallObject = Duality.Resources.Scene.Current.FindGameObject("Ball");
            RigidBody  bodyBall      = theBallObject.GetComponent <RigidBody>();

            if (bodyBall != null)
            {
                Transform transformComponent = theBallObject.GetComponent <Transform>();
                if (transformComponent.Pos.Y >= 250)
                {
                    //Afixa mensagem com texto de GameOver
                    //setTextLabel("Game Over.", true);
                    //Time.Freeze();
                    //Time.Resume();
                    DualityApp.Terminate();
                }
            }
        }
Beispiel #20
0
        public void Quit()
        {
            if (!(_server.Idle && _client.Idle))
            {
                Console?.Info.WriteLine("Shutting down");
            }
            else
            {
                DualityApp.Terminate();
            }

            if (!_server.Idle)
            {
                _server.Quit();
            }
            if (!_client.Idle)
            {
                _client.Quit();
            }
        }
Beispiel #21
0
        public void OnUpdate()
        {
            if (State == GameState.PrePlay)
            {
                State = GameState.Play;
            }

            if (State == GameState.Play)
            {
                foreach (var item in PlayerList)
                {
                    item.TimeBody.RecordingActive = true;
                }
            }

            if (DualityApp.Keyboard.KeyHit(Duality.Input.Key.Escape))
            {
                DualityApp.Terminate();
            }
        }
Beispiel #22
0
        void ICmpUpdatable.OnUpdate()
        {
            timer += Time.DeltaTime;
            if (timer > 0.5f)
            {
                if (DualityApp.Keyboard.KeyHit(Key.Enter) || DualityApp.Gamepads[0].ButtonHit(GamepadButton.A))
                {
                    GameManager.PlaySFX(GameManager.SoundType.buttonPress);
                    GameManager.GoToNextScene();
                }
                if (DualityApp.Keyboard.KeyHit(Key.Escape))
                {
                    DualityApp.Terminate();
                }

                if (DualityApp.Keyboard.KeyHit(Key.S) || DualityApp.Gamepads[0].ButtonHit(GamepadButton.Y))
                {
                    GameManager.GoToSettingsu();
                }
            }
        }
Beispiel #23
0
        public void Dispose()
        {
            this.window.Dispose();

            // Shut down the Duality core
            DualityApp.Terminate();

            AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;

            foreach (ILogOutput logOutput in this.logOutputs)
            {
                Logs.RemoveGlobalOutput(logOutput);
            }
            this.logOutputs.Clear();

            foreach (IDisposable disposable in this.disposables)
            {
                disposable.Dispose();
            }
            this.disposables.Clear();
        }
        public void AfterTest(TestDetails details)
        {
            Console.WriteLine("----- Beginning Duality environment teardown -----");

            // Remove NUnit Console logs
            Log.Game.RemoveOutput(this.consoleLogOutput);
            Log.Core.RemoveOutput(this.consoleLogOutput);
            Log.Editor.RemoveOutput(this.consoleLogOutput);
            this.consoleLogOutput = null;

            if (this.dummyWindow != null)
            {
                ContentProvider.ClearContent();
                ContentProvider.DisposeDefaultContent();
                this.dummyWindow.Dispose();
                this.dummyWindow = null;
            }
            DualityApp.Terminate();
            Environment.CurrentDirectory = this.oldEnvDir;

            Console.WriteLine("----- Duality environment teardown complete -----");
        }
Beispiel #25
0
 public void OnUpdate()
 {
     if (DualityApp.Keyboard.KeyHit(Key.Up) || DualityApp.Keyboard.KeyHit(Key.Down) || DualityApp.Keyboard.KeyHit(Key.ShiftRight) || DualityApp.Keyboard.KeyHit(Key.ShiftLeft))
     {
         //Move Cursor
         selectedExit = !selectedExit;
         GameObj.Transform.MoveBy(Vector2.UnitY * 40 * multi);
         multi *= -1;
     }
     else if (DualityApp.Keyboard.KeyHit(Key.Enter) || DualityApp.Keyboard.KeyHit(Key.Space))
     {
         if (!selectedExit)
         {
             Scene.SwitchTo(x);
         }
         else
         {
             DualityApp.Terminate();
             //Close game
         }
     }
 }
Beispiel #26
0
        private static void Main(string[] args)
        {
            // Override working directory
            Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            DualityApp.Init(DualityApp.ExecutionContext.Game, new DefaultAssemblyLoader(), args);

            using (INativeWindow window = DualityApp.OpenWindow(new WindowOptions {
                Title = AssemblyTitle,
                RefreshMode = (args.Contains("/nv") ? RefreshMode.NoSync : (args.Contains("/mv") ? RefreshMode.ManualSync : RefreshMode.VSync)),
                Size = LevelRenderSetup.TargetSize
            })) {
                controller = new Controller(window);
                controller.ShowMainMenu();
                window.Run();
            }

            DualityApp.Terminate();

            // ToDo: Linux-specific workaround
            Environment.Exit(0);
        }
Beispiel #27
0
        public static void Main()
        {
            DualityApp.Init(
                DualityApp.ExecutionEnvironment.Launcher,
                DualityApp.ExecutionContext.Game,
                new DefaultAssemblyLoader(),
                null);

            WindowOptions options = new WindowOptions
            {
                Size = new Point2(800, 600),
            };

            using (INativeWindow launcherWindow = DualityApp.OpenWindow(options))
            {
                // Run tests
                BitmapDebuggerVisualizer.TestShow(Pixmap.DualityIcon.Res);
                BitmapDebuggerVisualizer.TestShow(Pixmap.DualityIcon.Res.MainLayer);
                BitmapDebuggerVisualizer.TestShow(Texture.DualityIcon.Res);
                BitmapDebuggerVisualizer.TestShow(Font.GenericMonospace10.Res.Material.MainTexture.Res);
            }
            DualityApp.Terminate();
        }
Beispiel #28
0
		void ICmpUpdatable.OnUpdate()
		{
			if (DualityApp.Keyboard.KeyHit(Key.Escape))
			{
				DualityApp.Terminate();
			}
			if (DualityApp.Keyboard.KeyHit(Key.Space))
			{
				//preloading materials and sounds
				foreach (ContentRef<Material> m in ContentProvider.GetAvailableContent<Material>())
				{
					m.EnsureLoaded();
				}
				foreach (ContentRef<Sound> s in ContentProvider.GetAvailableContent<Sound>())
				{
					s.EnsureLoaded();
				}

				GameScene.Res.FindComponent<GameController>().Reset();

				Scene.SwitchTo(GameScene);
			}
		}
Beispiel #29
0
        public static bool Terminate(bool byUser)
        {
            bool cancel = false;

            // ...

            // Did we cancel it? Return false.
            if (cancel)
            {
                return(false);
            }

            // Otherwise, actually start terminating.
            // From this point on, there's no return - need to re-init the editor afterwards.
            if (Terminating != null)
            {
                Terminating(null, EventArgs.Empty);
            }

            // Unregister events
            mainWindow.Activated  -= mainWindow_Activated;
            mainWindow.Deactivate -= mainWindow_Deactivate;
            Scene.Leaving         -= Scene_Leaving;
            Scene.Entered         -= Scene_Entered;
            Application.Idle      -= Application_Idle;

            // Shut down the editor backend
            DualityApp.ShutdownBackend(ref graphicsBack);

            // Shut down the plugin manager
            pluginManager.Terminate();

            // Terminate Duality
            DualityApp.Terminate();

            return(true);
        }
Beispiel #30
0
        public static void Main()
        {
            DualityApp.Init(DualityApp.ExecutionEnvironment.Launcher, DualityApp.ExecutionContext.Game);
            using (DualityDebuggingTester launcherWindow = new DualityDebuggingTester(
                       DualityApp.UserData.GfxWidth,
                       DualityApp.UserData.GfxHeight,
                       DualityApp.DefaultMode,
                       DualityApp.AppData.AppName,
                       GameWindowFlags.Default))
            {
                // Initialize default content
                launcherWindow.MakeCurrent();
                DualityApp.TargetResolution = new Vector2(launcherWindow.Width, launcherWindow.Height);
                DualityApp.TargetMode       = launcherWindow.Context.GraphicsMode;
                ContentProvider.InitDefaultContent();

                // Run tests
                BitmapDebuggerVisualizer.TestShow(Pixmap.DualityIcon.Res);
                BitmapDebuggerVisualizer.TestShow(Pixmap.DualityIcon.Res.MainLayer);
                BitmapDebuggerVisualizer.TestShow(Texture.DualityIcon.Res);
                BitmapDebuggerVisualizer.TestShow(Font.GenericMonospace10.Res.Material.MainTexture.Res);
            }
            DualityApp.Terminate();
        }