Esempio n. 1
0
 public CueExport(Cue cue)
 {
     Name = cue.Name;
     Pan = cue.Pan;
     Volume = cue.Volume;
     Pitch = cue.Pitch;
     Looped = cue.Looped;
     Name = cue.Name;
     PlaybackMode = cue.CuePlaybackMode;
     Sounds = new List<SoundExport>(cue.Children.Count);
     foreach (Sound sound in cue.Children)
     {
         Sounds.Add(new SoundExport(sound));
     }
 }
Esempio n. 2
0
	public override void Start()
	{
		base.Start();

		Cue[] tmp = GetComponents<Cue>();
		for(int i = 0; i < tmp.Length; ++i)
		{
			if(tmp[i].Type == CueType.GRASS)
				CueGrass = tmp[i];
			else if (tmp[i].Type == CueType.SNOW)
				CueSnow = tmp[i];
			else if (tmp[i].Type == CueType.SAND)
				CueSand = tmp[i];
			else if (tmp[i].Type == CueType.DIRT)
				CueDirt = tmp[i];
		}
	}
Esempio n. 3
0
File: Sound.cs Progetto: THSJF/sjf
        public int Play(string k, bool apply3d, float Position)
        {
            if (Main.Mode == Modes.SINGLE)
            {
                float num = (float)(((double)Position - 224.0) / 448.0);
                Sound.emitter.Position = (double)Position - 224.0 <= 0.0 ? ((double)Position - 224.0 >= 0.0 ? new Vector3(1.5f * num, 0.0f, 1f - Math.Abs(num)) : new Vector3(1.5f * num, 0.0f, 1f - Math.Abs(num))) : new Vector3(1.5f * num, 0.0f, 1f - Math.Abs(num));
            }
            if (!apply3d)
            {
                Sound.emitter.Position = Vector3.Zero;
            }
            foreach (string str in Sound.already)
            {
                if (str == k)
                {
                    return(0);
                }
            }
            if (k.Contains(".wav"))
            {
                k = k.Replace(".wav", "");
            }
            foreach (string key in this.SEs.Keys)
            {
                if (key == k)
                {
                    this.SEs[key].Dispose();
                    this.SEs[key] = Sound.SB.GetCue(k);
                    this.SEs[key].Apply3D(Sound.listener, Sound.emitter);
                    this.SEs[key].Play();
                    Sound.already.Add(k);
                    return(0);
                }
            }
            Cue cue = Sound.SB.GetCue(k);

            this.SEs.Add(k, cue);
            cue.Apply3D(Sound.listener, Sound.emitter);
            cue.Play();
            Sound.already.Add(k);
            return(0);
        }
        public override void Initialize()
        {
            this.safehouse = SaveManager.Instance.XmlPath.Contains("safehouse");

            myPlayerController = (PlayerController)this.MyObject.GetComponent <PlayerController>();
            if (myPlayerController == null)
            {
                Debug.Log("There is some error in getting player controller");
            }
            this.maxHP                  = this.myPlayerController.HitPoints;
            this.currentHP              = this.maxHP;
            this.myEq                   = this.myPlayerController.Equipment;
            this.hpTexture              = ResourceManager.Instance.LoadTexture(@"Textures/HUD/HP");
            this.hpBGTexture            = ResourceManager.Instance.LoadTexture(@"Textures/HUD/HPBG");
            this.heartTexture           = ResourceManager.Instance.LoadTexture(@"Textures/HUD/heart");
            this.popularityBGTexture    = ResourceManager.Instance.LoadTexture(@"Textures/HUD/fameBG");
            this.popularityFillTexture  = ResourceManager.Instance.LoadTexture(@"Textures/HUD/fame");
            this.popularitySadTexture   = ResourceManager.Instance.LoadTexture(@"Textures/HUD/sad");
            this.populartiyHappyTexture = ResourceManager.Instance.LoadTexture(@"Textures/HUD/smile");
            this.backpackTexture        = ResourceManager.Instance.LoadTexture(@"Textures/HUD/backpack");;
            this.burgerTexture          = ResourceManager.Instance.LoadTexture(@"Textures/HUD/burger");
            this.equipmentFont          = TrashSoupGame.Instance.Content.Load <SpriteFont>(@"Fonts/FontTest");
            this.liveBGTexture          = ResourceManager.Instance.LoadTexture(@"Textures/HUD/LIVEBG");
            this.liveTexture            = ResourceManager.Instance.LoadTexture(@"Textures/HUD/LIVE");

            this.bgTexture = ResourceManager.Instance.LoadTexture(@"Textures/HUD/window_red2_0");

            if (!TrashSoupGame.Instance.EditorMode)
            {
                ExplorationCue = AudioManager.Instance.GetCue("exploration");
                ExplorationCue.Play();
            }

            popularityFirstStepApplause    = TrashSoupGame.Instance.Content.Load <SoundEffect>(@"Audio/Ambient/applause_1");
            popularityFirstEffectInstance  = popularityFirstStepApplause.CreateInstance();
            popularitySecondStepApplause   = TrashSoupGame.Instance.Content.Load <SoundEffect>(@"Audio/Ambient/applause_2");
            popularitySecondEffectInstance = popularitySecondStepApplause.CreateInstance();
            popularityThirdStepApplause    = TrashSoupGame.Instance.Content.Load <SoundEffect>(@"Audio/Ambient/applause_3");
            popularityThirdEffectInstance  = popularityThirdStepApplause.CreateInstance();

            base.Initialize();
        }
