/// <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> /// Returns a default HUD for the VTank Client. Two scaled bars: one left, one right. /// Detects whether the player is using a weapon that requires a charge bar or a /// overheat bar instead of the default cooldown bar. /// </summary> public static HUD GetHudForPlayer(PlayerTank player) { HUD _hud = new HUD(2); _hud.Bars[0].BarColor = new Color(0.1f, 1.0f, 0.2f); //Green Health Bar _hud.Bars[0].Opacity = 0.1f; _hud.Bars[1].Opacity = 0.1f; _hud.Bars[0].Scale = .5f; _hud.Bars[1].Scale = .5f; _hud.Bars[0].Origin = new Vector2(0, 0); _hud.Bars[0].TextEnabled = false; _hud.Bars[1].TextEnabled = false; _hud.Bars[1].Orientation = HUD_Bar.HUDOrientation.RIGHT; _hud.HasChargeBar = false; _hud.HasOverHeatBar = false; if (player.Weapon.CanCharge) { _hud.Bars[1].BarColor = new Color(0.0f, 0.0f, 1.0f); //Blue cooldown bar _hud.HasChargeBar = true; } else if (player.Weapon.UsesOverHeat) { _hud.Bars[1].BarColor = new Color(1.0f, 0.0f, 0.0f); //Red cooldown bar _hud.HasOverHeatBar = true; } else { _hud.Bars[1].BarColor = new Color(1.0f, 1.0f, 0.0f); //Yellow cooldown bar _hud.Bars[1].Opacity = 0.1f; } return _hud; }
/// <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(); }