Example #1
0
        public void Apply3D(Cue cue, Listener listener, Emitter emitter)
        {
            m_x3dAudio.Calculate(listener, emitter, CalculateFlags.Matrix | CalculateFlags.Doppler | CalculateFlags.EmitterAngle, m_dsp);

            cue.SetMatrixCoefficients(m_dsp.SourceChannelCount, m_dsp.DestinationChannelCount, m_dsp.MatrixCoefficients);
            cue.SetVariable(MyCueVariableEnum.Distance, m_dsp.EmitterToListenerDistance);
            cue.SetVariable(MyCueVariableEnum.DopplerPitchScalar, m_dsp.DopplerFactor);
            cue.SetVariable(MyCueVariableEnum.OrientationAngleDegrees, m_dsp.EmitterToListenerAngle * 57.29578f); // From radians to degrees
        }
Example #2
0
        public void Play(string a, float v, float pI, float pA, bool keep)
        {
            Cue sound = theSounds.GetCue(a);

            sound.SetVariable("Volume", v);
            sound.SetVariable("Pitch", pI);
            sound.Play();

            if (keep)
            {
                keptSounds.Add(sound);
            }
        }
Example #3
0
        /// <summary>
        /// Update gear volume and pitch
        /// </summary>
        /// <param name="gearSound">Gear sound</param>
        /// <param name="volume">Volume</param>
        /// <param name="pitch">pitch</param>
        private static void UpdateGearVolumeAndPitch(
            string gearSound, float volume, float pitch)
        {
            if (audioEngine == null)
            {
                return;
            }

            // Gear changing in progress?
            if (gearChangeSoundInitiatedMs > 0)
            {
                gearChangeSoundInitiatedMs -=
                    BaseGame.ElapsedTimeThisFrameInMilliseconds;
                // If gear change sound ends in this frame (max time - frameMs),
                // then start gear sound!
                if (gearChangeSoundInitiatedMs <= 0)
                {
                    gearChangeSoundInitiatedMs = 0;
                    PlayGearSound(gearSound);
                    volume = lastGearVolume = 1.0f;
                    pitch  = lastGearPitch = -0.3f;
                }
            }

            // Set the global volume for this category
            gearsCategory.SetVolume(MathHelper.Clamp(volume, 0, 1) *
                                    GameSettings.Default.SoundVolume);

            // Set pitch only if this is a gear sound
            if (currentGearCue != null)
            {
                currentGearCue.SetVariable("Pitch",
                                           55 * MathHelper.Clamp(pitch, -1, 1));
            }
        }
Example #4
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            if (!backgroundMusic.IsPlaying)
            {
                backgroundMusic = AudioManager.BackgroundSoundBank.GetCue(backgroundMusic.Name);
                backgroundMusic.SetVariable("Volume", 4.0f);
                backgroundMusic.Play();
            }

            spriteBatch.Begin();
            switch (menu.DrawScreen)
            {
            case ScreenType.Game:
                level.Draw(spriteBatch);
                break;

            default:
                menu.Draw(spriteBatch);
                break;
            }
            spriteBatch.End();

            base.Draw(gameTime);
        }
Example #5
0
 public override void farmerAdjacentAction(GameLocation location)
 {
     if (this.name == null || this.isTemporarilyInvisible)
     {
         return;
     }
     if (this.name.Contains("Block") && (this.pit != menu.sca + menu.gro || this.dur != menu.dur || this.sou != menu.labels[menu.labelIndex]))
     {
         this.pit = musicIndex.ContainsKey(menu.sca + menu.gro) ? menu.sca + menu.gro : null;
         this.dur = menu.dur;
         this.sou = menu.labels[menu.labelIndex];
     }
     if ((this.cue == null || Game1.currentGameTime.TotalGameTime.TotalMilliseconds - this.lastNoteBlockSoundTime >= 1000) && sou != null && pit != null && dur != null)
     {
         if (cueInternal != null && cueInternal.IsPlaying)
         {
             cueInternal.Stop(AudioStopOptions.AsAuthored);
         }
         cue = ModEntry.soundBank.GetCue(musicIndex[this.name] + musicIndex[sou] + musicIndex[dur] + musicIndex[pit]);
         cue.SetVariable("Volume", menu.value / 2.1f);
         if (menu.whetherToStopNextTime)
         {
             cueInternal = cue;
             cueInternal.Play();
         }
         else
         {
             cue.Play();
         }
         this.scale.Y                = 1.3f;
         this.shakeTimer             = 200;
         this.lastNoteBlockSoundTime = (int)Game1.currentGameTime.TotalGameTime.TotalMilliseconds;
         return;
     }
 }
Example #6
0
 /// <summary>
 /// Set the current volume for this sound
 /// </summary>
 /// <param name="vol"></param>
 public void SetVolume(float vol)
 {
     if (cue != null)
     {
         cue.SetVariable("Volume", vol);
     }
 }
