Пример #1
0
 public ConsoleHandler(ConsoleComponent console, IGameLoader gameLoader)
 {
     this.console    = console;
     this.gameLoader = gameLoader;
     //this.engine = engine;
     this.ConfigureConsole();
 }
Пример #2
0
        public McGame()
        {
            Gdm = new GraphicsDeviceManager(this)
            {
                PreferredBackBufferHeight = GameConts.Height * GameConts.Instance.Scale,
                PreferredBackBufferWidth  = GameConts.Width * GameConts.Instance.Scale
            };

            Cc = new ConsoleCommands(this);

            Console = new ConsoleComponent(this)
            {
                Interpreter = Cc.ManualInterpreter
            };
            FpsCounterComponent = new FpsCounterComponent(this);

            Components.Add(Console);
            Components.Add(FpsCounterComponent);

            IsMouseVisible        = true;
            Content.RootDirectory = "Content";

            Window.Title = $"{GameConts.Name} :: {GameConts.Version}";

            GameConts.Instance.Load();

            Window.IsBorderless = GameConts.Instance.Borderless;
            Gdm.IsFullScreen    = GameConts.Instance.FullScreen;

            IsFixedTimeStep = false;
            Gdm.SynchronizeWithVerticalRetrace = true;
            Gdm.ApplyChanges();
        }
Пример #3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Window.Title = Settings.GameName;


            Engine.Services.Register(new GraphicsDeviceService(this.GraphicsDevice));
            Engine.Services.Register(new ContentManagerService(this.Content));
            Engine.Services.Register(new LightManagerService(new PenumbraComponent(this)));
            Engine.Services.Register(new NetHandler());
            Engine.Services.Register(new SceneManager());
            Engine.Services.Get <LightManagerService>().Component.Initialize();

            _camera = new Camera(new Rectangle(0, 0, Settings.ResolutionX, Settings.ResolutionY));

            EventInput.Initialize(this.Window);
            this.InitalizeScenes();

            _consoleComponent           = new ConsoleComponent(this);
            _consoleComponent.FontColor = Color.Wheat;
            this.Components.Add(_consoleComponent);
            this.InitalizeCommands();

            _consoleRedirector = new ConsoleRedirector(_consoleComponent);
            Console.SetOut(_consoleRedirector);

            GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;

            base.Initialize();
        }
Пример #4
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Client.ServiceLocator.RegisterService(new GraphicsDeviceService(this.GraphicsDevice));
            Client.ServiceLocator.RegisterService(new ContentManagerService(this.Content));
            Client.ServiceLocator.RegisterService(new LightManagerService(new PenumbraComponent(this)));
            Client.ServiceLocator.RegisterService(new NetHandler());
            Client.ServiceLocator.RegisterService(new SceneManager());


            Client.ServiceLocator.GetService <LightManagerService>().Component.Initialize();

            _camera = new Camera(new Rectangle(0, 0, Settings.ResolutionX, Settings.ResolutionY));

            EventInput.Initialize(this.Window);
            this.InitalizeScenes();

            _consoleComponent = new ConsoleComponent(this);
            this.Components.Add(_consoleComponent);
            this.InitalizeCommands();

            _consoleRedirector = new ConsoleRedirector(_consoleComponent);
            Console.SetOut(_consoleRedirector);


            Window.Title = Settings.GameName;

            base.Initialize();
        }
Пример #5
0
        public HelloPythonGame()
        {
            Window.Title = "Hello Python in MonoGame :)";
            _graphics    = new GraphicsDeviceManager(this)
            {
                PreferredBackBufferWidth  = 1280,
                PreferredBackBufferHeight = 720
            };

            // Create a sample cube component.
            var cube = new CubeComponent(this);

            Components.Add(cube);

            // Create a console component.
            _console = new ConsoleComponent(this);
            Components.Add(_console);

            // Create an interpreter - this will execute the commands typed into console.
            // In this case we are creating a python interpreter which allows python code to be executed.
            var interpreter = new PythonInterpreter();

            // Register the cube and the console itself as objects we can manipulate in-game.
            interpreter.AddVariable("cube", cube);
            interpreter.AddVariable("console", _console);
            // Finally, tell the console to use this interpreter.
            _console.Interpreter = interpreter;

            // Add component for on-screen helper instructions.
            Components.Add(new InstructionsComponent(this));
        }
