Beispiel #1
0
        public override void unload()
        {
            // Remove objects from collision manager
            collisionManager.removeAllObjects();

            // Set every game element to null so we can save memory
            car = null;
            level = null;
            checkPoints.Clear();
            timeBonuses.Clear();
            sceneObjects.Clear();
            geometry.Clear();
            skyBox = null;
            terrain = null;

            font = null;
            retroFont = null;
            speedPanel = null;
            timePanel = null;

            MediaPlayer.Stop();
            song = null;
            carCrash = null;
            pickTime = null;

            // Clear input callbacks
            Input.clearCallbacks();

            loaded = false;
        }
Beispiel #2
0
        public GameState(UrbanRace game)
            : base(game)
        {
            // Initialise attributes and properties
            this.type = Type.GAME;
            this.laps = 1;
            this.levelName = "level.xml";
            this.level = null;
            this.car = null;
            this.checkPoints = new List<CheckPoint>();
            this.timeBonuses = new List<TimeBonus>();
            this.sceneObjects = new List<GameObject>();
            this.geometry = new List<GameObject>();
            this.skyBox = null;
            this.terrain = null;
            this.collisionManager = new CollisionManager();
            this.font = null;
            this.speedPanel = null;
            this.nextCheckPoint = 0;

            // Audio
            this.song = null;
            this.carCrash = null;
            this.pickTime = null;

            // GUI
            speedPanelPos = new Vector2(Settings.getOpt("gameSpeedPanelX"), Settings.getOpt("gameSpeedPanelY"));
            speedTextPos = new Vector2(Settings.getOpt("gameSpeedTextX"), Settings.getOpt("gameSpeedTextY"));
            lapsPanelPos = new Vector2(Settings.getOpt("gameLapsPanelX"), Settings.getOpt("gameLapsPanelY"));
            lapsText1Pos = new Vector2(Settings.getOpt("gameLapsText1X"), Settings.getOpt("gameLapsText1Y"));
            lapsText2Pos = new Vector2(Settings.getOpt("gameLapsText2X"), Settings.getOpt("gameLapsText2Y"));
            timePanelPos = new Vector2(Settings.getOpt("gameTimePanelX"), Settings.getOpt("gameTimePanelY"));
            timeTextPos = new Vector2(Settings.getOpt("gameTimeTextX"), Settings.getOpt("gameTimeTextY"));

            // Time (in ms)
            this.remainingTime = 0.0;
            this.totalTime = 0.0;
            this.playTime = 0.0;

            // Configure callbacks
            collisionManager.addCallback(GameObject.Type.CAR, GameObject.Type.SCENEOBJECT, collisionCarScene, CollisionManager.CallbackType.DURING);
            collisionManager.addCallback(GameObject.Type.CAR, GameObject.Type.TIMEBONUS, collisionCarBonus, CollisionManager.CallbackType.BEGIN);
            collisionManager.addCallback(GameObject.Type.CAR, GameObject.Type.CHECKPOINT, collisionCarCheckPoint, CollisionManager.CallbackType.BEGIN);

            // Load shapes
            CollisionManager.initShapeCatalog(game.Content.RootDirectory);

            this.spriteBatch = new SpriteBatch(game.GraphicsDevice);
        }
Beispiel #3
0
 public void setTerrain(string file, Vector3 position, Quaternion orientation, float scale)
 {
     terrain = new Terrain(game, file, position, orientation, scale);
 }