Example #7
0
 private void jump()
 {
     if ((double)this.minecartDY >= 1.0 || this.respawnCounter > 0)
     {
         return;
     }
     if (!this.isJumping)
     {
         this.movingOnSlope = 0;
         this.minecartPositionBeforeJump = this.mineCartYPosition;
         this.isJumping = true;
         if (this.minecartLoop != null)
         {
             this.minecartLoop.Stop(AudioStopOptions.Immediate);
         }
         if (Game1.soundBank != null)
         {
             Cue    cue  = Game1.soundBank.GetCue("pickUpItem");
             string name = "Pitch";
             double num  = 200.0;
             cue.SetVariable(name, (float)num);
             cue.Play();
         }
     }
     if (this.reachedJumpApex)
     {
         return;
     }
     this.minecartDY = Math.Max(-4.5f, this.minecartDY - 0.6f);
     if ((double)this.minecartDY > -4.5)
     {
         return;
     }
     this.reachedJumpApex = true;
 }
 // Token: 0x06000D40 RID: 3392 RVA: 0x0010C3A8 File Offset: 0x0010A5A8
 private void jump()
 {
     if (this.minecartDY < 1f && this.respawnCounter <= 0)
     {
         if (!this.isJumping)
         {
             this.movingOnSlope = 0;
             this.minecartPositionBeforeJump = this.mineCartYPosition;
             this.isJumping = true;
             if (this.minecartLoop != null)
             {
                 this.minecartLoop.Stop(AudioStopOptions.Immediate);
             }
             if (Game1.soundBank != null)
             {
                 Cue expr_68 = Game1.soundBank.GetCue("pickUpItem");
                 expr_68.SetVariable("Pitch", 200f);
                 expr_68.Play();
             }
         }
         if (!this.reachedJumpApex)
         {
             this.minecartDY = Math.Max(-4.5f, this.minecartDY - 0.6f);
             if (this.minecartDY <= -4.5f)
             {
                 this.reachedJumpApex = true;
             }
         }
     }
 }
Example #9
0
        }                            // PlayRocketMotorSound(volume)

        /// <summary>
        /// Change rocket motor pitch effect
        /// </summary>
        /// <param name="pitchFactor">Pitch factor</param>
        public static void ChangeRocketMotorPitchEffect(float pitchFactor)
        {
            //doesn't work at all, need Audio3DListener, etc. to get this to work!
            //rocketMotorSound.SetVariable("OrientationAngle",
            //MathHelper.Pi / 2.0f);
            //rocketMotorSound.SetVariable("Distance", 1000000);
            rocketMotorSound.SetVariable("Pitch", -10 + 55 * pitchFactor);
        }         // ChangeRocketMotorPitchEffect(pitchFactor)
Example #10
0
 // Token: 0x06000D6D RID: 3437 RVA: 0x0010E334 File Offset: 0x0010C534
 public AnimalQueryMenu(FarmAnimal animal) : base(Game1.viewport.Width / 2 - AnimalQueryMenu.width / 2, Game1.viewport.Height / 2 - AnimalQueryMenu.height / 2, AnimalQueryMenu.width, AnimalQueryMenu.height, false)
 {
     Game1.player.Halt();
     Game1.player.faceGeneralDirection(animal.position, 0);
     AnimalQueryMenu.width               = Game1.tileSize * 6;
     AnimalQueryMenu.height              = Game1.tileSize * 8;
     this.animal                         = animal;
     this.textBox                        = new TextBox(null, null, Game1.dialogueFont, Game1.textColor);
     this.textBox.X                      = Game1.viewport.Width / 2 - Game1.tileSize * 2 - 12;
     this.textBox.Y                      = this.yPositionOnScreen - 4 + Game1.tileSize * 2;
     this.textBox.Width                  = Game1.tileSize * 4;
     this.textBox.Height                 = Game1.tileSize * 3;
     this.textBox.Text                   = animal.name;
     this.textBox.Highlighted            = false;
     Game1.keyboardDispatcher.Subscriber = this.textBox;
     this.textBox.Selected               = false;
     if (animal.parentId != -1L)
     {
         FarmAnimal parent = Utility.getAnimal(animal.parentId);
         if (parent != null)
         {
             this.parentName = parent.name;
         }
     }
     if (animal.sound != null && Game1.soundBank != null)
     {
         Cue expr_173 = Game1.soundBank.GetCue(animal.sound);
         expr_173.SetVariable("Pitch", (float)(1200 + Game1.random.Next(-200, 201)));
         expr_173.Play();
     }
     this.okButton       = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + AnimalQueryMenu.width + 4, this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false);
     this.sellButton     = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + AnimalQueryMenu.width + 4, this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 3 - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(0, 384, 16, 16), 4f, false);
     this.moveHomeButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + AnimalQueryMenu.width + 4, this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 4 - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(16, 384, 16, 16), 4f, false);
     if (!animal.isBaby() && !animal.isCoopDweller())
     {
         this.allowReproductionButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + AnimalQueryMenu.width + Game1.pixelZoom * 4, this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 2 - IClickableMenu.borderWidth + Game1.pixelZoom * 2, Game1.pixelZoom * 9, Game1.pixelZoom * 9), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(animal.allowReproduction ? 128 : 137, 393, 9, 9), 4f, false);
     }
     this.love          = new ClickableTextureComponent(Math.Round((double)animal.friendshipTowardFarmer, 0) / 10.0 + "<", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + Game1.tileSize / 2 + 16, this.yPositionOnScreen - Game1.tileSize / 2 + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 2, AnimalQueryMenu.width - Game1.tileSize * 2, Game1.tileSize), null, "Friendship", Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(172, 512, 16, 16), 4f, false);
     this.loveHover     = new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder, this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 3 - Game1.tileSize / 2, AnimalQueryMenu.width, Game1.tileSize), "Friendship");
     this.fullnessLevel = (double)((float)animal.fullness / 255f);
     if (animal.home != null && animal.home.indoors != null)
     {
         int piecesHay = animal.home.indoors.numberOfObjectsWithName("Hay");
         if (piecesHay > 0)
         {
             int numAnimals = (animal.home.indoors as AnimalHouse).animalsThatLiveHere.Count;
             this.fullnessLevel = Math.Min(1.0, this.fullnessLevel + (double)piecesHay / (double)numAnimals);
         }
     }
     else
     {
         Utility.fixAllAnimals();
     }
     this.happinessLevel = (double)((float)animal.happiness / 255f);
     this.loveLevel      = (double)((float)animal.friendshipTowardFarmer / 1000f);
 }