Esempio n. 5
0
        /*******************************************************************************************
        * Main Load
        * *****************************************************************************************/
        protected override void LoadContent()
        {
            // load font
            spriteBatch      = new SpriteBatch(GraphicsDevice);
            statsFont        = Content.Load <SpriteFont>("Fonts/StatsFont");
            instructionsFont = Content.Load <SpriteFont>("Fonts/InstructionsFont");

            // load sounds and play initial sound
            audioEngine = new AudioEngine("Content/Audio/GameAudio.xgs");
            waveBank    = new WaveBank(audioEngine, "Content/Audio/Wave Bank.xwb");
            soundBank   = new SoundBank(audioEngine, "Content/Audio/Sound Bank.xsb");
            trackCue    = soundBank.GetCue("Tracks");
            trackCue.Play();

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // load spaceship
            spaceship.LoadContent(Content, "Models/spaceship");


            CreateObstacles1();
            CreateObstacles2();
            CreateObstacles3();
            CreateObstacles4();
            CreateObstacles5();
            CreateObstacles6();
            CreateAstronauts();
            CreateStars();

            // load ground
            ground.LoadContent(Content, "Models/ground");

            // load lifebar
            lifebar = Content.Load <Texture2D>("Textures/lifebar5");

            // load uhd
            uhd = Content.Load <Texture2D>("Textures/uhd");

            // load logo
            logo = Content.Load <Texture2D>("Textures/logo");
        }
Esempio n. 6
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the Cues control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void Cues_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (View.Cues.SelectedIndices.Count > 1) //more than one selected
            {
                //force selection of a single item
                //forcing is necessary because we have a multiselect list. This is needed to also allow "no selection". See
                //http://devexpress.com/Support/Center/p/Q102277.aspx
                int index = View.Cues.SelectedIndex;
                View.Cues.UnSelectAll();
                View.Cues.SetSelected(index, true);
                return;
            }

            if (View.Cues.SelectedIndex >= 0) //valid selection?
            {
                //get that cue
                Cue selectedCue = (View.Cues.Items[View.Cues.SelectedIndex] as DisplayCue).Item;
                Core.Model.Instance.SelectedCue = selectedCue; //update the model
            }
        }
Esempio n. 7
0
        public override void unload()
        {
            // Set objects to null so they can bre freed
            background        = null;
            leftArrow         = null;
            pressedLeftArrow  = null;
            rightArrow        = null;
            pressedRightArrow = null;
            optionOver        = null;
            optionSelected    = null;

            // Music
            MediaPlayer.Stop();
            song = null;

            // Clear input callbacks
            Input.clearCallbacks();

            loaded = false;
        }
Esempio n. 8
0
 //* -----------------------------------------------------------------------*
 /// <summary>死んだ効果音をゆっくり破棄するスレッドです。</summary>
 ///
 /// <returns>スレッドが実行される間、<c>true</c></returns>
 private IEnumerator <object> threadGC()
 {
     while (true)
     {
         for (int i = 0; i < (isHighPriorityMode ? 6 : 20); i++)
         {
             yield return(null);
         }
         if (GRAVE_SE.Count > 0)
         {
             Cue cue = GRAVE_SE.Dequeue();
             if (cue != null)
             {
                 cue.Stop(AudioStopOptions.AsAuthored);
                 cue.Dispose();
                 cue = null;
             }
         }
     }
 }
Esempio n. 9
0
 public void HitByRain()
 {
     if (m_distortState == DistortState.NONE)
     {
         m_distortState = DistortState.FALLING;
         rainSound      = Sound.PlayCue("rain");
     }
     else
     {
         m_distortRestoreDelay = k_rainRestoreDelay;
         //if (m_distortState != DistortState.FALLING)
         //{
         //    if (rainSound != null)
         //    {
         //        rainSound.Stop(AudioStopOptions.AsAuthored);
         //        rainSound = null;
         //    }
         //}
     }
 }
