/// <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() { cBuilder = new ContentBuilder(); Content.RootDirectory = cBuilder.OutputDirectory; renderer = new EntityRenderer(graphics, Content); this.IsMouseVisible = true; base.Initialize(); }
public ModelToTexture(Model _tank, Model _turret) { model1 = _tank; model2 = _turret; renderer = new EntityRenderer(ServiceManager.Game.GraphicsDeviceManager, ServiceManager.Game.Content); bak = Renderer.GraphicOptions.BackgroundColor; //Set up the camera for the shot Camera cam = renderer.ActiveScene.CurrentCamera; renderer.ActiveScene.CreateCamera(new Vector3(100, 100, 20), Vector3.Zero, cam.Projection, "Side View"); renderer.ActiveScene.AccessCamera("Side View").CameraUp = Vector3.UnitZ; renderer.ActiveScene.SwitchCamera("Side View"); LoadContent(); renderTarget = new RenderTarget2D(ServiceManager.Game.GraphicsDevice, ServiceManager.Game.GraphicsDeviceManager.PreferredBackBufferWidth, ServiceManager.Game.GraphicsDeviceManager.PreferredBackBufferHeight, 1, SurfaceFormat.Color, ServiceManager.Game.GraphicsDevice.PresentationParameters.MultiSampleType, ServiceManager.Game.GraphicsDevice.PresentationParameters.MultiSampleQuality); }
/// <summary> /// Unload any content (textures, fonts, etc) used by this state. Called when the state is removed. /// </summary> public override void UnloadContent() { /*try { ServiceManager.Game.GraphicsDevice.Reset(); ServiceManager.Game.GraphicsDevice.VertexDeclaration = null; ServiceManager.Game.GraphicsDevice.Vertices[0].SetSource(null, 0, 0); } catch (Exception ex) { // If the graphics device was disposed already, it throws an exception. Console.Error.WriteLine(ex); }*/ if (mouseCursor != null) { mouseCursor.DisableCustomCursor(); mouseCursor = null; } EnvironmentEffects = null; Bases = null; buffbar = null; cd = null; hud = null; renderer = null; fps = null; map = null; visibleTiles = null; Scores = null; Players = null; Projectiles = null; Chat = null; buffer = null; miniMap.Dispose(); miniMap = null; if (OnGameFinished != null) { EventArgs args = new EventArgs(); OnGameFinished.Invoke(this, args); } }
/// <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)."); } } }
/// <summary> /// Initialize any components required by this state. /// </summary> public override void Initialize() { ServiceManager.Game.FormManager.ClearWindow(); Options options = ServiceManager.Game.Options; RendererAssetPool.DrawShadows = GraphicOptions.ShadowMaps; mouseCursor = new MouseCursor(options.KeySettings.Pointer); mouseCursor.EnableCustomCursor(); renderer = ServiceManager.Game.Renderer; fps = new FrameCounter(); Chat = new ChatArea(); Projectiles = new ProjectileManager(); Tiles = new TexturedTileGroupManager(); Utilities = new UtilityManager(); cd = new Countdown(); Lazers = new LazerBeamManager(this); Scene.Add(Lazers, 0); Players = new PlayerManager(); currentGameMode = ServiceManager.Theater.GetCurrentGameMode(); Flags = new FlagManager(); Bases = new BaseManager(); EnvironmentEffects = new EnvironmentEffectManager(); buffbar = new BuffBar(); Scores = new ScoreBoard(currentGameMode, Players); input = new ChatInput(new Vector2(5, ServiceManager.Game.GraphicsDevice.Viewport.Height), 300);//300 is a magic number...Create a chat width variable. input.Visible = false; hud = HUD.GetHudForPlayer(Players.GetLocalPlayer()); localPlayer = Players.GetLocalPlayer(); Scene.MainEntity = localPlayer; sky = ServiceManager.Resources.GetTexture2D("textures\\misc\\background\\sky"); tips = new GameTips(new GameContext(CurrentGameMode, localPlayer)); helpOverlay = new HelpOverlay(); }