Example #11
0
        public static void SetVariable(Cue cue, MyCueVariableEnum variableEnum, float value)
        {
            var varInfo = m_cueVariables[(int)variableEnum];

            if (varInfo.VariableIndex == -1 || CacheEnabled == false)
            {
                varInfo.VariableIndex = cue.GetVariableIndex(varInfo.VariableName);
                m_cueVariables[(int)variableEnum].VariableIndex = varInfo.VariableIndex;
            }
            cue.SetVariable(varInfo.VariableIndex, value);
        }
Example #12
0
        public void pet(FarmAnimal animal, StardewValley.Farmer farmer)
        {
            farmer.Halt();
            farmer.faceGeneralDirection(animal.position, 0);
            animal.Halt();
            animal.sprite.StopAnimation();
            animal.uniqueFrameAccumulator = -1;
            switch (Game1.player.FacingDirection)
            {
            case 0:
                animal.sprite.currentFrame = 0;
                break;

            case 1:
                animal.sprite.currentFrame = 12;
                break;

            case 2:
                animal.sprite.currentFrame = 8;
                break;

            case 3:
                animal.sprite.currentFrame = 4;
                break;
            }
            animal.wasPet = true;
            animal.friendshipTowardFarmer = Math.Min(1000, animal.friendshipTowardFarmer + 15);
            if (farmer.professions.Contains(3) && !animal.isCoopDweller())
            {
                animal.friendshipTowardFarmer = Math.Min(1000, animal.friendshipTowardFarmer + 15);
                animal.happiness = (byte)Math.Min((int)byte.MaxValue, ((uint)animal.happiness + (uint)Math.Max(5, 40 - (int)animal.happinessDrain)));
            }
            else if (farmer.professions.Contains(2) && animal.isCoopDweller())
            {
                animal.friendshipTowardFarmer = Math.Min(1000, animal.friendshipTowardFarmer + 15);
                animal.happiness = (byte)Math.Min((int)byte.MaxValue, ((uint)animal.happiness + (uint)Math.Max(5, 40 - (int)animal.happinessDrain)));
            }
            animal.doEmote((int)animal.moodMessage == 4 ? 12 : 20, true);
            animal.happiness = (byte)Math.Min((int)byte.MaxValue, (int)animal.happiness + Math.Max(5, 40 - (int)animal.happinessDrain));
            if (animal.sound != null && Game1.soundBank != null)
            {
                Cue    cue  = Game1.soundBank.GetCue(animal.sound);
                string name = "Pitch";
                double num  = (double)(1200 + Game1.random.Next(-200, 201));
                cue.SetVariable(name, (float)num);
                cue.Play();
            }
            farmer.gainExperience(0, 5);
            if (!animal.type.Equals("Sheep") || animal.friendshipTowardFarmer < 900)
            {
                return;
            }
            animal.daysToLay = (byte)2;
        }
        public static void CueSound(string sound, string name, float value)
        {
            if (!Utilities.BellsAndWhistles.HasSoundBank())
            {
                return;
            }

            Cue cue = Game1.soundBank.GetCue(sound);

            cue.SetVariable(name, value);
            cue.Play();
        }
Example #14
0
 public override bool performUseAction(Vector2 tileLocation)
 {
     if (Game1.soundBank != null)
     {
         Random arg_4F_0 = new Random((int)(Game1.uniqueIDForThisGame + tileLocation.X * 7f + tileLocation.Y * 11f + (float)Game1.mine.mineLevel));
         Cue    cue      = Game1.soundBank.GetCue("crystal");
         int    num      = arg_4F_0.Next(2400);
         num -= num % 100;
         cue.SetVariable("Pitch", (float)num);
         cue.Play();
     }
     this.glow = 0.7f;
     return(false);
 }
Example #15
0
 // Token: 0x0600119E RID: 4510 RVA: 0x0016906C File Offset: 0x0016726C
 public void setTrainComing(int delay)
 {
     this.trainTimer = delay;
     if (Game1.currentLocation.isOutdoors && !Game1.isFestival())
     {
         Game1.showGlobalMessage(Game1.content.LoadString("Strings\\Locations:Railroad_TrainComing", new object[0]));
         if (Game1.soundBank != null)
         {
             Cue expr_4A = Game1.soundBank.GetCue("distantTrain");
             expr_4A.SetVariable("Volume", 100f);
             expr_4A.Play();
         }
     }
 }
Example #16
0
 public void SetVariable(string name, float value)
 {
     if (modMusic != null)
     {
         if (name.Equals("Volume"))
         {
             modMusic.Volume = value;
         }
     }
     else
     {
         cue.SetVariable(name, value);
     }
 }
Example #17
0
 public override bool performUseAction(Vector2 tileLocation)
 {
     if (Game1.soundBank != null)
     {
         Random random   = new Random((int)((double)Game1.uniqueIDForThisGame + (double)tileLocation.X * 7.0 + (double)tileLocation.Y * 11.0 + (double)Game1.mine.mineLevel));
         Cue    cue      = Game1.soundBank.GetCue("crystal");
         int    maxValue = 2400;
         int    num1     = random.Next(maxValue);
         int    num2     = num1 - num1 % 100;
         cue.SetVariable("Pitch", (float)num2);
         cue.Play();
     }
     this.glow = 0.7f;
     return(false);
 }
Example #18
0
        public float this[String variable]
        {
            get { return(mCue.GetVariable(variable)); }
            set
            {
                mCue.SetVariable(variable, value);

                if (mVariableValues.ContainsKey(variable))
                {
                    mVariableValues[variable] = value;
                }
                else
                {
                    mVariableValues.Add(variable, value);
                }
            }
        }
Example #19
0
        /// <summary>
        /// Plays a 3D sound.
        /// </summary>
        /// <param name="soundName">The name of the sound to play.</param>
        /// <param name="listnerPos">The position of the listner.</param>
        /// <param name="origin">The origin of the sound.</param>
        public static void Play3DSound(string soundName, Vector3 listnerPos, Vector3 origin)
        {
            float minDist = 1e10f;

            float dist = (origin - listnerPos).LengthSquared();

            if (dist < minDist)
            {
                minDist = dist;
            }

            Cue c = soundBank.GetCue(soundName);

            cueSounds.Add(c);

            c.SetVariable("Distance", (float)System.Math.Sqrt(minDist));

            c.Play();
        }