Пример #6
0
        static void Main(string[] args)
        {
            #region Initialize
            ConsoleMan.Initialize("ScreenTest", new Pixel(ConsoleColor.Black));
            KeyMan.Start();

            ConsoleComponent console = new ConsoleComponent("Text1", DrawableComponentBuilder.MakeConsole());
            TextComponent    text    = new TextComponent("CursorPosition", new
                                                         DrawableComponent("CursorPosition", 20, 1, 20, 20, 0.0f));

            ConsoleMan.Add(console);
            ConsoleMan.Add(text);
            ConsoleMan.Start();
            #endregion

            Console.OutputEncoding = UTF32Encoding.UTF8;

            console.WriteLine("SHIT");
            string x = console.ReadLine();
            console.Write(x);
            while (true)
            {
                text.Text = System.Windows.Forms.Cursor.Position.ToString() + "\u0627";
            }

            ConsoleMan.Stop();
            KeyMan.Stop();

            return;
        }
Пример #7
0
        public SandboxGame()
        {
            _deviceManager = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            _penumbra = new PenumbraComponent(this, Transforms.OriginCenter_XRight_YUp | Transforms.Custom)
            {
                AmbientColor = Color.Black
            };
            Components.Add(_penumbra);
            _penumbraController = new PenumbraControllerComponent(this, _penumbra);
            Components.Add(_penumbraController);
            _scenarios = new ScenariosComponent(this, _penumbra, _penumbraController, _consoleInterpreter);
            Components.Add(_scenarios);
            var ui = new UIComponent(this, _penumbraController)
            {
                DrawOrder = int.MaxValue
            };
            Components.Add(ui);
            _camera = new CameraMovementComponent(this, _penumbra);
            Components.Add(_camera);
            Components.Add(new FpsGarbageComponent(this));
            _console = new ConsoleComponent(this);
            Components.Add(_console);

            // There's a bug when trying to change resolution during window resize.
            // https://github.com/mono/MonoGame/issues/3572
            _deviceManager.PreferredBackBufferWidth = 1280;
            _deviceManager.PreferredBackBufferHeight = 720;
            Window.AllowUserResizing = false;
            IsMouseVisible = true;
        }
Пример #8
0
 public ConsoleScreen(DemoGame game) : base(game)
 {
     BlockDrawing  = false;
     BlockUpdating = false;
     console       = game.Services.GetService <ConsoleComponent>();
     console.ToggleOpenClose();
     scriptManager = game.Services.GetService <ScriptingEngine>();
 }
Пример #9
0
 public LostRPGMain()
 {
     this.graphics = new GraphicsDeviceManager(this);
     this.Content.RootDirectory = "Content";
     //this.graphics.IsFullScreen = true;
     this.IsMouseVisible = true;
     this.graphics.PreferredBackBufferWidth  = 1280;
     this.graphics.PreferredBackBufferHeight = 720;
     ////
     this.console = new ConsoleComponent(this);
     this.Components.Add(this.console);
 }
Пример #10
0
        public override void InitializeComponents()
        {
            var location    = Assembly.GetExecutingAssembly().Location;
            var shadersPath = Path.GetDirectoryName(location) + "\\Shaders\\ShadowMapLightingShaders.hlsl";

            grid = new GridComponentTextured(GameDevice);
            var texturePath = Path.GetDirectoryName(location) + "\\Textures\\marble_texture2.jpg";

            grid.InitializeResources(texturePath, new BlackPlastic(), shadersPath, shadersPath, InputElements.VertexPosNormTex);
            grid.Translation = new Vector3(-grid.Lenght / 2f, 0f, -grid.Lenght / 2f);

            cow         = new ObjModelComponent(GameDevice);
            texturePath = Path.GetDirectoryName(location) + "\\Textures\\cow_texture.jpg";
            var filePath = Path.GetDirectoryName(location) + "\\Meshes\\cow.obj";

            cow.InitializeResources(texturePath, new Silver(), shadersPath, shadersPath, InputElements.VertexPosNormTex, filePath);
            cow.Scaling = new Vector3(0.01f, 0.01f, 0.01f);

            texturePath = Path.GetDirectoryName(location) + "\\Textures\\marble_texture2.jpg";

            string[] cubetexturesPath = new string[] {
                Path.GetDirectoryName(location) + "\\Textures\\SkyText\\miramar_ft.bmp",
                Path.GetDirectoryName(location) + "\\Textures\\SkyText\\miramar_bk.bmp",
                Path.GetDirectoryName(location) + "\\Textures\\SkyText\\miramar_dn.bmp",
                Path.GetDirectoryName(location) + "\\Textures\\SkyText\\miramar_up.bmp",
                Path.GetDirectoryName(location) + "\\Textures\\SkyText\\miramar_lf.bmp",
                Path.GetDirectoryName(location) + "\\Textures\\SkyText\\miramar_rt.bmp",
            };
            skySphere = new FBXComponent(GameDevice);
            filePath  = Path.GetDirectoryName(location) + "\\Meshes\\skySphere2.fbx";
            skySphere.InitializeResources(cubetexturesPath, shadersPath, shadersPath, InputElements.VertexPosNormTex, filePath);
            skySphere.isLighten = false;
            //  skySphere.InitializeResources(texturePath, new Silver(), shadersPath, shadersPath, InputElements.VertexPosNormTex, filePath);

            skySphere.Scaling = new Vector3(0.1f, 0.1f, 0.1f);

            plane        = new PlaneComponent(GameDevice);
            PlaneTexture = worldPositionMap;
            plane.InitializeResources(shadowMapResourseView, new Silver(), shadersPath, shadersPath, InputElements.VertexPosNormTex);
            plane.Rotation    = Matrix.RotationYawPitchRoll(MathUtil.DegreesToRadians(0f), MathUtil.DegreesToRadians(-90f), MathUtil.DegreesToRadians(0f));
            plane.Translation = new Vector3(10f, 10f, 0f);

            consoleComponent = new ConsoleComponent();
            consoleComponent.Initialize(this);

            LuaManager = new LuaScriptManager(this);
        }