Esempio n. 10
0
 public CosmeticDebris(Texture2D texture, Vector2 startingPosition, float rotationSpeed, float xVelocity, float yVelocity, int groundYLevel, Rectangle sourceRect, Color color, Cue tapSound, LightSource light, int lightTailLength, int disappearTime)
 {
     this.timeToDisappearAfterReachingGround = disappearTime;
     this.disappearTimer = this.timeToDisappearAfterReachingGround;
     this.texture        = texture;
     this.position       = startingPosition;
     this.rotationSpeed  = rotationSpeed;
     this.xVelocity      = xVelocity;
     this.yVelocity      = yVelocity;
     this.sourceRect     = sourceRect;
     this.groundYLevel   = groundYLevel;
     this.color          = color;
     this.tapSound       = tapSound;
     this.light          = light;
     if (lightTailLength > 0)
     {
         this.lightTail       = new Queue <Vector2>();
         this.lightTailLength = lightTailLength;
     }
 }
Esempio n. 11
0
        public static void Play(string musicCueName)
        {
            while (!Wave.IsPrepared)
            {
                Audio.Sound.Update();
            }

            if (string.Compare(_musicStr, musicCueName, true, CultureInfo.InvariantCulture) != 0)
            {
                _musicStr = musicCueName;

                if (_musicCue != null)
                {
                    _musicCue.Dispose();
                }

                _musicCue = Sound.GetCue(_musicStr);
                _musicCue.Play();
            }
        }
        public static void playSound(String soundIdentifier, Vector2 point)
        {
            if (theWorld == null)
            {
                throw new FieldAccessException("World object not instantiated.");
            }
            Point lookingAt = theWorld.LookingAt;


            float length = (new Vector2((lookingAt.X + ((Globals.VIEWPORT_WIDTH / Globals.TILE_SIZE) / 2)), (lookingAt.Y + ((Globals.VIEWPORT_HEIGHT / Globals.TILE_SIZE) / 2))) - point).Length();

            float newVolume = GameOptions.Instance.sfxVolume * (80.0f * (float)Math.Log10(-0.05f * length + 1.0f));

            LoggerFactory.GetLogger().Trace("Playing sound at volume: " + newVolume + "db");

            Cue cue = Sounds.Instance.LoadSound(soundIdentifier);

            cue.SetVariable("Volume", newVolume);
            cue.Play();
        }
Esempio n. 13
0
    private void FixedUpdate()
    {
        if (cue == null)
        {
            cue = hitController.GetCue();
        }
        switch (CurrentStage)
        {
        case TurnStage.AwaitingTurnCompletion:
            if (!BodiesAreMoving())
            {
                EndTurn();
            }
            break;

        case TurnStage.SettingUpNextTurn:
            LerpCamTo(lerpTarget);
            break;
        }
    }
Esempio n. 14
0
        }         // PlayExplosionSound()

        public static void PlayWhosh(float volume)
        {
            //*lags a little!
            // Sound bank must be valid
            if (soundBank == null)
            {
                return;
            }

            // Get whosh cue, will either create cue or reuse existing cue
            Cue newWhoshCue = soundBank.GetCue(Sounds.Whosh.ToString());            //"Whosh");

            // Set volume
            newWhoshCue.SetVariable("Volume", volume * 100);
            // And play
            newWhoshCue.Play();
            //*/

            //Play(Sounds.Whosh);
        }         // PlayWhosh(volume)
Esempio n. 15
0
 public override void doCollisionAction(Rectangle positionOfCollider, int speedOfCollision, Vector2 tileLocation, Character who, GameLocation location)
 {
     if (speedOfCollision > 0 && this.maxShake == 0f && positionOfCollider.Intersects(this.getBoundingBox(tileLocation)))
     {
         if ((who == null || who.GetType() != typeof(FarmAnimal)) && Grass.grassSound != null && !Grass.grassSound.IsPlaying && Utility.isOnScreen(new Point((int)tileLocation.X, (int)tileLocation.Y), 2, location) && Game1.soundBank != null)
         {
             Grass.grassSound = Game1.soundBank.GetCue("grassyStep");
             Grass.grassSound.Play();
         }
         this.shake(0.3926991f / (float)((5 + Game1.player.addedSpeed) / speedOfCollision), 0.03926991f / (float)((5 + Game1.player.addedSpeed) / speedOfCollision), (float)positionOfCollider.Center.X > tileLocation.X * (float)Game1.tileSize + (float)(Game1.tileSize / 2));
     }
     if (who is Farmer && Game1.player.CurrentTool != null && Game1.player.CurrentTool is MeleeWeapon && ((MeleeWeapon)Game1.player.CurrentTool).isOnSpecial && ((MeleeWeapon)Game1.player.CurrentTool).type == 0 && Math.Abs(this.shakeRotation) < 0.001f && this.performToolAction(Game1.player.CurrentTool, -1, tileLocation, null))
     {
         Game1.currentLocation.terrainFeatures.Remove(tileLocation);
     }
     if (who is Farmer)
     {
         (who as Farmer).temporarySpeedBuff = -1f;
     }
 }
        public void CanDequeueTwiceInARow()
        {
            Node node1 = new Node(10);
            Node node2 = new Node(20);
            Node node3 = new Node(30);

            Stack stack1 = new Stack(null);
            Stack stack2 = new Stack(null);

            Cue queue = new Cue(stack1, stack2);

            queue.Enqueue(node1);
            queue.Enqueue(node2);
            queue.Enqueue(node3);

            queue.Dequeue();
            queue.Dequeue();

            Assert.Equal(node3.Value, queue.Dequeue().Value);
        }