Example #20
0
        public void setTrainComing(int delay)
        {
            this.trainTimer = delay;
            if (!Game1.currentLocation.isOutdoors || Game1.isFestival())
            {
                return;
            }
            Game1.showGlobalMessage(Game1.content.LoadString("Strings\\Locations:Railroad_TrainComing"));
            if (Game1.soundBank == null)
            {
                return;
            }
            Cue    cue  = Game1.soundBank.GetCue("distantTrain");
            string name = "Volume";
            double num  = 100.0;

            cue.SetVariable(name, (float)num);
            cue.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();
        }
Example #22
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)
Example #23
0
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     if (Game1.globalFade || freeze)
     {
         return;
     }
     if (okButton != null && okButton.containsPoint(x, y) && readyToClose())
     {
         if (onFarm)
         {
             Game1.globalFadeToBlack(new Game1.afterFadeFunction(setUpForReturnToShopMenu), 0.02f);
             Game1.playSound("smallSelect");
         }
         else
         {
             Game1.exitActiveMenu();
             Game1.playSound("bigDeSelect");
         }
     }
     if (onFarm)
     {
         Vector2  tile       = new Vector2((x + Game1.viewport.X) / Game1.tileSize, (y + Game1.viewport.Y) / Game1.tileSize);
         Building buildingAt = currentFarm.getBuildingAt(tile);
         if (buildingAt != null && !namingAnimal)
         {
             if (buildingAt.buildingType.Contains(animalBeingPurchased.buildingTypeILiveIn))
             {
                 if ((buildingAt.indoors as AnimalHouse).isFull())
                 {
                     Game1.showRedMessage("That Building Is Full");
                 }
                 else if (animalBeingPurchased.harvestType != 2)
                 {
                     namingAnimal  = true;
                     newAnimalHome = buildingAt;
                     if (animalBeingPurchased.sound != null && Game1.soundBank != null)
                     {
                         Cue cue = Game1.soundBank.GetCue(animalBeingPurchased.sound);
                         cue.SetVariable("Pitch", 1200 + Game1.random.Next(-200, 201));
                         cue.Play();
                     }
                     textBox.OnEnterPressed += e;
                     Game1.keyboardDispatcher.Subscriber = textBox;
                     textBox.Text     = animalBeingPurchased.name;
                     textBox.Selected = true;
                 }
                 else if (Game1.player.money >= priceOfAnimal)
                 {
                     newAnimalHome                     = buildingAt;
                     animalBeingPurchased.home         = newAnimalHome;
                     animalBeingPurchased.homeLocation = new Vector2(newAnimalHome.tileX, newAnimalHome.tileY);
                     animalBeingPurchased.setRandomPosition(animalBeingPurchased.home.indoors);
                     (newAnimalHome.indoors as AnimalHouse).animals.Add(animalBeingPurchased.myID, animalBeingPurchased);
                     (newAnimalHome.indoors as AnimalHouse).animalsThatLiveHere.Add(animalBeingPurchased.myID);
                     newAnimalHome = null;
                     namingAnimal  = false;
                     if (animalBeingPurchased.sound != null && Game1.soundBank != null)
                     {
                         Cue cue2 = Game1.soundBank.GetCue(animalBeingPurchased.sound);
                         cue2.SetVariable("Pitch", 1200 + Game1.random.Next(-200, 201));
                         cue2.Play();
                     }
                     Game1.player.money -= priceOfAnimal;
                     Game1.addHUDMessage(new HUDMessage("Purchased " + animalBeingPurchased.type, Color.LimeGreen, 3500f));
                     animalBeingPurchased = new FarmAnimal(animalBeingPurchased.type, MultiplayerUtility.getNewID(), Game1.player.uniqueMultiplayerID);
                 }
                 else if (Game1.player.money < priceOfAnimal)
                 {
                     Game1.dayTimeMoneyBox.moneyShakeTimer = 1000;
                 }
             }
             else
             {
                 Game1.showRedMessage(animalBeingPurchased.type.Split(new char[]
                 {
                     ' '
                 }).Last() + "s Can't Live There.");
             }
         }
         if (namingAnimal && doneNamingButton.containsPoint(x, y))
         {
             textBoxEnter(textBox);
             Game1.playSound("smallSelect");
             return;
         }
         if (namingAnimal && randomButton.containsPoint(x, y))
         {
             animalBeingPurchased.name = Dialogue.randomName();
             textBox.Text       = animalBeingPurchased.name;
             randomButton.scale = randomButton.baseScale;
             Game1.playSound("drumkit6");
             return;
         }
     }
     else
     {
         if (backButton.containsPoint(x, y))
         {
             currentFarmIndex = (currentFarmIndex == 0) ? 1 : 0;
             populateAnimalStock();
             backButton.scale = backButton.baseScale;
         }
         if (forwardButton.containsPoint(x, y))
         {
             currentFarmIndex = (currentFarmIndex == 0) ? 1 : 0;
             populateAnimalStock();
             forwardButton.scale = forwardButton.baseScale;
         }
         foreach (ClickableTextureComponent current in animalsToPurchase)
         {
             if (current.containsPoint(x, y) && (current.item as StardewValley.Object).type == null)
             {
                 int num = Convert.ToInt32(current.name);
                 if (Game1.player.money >= num)
                 {
                     Game1.globalFadeToBlack(new Game1.afterFadeFunction(setUpForAnimalPlacement), 0.02f);
                     Game1.playSound("smallSelect");
                     onFarm = true;
                     animalBeingPurchased = new FarmAnimal(current.hoverText, MultiplayerUtility.getNewID(), Game1.player.uniqueMultiplayerID);
                     priceOfAnimal        = num;
                 }
                 else
                 {
                     Game1.addHUDMessage(new HUDMessage("Not Enough Money", Color.Red, 3500f));
                 }
             }
         }
     }
 }