Пример #11
0
        public GMGame()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth  = 1366;
            graphics.PreferredBackBufferHeight = 768;


            console = new ConsoleComponent(this);
            console.TimeToToggleOpenClose = 0.05f;
            Components.Add(console);

            interpreter         = new PythonInterpreter();
            console.Interpreter = interpreter;

            interpreter.AddVariable("gm", this);

            Content.RootDirectory = "Content";
            world = new MainWorld(this);
        }
Пример #12
0
        public SandboxGame()
        {
            _graphics             = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            _camera = new CameraControllerComponent(this);
            _cube   = new CubeComponent(this);
            Components.Add(_camera);
            Components.Add(_cube);

            _console = new ConsoleComponent(this)
            {
                Padding               = 10.0f,
                FontColor             = Color.White,
                InputPrefixColor      = Color.White,
                BackgroundColor       = Color.White,
                BottomBorderThickness = 4.0f,
                BottomBorderColor     = Color.Red,
                SelectionColor        = SelectionColor,
                LogInput              = cmd => Debug.WriteLine(cmd) // Logs input commands to VS output window.
            };
            Components.Add(_console);

            // Add search path for IronPython standard library. This is so that Python engine knows where to load modules from.
            _pythonInterpreter.AddSearchPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Lib\\"));

            // Import threading module and Timer function.
            _pythonInterpreter.RunScript("import threading");
            _pythonInterpreter.RunScript("import random");
            _pythonInterpreter.RunScript("from threading import Timer");

            // There's a bug when trying to change resolution during window resize.
            // https://github.com/mono/MonoGame/issues/3572
            _graphics.PreferredBackBufferWidth  = 1280;
            _graphics.PreferredBackBufferHeight = 720;
            Window.AllowUserResizing            = false;

            IsMouseVisible = true;
        }
        public PlatformerGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            #if WINDOWS_PHONE
            TargetElapsedTime = TimeSpan.FromTicks(333333);
            #endif

            graphics.PreferredBackBufferWidth = 1280;
            graphics.PreferredBackBufferHeight = 720;
            graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
            IsMouseVisible = true;

            Accelerometer.Initialize();

            Penumbra = new PenumbraComponent(this)
            {
                AmbientColor = new Color(30, 20, 10),
                Visible = true,
                Debug = false
            };

            penumbraController = new PenumbraControllerComponent(this, Penumbra);
            Components.Add(penumbraController);

            Console = new ConsoleComponent(this);
            Components.Add(Console);
        }