Esempio n. 17
0
        private void m_btnBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            open.Filter = "Wave File (*.wav)|*.wav;";
            if (open.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string fileName       = open.FileName;
            var    inPath         = fileName;
            string outputFileName = fileName.Substring(0, fileName.Length - 4);
            var    outPath        = outputFileName + "Cue.wav";
            //var reader = new AudioFileReader(inPath);
            CueWaveFileReader reader = new CueWaveFileReader(inPath);
            //var reader2 = new AudioFileReader(inPath);
            Cue cue = new Cue(9895490, "HI");

            if (reader.Cues != null)
            {
                //reader.Cues.Add(cue);


                MessageBox.Show(reader.Cues.Count.ToString());

                int[]    list          = reader.Cues.CuePositions;
                string[] cueLabelLists = reader.Cues.CueLabels;
                Console.WriteLine("List of cues  {0}", list);
                int cueLabelCount = 0;

                foreach (int cuePoint in list)
                {
                    decimal tempCuePointInSec = cuePoint / 44100;

                    MessageBox.Show("Cue Point Position in seconds : " + tempCuePointInSec.ToString() + " and it's label is " + cueLabelLists[cueLabelCount]);
                    cueLabelCount++;
                }

                //CueWaveFileWriter.CreateWaveFile(outPath, reader);
            }
        }
    public List <Cue> Load(string csvfile, bool timed = false, DateTime startTime = default(DateTime))
    {
        string text = File.ReadAllText(csvfile);

        rowList.Clear();
        string[][] grid = CsvParser2.Parse(text);



        for (int i = 1; i < grid.Length; i++)
        {
            Cue row = new Cue();
            int.TryParse(grid[i][0], out row.NewScreenNumber);
            int.TryParse(grid[i][1], out row.CueNumberForInput);
            row.TypeoOfChange = grid[i][2];
            int.TryParse(grid[i][3], out row.StartingGain);
            int.TryParse(grid[i][4], out row.StartingFrequency);
            int.TryParse(grid[i][5], out row.EndingGain);
            int.TryParse(grid[i][6], out row.EndingFrequency);
            int.TryParse(grid[i][7], out row.StartingTactorLocation);
            int.TryParse(grid[i][8], out row.EndingTactorLocation);
            int.TryParse(grid[i][9], out row.StartingISI);
            int.TryParse(grid[i][10], out row.EndingISI);
            int.TryParse(grid[i][11], out row.StartingPulseDuration);
            int.TryParse(grid[i][12], out row.EndingPulseDuration);
            int.TryParse(grid[i][13], out row.StartChangeAfterPulseNumber);
            int.TryParse(grid[i][14], out row.EndChangeAfterPulseNumber);

            if (grid[i].Length > 15)
            {
                // DateTime.TryParse(grid[i][15], out row.presentTime);
                row.presentTime = grid[i][15];
            }

            //else
            //    row.presentTime = "-";
            rowList.Add(row);
        }
        Loaded = true;
        return(rowList);
    }
Esempio n. 19
0
        /// <summary>
        /// Damages all actors in a radius around the rocket.
        /// </summary>
        /// <param name="touchedActor">The actor that was originally hit.</param>
        public override void Explode(Actor touchedActor)
        {
            // stop the rocket-flying cue
            if (rocketCue != null)
            {
                rocketCue.Stop(AudioStopOptions.Immediate);
                rocketCue.Dispose();
                rocketCue = null;
            }

            // play the explosion cue
            world.AudioManager.PlayCue("explosionMedium");

            // add a double-particle system effect
            world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                         Vector2.Zero, 64, 32f, 64f, 3f, 0.05f, explosionColors));
            world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                         Vector2.Zero, 16, 128f, 256f, 4f, 0.1f, explosionColors));

            base.Explode(touchedActor);
        }
Esempio n. 20
0
        public override void Removed(EventArgs e)
        {
            base.Removed(e);
            if (starParticles != null && children.Contains(starParticles))
            {
                RemoveChild(starParticles);
            }
            starParticles = null;

            if (steamParticles != null && children.Contains(steamParticles))
            {
                RemoveChild(steamParticles);
            }
            steamParticles = null;

            if (spacePsst != null)
            {
                spacePsst.Stop(AudioStopOptions.Immediate);
                spacePsst = null;
            }
        }
