Ejemplo n.º 1
0
 public void Dispose()
 {
     wrButtonPanel.Dispose();
     wrMain.Dispose();
     Minimap.Dispose();
     TeamDataPanel.Dispose();
     SelectionPanel.Dispose();
     UnitDataPanel.Dispose();
     BuildingDataPanel.Dispose();
     if (BuildingPanel != null)
     {
         BuildingPanel.Dispose();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Ends the level and releases all resources held by the level and all it's parts.
        /// </summary>
        public new void Dispose()
        {
            IsEnding            = true;
            Scene.UpdateEnabled = false;
            try {
                Ending?.Invoke();
            }
            catch (Exception e) {
                Urho.IO.Log.Write(LogLevel.Warning,
                                  $"There was an unexpected exception during the invocation of {nameof(Ending)}: {e.Message}");
            }

            List <IDisposable> toDispose = new List <IDisposable>();

            toDispose.AddRange(entities.Values);
            toDispose.AddRange(players.Values);


            foreach (var thing in toDispose)
            {
                thing?.Dispose();
            }

            //Everything that is loaded anywhere else but the constructor may not be loaded at the time of disposing
            PackageManager.ActivePackage.ClearCaches();
            ToolManager?.Dispose();
            Input?.Dispose();
            cameraController?.Dispose();
            Camera?.Dispose();
            Input = null;
            map?.Dispose();
            Minimap?.Dispose();
            octree?.Dispose();

            //Have to get the reference before i remove the level from the scene by RemoveAllChildren on the scene
            Scene scene = Scene;

            scene.RemoveAllChildren();
            scene.RemoveAllComponents();
            scene.Remove();
            scene.Dispose();
            LevelNode?.Dispose();

            base.Dispose();
            CurrentLevel = null;
            GC.Collect();
        }
Ejemplo n.º 3
0
        protected override void End()
        {
            base.End();

            UIManager.Unregister(_toolbar);
            UIManager.Unregister(_minimap);
            _minimap.Dispose();
            _toolbar.Dispose();

            InputManager.StopListening(Keys.Escape);
            InputManager.StopListening(Keys.Up);
            InputManager.StopListening(Keys.Down);
            InputManager.StopListening(Keys.Left);
            InputManager.StopListening(Keys.Right);

            InputManager.StopListening(Mouse.Left);
            InputManager.StopListening(Mouse.Right);
        }
Ejemplo n.º 4
0
        /// <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);
            }
        }