public Commands(GameConsole _console, Printer _printer)
 {
     console = _console;
     printer = _printer;
 }
Exemple #2
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()
        {
            IsMouseVisible = true;

            //Manager.Initialize();
            ServiceManager.CreateResourceManager();
            ServiceManager.CreateAudioManager();
            ServiceManager.CreateMP3Player();
            ServiceManager.CreateStateManager();
            ServiceManager.CreateLogger();
            base.Initialize();

            PresentationParameters pp = GraphicsDevice.PresentationParameters;

            const int borderPadding = 20;
            Console = new GameConsole(new Rectangle(
                borderPadding, borderPadding,
                GraphicsDeviceManager.PreferredBackBufferWidth - borderPadding,
                GraphicsDeviceManager.PreferredBackBufferHeight - borderPadding));

            Options.VideoOptions video = Options.Video;
            // Set anti-aliasing options.
            string antialiasing = video.AntiAliasing.ToLower();
            if (antialiasing == "off")
            {
                pp.MultiSampleQuality = 0;
                pp.MultiSampleType = MultiSampleType.None;
                GraphicsDeviceManager.PreferMultiSampling = false;
            }
            else
            {
                GraphicsDeviceManager.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(
                    GraphicsDeviceManager_PreparingDeviceSettings);
            }

            GraphicsDeviceManager.DeviceReset += new System.EventHandler(GraphicsDeviceManager_DeviceReset);
            // TODO: Don't forget other options.

            GraphicsDeviceManager.ApplyChanges();
            //ServiceManager.Game.GraphicsDevice.GraphicsDeviceCapabilities.MaxPointSize;

            Renderer = new EntityRenderer(GraphicsDeviceManager, Content);
            Renderer.SceneTools.Entities.Camera cam = Renderer.ActiveScene.CurrentCamera;
            Camera camera = Renderer.ActiveScene.CreateCamera(
                new Vector3(100, 100, 60),  // Position
                Vector3.Backward * 20,      // Target
                cam.Projection,             // Projection
                DefaultCameraName           /* Name */);
            camera.CameraUp = Vector3.UnitZ;
            camera.Updatable = false;

            lastTimeStamp = Network.Util.Clock.GetTimeMilliseconds();

            screenshotTarget = new RenderTarget2D(GraphicsDevice,
                pp.BackBufferWidth, pp.BackBufferHeight, 1, GraphicsDevice.DisplayMode.Format);

            WeaponLoader.LoadFiles();

            ServiceManager.StateManager.ChangeState<LoginScreenState>();

            ServiceManager.Game.GraphicsDevice.RenderState.PointSizeMax =
                ServiceManager.Game.GraphicsDevice.GraphicsDeviceCapabilities.MaxPointSize;

            Console.DebugPrint("Max Point Size: " + ServiceManager.Game.GraphicsDevice.GraphicsDeviceCapabilities.MaxPointSize);

            if (ServiceManager.MP3Player != null)
            {
                MENU_PATH = Path.Combine(
                    ServiceManager.MP3Player.AudioDirectory, @"official\menu.wav");
                if (!ServiceManager.MP3Player.Play(MENU_PATH, true))
                {
                    Console.DebugPrint("[WARNING] Cannot play file official\\menu.wav (not found).");
                }
            }
        }