Example #24
0
 /// <summary>
 /// Applies the value of the variable to the specified cue instance.
 /// </summary>
 /// <param name="cue">Cue that contains the variable to be set.</param>
 public void Apply(Cue cue)
 {
     cue.SetVariable(Name, Value);
 }
Example #25
0
        public override void receiveLeftClick(int x, int y, bool playSound = true)
        {
            if (Game1.globalFade || this.Freeze)
            {
                return;
            }

            if (this.BackButton != null && this.BackButton.containsPoint(x, y))
            {
                this.BackButton.scale = this.BackButton.baseScale;
                this.BackButtonPressed();
            }

            if (this.OkButton != null && this.OkButton.containsPoint(x, y) && this.readyToClose())
            {
                if (this.OnFarm)
                {
                    Game1.globalFadeToBlack(this.SetUpForReturnToShopMenu);
                    Game1.playSound("smallSelect");
                }
                else
                {
                    Game1.exitActiveMenu();
                    Game1.playSound("bigDeSelect");
                }
            }
            if (this.OnFarm)
            {
                Building building = Game1.getFarm().getBuildingAt(new Vector2((x + Game1.viewport.X) / Game1.tileSize, (y + Game1.viewport.Y) / Game1.tileSize));
                if (building != null && !this.NamingAnimal)
                {
                    if (building.buildingType.Contains(this.AnimalBeingPurchased.buildingTypeILiveIn.Value))
                    {
                        AnimalHouse animalHouse = (AnimalHouse)building.indoors.Value;
                        if (animalHouse.isFull())
                        {
                            Game1.showRedMessage("That Building Is Full");
                        }
                        else if (this.AnimalBeingPurchased.harvestType.Value != 2)
                        {
                            this.NamingAnimal  = true;
                            this.NewAnimalHome = building;
                            if (this.AnimalBeingPurchased.sound.Value != null && Game1.soundBank != null)
                            {
                                Cue cue = Game1.soundBank.GetCue(this.AnimalBeingPurchased.sound.Value);
                                cue.SetVariable("Pitch", 1200 + Game1.random.Next(-200, 201));
                                cue.Play();
                            }
                            this.TextBox.OnEnterPressed        += this.TextBoxEvent;
                            Game1.keyboardDispatcher.Subscriber = this.TextBox;
                            this.TextBox.Text     = this.AnimalBeingPurchased.Name;
                            this.TextBox.Selected = true;
                        }
                        else if (Game1.player.money >= this.PriceOfAnimal)
                        {
                            this.NewAnimalHome             = building;
                            this.AnimalBeingPurchased.home = this.NewAnimalHome;
                            this.AnimalBeingPurchased.homeLocation.Value = new Vector2(this.NewAnimalHome.tileX.Value, this.NewAnimalHome.tileY.Value);
                            this.AnimalBeingPurchased.setRandomPosition(this.AnimalBeingPurchased.home.indoors.Value);
                            ((AnimalHouse)this.NewAnimalHome.indoors.Value).animals.Add(this.AnimalBeingPurchased.myID.Value, this.AnimalBeingPurchased);
                            ((AnimalHouse)this.NewAnimalHome.indoors.Value).animalsThatLiveHere.Add(this.AnimalBeingPurchased.myID.Value);
                            this.NewAnimalHome = null;
                            this.NamingAnimal  = false;
                            if (this.AnimalBeingPurchased.sound.Value != null && Game1.soundBank != null)
                            {
                                Cue cue = Game1.soundBank.GetCue(this.AnimalBeingPurchased.sound.Value);
                                cue.SetVariable("Pitch", 1200 + Game1.random.Next(-200, 201));
                                cue.Play();
                            }
                            Game1.player.money -= this.PriceOfAnimal;
                            Game1.addHUDMessage(new HUDMessage("Purchased " + this.AnimalBeingPurchased.type.Value, Color.LimeGreen, 3500f));
                            this.AnimalBeingPurchased = new FarmAnimal(this.AnimalBeingPurchased.type.Value, this.GetNewId(), Game1.player.UniqueMultiplayerID);
                        }
                        else if (Game1.player.money < this.PriceOfAnimal)
                        {
                            Game1.dayTimeMoneyBox.moneyShakeTimer = 1000;
                        }
                    }
                    else
                    {
                        Game1.showRedMessage(this.AnimalBeingPurchased.type.Value.Split(' ').Last() + "s Can't Live There.");
                    }
                }
                if (this.NamingAnimal && this.DoneNamingButton.containsPoint(x, y))
                {
                    this.TextBoxEnter(this.TextBox);
                    Game1.playSound("smallSelect");
                }
                else
                {
                    if (!this.NamingAnimal || !this.RandomButton.containsPoint(x, y))
                    {
                        return;
                    }
                    this.AnimalBeingPurchased.Name = Dialogue.randomName();
                    this.TextBox.Text       = this.AnimalBeingPurchased.Name;
                    this.RandomButton.scale = this.RandomButton.baseScale;
                    Game1.playSound("drumkit6");
                }
            }
            else
            {
                foreach (ClickableTextureComponent textureComponent in this.AnimalsToPurchase)
                {
                    if (textureComponent.containsPoint(x, y) && ((Object)textureComponent.item).Type == null)
                    {
                        int int32 = Convert.ToInt32(textureComponent.name);
                        if (Game1.player.money >= int32)
                        {
                            Game1.globalFadeToBlack(this.SetUpForAnimalPlacement);
                            Game1.playSound("smallSelect");
                            this.OnFarm = true;
                            this.AnimalBeingPurchased = new FarmAnimal(textureComponent.hoverText, this.GetNewId(), Game1.player.UniqueMultiplayerID);
                            this.PriceOfAnimal        = int32;
                        }
                        else
                        {
                            Game1.addHUDMessage(new HUDMessage("Not Enough Money", Color.Red, 3500f));
                        }
                    }
                }
            }
        }