Esempio n. 21
0
        public DefeatState(UrbanRace game) : base(game)
        {
            this.type = Type.DEFEAT;

            this.spriteBatch    = new SpriteBatch(game.GraphicsDevice);
            this.background     = null;
            this.button         = null;
            this.pressedButton  = null;
            this.selectedButton = null;
            this.retroFont      = null;

            retryButtonPos = new Vector2(Settings.getOpt("defeatRetryButtonX"), Settings.getOpt("defeatRetryButtonY"));
            retryTextPos   = new Vector2(Settings.getOpt("defeatRetryTextX"), Settings.getOpt("defeatRetryTextY"));
            menuButtonPos  = new Vector2(Settings.getOpt("defeatMenuButtonX"), Settings.getOpt("defeatMenuButtonY"));
            menuTextPos    = new Vector2(Settings.getOpt("defeatMenuTextX"), Settings.getOpt("defeatMenuTextY"));

            // Audio
            optionOver     = null;
            optionSelected = null;
            song           = null;
        }
Esempio n. 22
0
        public void Play()
        {
            if (cue.IsPaused)
            {
                cue.Resume();
                return;
            }

            if (cue.IsPlaying)
            {
                return;
            }

            if (cue.IsStopped)
            {
                cue    = sb.GetCue(cueName);
                Volume = vol;
            }

            cue.Play();
        }
Esempio n. 23
0
        /// <summary>
        /// Play a sound from the mod's wave bank.
        /// </summary>
        /// <param name="soundName">The name of the sound in the mod's wave bank. This will fail if the sound doesn't exists. This is also case sensitive.</param>
        public void playSound(string soundName)
        {
            Game1.waveBank  = this.waveBank;
            Game1.soundBank = this.soundBank;

            Cue currentCue = this.soundBank.GetCue(soundName);

            if (currentCue == null)
            {
                return;
            }
            else
            {
                currentCue.Play();
                currentlyPlayingSounds.Add(currentCue);
            }

            Game1.waveBank  = this.vanillaWaveBank;
            Game1.soundBank = this.vanillaSoundBank;
            removeAllStopedSounds();
        }
Esempio n. 24
0
 public Intro()
 {
     new List <int>();
     new List <int>();
     new List <int>();
     this.texture         = Game1.content.Load <Texture2D>("Minigames\\Intro");
     this.roadsideTexture = Game1.content.Load <Texture2D>("Maps\\spring_outdoorsTileSheet");
     this.cloudTexture    = Game1.content.Load <Texture2D>("Minigames\\Clouds");
     this.transformMatrix = Matrix.CreateScale(3f);
     this.skyColor        = new Color(64, 136, 248);
     this.roadColor       = new Color(130, 130, 130);
     this.createBeginningOfLevel();
     Game1.player.FarmerSprite.SourceRect = new Rectangle(0, 0, 16, 32);
     this.bigCloudPosition = (float)this.cloudTexture.Width;
     if (Game1.soundBank != null)
     {
         Intro.roadNoise = Game1.soundBank.GetCue("roadnoise");
     }
     this.currentState = 1;
     Game1.changeMusicTrack("spring_day_ambient");
 }
        public void CanEnqueueANode()
        {
            Node node1 = new Node(10);
            Node node2 = new Node(20);
            Node node3 = new Node(30);
            Node node4 = new Node(40);
            Node node5 = new Node(50);

            Stack stack1 = new Stack(null);
            Stack stack2 = new Stack(null);

            Cue queue = new Cue(stack1, stack2);

            queue.Enqueue(node1);
            queue.Enqueue(node2);
            queue.Enqueue(node3);
            queue.Enqueue(node4);
            queue.Enqueue(node5);

            Assert.Equal(node1.Value, queue.Dequeue().Value);
        }
Esempio n. 26
0
    private void Start()
    {
        cueBall = GameObject.FindGameObjectWithTag("CueBall");

        turnManager = GameObject.FindGameObjectWithTag("TurnManager")
                      .GetComponent <TurnManager>();

        cue = Instantiate(cueToInstantiate);

        cam = Camera.main;

        SetCueToTurnStart();
        cam.transform.position = cue.cameraSocket.position;

        lineRenderer.gameObject.SetActive(false);
        //InstantiateTrajectoryIndicators();

        audioSource = GameObject.FindGameObjectWithTag("CueBall")
                      .GetComponent <AudioSource>();
        cueStrike = Resources.Load <AudioClip>("Audio/cueStrike");
    }
