/// <summary>
        /// Unload graphics content used by the game.
        /// </summary>
        public override void UnloadContent()
        {
            List<Body> Bodies = new List<Body>();
            foreach (Body body in PhysicsSystem.CurrentPhysicsSystem.Bodies)
                Bodies.Add(body);

            foreach (Body body in Bodies)
                PhysicsSystem.CurrentPhysicsSystem.RemoveBody(body);

            List<CollisionSkin> Skins = new List<CollisionSkin>();
            foreach (CollisionSkin skin in PhysicsSystem.CurrentPhysicsSystem.CollisionSystem.CollisionSkins)
                Skins.Add(skin);

            foreach (CollisionSkin skin in Skins)
                PhysicsSystem.CurrentPhysicsSystem.CollisionSystem.RemoveCollisionSkin(skin);

            parentGame.Components.Remove(terrainActor);
            terrainActor.Dispose();

            NormalDrawing.Unload();
            terrainEngine.Unload();

            Player.baseRotationValue = 0;
            Player.cannonRotationValue = 0;
            Player.turretRotationValue = 0;

            Player.baseBone.Transform = Matrix.Identity;
            Player.Unload();

            Player = null;
            MouseCam = null;
            terrainEngine = null;

            //LevelVars = null;
            NormalDrawing = null;

            //ambieCue = parentGame.soundBank.GetCue("ambient");
            //ambieCue.Stop(AudioStopOptions.Immediate);

            if (ambieCue != null && ambieCue.IsPlaying)
                ambieCue.Stop(AudioStopOptions.Immediate);

            if (birdCue.IsCreated && birdCue.IsPlaying)
                birdCue.Stop(AudioStopOptions.Immediate);

            if (cue != null && cue.IsPlaying)
                cue.Stop(AudioStopOptions.Immediate);

            SetScore();

            #if XBOX
            parentGame.SaveGame();
            #endif

            parentGame = null;

            content.Unload();
        }
Example #2
0
 public FollowCam(ParentGame game, PlayerTank player)
 {
     this.device = game.GraphicsDevice;
     parentGame = game;
     Player = player;
 }
        void LoadObjects()
        {
            ResourceList LR = parentGame.LoadedResources;
            Dictionary<string, string> LLL = parentGame.Level_Loader.GetLevelLoadList();

            playerModel =     LR.ModelList[LLL["PlayerTankModel"]].Model_rez;
            playerTextures =  LR.ModelList[LLL["PlayerTankModel"]].Textures_rez;
            rocketModel =     LR.ModelList[LLL["PlayerRocketModel"]].Model_rez;
            rocketTextures =  LR.ModelList[LLL["PlayerRocketModel"]].Textures_rez;
            //cornerModel = LoadedResources.ModelList["Model\\sphere"].Model_rez;

            Vector3 pos = parentGame.Level_Loader.myLevel.playerSpawn.Position;
            float h; Vector3 n;
            terrainEngine.GetHeight(pos, out h, out n);
            pos.Y = h;

            Player = new PlayerTank(
                parentGame,
                playerModel,
                playerTextures,
                pos,
                rocketModel,
                rocketTextures,
                this);
            Player.Load();
            Player.scale = 1.0f;
            Player.alive = true;
            Player.rotation = new Vector3(0, 0, 0);

            Player.baseBone.Transform = Matrix.Identity;

            Player.UpdateWorldMatrix();

            BunkerModel = LR.ModelList[LLL["BunkerModel"]].Model_rez;
            BunkerTextures = LR.ModelList[LLL["BunkerModel"]].Textures_rez;
            BunkerDestroyed = LR.ModelList[LLL["BunkerDestroyed"]].Model_rez;
            BunkerDestroyedTextures = LR.ModelList[LLL["BunkerDestroyed"]].Textures_rez;

            BunkerPiece1 = LR.ModelList[LLL["BunkerPiece1"]].Model_rez;
            BunkerPiece1Textures = LR.ModelList[LLL["BunkerPiece1"]].Textures_rez;
            BunkerPiece2 = LR.ModelList[LLL["BunkerPiece2"]].Model_rez;
            BunkerPiece2Textures = LR.ModelList[LLL["BunkerPiece2"]].Textures_rez;
            BunkerPiece3 = LR.ModelList[LLL["BunkerPiece3"]].Model_rez;
            BunkerPiece3Textures = LR.ModelList[LLL["BunkerPiece3"]].Textures_rez;
            BunkerPiece4 = LR.ModelList[LLL["BunkerPiece4"]].Model_rez;
            BunkerPiece4Textures = LR.ModelList[LLL["BunkerPiece4"]].Textures_rez;

            DepotModel = LR.ModelList[LLL["DepotModel"]].Model_rez;
            DepotTextures = LR.ModelList[LLL["DepotModel"]].Textures_rez;
            DepotDestroyed = LR.ModelList[LLL["DepotDestroyed"]].Model_rez;
            DepotDestroyedTextures = LR.ModelList[LLL["DepotDestroyed"]].Textures_rez;

            DepotPiece1 = LR.ModelList[LLL["DepotPiece1"]].Model_rez;
            DepotPiece1Textures = LR.ModelList[LLL["DepotPiece1"]].Textures_rez;
            DepotPiece2 = LR.ModelList[LLL["DepotPiece2"]].Model_rez;
            DepotPiece2Textures = LR.ModelList[LLL["DepotPiece2"]].Textures_rez;
            DepotPiece3 = LR.ModelList[LLL["DepotPiece3"]].Model_rez;
            DepotPiece3Textures = LR.ModelList[LLL["DepotPiece3"]].Textures_rez;
            DepotPiece4 = LR.ModelList[LLL["DepotPiece4"]].Model_rez;
            DepotPiece4Textures = LR.ModelList[LLL["DepotPiece4"]].Textures_rez;

            RingModel = LR.ModelList[LLL["Ring"]].Model_rez;
            //RingTex1 = LR.Tex2dList[LLL["RingTexture1"]];
            //RingTex2 = LR.Tex2dList[LLL["RingTexture2"]];

            RingTex1 = LR.ModelList[LLL["Ring"]].Textures_rez[0];
            RingTex2 = LR.ModelList[LLL["Ring"]].Textures_rez[0];
            RingTextures = new Texture2D[2];
            RingTextures[0] = RingTex1;
            RingTextures[1] = RingTex2;

            TimeRemaining = parentGame.Level_Loader.myLevel.Time;

            RadarTexture = LR.Tex2dList[LLL["RadarTexture"]];
            BlipTexture = LR.Tex2dList[LLL["BlipTexture"]];

            MissileStart = parentGame.Level_Loader.myLevel.Missiles;
            MissileRemain = MissileStart;

            LevelNum = parentGame.LevelNum;

            FogColor = parentGame.Level_Loader.myLevel.FogColor;
            //LevelVars.Player.position = parentGame.Level_Loader.myLevel.playerSpawn.Position;
        }