public override void Init(Scene level)
 {
     _level = (RaceLevel)level;
     _playThroughListener = SoundLoaded;
     _timeUpdatedListener = TimeUpdated;
     if (jQuery.Browser.Mozilla || jQuery.Browser.Opera)
         _engine = _level.LoadAudio("Audio/Race/engine.ogg");
     else
         _engine = _level.LoadAudio("Audio/Race/engine.mp3");
     _engine.AddEventListener("canplaythrough", _playThroughListener, false);
 }
 public override void Dispose()
 {
     if (_engine != null)
     {
         _engine.Pause();
         _engine.RemoveEventListener("timeupdate", _timeUpdatedListener, false);
     }
     _playThroughListener = null;
     _timeUpdatedListener = null;
     _level = null;
     _engine = null;
 }
Beispiel #3
0
        protected override void Init()
        {
            if (jQuery.Browser.Mozilla)
                _music = LoadAudio("Audio/race.ogg");
            else
                _music = LoadAudio("Audio/race.mp3");

            TimeLeft = RoadLength / 35;

            Position = 0;
            Shift = 0;

            pendingTimers = new List<int>();

            AddSystem(new RoadSystem());
            AddSystem(new CloudSystem());
            AddSystem(new ObstacleSystem());
            AddSystem(_npcSystem = new NpcSystem());
            AddSystem(CarSystem = new CarSystem());
            AddSystem(_engineSoundSystem = new EngineSoundSystem());

            // Get reference to game images
            _backgroundImage = LoadImage("Images/Race/bg.png", false);
            _timeLeftFrame = LoadImage("Images/Race/TimeLeft.png", false);
            _meterImage = LoadImage("Images/Race/rpm10.png", false);
            _markerImage = LoadImage("Images/Race/marker.png", false);

            // Setup the track
            Curve = 0;

            _rpm = 200;
            Status = RaceStatus.Starting;

            // Calculate the distance table for track rendering
            DistanceTable = new float[Lines];
            for (int i = 0; i < Lines + 1; i++)
            {
                DistanceTable[i] = 1000000 / (300 - i);
            }

            ShowMessage(_startMessage);
            Window.SetTimeout(delegate()
            {
                HideMessage();
                Status = RaceStatus.Running;
                _music.Play();

                _music.AddEventListener("ended", delegate(ElementEvent e) { _music.Play(); }, false);
            }, 3000);
        }
Beispiel #4
0
 public override void Dispose()
 {
     base.Dispose();
     _backgroundImage = null;
     _timeLeftFrame = null;
     _meterImage = null;
     _markerImage = null;
     _music.Pause();
     _music = null;
 }
Beispiel #5
0
        protected override void Init()
        {
            #if DEBUG
            if (Current != null) throw Exception.Create("Cannot have more than one ShooterLevel running at the same time!", null);
            #endif
            pendingTimers = new List<int>();

            if (jQuery.Browser.Mozilla)
                _music = LoadAudio("Audio/boss.ogg");
            else
                _music = LoadAudio("Audio/boss.mp3");

            Current = this;
            Status = ShooterStatus.Starting;
            BaseSpeed = 0.05f;
            _backgroundImage = LoadImage("Images/shooter/bg.png", false);
            AddSystem(new CloudSystem());
            AddSystem(Meteor = new MeteorSystem());
            AddSystem(Buildings = new BuildingSystem(700, _length, 3));
            AddSystem(Dinos = new DinosSystem(_length));
            AddSystem(_weapons = new WeaponsSystem());
            AddSystem(Plasma = new PlasmaSystem());
            AddSystem(Bonus = new BonusSystem());

            ShowMessage(_startMessage);
            Window.SetTimeout(delegate()
            {
                HideMessage();
                Status = ShooterStatus.Running;
                _music.Play();

                _music.AddEventListener("ended", delegate(ElementEvent e) { _music.Play(); }, false);
            }, 3000);
        }
Beispiel #6
0
 public override void Dispose()
 {
     base.Dispose();
     _backgroundImage = null;
     _music.Pause();
     _music = null;
     Current = null;
 }
Beispiel #7
0
        public override void CleanUp()
        {
            base.CleanUp();

            if (audio != null)
            {
                audio.Pause();
                audio.Src = null;
                audio = null;
            }
        }
Beispiel #8
0
        //public AudioOverlay(RenderContext renderContext, TourStop owner, string filename)
        //{
        //    isDesignTimeOnly = true;
        //    X = 0;
        //    Y = 0;
        //    this.filename = Guid.NewGuid().ToString() + filename.Substr(filename.LastIndexOf("."));
        //    this.Owner = owner;
        //    this.Name = owner.GetNextDefaultName("Audio");
        //    // File.Copy(filename, Owner.Owner.WorkingDirectory + this.filename);
        //}
        public override void InitializeTexture()
        {
            if (audio == null)
            {
                audio = (AudioElement)Document.CreateElement("audio");
                //audio.AutoPlay = true;
                //audio.MediaFailed += new EventHandler<ExceptionRoutedEventArgs>(audio_MediaFailed);
                //audio.MediaOpened += new RoutedEventHandler(audio_MediaOpened);
                //Viewer.MasterView.audio.Children.Add(audio);
                audio.Src = Owner.Owner.GetFileStream(this.filename);
                audio.AddEventListener("canplaythrough", delegate
                {
                    audioReady = true;
                    audio_MediaOpened();
                    audio.Play();
                }, false);

            }
        }