Esempio n. 27
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Sonya.Initialize(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            SubZero.Initialize(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            SonyaGreenBar.health(new Vector2(graphics.PreferredBackBufferWidth / 45,
                                             graphics.PreferredBackBufferHeight / 30), SonyaHealth, Color.LimeGreen);
            SonyaRedBar.health(new Vector2(graphics.PreferredBackBufferWidth / 45,
                                           graphics.PreferredBackBufferHeight / 30), SonyaHealth, Color.Red);

            SubZGreenBar.health(new Vector2(graphics.PreferredBackBufferWidth - 580,
                                            graphics.PreferredBackBufferHeight / 30), SonyaHealth, Color.LimeGreen);
            SubZRedBar.health(new Vector2(graphics.PreferredBackBufferWidth - 580,
                                          graphics.PreferredBackBufferHeight / 30), SonyaHealth, Color.Red);
            audioEngine = new AudioEngine("Content\\game music.xgs");
            waveBank    = new WaveBank(audioEngine, "Content\\Wave Bank.xwb");
            soundBank   = new SoundBank(audioEngine, "Content\\Sound Bank.xsb");
            musicCue    = soundBank.GetCue("fighting backgorund music");
            musicCue.Play();
            base.Initialize();
            this.IsMouseVisible = false;
        }
Esempio n. 28
0
        public override void Update(float elapsedTime)
        {
            CLOUD_STATE emitterState = currentState;

            if (currentState == CLOUD_STATE.LIGHTNING)
            {
                if (rumbleSound == null)
                {
                    rumbleSound = Sound.PlayCue("rumble1");
                }
            }

            if (currentState == CLOUD_STATE.TRANSITION)
            {
                if (m_anim.Done)
                {
                    currentState = transitionTarget;
                    PlayAnim();
                }

                emitterState = transitionTarget;
            }

            switch (emitterState)
            {
            case CLOUD_STATE.RAIN:
                m_rainParticle.Effect.Trigger(Position);
                break;

            case CLOUD_STATE.HAIL:
                m_hailParticle.Effect.Trigger(Position);
                break;
            }


            m_anim.Update(elapsedTime);
            Texture = m_anim.CurrentFrame;

            base.Update(elapsedTime);
        }
Esempio n. 29
0
        protected static LoadCuesResult LoadCues(byte[] header, string filename)
        {
            LoadCuesResult result;

            result.cues        = new OrderedDictionary <string, Cue>();
            result.cuesWithIds = 0;

            var cuePackagePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename);

            using (var fs = File.OpenRead(cuePackagePath))
            {
                for (var i = 0; i < header.Length; i++)
                {
                    if (fs.ReadByte() != header[i])
                    {
                        throw new Exception("Cues package is corrupt");
                    }
                }

                using (var br = new BinaryReader(new GZipStream(fs, CompressionMode.Decompress, false)))
                {
                    var count = br.ReadInt32();
                    for (var i = 0; i < count; i++)
                    {
                        var name    = br.ReadString();
                        var context = new CueDeserializeContext(br);
                        var cue     = new Cue(context);

                        // Post-processing:
                        result.cues.Add(name, cue);
                        if (cue.type == CueType.Cycle || cue.type == CueType.RandomCycle)
                        {
                            cue.id = result.cuesWithIds++;
                        }
                    }
                }
            }

            return(result);
        }
Esempio n. 30
0
        public static Vector2 PitchToPos(Cue cue)
        {
            float x = 0, y = 0;

            if (cue.behavior == TargetBehavior.Melee)
            {
                switch (cue.pitch)
                {
                case 98:
                    x = -2f * xSize;
                    y = -1 * ySize;
                    break;

                case 99:
                    x = 2f * xSize;
                    y = -1 * ySize;
                    break;

                case 100:
                    x = -2f * xSize;
                    y = 1 * ySize;
                    break;

                case 101:
                    x = 2f * xSize;
                    y = 1 * ySize;
                    break;
                }
            }
            else
            {
                int col = cue.pitch % 12;
                int row = cue.pitch / 12;
                x = -xStart + (col + (float)cue.gridOffset.x) * xSize;
                y = -yStart + (row + (float)cue.gridOffset.y) * ySize;
            }


            return(new Vector2(x, y));
        }