Example #26
0
 public override void SetVariable(string name, float value) => cue.SetVariable(name, value);
Example #27
0
 public void SetVariable(string var, int val)
 {
     cue.SetVariable(var, val);
 }
Example #28
0
            public virtual bool updateWhenCurrentLocation(GameTime time, GameLocation location)
            {
                if (!Game1.shouldTimePass())
                {
                    return(false);
                }
                if (this.health <= 0)
                {
                    return(true);
                }
                if (this.hitGlowTimer > 0)
                {
                    this.hitGlowTimer = this.hitGlowTimer - time.ElapsedGameTime.Milliseconds;
                }
                if (this.sprite.currentAnimation != null)
                {
                    if (this.sprite.animateOnce(time))
                    {
                        this.sprite.currentAnimation = (List <FarmerSprite.AnimationFrame>)null;
                    }
                    return(false);
                }
                this.update(time, location, this.myID, false);
                if (this.behaviors(time, location) || this.sprite.currentAnimation != null)
                {
                    return(false);
                }
                if (this.controller != null && this.controller.timerSinceLastCheckPoint > 10000)
                {
                    this.controller = (PathFindController)null;
                    this.Halt();
                }
                if (location is Farm && this.noWarpTimer <= 0 && this.home != null && this.home.getRectForAnimalDoor().Contains(this.GetBoundingBox().Center.X, this.GetBoundingBox().Top))
                {
                    ((AnimalHouse)this.home.indoors).animals.Add(this.myID, this);
                    this.setRandomPosition(this.home.indoors);
                    this.faceDirection(Game1.random.Next(4));
                    this.controller = (PathFindController)null;
                    if (Utility.isOnScreen(this.getTileLocationPoint(), Game1.tileSize * 3, location))
                    {
                        Game1.playSound("dwoop");
                    }
                    return(true);
                }
                int      val1            = 0;
                int      noWarpTimer     = this.noWarpTimer;
                TimeSpan elapsedGameTime = time.ElapsedGameTime;
                int      milliseconds1   = elapsedGameTime.Milliseconds;
                int      val2            = noWarpTimer - milliseconds1;

                this.noWarpTimer = Math.Max(val1, val2);
                if (this.pauseTimer > 0)
                {
                    int pauseTimer = this.pauseTimer;
                    elapsedGameTime = time.ElapsedGameTime;
                    int milliseconds2 = elapsedGameTime.Milliseconds;
                    this.pauseTimer = pauseTimer - milliseconds2;
                }
                if (Game1.timeOfDay >= 2000)
                {
                    this.sprite.currentFrame = this.buildingTypeILiveIn.Contains("Coop") ? 16 : 12;
                    this.sprite.UpdateSourceRect();
                    if (!this.isEmoting && Game1.random.NextDouble() < 0.002)
                    {
                        this.doEmote(24, true);
                    }
                }
                else if (this.pauseTimer <= 0)
                {
                    if (Game1.random.NextDouble() < 0.001 && this.age >= (int)this.ageWhenMature && ((int)Game1.gameMode == 3 && this.sound != null) && (Utility.isOnScreen(this.position, Game1.tileSize * 3) && Game1.soundBank != null))
                    {
                        Cue    cue  = Game1.soundBank.GetCue(this.sound);
                        string name = "Pitch";
                        double num  = (double)(1200 + Game1.random.Next(-200, 201));
                        cue.SetVariable(name, (float)num);
                        cue.Play();
                    }
                    if (!Game1.IsClient && Game1.random.NextDouble() < 0.007 && this.uniqueFrameAccumulator == -1)
                    {
                        int direction = Game1.random.Next(5);
                        if (direction != (this.facingDirection + 2) % 4)
                        {
                            if (direction < 4)
                            {
                                int facingDirection = this.facingDirection;
                                this.faceDirection(direction);
                                if (!location.isOutdoors && location.isCollidingPosition(this.nextPosition(direction), Game1.viewport, (Character)this))
                                {
                                    this.faceDirection(facingDirection);
                                    return(false);
                                }
                            }
                            switch (direction)
                            {
                            case 0:
                                this.SetMovingUp(true);
                                break;

                            case 1:
                                this.SetMovingRight(true);
                                break;

                            case 2:
                                this.SetMovingDown(true);
                                break;

                            case 3:
                                this.SetMovingLeft(true);
                                break;

                            default:
                                this.Halt();
                                this.sprite.StopAnimation();
                                break;
                            }
                        }
                        else if (this.noWarpTimer <= 0)
                        {
                            this.Halt();
                            this.sprite.StopAnimation();
                        }
                    }
                    if (!Game1.IsClient && this.isMoving() && (Game1.random.NextDouble() < 0.014 && this.uniqueFrameAccumulator == -1) || Game1.IsClient && Game1.random.NextDouble() < 0.014 && (double)this.distanceFromLastServerPosition() <= 4.0)
                    {
                        this.Halt();
                        this.sprite.StopAnimation();
                        if (Game1.random.NextDouble() < 0.75)
                        {
                            this.uniqueFrameAccumulator = 0;
                            if (this.buildingTypeILiveIn.Contains("Coop"))
                            {
                                switch (this.facingDirection)
                                {
                                case 0:
                                    this.sprite.currentFrame = 20;
                                    break;

                                case 1:
                                    this.sprite.currentFrame = 18;
                                    break;

                                case 2:
                                    this.sprite.currentFrame = 16;
                                    break;

                                case 3:
                                    this.sprite.currentFrame = 22;
                                    break;
                                }
                            }
                            else if (this.buildingTypeILiveIn.Contains("Barn"))
                            {
                                switch (this.facingDirection)
                                {
                                case 0:
                                    this.sprite.currentFrame = 15;
                                    break;

                                case 1:
                                    this.sprite.currentFrame = 14;
                                    break;

                                case 2:
                                    this.sprite.currentFrame = 13;
                                    break;

                                case 3:
                                    this.sprite.currentFrame = 14;
                                    break;
                                }
                            }
                        }
                        this.sprite.UpdateSourceRect();
                    }
                    if (this.uniqueFrameAccumulator != -1)
                    {
                        int frameAccumulator = this.uniqueFrameAccumulator;
                        elapsedGameTime = time.ElapsedGameTime;
                        int milliseconds2 = elapsedGameTime.Milliseconds;
                        this.uniqueFrameAccumulator = frameAccumulator + milliseconds2;
                        if (this.uniqueFrameAccumulator > 500)
                        {
                            if (this.buildingTypeILiveIn.Contains("Coop"))
                            {
                                this.sprite.CurrentFrame = this.sprite.CurrentFrame + 1 - this.sprite.CurrentFrame % 2 * 2;
                            }
                            else if (this.sprite.CurrentFrame > 12)
                            {
                                this.sprite.CurrentFrame = (this.sprite.CurrentFrame - 13) * 4;
                            }
                            else
                            {
                                switch (this.facingDirection)
                                {
                                case 0:
                                    this.sprite.CurrentFrame = 15;
                                    break;

                                case 1:
                                    this.sprite.CurrentFrame = 14;
                                    break;

                                case 2:
                                    this.sprite.CurrentFrame = 13;
                                    break;

                                case 3:
                                    this.sprite.CurrentFrame = 14;
                                    break;
                                }
                            }
                            this.uniqueFrameAccumulator = 0;
                            if (Game1.random.NextDouble() < 0.4)
                            {
                                this.uniqueFrameAccumulator = -1;
                            }
                        }
                    }
                    else if (!Game1.IsClient)
                    {
                        this.MovePosition(time, Game1.viewport, location);
                    }
                }
                if (!this.isMoving() && location is Farm && this.controller == null)
                {
                    this.Halt();
                    Microsoft.Xna.Framework.Rectangle boundingBox1 = this.GetBoundingBox();
                    foreach (KeyValuePair <long, FarmAnimal> animal in (Dictionary <long, FarmAnimal>)(location as Farm).animals)
                    {
                        if (!animal.Value.Equals((object)this))
                        {
                            Microsoft.Xna.Framework.Rectangle boundingBox2 = animal.Value.GetBoundingBox();
                            if (boundingBox2.Intersects(boundingBox1))
                            {
                                int x1 = boundingBox1.Center.X;
                                boundingBox2 = animal.Value.GetBoundingBox();
                                int x2   = boundingBox2.Center.X;
                                int num1 = x1 - x2;
                                int y1   = boundingBox1.Center.Y;
                                boundingBox2 = animal.Value.GetBoundingBox();
                                int y2   = boundingBox2.Center.Y;
                                int num2 = y1 - y2;
                                if (num1 > 0 && Math.Abs(num1) > Math.Abs(num2))
                                {
                                    this.SetMovingUp(true);
                                }
                                else if (num1 < 0 && Math.Abs(num1) > Math.Abs(num2))
                                {
                                    this.SetMovingDown(true);
                                }
                                else if (num2 > 0)
                                {
                                    this.SetMovingLeft(true);
                                }
                                else
                                {
                                    this.SetMovingRight(true);
                                }
                            }
                        }
                    }
                }
                return(false);
            }