Пример #14
0
        public Main()
        {
            self = this;

            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Set Width and Height og game screen
            graphics.PreferredBackBufferWidth  = Settings.Default.ScreenWidth;
            graphics.PreferredBackBufferHeight = Settings.Default.ScreenHeight;

            // Set windows start posion to center screen
            Window.Position = new Point((GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width / 2) - (graphics.PreferredBackBufferWidth / 2), (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / 2) - (graphics.PreferredBackBufferHeight / 2));

            // For detect FPS in FramerateCounter.cs
            graphics.SynchronizeWithVerticalRetrace = false;
            IsFixedTimeStep = false;

            // Restore fullscreen setting
            if (Settings.Default.FullScreen)
            {
                graphics.ToggleFullScreen();
            }
            graphics.ApplyChanges();

            // Initial ScreenTransition
            ScreenTransitions.FadeOUT();

            // Initial QuakeConsole
            console = new ConsoleComponent(this);
            Components.Add(console);

            // Add interpreter for QuakeConsole
            pythonInterpreter   = new PythonInterpreter();
            manualInterpreter   = new ManualInterpreter();
            console.Interpreter = manualInterpreter;

            // Add variable for PythonInterpreter
            pythonInterpreter.AddVariable("console", console);
            pythonInterpreter.AddVariable("manual", manualInterpreter);

            // Add command for ManualInterpreter
            manualInterpreter.RegisterCommand("fullscreen", args => {
                if (args.Length == 0)
                {
                    return;
                }
                else if (graphics.IsFullScreen && args[0].Equals("off"))
                {
                    graphics.ToggleFullScreen();
                }
                else if (!graphics.IsFullScreen && args[0].Equals("on"))
                {
                    graphics.ToggleFullScreen();
                }
            });
            manualInterpreter.RegisterCommand("fps", args => {
                if (args.Length == 0)
                {
                    return;
                }
                else if (args[0].Equals("on"))
                {
                    Settings.Default.ShowFPS = true;
                    Settings.Default.Save();
                }
                else if (args[0].Equals("off"))
                {
                    Settings.Default.ShowFPS = false;
                    Settings.Default.Save();
                }
            });
            manualInterpreter.RegisterCommand("Level", args => {
                if (args.Length < 2)
                {
                    return;
                }
                else if (args[0].Equals("="))
                {
                    Settings.Default.LevelSelected = int.Parse(args[1]);
                    Settings.Default.Save();
                }
            });
            manualInterpreter.RegisterCommand("console.Interpreter", args => {
                if (args.Length < 2)
                {
                    return;
                }
                else if (args[0].Equals("=") & args[1].Equals("python"))
                {
                    console.Interpreter = pythonInterpreter;
                }
            });
            manualInterpreter.RegisterCommand("exit", args => { Exit(); });
            manualInterpreter.RegisterCommand("ResetLevel", args => { ScreenManager.LoadScreen(new GamePlayScreen()); });

            BGM = Content.Load <Song>("Audios/POL-mad-run-short");
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Volume      = Settings.Default.BGMVolume;
            MediaPlayer.Play(BGM);

            AudioManager.AddAudioEffect("click", Content.Load <SoundEffect>("Audios/NFF-select").CreateInstance());
            AudioManager.AddAudioEffect("shoot", Content.Load <SoundEffect>("Audios/NFF-rasp").CreateInstance());
            AudioManager.AddAudioEffect("die", Content.Load <SoundEffect>("Audios/NFF-lose").CreateInstance());
            AudioManager.AddAudioEffect("switch", Content.Load <SoundEffect>("Audios/NFF-click-switch").CreateInstance());
        }
Пример #15
0
 public ConsoleRedirector(ConsoleComponent consoleComponent)
 {
     _consoleComponent = consoleComponent;
 }
Пример #16
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Content.RootDirectory = "Content";
            ContentManager        = Content;
            Services.AddService(Content);


            Services.AddService(graphics);

            gameManager = new GameStateManager(this);
            Services.AddService(gameManager);


            var soundDir = new DirectoryInfo(Path.Combine(Content.RootDirectory, "SFX"));
            var musicDir = new DirectoryInfo(Path.Combine(Content.RootDirectory, "Music"));

            AudioManager.Initialize(this, soundDir, musicDir);


            inputHandler = InputHandler.InitializeSingleton(this);
            Components.Add(inputHandler);
            Components.Add(gameManager);


            var settings = GameSettings.LoadFromFile();

            Services.AddService(settings);

            graphics.PreferredBackBufferWidth  = graphics.GraphicsDevice.DisplayMode.Width;
            graphics.PreferredBackBufferHeight = graphics.GraphicsDevice.DisplayMode.Height;
            graphics.ApplyChanges();
            Window.IsBorderless = true;


            camera = new FocusCamera(GraphicsDevice.Viewport, null);

            Services.AddService(camera);

            spriteBatch = new SpriteBatch(GraphicsDevice);
            Services.AddService(spriteBatch);



            var transMan = new TransitionManager(this, gameManager);

            context = new GameContext
            {
                camera            = camera,
                gameManager       = gameManager,
                transitionManager = transMan,
                input             = inputHandler,
                scripter          = scriptManager,
                spriteBatch       = spriteBatch,
                content           = Content,
                graphics          = GraphicsDevice
            };

            scriptManager = new ScriptingEngine(context);
            Services.AddService(scriptManager);

            context.scripter = scriptManager;

            Services.AddService(context);



            var console = new ConsoleComponent(this);

            console.Initialize();
            console.TimeToToggleOpenClose = 0.25f;
            console.Interpreter           = scriptManager;
            Services.AddService(console);

            base.Initialize();
        }
Пример #17
0
 public ConsoleMediator()
     : base(NAME)
 {
     ViewComponent = new ConsoleComponent();
 }