Esempio n. 31
0
        /// <summary>
        ///     Creates and adds a new cue at the current player position.
        /// </summary>
        /// <remarks>
        ///     This should not change the currently selected cue and the player itself.
        ///     Usually, the player would actually play the music when this is called,
        ///     and the player should run through.
        /// </remarks>
        public void CreateCueHere()
        {
            if ((SelectedTrack != null)) //there is a track selected?
            {
                //add a cue to the current track
                TimeSpan position = Player.Position; //get position of the cursor

                Cue cue = new Cue {
                    Description = String.Format("Cue at {0}",
                                                (DateTime.MinValue +
                                                 new TimeSpan(0, 0, position.Minutes, position.Seconds,
                                                              position.Milliseconds)).ToString("mm:ss.fff")),
                    Shortcut = GetNextCueShortcut(),
                    Time     = position.TotalSeconds
                };
                InsertCueToTrackOrdered(cue);
                Compilation.IsDirty = true;
                //explicitly set to dirty TODO this new dirty state should get recognized by the model itself.

                //OnPropertyChanged("SelectedCue"); //explicitly raise now to reflect the change to the cues in general
            }
        }
    public override void Update(GameTime gameTime)
    {
        if (state_ != camera_.CurrentCamera.State)
        {
            state_ = camera_.CurrentCamera.State;
            defaultCategory.SetVolume(50);
            switch (state_)
            {
                case CameraState.Chase:
                    cameraCue = soundBank.GetCue("chase");
                    cameraCue.Play();
                    break;
                case CameraState.Reverse:
                    cameraCue = soundBank.GetCue("reverse");
                    cameraCue.Play();
                    break;
                case CameraState.Dynamic:
                    cameraCue = soundBank.GetCue("dynamic");
                    cameraCue.Play();
                    break;
                case CameraState.TopDown:
                    cameraCue = soundBank.GetCue("top_down");
                    cameraCue.Play();
                    break;
            }
        }

        for (int i = 0; i < cueArray.Length; i++)
            cueArray[i].Apply3D(listener_, CarSoundEmitters.AudioEmitters[i]);

        if (car_.LinearVelocity.LengthSquared() <= 400)
            musicCategory.SetVolume(car_.LinearVelocity.LengthSquared() / 16);
        else if (car_.LinearVelocity.LengthSquared() > 1650)
            musicCategory.SetVolume(0);
        else
            musicCategory.SetVolume(25);

        base.Update(gameTime);
    }
Esempio n. 33
0
 public virtual void SetSound()
 {
     if (lane.LaneKind == LaneKind.Car)
     {
         if (vehicleStyleIndex == 1 && this.CurChildFrame == 0)
         {
             cue = stage.audio.PlaySound(Sfx.genLee, audioListener, audioEmitter);
         }
         else if (vehicleStyleIndex == 11)
         {
             cue = stage.audio.PlaySound(Sfx.siren, audioListener, audioEmitter);
         }
         else if (vehicleStyleIndex == 12)
         {
             cue = stage.audio.PlaySound(Sfx.batman, audioListener, audioEmitter);
         }
         else
         {
             cue = stage.audio.PlaySound(Sfx.carRumble, audioListener, audioEmitter);
         }
     }
 }
Esempio n. 34
0
        public Cue PlaySong(string name, float delayTime)
        {
            if (currentSongCue != null && currentSongCue.IsPlaying)
                currentSongCue.Stop(AudioStopOptions.AsAuthored);

            #if !USE_XACT
            currentMediaPlayerSong = songs[name];
            if (delayTime <= 0.0f)
            {
                gameHasControl = MediaPlayer.GameHasControl;
                if (gameHasControl)
                {
                    try
                    {
                        MediaPlayer.Play(currentMediaPlayerSong);
                        MediaPlayer.IsRepeating = true;
                    }
                    catch { }
                }
            }
            else
            {
                currentSongDelayTime = delayTime;
                currentSongDelayTimeTotal = delayTime;
            }
            return null;
            #else
            currentSongCue = currentSoundBank.GetCue(name);
            if (delayTime <= 0.0f)
            {
                currentSongDelayTime = -1.0f;

                currentSongCue.Play();
            }
            else
            {
                currentSongDelayTime = delayTime;
            }

            return currentSongCue;
            #endif
        }
Esempio n. 35
0
 private void InitializeInstance(SoundEffectInstance instance, Cue cue)
 {
     if (Pan.HasValue)
         instance.Pan = Pan.Value;
     else
     {
         instance.Pan = cue.Pan;
     }
     if (Pitch.HasValue)
         instance.Pitch = Pitch.Value;
     else
     {
         instance.Pitch = cue.Pitch;
     }
     if (Volume.HasValue)
         instance.Volume = Volume.Value;
     else
     {
         instance.Volume = cue.Volume;
     }
 }
Esempio n. 36
0
 public void RefreshProperties(Cue cue)
 {
     Pitch = cue.Pitch;
     Pan = cue.Pan;
     Volume = cue.Volume;
 }
Esempio n. 37
0
 public static bool IsValidForStop(Cue c)
 {
     return c != null && !c.IsDisposed && c.IsPlaying;
 }
Esempio n. 38
0
 public void StopCurrentSong()
 {
     if (currentSongCue != null)
     {
         currentSongCue.Stop(AudioStopOptions.AsAuthored);
         currentSongCue = null;
     }
     else
     {
         gameHasControl = MediaPlayer.GameHasControl;
         if (gameHasControl)
         {
             try
             {
                 MediaPlayer.Stop();
             }
             catch { }
             currentMediaPlayerSong = null;
         }
     }
 }
Esempio n. 39
0
 public static bool IsValidForPlay(Cue c)
 {
     return c == null || c.IsDisposed || !c.IsPlaying;
 }