Example #29
0
 // Token: 0x06000F96 RID: 3990 RVA: 0x0013F5B0 File Offset: 0x0013D7B0
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     if (Game1.globalFade || this.freeze)
     {
         return;
     }
     if (this.okButton != null && this.okButton.containsPoint(x, y) && this.readyToClose())
     {
         if (this.onFarm)
         {
             Game1.globalFadeToBlack(new Game1.afterFadeFunction(this.setUpForReturnToShopMenu), 0.02f);
             Game1.playSound("smallSelect");
         }
         else
         {
             Game1.exitActiveMenu();
             Game1.playSound("bigDeSelect");
         }
     }
     if (this.onFarm)
     {
         Vector2  clickTile = new Vector2((float)((x + Game1.viewport.X) / Game1.tileSize), (float)((y + Game1.viewport.Y) / Game1.tileSize));
         Building selection = (Game1.getLocationFromName("Farm") as Farm).getBuildingAt(clickTile);
         if (selection != null && !this.namingAnimal)
         {
             if (selection.buildingType.Contains(this.animalBeingPurchased.buildingTypeILiveIn))
             {
                 if ((selection.indoors as AnimalHouse).isFull())
                 {
                     Game1.showRedMessage("That Building Is Full");
                 }
                 else if (this.animalBeingPurchased.harvestType != 2)
                 {
                     this.namingAnimal  = true;
                     this.newAnimalHome = selection;
                     if (this.animalBeingPurchased.sound != null && Game1.soundBank != null)
                     {
                         Cue expr_14B = Game1.soundBank.GetCue(this.animalBeingPurchased.sound);
                         expr_14B.SetVariable("Pitch", (float)(1200 + Game1.random.Next(-200, 201)));
                         expr_14B.Play();
                     }
                     this.textBox.OnEnterPressed        += this.e;
                     Game1.keyboardDispatcher.Subscriber = this.textBox;
                     this.textBox.Text     = this.animalBeingPurchased.name;
                     this.textBox.Selected = true;
                 }
                 else if (Game1.player.money >= this.priceOfAnimal)
                 {
                     this.newAnimalHome                     = selection;
                     this.animalBeingPurchased.home         = this.newAnimalHome;
                     this.animalBeingPurchased.homeLocation = new Vector2((float)this.newAnimalHome.tileX, (float)this.newAnimalHome.tileY);
                     this.animalBeingPurchased.setRandomPosition(this.animalBeingPurchased.home.indoors);
                     (this.newAnimalHome.indoors as AnimalHouse).animals.Add(this.animalBeingPurchased.myID, this.animalBeingPurchased);
                     (this.newAnimalHome.indoors as AnimalHouse).animalsThatLiveHere.Add(this.animalBeingPurchased.myID);
                     this.newAnimalHome = null;
                     this.namingAnimal  = false;
                     if (this.animalBeingPurchased.sound != null && Game1.soundBank != null)
                     {
                         Cue expr_2B5 = Game1.soundBank.GetCue(this.animalBeingPurchased.sound);
                         expr_2B5.SetVariable("Pitch", (float)(1200 + Game1.random.Next(-200, 201)));
                         expr_2B5.Play();
                     }
                     Game1.player.money -= this.priceOfAnimal;
                     Game1.addHUDMessage(new HUDMessage("Purchased " + this.animalBeingPurchased.type, Color.LimeGreen, 3500f));
                     this.animalBeingPurchased = new FarmAnimal(this.animalBeingPurchased.type, MultiplayerUtility.getNewID(), Game1.player.uniqueMultiplayerID);
                 }
                 else if (Game1.player.money < this.priceOfAnimal)
                 {
                     Game1.dayTimeMoneyBox.moneyShakeTimer = 1000;
                 }
             }
             else
             {
                 Game1.showRedMessage(this.animalBeingPurchased.type.Split(new char[]
                 {
                     ' '
                 }).Last <string>() + "s Can't Live There.");
             }
         }
         if (this.namingAnimal && this.doneNamingButton.containsPoint(x, y))
         {
             this.textBoxEnter(this.textBox);
             Game1.playSound("smallSelect");
             return;
         }
         if (this.namingAnimal && this.randomButton.containsPoint(x, y))
         {
             this.animalBeingPurchased.name = Dialogue.randomName();
             this.textBox.Text       = this.animalBeingPurchased.name;
             this.randomButton.scale = this.randomButton.baseScale;
             Game1.playSound("drumkit6");
             return;
         }
     }
     else
     {
         foreach (ClickableTextureComponent c in this.animalsToPurchase)
         {
             if (c.containsPoint(x, y) && (c.item as Object).type == null)
             {
                 int price = Convert.ToInt32(c.name);
                 if (Game1.player.money >= price)
                 {
                     Game1.globalFadeToBlack(new Game1.afterFadeFunction(this.setUpForAnimalPlacement), 0.02f);
                     Game1.playSound("smallSelect");
                     this.onFarm = true;
                     this.animalBeingPurchased = new FarmAnimal(c.hoverText, MultiplayerUtility.getNewID(), Game1.player.uniqueMultiplayerID);
                     this.priceOfAnimal        = price;
                 }
                 else
                 {
                     Game1.addHUDMessage(new HUDMessage("Not Enough Money", Color.Red, 3500f));
                 }
             }
         }
     }
 }
