예제 #1
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).");
                }
            }
        }
예제 #2
0
        public static void Main(string[] args)
        {
            bool   loadGUI    = true;
            string configFile = DefaultConfigFile;

            if (args.Length > 1)
            {
                // Command-line arguments exist.
                for (int i = 0; i < args.Length; ++i)
                {
                    if (args[i] == "-c" || args[i] == "--config-file")
                    {
                        // Argument: custom configuration file.
                        if (args.Length >= i + 1)
                        {
                            PrintUsage("-c", "filename");
                        }

                        configFile = args[i + 1];
                        ++i;
                    }

                    else if (args[i] == "-ng" || args[i] == "--nogui" || args[i] == "nogui")
                    {
                        // Argument: Hide the GUI.
                        loadGUI = false;
                    }
                }
            }


            try
            {
                WeaponLoader.LoadFiles();
                BotRunner runner = new BotRunner();

                if (loadGUI)
                {
                    try
                    {
                        Application.Run(new MainWindow(configFile, runner));
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Error: " + e.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Environment.Exit(1);
                    }
                }
                else
                {
                    runner.Parse(configFile);
                    runner.Start(true);
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error!");
                Console.Error.WriteLine(e);
                Console.Error.WriteLine(e.StackTrace);

                throw;
            }
        }