Esempio n. 40
0
 /// <summary>
 /// Set the AudioCue up to be ready to play the specified sound.
 /// </summary>
 /// <param name="soundBank">The SoundBank to find the sound in.</param>
 /// <param name="soundName">The name of the sound to play.</param>
 public void SetUp(SoundBank soundBank, String soundName)
 {
     Debug.Assert(m_state == State.AVAILABLE);
     m_cue = soundBank.GetCue(soundName);
     m_state = State.SETUP;
 }
 static public Cue GetCue(string cueName)
 {
     Cue tempCue = new Cue();
     return tempCue;
 }
Esempio n. 42
0
        public void PrevSong()
        {
            if (SongList.Count == 0)
                return;

            if (currentSongCue != null && currentSongCue.IsPlaying)
                currentSongCue.Stop(AudioStopOptions.AsAuthored);

            currentSongId = (--currentSongId + SongList.Count) % SongList.Count;

            #if !USE_XACT
            gameHasControl = MediaPlayer.GameHasControl;
            if (gameHasControl)
            {
                currentMediaPlayerSong = songs[SongList[currentSongId]];
                try
                {
                    MediaPlayer.Play(currentMediaPlayerSong);
                    MediaPlayer.IsRepeating = true;
                }
                catch { }
            }
            #else
            currentSongCue = currentSoundBank.GetCue(SongList[currentSongId]);
            currentSongCue.Play();
            #endif
        }
Esempio n. 43
0
 public void SetCurrentSongCue(Cue songCue)
 {
     currentSongCue = songCue;
 }
Esempio n. 44
0
        /// <summary>
        /// Starts a new combat stage.  Called right after the stage changes.
        /// </summary>
        /// <remarks>The stage never changes into NotStarted.</remarks>
        protected override void StartStage()
        {
            switch (stage)
            {
                case CombatActionStage.Preparing: // called from Start()
                    {
                        // play the animations
                        combatant.CombatSprite.PlayAnimation("SpellCast");
                        spellSpritePosition = Combatant.Position;
                        spell.SpellSprite.PlayAnimation("Creation");
                        // remove the magic points
                        Combatant.PayCostForSpell(spell);
                    }
                    break;

                case CombatActionStage.Advancing:
                    {
                        // play the animations
                        spell.SpellSprite.PlayAnimation("Traveling");
                        // calculate the projectile destination
                        projectileDirection = Target.Position -
                            Combatant.OriginalPosition;
                        totalProjectileDistance = projectileDirection.Length();
                        projectileDirection.Normalize();
                        projectileDistanceCovered = 0f;
                        // determine if the projectile is flipped
                        if (Target.Position.X > Combatant.Position.X)
                        {
                            projectileSpriteEffect = SpriteEffects.FlipHorizontally;
                        }
                        else
                        {
                            projectileSpriteEffect = SpriteEffects.None;
                        }
                        // get the projectile's cue and play it
                        projectileCue = AudioManager.GetCue(spell.TravelingCueName);
                        if (projectileCue != null)
                        {
                            projectileCue.Play();
                        }
                    }
                    break;

                case CombatActionStage.Executing:
                    {
                        // play the animation
                        spell.SpellSprite.PlayAnimation("Impact");
                        // stop the projectile sound effect
                        if (projectileCue != null)
                        {
                            projectileCue.Stop(AudioStopOptions.Immediate);
                        }
                        // apply the spell effect to the primary target
                        bool damagedAnyone = ApplySpell(Target);
                        // apply the spell to the secondary targets
                        foreach (Combatant targetCombatant in
                            CombatEngine.SecondaryTargetedCombatants)
                        {
                            // skip dead or dying targets
                            if (targetCombatant.IsDeadOrDying)
                            {
                                continue;
                            }
                            // apply the spell
                            damagedAnyone |= ApplySpell(targetCombatant);
                        }
                        // play the impact sound effect
                        if (damagedAnyone)
                        {
                            AudioManager.PlayCue(spell.ImpactCueName);
                            if (spell.Overlay != null)
                            {
                                spell.Overlay.PlayAnimation(0);
                                spell.Overlay.ResetAnimation();
                            }
                        }
                    }
                    break;

                case CombatActionStage.Returning:
                    // play the animation
                    combatant.CombatSprite.PlayAnimation("Idle");
                    break;

                case CombatActionStage.Finishing:
                    // play the animation
                    combatant.CombatSprite.PlayAnimation("Idle");
                    break;

                case CombatActionStage.Complete:
                    // play the animation
                    combatant.CombatSprite.PlayAnimation("Idle");
                    // make sure that the overlay has stopped
                    spell.Overlay.StopAnimation();
                    break;
            }
        }
Esempio n. 45
0
 /// <summary>
 /// Marks this AudioCue as no longer in use
 /// </summary>
 public void Free()
 {
     Debug.Assert(m_state != State.AVAILABLE);
     Debug.Assert(false == m_cue.IsPlaying);
     m_cue.Dispose();
     m_cue = null;
     m_state = State.AVAILABLE;
 }