Example #30
0
        public override void Update(GameTime gameTime)
        {
            if (m_screen.IsActive)
            {
                m_killTime -= (float)gameTime.ElapsedGameTime.TotalSeconds;
            }

            //if ((float)gameTime.TotalGameTime.TotalSeconds > m_killTime)
            if (m_killTime < 0.0f)
            {
                bDead = true;
                // Cue c = Game1.Audio.PlaySound("sfx_cannonball_hit_water");
                Cue c = Game1.Audio.GetCue("sfx_cannonball_hit_water");

                AudioListener al = new AudioListener();
                al.Position = new Vector3(m_screen.Player.Position, 0);
                al.Up       = Vector3.Backward;
                al.Forward  = Vector3.Up;

                AudioEmitter ae = new AudioEmitter();
                ae.Position = new Vector3(Position, 0);
                ae.Up       = Vector3.Backward;
                ae.Forward  = Vector3.Up;

                c.Apply3D(al, ae);
                Game1.Audio.PlayCue(c);
                c.SetVariable("Distance", (m_screen.Player.Position - Position).Length());

                Watersplash w = new Watersplash(Game);
                w.Initialize(10, Position, true);

                //Game1.Audio.SetParameter("sfx_cannonball_hit_water", "Distance", (m_screen.Player.Position - Position).Length());
            }



            m_obb.Orientation = Rotation;
            m_obb.Center      = Position;
            m_obb.CalculateAxis();

            for (Actor a = Actors.First.Value; a != null; a = a.NextActor)
            {
                if (a is PDVehicle)
                {
                    if (a != Owner)
                    {
                        if ((a as PDVehicle).Obb.TestOBBOBB(Obb))
                        {
                            SpriteEffect e = new EffectCannonFire(Game);
                            e.Initialize(10, Position, true);

                            bDead = true;

                            // Cue c = Game1.Audio.PlaySound("sfx_cannonball_hit");
                            Cue           c  = Game1.Audio.GetCue("sfx_cannonball_hit");
                            AudioListener al = new AudioListener();
                            al.Position = new Vector3(m_screen.Player.Position, 0);
                            al.Up       = Vector3.Backward;
                            al.Forward  = Vector3.Up;

                            AudioEmitter ae = new AudioEmitter();
                            ae.Position = new Vector3(Position, 0);
                            ae.Up       = Vector3.Backward;
                            ae.Forward  = Vector3.Up;

                            c.Apply3D(al, ae);
                            Game1.Audio.PlayCue(c);
                            c.SetVariable("Distance", (m_screen.Player.Position - Position).Length());
                            // Game1.Audio.SetParameter("sfx_cannonball_hit", "Distance", (m_screen.Player.Position - Position).Length());

                            // Damage target
                            (a as PDVehicle).Damage(Damage);
                        }
                    }
                }
            }

            base.Update(gameTime);
        }