예제 #1
0
        public override void Unload()
        {
            //this.IsExiting = true;
            //System.Diagnostics.Debugger.Break();
            ScreenState = GameStateManagement.ScreenState.TransitionOff;
            AxiosLog.Instance.AddLine("Memory usage before cleanup: " + GC.GetTotalMemory(true).ToString(), LoggingFlag.DEBUG);
            foreach (AxiosGameObject g in _gameObjects)
                g.UnloadContent(this);

            foreach (AxiosUIObject g in _uiobjects)
                g.UnloadContent(this);

            this._gameObjects.Clear();
            this._uiobjects.Clear();
            this.World.Clear();
            _timers.Clear();
            _uiobjects.Clear();
            AxiosLog.Instance.AddLine("Memory usage after cleanup: " + GC.GetTotalMemory(true).ToString(), LoggingFlag.DEBUG);
            //AxiosRegularFile f = new AxiosRegularFile("log.log");
            //f.WriteData(AxiosLog.Instance.GetLog(), FileMode.Append);
            //AxiosIsolatedFile f = new AxiosIsolatedFile("log.log");
            //f.WriteData(AxiosLog.Instance.GetLog(), FileMode.Append);
            //CleanUp();
            #if WINDOWS
            if (_console != null && !_console.KeepRunning)
            {
                //System.Diagnostics.Debugger.Break();
                ScreenManager.Game.Components.Remove(_console);
                _console.Dispose();
                _console = null;
            }
            #endif
        }
예제 #2
0
        /*public void AddGameObject<T>(T gameobject)
        {
            if (gameobject is AxiosGameObject || gameobject is AxiosUIObject)
                gameobject.LoadContent(this);

            if (gameobject is AxiosGameObject || gameobject is AxiosUIObject)
                gameobject.RemoveObject += new AxiosGameObject.RemoveAxiosGameObjectHandler(RemoveGameObject);

            if (gameobject is AxiosGameObject)
            {
                this._gameObjects.Add(gameobject);
            }
            else if (gameobject is AxiosUIObject)
            {
                this._uiobjects.Add(gameobject);
            }
        }*/
        /*public void AddGameObject(AxiosGameObject gameobject)
        {
            gameobject.LoadContent(this);
            gameobject.RemoveObject += new AxiosGameObject.AxiosGameObjectHandler(RemoveGameObject);
            this._gameObjects.Add(gameobject);
        }

        public void AddGameObject(AxiosTimer timer)
        {
            timer.LoadContent(this);
            _timers.Add(timer);
        }

        public void AddGameObject(AxiosUIObject uiobject)
        {
            uiobject.LoadContent(this);
            uiobject.RemoveObject += new AxiosEvents.AxiosGameObjectHandler(RemoveGameObject);
            _uiobjects.Add(uiobject);
        }*/
        public void AddGameObject(object obj)
        {
            #if WINDOWS
            if (obj is AxiosCommandConsole)
            {
                if (_console != null)
                {
                    //remove the current one first

                    ScreenManager.Game.Components.Remove(_console);
                    _console.Dispose();
                    _console = null;
                }
                _console = (AxiosCommandConsole)obj;
                ScreenManager.Game.Components.Add(_console);
                _console.LoadContent(ScreenManager.Game.Content);
            }
            #endif
            if (obj is AxiosGameObject || obj is AxiosUIObject || obj is AxiosTimer)
            {
                AxiosGameObject tmp = obj as AxiosGameObject;
                if (obj is AxiosGameObject || obj is AxiosUIObject)
                    tmp.RemoveObject += new AxiosEvents.AxiosGameObjectHandler(RemoveGameObject);

                tmp.LoadContent(this);

                if (obj is AxiosGameObject && !(obj is AxiosUIObject))
                {
                    _gameObjects.Add(tmp);
                }
                else if (obj is AxiosUIObject)
                {
                    _uiobjects.Add(obj as AxiosUIObject);
                }
                else if (obj is AxiosTimer)
                {
                    _timers.Add(obj as AxiosTimer);
                }
            }
        }