示例#1
0
        protected void clearRoom()
        {
            clearRace();

            RaceUI.Clear();
            _viewMan = null;

            _aiRegionBased = null;
            _aiPathBased   = null;

            _race          = null;
            _track         = null;
            _startingGrid  = null;
            _lapTestRegion = new Vecregion();
        }
示例#2
0
        protected override async Task <IRoom> loadAsync()
        {
            clearRoom();

            IGameFactory factory = _game.Factory;

            _room = factory.Room.GetRoom(ROOM_ID);
            _room.RoomLimitsProvider = AGSRoomLimits.FromBackground;

            _music = await factory.Sound.LoadAudioClipAsync(LF.MusicAssetFolder + "Welcome_to_the_Show.ogg");

            _room.Events.OnBeforeFadeIn.Subscribe(onLoad);
            _room.Events.OnAfterFadeIn.Subscribe(onAfterFadeIn);
            _room.Events.OnAfterFadeOut.Subscribe(onLeave);

            _track = await TrackLoader.LoadAsync(_roomAssetFolder + "track01.ini", _roomAssetFolder, _game.Factory.Graphics);

            _race = new Race(_game, _room, _track);

            _room.Background = addObject("RaceRoom.BG", _track.Background);

            // TODO: move to track config
            _startingGrid    = new Vector2[Race.MAX_RACING_CARS];
            _startingGrid[0] = compatVector(1140, 326 + 12);
            _startingGrid[1] = compatVector(1172, 273 + 12);
            _startingGrid[2] = compatVector(1204, 326 + 12);
            _startingGrid[3] = compatVector(1236, 273 + 12);
            _startingGrid[4] = compatVector(1268, 326 + 12);
            _startingGrid[5] = compatVector(1300, 273 + 12);
            Vector2 p1 = compatVector(1104, 399);
            Vector2 p2 = compatVector(1119, 190);

            _lapTestRegion = new Vecregion(p1, p2);

            // Create Ai controllers supported by this track
            if (_track.AiData.AIRegionMask != null && _track.AiData.AIRegionAngles != null)
            {
                _aiRegionBased = new AIRegionBased(_game, _track.AiData.AIRegionMask, _track.AiData.AIRegionAngles);
            }
            if (_track.AiData.AIPathNodes != null)
            {
                _aiPathBased = new AIPathBase(_game, _track.AiData.AIPathNodes);
            }

            _viewMan = new ViewportManager(_game.State);
            return(_room);
        }