コード例 #1
0
            public void SetVariable(string var, int val)
            {
                if (var.Equals("Volume", StringComparison.OrdinalIgnoreCase) && Game1.player?.currentLocation is Town) //if volume is being set AND the local player is in town
                {
                    val = Convert.ToInt32(Utility.Clamp(VolumeModifier(val), 0, 100));                                 //modify the volume, clamp it between 0 and 100, and convert it to the nearest integer
                }

                WrappedCue.SetVariable(var, val);
            }
コード例 #2
0
 public override void updateEvenIfFarmerIsntHere(GameTime time, bool skipWasUpdatedFlush = false)
 {
     base.updateEvenIfFarmerIsntHere(time, skipWasUpdatedFlush);
     if (train.Value != null && train.Value.Update(time, this) && Game1.IsMasterGame)
     {
         train.Value = null;
     }
     if (!Game1.IsMasterGame)
     {
         return;
     }
     if (Game1.timeOfDay == trainTime - trainTime % 10 && (int)trainTimer == 0 && !Game1.isFestival() && train.Value == null)
     {
         setTrainComing(15000);
     }
     if ((int)trainTimer > 0)
     {
         trainTimer.Value -= time.ElapsedGameTime.Milliseconds;
         if ((int)trainTimer <= 0)
         {
             train.Value = new Train();
             playSound("trainWhistle");
         }
         if ((int)trainTimer < 3500 && Game1.currentLocation == this && Game1.soundBank != null && (trainLoop == null || !trainLoop.IsPlaying))
         {
             trainLoop = Game1.soundBank.GetCue("trainLoop");
             trainLoop.SetVariable("Volume", 0f);
             trainLoop.Play();
         }
     }
     if (train.Value != null)
     {
         if (Game1.currentLocation == this && Game1.soundBank != null && (trainLoop == null || !trainLoop.IsPlaying))
         {
             trainLoop = Game1.soundBank.GetCue("trainLoop");
             trainLoop.SetVariable("Volume", 0f);
             trainLoop.Play();
         }
         if (trainLoop != null && trainLoop.GetVariable("Volume") < 100f)
         {
             trainLoop.SetVariable("Volume", trainLoop.GetVariable("Volume") + 0.5f);
         }
     }
     else if (trainLoop != null && (int)trainTimer <= 0)
     {
         trainLoop.SetVariable("Volume", trainLoop.GetVariable("Volume") - 0.15f);
         if (trainLoop.GetVariable("Volume") <= 0f)
         {
             trainLoop.Stop(AudioStopOptions.Immediate);
             trainLoop = null;
         }
     }
     else if ((int)trainTimer > 0 && trainLoop != null)
     {
         trainLoop.SetVariable("Volume", trainLoop.GetVariable("Volume") + 0.15f);
     }
 }
コード例 #3
0
ファイル: Quartz.cs プロジェクト: osheroff/stardew-valley
        public override bool performUseAction(Vector2 tileLocation, GameLocation location)
        {
            if (Game1.soundBank != null)
            {
                Random random = new Random((int)((float)Game1.uniqueIDForThisGame + tileLocation.X * 7f + tileLocation.Y * 11f + (float)Game1.CurrentMineLevel));
                ICue   c      = Game1.soundBank.GetCue("crystal");
                int    pitch  = random.Next(2400);
                pitch -= pitch % 100;
                c.SetVariable("Pitch", pitch);
                c.Play();
            }
            glow.Value = 0.7f;
            Color glowColor = ((glow.Value > 0f) ? new Color(color.R + (int)(glow.Value * 50f), color.G + (int)(glow.Value * 50f), color.B + (int)(glow.Value * 50f)) : ((Color)color));

            glowColor *= 0.3f + glow.Value;
            Utility.removeLightSource((int)(tileLocation.X * 1000f + tileLocation.Y));
            if ((int)bigness < 2)
            {
                Game1.currentLightSources.Add(new LightSource(4, new Vector2(tileLocation.X * 64f + 32f, tileLocation.Y * 64f + 32f), 1f, Utility.getOppositeColor(glowColor), (int)(tileLocation.X * 1000f + tileLocation.Y), LightSource.LightContext.None, 0L));
            }
            else if ((int)bigness >= 2)
            {
                Game1.currentLightSources.Add(new LightSource(4, new Vector2(tileLocation.X * 64f + 32f, tileLocation.Y * 64f + 32f), 1f, Utility.getOppositeColor(glowColor), (int)(tileLocation.X * 1000f + tileLocation.Y), LightSource.LightContext.None, 0L));
            }
            return(false);
        }
コード例 #4
0
        public static bool prefix_playTrainApproach()
        {
            if (!Game1.currentLocation.isOutdoors || Game1.isFestival())
            {
                return(false);
            }

            if (BetterTrainLootMod.Instance.config.enableMod)
            {
                if ((BetterTrainLootMod.Instance.config.showTrainIsComingMessage && Game1.player.currentLocation.Name != "Desert") ||
                    (BetterTrainLootMod.Instance.config.showDesertTrainIsComingMessage && Game1.player.currentLocation.Name == "Desert"))
                {
                    Game1.showGlobalMessage(Game1.content.LoadString("Strings\\Locations:Railroad_TrainComing"));
                }

                if (Game1.soundBank == null)
                {
                    return(false);
                }

                if ((BetterTrainLootMod.Instance.config.enableTrainWhistle && Game1.player.currentLocation.Name != "Desert") ||
                    (BetterTrainLootMod.Instance.config.enableDesertTrainWhistle && Game1.player.currentLocation.Name == "Desert"))
                {
                    ICue cue = Game1.soundBank.GetCue("distantTrain");
                    cue.SetVariable("Volume", 100f);
                    cue.Play();
                }
                return(false);
            }
            return(true);
        }
コード例 #5
0
 private void jump()
 {
     if (!(minecartDY < 1f) || respawnCounter > 0)
     {
         return;
     }
     if (!isJumping)
     {
         movingOnSlope = 0;
         minecartPositionBeforeJump = mineCartYPosition;
         isJumping = true;
         if (minecartLoop != null)
         {
             minecartLoop.Stop(AudioStopOptions.Immediate);
         }
         if (Game1.soundBank != null)
         {
             ICue cue = Game1.soundBank.GetCue("pickUpItem");
             cue.SetVariable("Pitch", 200);
             cue.Play();
         }
     }
     if (!reachedJumpApex)
     {
         minecartDY = Math.Max(-4.5f, minecartDY - 0.6f);
         if (minecartDY <= -4.5f)
         {
             reachedJumpApex = true;
         }
     }
 }
コード例 #6
0
        public static bool playSoundPitched_prePatch_GekoX_ShutUp(string cueName, int pitch)
        {
            try {
                if (ModEntry.config.sounds.Contains(cueName))
                {
                    if (ModEntry.config.showDebugSpam)
                    {
                        ModEntry.monitor.Log($"Shutting {cueName} up", LogLevel.Info);
                    }

                    return(false);
                }

                if (Game1.soundBank != null)
                {
                    try {
                        ICue cue = Game1.soundBank.GetCue(cueName);
                        cue.SetVariable("Pitch", pitch);
                        cue.Play();
                    } catch (Exception ex) {
                        Game1.debugOutput = Game1.parseText(ex.Message);
                        Console.WriteLine(ex);
                    }
                }

                return(false);
            }

            catch (Exception e) {
                ModEntry.monitor.Log($"Failed in {nameof(playSoundPitched_prePatch_GekoX_ShutUp)}:\n{e}", LogLevel.Error);
                return(true);
            }
        }
コード例 #7
0
        /// <summary>Raised after the game state is updated (≈60 times per second).</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
        {
            if (this.Cue != null)
            {
                ICue sound = this.Cue;
                sound.SetVariable("Volume", 100);
                sound.SetVariable("Frequency", this.Frequency);
                sound.SetVariable("Pitch", this.Pitch);
                if (!sound.IsPlaying)
                {
                    sound.Play();
                }

                if (e.IsMultipleOf(30))
                {
                    this.Monitor.Log($"Playing {sound.Name} from {this.Source} @ freq: {sound.GetVariable("Frequency")}, vol: {sound.GetVariable("Volume")}, pitch: {sound.GetVariable("Pitch")}, state: {this.GetPlaybackState(sound)}");
                }
            }
        }
コード例 #8
0
            public void activate()
            {
                glowTimer  = 1000f;
                shakeTimer = 100f;
                ICue cue = Game1.soundBank.GetCue("crystal");

                cue.SetVariable("Pitch", pitch);
                cue.Play();
                currentColor = color;
            }
コード例 #9
0
        public static void PlaySingingStone(SObject @object)
        {
            if (Game1.soundBank is not null)
            {
                @object.shakeTimer = 100;

                ICue cue   = Game1.soundBank.GetCue("crystal");
                int  pitch = Game1.random.Next(2400);
                pitch -= pitch % 100;
                cue.SetVariable("Pitch", pitch);
                cue.Play();
            }
        }
コード例 #10
0
 public void PlayTrainApproach()
 {
     if ((bool)Game1.currentLocation.isOutdoors && !Game1.isFestival() && Game1.currentLocation.GetLocationContext() == LocationContext.Default)
     {
         Game1.showGlobalMessage(Game1.content.LoadString("Strings\\Locations:Railroad_TrainComing"));
         if (Game1.soundBank != null)
         {
             ICue cue = Game1.soundBank.GetCue("distantTrain");
             cue.SetVariable("Volume", 100f);
             cue.Play();
         }
     }
 }
コード例 #11
0
 protected override void updateAnimation(GameTime time)
 {
     Sprite.AnimateDown(time);
     if (yJumpOffset == 0)
     {
         jumpWithoutSound();
         yJumpVelocity = (float)Game1.random.Next(50, 70) / 10f;
         if (Game1.random.NextDouble() < 0.1 && (meep == null || !meep.IsPlaying) && Utility.isOnScreen(base.Position, 64) && Game1.soundBank != null && Game1.currentLocation == base.currentLocation)
         {
             meep = Game1.soundBank.GetCue("dustMeep");
             meep.SetVariable("Pitch", voice * 100 + Game1.random.Next(-100, 100));
             meep.Play();
         }
     }
     resetAnimationSpeed();
 }
コード例 #12
0
        private void AttemptToWarp(TrainStop stop)
        {
            if (!TryToChargeMoney(stop.Cost))
            {
                Game1.drawObjectDialogue(Helper.Translation.Get("NotEnoughMoney", new { DestinationName = stop.TranslatedName }));
                return;
            }
            LocationRequest request = Game1.getLocationRequest(stop.TargetMapName);

            request.OnWarp    += Request_OnWarp;
            destinationMessage = Helper.Translation.Get("ArrivalMessage", new { DestinationName = stop.TranslatedName });

            Game1.warpFarmer(request, stop.TargetX, stop.TargetY, stop.FacingDirectionAfterWarp);

            cue = Game1.soundBank.GetCue("trainLoop");
            cue.SetVariable("Volume", 100f);
            cue.Play();
        }
コード例 #13
0
 protected override void updateAnimation(GameTime time)
 {
     Sprite.AnimateDown(time);
     if (yJumpOffset == 0)
     {
         jumpWithoutSound();
         yJumpVelocity = Game1.random.Next(50, 70) / 10f;
         if (Game1.random.NextDouble() < 0.1 &&
             !meep.IsPlaying &&
             Utility.isOnScreen(Position, 64) &&
             currentLocation.Equals(Game1.currentLocation))
         {
             meep.SetVariable("Pitch", voice.Value * 100 +
                              Game1.random.Next(-100, 100));
             Utilities.TryPlayCue(meep);
         }
     }
     resetAnimationSpeed();
 }
コード例 #14
0
ファイル: Scene.cs プロジェクト: somnomania/smapi-mod-dump
        public void run(TV tv, Channel channel)
        {
            currentTV      = tv;
            currentChannel = channel;

            if (beforeAction != null)
            {
                beforeAction.Invoke();
            }

            Game1.changeMusicTrack(musicTrack ?? "none", false,
                                   Game1.MusicContext.Event);

            if (soundAsset != null &&
                Constants.TargetPlatform != GamePlatform.Android)
            {
                playCustomSound($"{soundAsset}.wav");
            }
            else if (soundCue != null)
            {
                ICue cue = Game1.soundBank.GetCue(soundCue);
                if (soundCue == "distantTrain")
                {
                    cue.SetVariable("Volume", 100f);
                }
                cue.Play();
            }


            Helper.Reflection.GetField <TemporaryAnimatedSprite> (tv, "screen")
            .SetValue(background);
            Helper.Reflection.GetField <TemporaryAnimatedSprite> (tv, "screenOverlay")
            .SetValue(overlay);
            Game1.drawObjectDialogue(Game1.parseText(message));

            Game1.afterDialogues = end;
        }
コード例 #15
0
        public static bool PlayClamTone(MermaidHouse __instance, int which, Farmer who, ref Farmer ___pearlRecipient, ref List <int> ___lastFiveClamTones, ref float ___fairyTimer, ref Texture2D ___mermaidSprites, ref float ___oldStopWatchTime)
        {
            try
            {
                if (___oldStopWatchTime < 68000f && !mod.config.DebugAllowClamClickDuringSong)
                {
                    return(false);
                }

                var  clamPitch = mod.config.ClamPitches[which];
                ICue clamTone  = Game1.soundBank.GetCue("clam_tone");
                clamTone.SetVariable("Pitch", clamPitch);
                clamTone.Play();

                var clamPosition = mod.config.ClamPositions[which] * 64;
                var clamColor    = mod.config.ClamColors[which];

                __instance.temporarySprites.Add(new TemporaryAnimatedSprite
                {
                    texture         = mod.clamTexture,
                    color           = clamColor,
                    sourceRect      = new Microsoft.Xna.Framework.Rectangle(0, 0, 16, 16),
                    scale           = 4f,
                    position        = clamPosition,
                    interval        = 1000f,
                    animationLength = 1,
                    alphaFade       = 0.03f,
                    layerDepth      = 0.0001f
                });

                ___lastFiveClamTones.Add(which);

                while (___lastFiveClamTones.Count > 5)
                {
                    ___lastFiveClamTones.RemoveAt(0);
                }

                if (who != null && !who.mailReceived.Contains("gotPearl") && ___lastFiveClamTones.Count == 5 &&
                    ___lastFiveClamTones[0] == 0 && ___lastFiveClamTones[1] == 4 && ___lastFiveClamTones[2] == 3 && ___lastFiveClamTones[3] == 1 && ___lastFiveClamTones[4] == 2)
                {
                    who.freezePause = 4500;
                    ___fairyTimer   = 3500f;
                    __instance.temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        interval = 1f,
                        delayBeforeAnimationStart = 885,
                        texture                 = ___mermaidSprites,
                        endFunction             = new TemporaryAnimatedSprite.endBehavior(__instance.playClamTone),
                        extraInfoForEndBehavior = 0
                    });
                    __instance.temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        interval = 1f,
                        delayBeforeAnimationStart = 1270,
                        texture                 = ___mermaidSprites,
                        endFunction             = new TemporaryAnimatedSprite.endBehavior(__instance.playClamTone),
                        extraInfoForEndBehavior = 4
                    });
                    __instance.temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        interval = 1f,
                        delayBeforeAnimationStart = 1655,
                        texture                 = ___mermaidSprites,
                        endFunction             = new TemporaryAnimatedSprite.endBehavior(__instance.playClamTone),
                        extraInfoForEndBehavior = 3
                    });
                    __instance.temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        interval = 1f,
                        delayBeforeAnimationStart = 2040,
                        texture                 = ___mermaidSprites,
                        endFunction             = new TemporaryAnimatedSprite.endBehavior(__instance.playClamTone),
                        extraInfoForEndBehavior = 1
                    });
                    __instance.temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        interval = 1f,
                        delayBeforeAnimationStart = 2425,
                        texture                 = ___mermaidSprites,
                        endFunction             = new TemporaryAnimatedSprite.endBehavior(__instance.playClamTone),
                        extraInfoForEndBehavior = 2
                    });
                    __instance.temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        texture = ___mermaidSprites,
                        delayBeforeAnimationStart = 885,
                        sourceRect            = new Microsoft.Xna.Framework.Rectangle(2, 127, 19, 18),
                        sourceRectStartingPos = new Vector2(2f, 127f),
                        scale              = 4f,
                        position           = new Vector2(28f, 49f) * 4f,
                        interval           = 96f,
                        animationLength    = 4,
                        totalNumberOfLoops = 121
                    });
                    __instance.temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        texture = ___mermaidSprites,
                        delayBeforeAnimationStart = 1270,
                        sourceRect            = new Microsoft.Xna.Framework.Rectangle(2, 127, 19, 18),
                        sourceRectStartingPos = new Vector2(2f, 127f),
                        scale              = 4f,
                        position           = new Vector2(108f, 49f) * 4f,
                        interval           = 96f,
                        animationLength    = 4,
                        totalNumberOfLoops = 117
                    });
                    __instance.temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        texture = ___mermaidSprites,
                        delayBeforeAnimationStart = 1655,
                        sourceRect            = new Microsoft.Xna.Framework.Rectangle(2, 127, 19, 18),
                        sourceRectStartingPos = new Vector2(2f, 127f),
                        scale              = 4f,
                        position           = new Vector2(88f, 39f) * 4f,
                        interval           = 96f,
                        animationLength    = 4,
                        totalNumberOfLoops = 113
                    });
                    __instance.temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        texture = ___mermaidSprites,
                        delayBeforeAnimationStart = 2040,
                        sourceRect            = new Microsoft.Xna.Framework.Rectangle(2, 127, 19, 18),
                        sourceRectStartingPos = new Vector2(2f, 127f),
                        scale              = 4f,
                        position           = new Vector2(48f, 39f) * 4f,
                        interval           = 96f,
                        animationLength    = 4,
                        totalNumberOfLoops = 19
                    });
                    __instance.temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        texture = ___mermaidSprites,
                        delayBeforeAnimationStart = 2425,
                        sourceRect            = new Microsoft.Xna.Framework.Rectangle(2, 127, 19, 18),
                        sourceRectStartingPos = new Vector2(2f, 127f),
                        scale              = 4f,
                        position           = new Vector2(68f, 29f) * 4f,
                        interval           = 96f,
                        animationLength    = 4,
                        totalNumberOfLoops = 15
                    });
                    ___pearlRecipient = who;
                }

                return(false);
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
                return(true);
            }
        }
コード例 #16
0
        public void playClamTone(int which, Farmer who)
        {
            if (!(oldStopWatchTime < 68000f))
            {
                ICue clamTone = Game1.soundBank.GetCue("clam_tone");
                switch (which)
                {
                case 0:
                    clamTone.SetVariable("Pitch", 300);
                    temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        texture         = mermaidSprites,
                        color           = Color.HotPink,
                        sourceRect      = new Microsoft.Xna.Framework.Rectangle(125, 126, 11, 12),
                        scale           = 4f,
                        position        = new Vector2(35f, 98f) * 4f,
                        interval        = 1000f,
                        animationLength = 1,
                        alphaFade       = 0.03f,
                        layerDepth      = 0.0001f
                    });
                    break;

                case 1:
                    clamTone.SetVariable("Pitch", 600);
                    temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        texture         = mermaidSprites,
                        color           = Color.Orange,
                        sourceRect      = new Microsoft.Xna.Framework.Rectangle(125, 126, 11, 12),
                        scale           = 4f,
                        position        = new Vector2(51f, 98f) * 4f,
                        interval        = 1000f,
                        animationLength = 1,
                        alphaFade       = 0.03f,
                        layerDepth      = 0.0001f
                    });
                    break;

                case 2:
                    clamTone.SetVariable("Pitch", 800);
                    temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        texture         = mermaidSprites,
                        color           = Color.Yellow,
                        sourceRect      = new Microsoft.Xna.Framework.Rectangle(125, 126, 11, 12),
                        scale           = 4f,
                        position        = new Vector2(67f, 98f) * 4f,
                        interval        = 1000f,
                        animationLength = 1,
                        alphaFade       = 0.03f,
                        layerDepth      = 0.0001f
                    });
                    break;

                case 3:
                    clamTone.SetVariable("Pitch", 1000);
                    temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        texture         = mermaidSprites,
                        color           = Color.Cyan,
                        sourceRect      = new Microsoft.Xna.Framework.Rectangle(125, 126, 11, 12),
                        scale           = 4f,
                        position        = new Vector2(83f, 98f) * 4f,
                        interval        = 1000f,
                        animationLength = 1,
                        alphaFade       = 0.03f,
                        layerDepth      = 0.0001f
                    });
                    break;

                case 4:
                    clamTone.SetVariable("Pitch", 1200);
                    temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        texture         = mermaidSprites,
                        color           = Color.Lime,
                        sourceRect      = new Microsoft.Xna.Framework.Rectangle(125, 126, 11, 12),
                        scale           = 4f,
                        position        = new Vector2(99f, 98f) * 4f,
                        interval        = 1000f,
                        animationLength = 1,
                        alphaFade       = 0.03f,
                        layerDepth      = 0.0001f
                    });
                    break;
                }
                clamTone.Play();
                lastFiveClamTones.Add(which);
                if (lastFiveClamTones.Count > 5)
                {
                    lastFiveClamTones.RemoveAt(0);
                }
                if (lastFiveClamTones.Count == 5 && lastFiveClamTones[0] == 0 && lastFiveClamTones[1] == 4 && lastFiveClamTones[2] == 3 && lastFiveClamTones[3] == 1 && lastFiveClamTones[4] == 2 && who != null && !who.mailReceived.Contains("gotPearl"))
                {
                    who.freezePause = 4500;
                    fairyTimer      = 3500f;
                    temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        interval = 1f,
                        delayBeforeAnimationStart = 885,
                        texture                 = mermaidSprites,
                        endFunction             = playClamTone,
                        extraInfoForEndBehavior = 0
                    });
                    temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        interval = 1f,
                        delayBeforeAnimationStart = 1270,
                        texture                 = mermaidSprites,
                        endFunction             = playClamTone,
                        extraInfoForEndBehavior = 4
                    });
                    temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        interval = 1f,
                        delayBeforeAnimationStart = 1655,
                        texture                 = mermaidSprites,
                        endFunction             = playClamTone,
                        extraInfoForEndBehavior = 3
                    });
                    temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        interval = 1f,
                        delayBeforeAnimationStart = 2040,
                        texture                 = mermaidSprites,
                        endFunction             = playClamTone,
                        extraInfoForEndBehavior = 1
                    });
                    temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        interval = 1f,
                        delayBeforeAnimationStart = 2425,
                        texture                 = mermaidSprites,
                        endFunction             = playClamTone,
                        extraInfoForEndBehavior = 2
                    });
                    temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        texture = mermaidSprites,
                        delayBeforeAnimationStart = 885,
                        sourceRect            = new Microsoft.Xna.Framework.Rectangle(2, 127, 19, 18),
                        sourceRectStartingPos = new Vector2(2f, 127f),
                        scale              = 4f,
                        position           = new Vector2(28f, 49f) * 4f,
                        interval           = 96f,
                        animationLength    = 4,
                        totalNumberOfLoops = 121
                    });
                    temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        texture = mermaidSprites,
                        delayBeforeAnimationStart = 1270,
                        sourceRect            = new Microsoft.Xna.Framework.Rectangle(2, 127, 19, 18),
                        sourceRectStartingPos = new Vector2(2f, 127f),
                        scale              = 4f,
                        position           = new Vector2(108f, 49f) * 4f,
                        interval           = 96f,
                        animationLength    = 4,
                        totalNumberOfLoops = 117
                    });
                    temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        texture = mermaidSprites,
                        delayBeforeAnimationStart = 1655,
                        sourceRect            = new Microsoft.Xna.Framework.Rectangle(2, 127, 19, 18),
                        sourceRectStartingPos = new Vector2(2f, 127f),
                        scale              = 4f,
                        position           = new Vector2(88f, 39f) * 4f,
                        interval           = 96f,
                        animationLength    = 4,
                        totalNumberOfLoops = 113
                    });
                    temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        texture = mermaidSprites,
                        delayBeforeAnimationStart = 2040,
                        sourceRect            = new Microsoft.Xna.Framework.Rectangle(2, 127, 19, 18),
                        sourceRectStartingPos = new Vector2(2f, 127f),
                        scale              = 4f,
                        position           = new Vector2(48f, 39f) * 4f,
                        interval           = 96f,
                        animationLength    = 4,
                        totalNumberOfLoops = 19
                    });
                    temporarySprites.Add(new TemporaryAnimatedSprite
                    {
                        texture = mermaidSprites,
                        delayBeforeAnimationStart = 2425,
                        sourceRect            = new Microsoft.Xna.Framework.Rectangle(2, 127, 19, 18),
                        sourceRectStartingPos = new Vector2(2f, 127f),
                        scale              = 4f,
                        position           = new Vector2(68f, 29f) * 4f,
                        interval           = 96f,
                        animationLength    = 4,
                        totalNumberOfLoops = 15
                    });
                    pearlRecipient = who;
                }
            }
        }
コード例 #17
0
ファイル: AnimalQueryMenu.cs プロジェクト: s-yi/StardewValley
 public AnimalQueryMenu(FarmAnimal animal)
     : base(Game1.uiViewport.Width / 2 - width / 2, Game1.uiViewport.Height / 2 - height / 2, width, height)
 {
     Game1.player.Halt();
     Game1.player.faceGeneralDirection(animal.Position, 0, opposite: false, useTileCalculations: false);
     width          = 384;
     height         = 512;
     this.animal    = animal;
     textBox        = new TextBox(null, null, Game1.dialogueFont, Game1.textColor);
     textBox.X      = Game1.uiViewport.Width / 2 - 128 - 12;
     textBox.Y      = yPositionOnScreen - 4 + 128;
     textBox.Width  = 256;
     textBox.Height = 192;
     textBoxCC      = new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(textBox.X, textBox.Y, textBox.Width, 64), "")
     {
         myID           = 110,
         downNeighborID = 104
     };
     textBox.Text = animal.displayName;
     Game1.keyboardDispatcher.Subscriber = textBox;
     textBox.Selected = false;
     if ((long)animal.parentId != -1)
     {
         FarmAnimal parent = Utility.getAnimal(animal.parentId);
         if (parent != null)
         {
             parentName = parent.displayName;
         }
     }
     if (animal.sound.Value != null && Game1.soundBank != null && !Game1.options.muteAnimalSounds)
     {
         ICue cue = Game1.soundBank.GetCue(animal.sound.Value);
         cue.SetVariable("Pitch", 1200 + Game1.random.Next(-200, 201));
         cue.Play();
     }
     okButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(xPositionOnScreen + width + 4, yPositionOnScreen + height - 64 - IClickableMenu.borderWidth, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46), 1f)
     {
         myID         = 101,
         upNeighborID = -99998
     };
     sellButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(xPositionOnScreen + width + 4, yPositionOnScreen + height - 192 - IClickableMenu.borderWidth, 64, 64), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(0, 384, 16, 16), 4f)
     {
         myID           = 103,
         downNeighborID = -99998,
         upNeighborID   = 104
     };
     moveHomeButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(xPositionOnScreen + width + 4, yPositionOnScreen + height - 256 - IClickableMenu.borderWidth, 64, 64), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(16, 384, 16, 16), 4f)
     {
         myID           = 104,
         downNeighborID = 103,
         upNeighborID   = 110
     };
     if (!animal.isBaby() && !animal.isCoopDweller() && animal.CanHavePregnancy())
     {
         allowReproductionButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(xPositionOnScreen + width + 16, yPositionOnScreen + height - 128 - IClickableMenu.borderWidth + 8, 36, 36), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(animal.allowReproduction ? 128 : 137, 393, 9, 9), 4f)
         {
             myID           = 106,
             downNeighborID = 101,
             upNeighborID   = 103
         };
     }
     love = new ClickableTextureComponent(Math.Round((double)(int)animal.friendshipTowardFarmer, 0) / 10.0 + "<", new Microsoft.Xna.Framework.Rectangle(xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + 32 + 16, yPositionOnScreen - 32 + IClickableMenu.spaceToClearTopBorder + 256 - 32, width - 128, 64), null, "Friendship", Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(172, 512, 16, 16), 4f)
     {
         myID = 102
     };
     loveHover = new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(xPositionOnScreen + IClickableMenu.spaceToClearSideBorder, yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + 192 - 32, width, 64), "Friendship")
     {
         myID = 109
     };
     fullnessLevel = (float)(int)(byte)animal.fullness / 255f;
     if (animal.home != null && animal.home.indoors.Value != null)
     {
         int piecesHay = animal.home.indoors.Value.numberOfObjectsWithName("Hay");
         if (piecesHay > 0)
         {
             int numAnimals = (animal.home.indoors.Value as AnimalHouse).animalsThatLiveHere.Count;
             fullnessLevel = Math.Min(1.0, fullnessLevel + (double)piecesHay / (double)numAnimals);
         }
     }
     else
     {
         Utility.fixAllAnimals();
     }
     happinessLevel = (float)(int)(byte)animal.happiness / 255f;
     loveLevel      = (float)(int)animal.friendshipTowardFarmer / 1000f;
     if (Game1.options.SnappyMenus)
     {
         populateClickableComponentList();
         snapToDefaultClickableComponent();
     }
 }
コード例 #18
0
ファイル: Fly.cs プロジェクト: s-yi/StardewValley
 protected override void updateAnimation(GameTime time)
 {
     if (Game1.soundBank != null && (buzz == null || !buzz.IsPlaying) && (base.currentLocation == null || base.currentLocation.Equals(Game1.currentLocation)))
     {
         buzz = Game1.soundBank.GetCue("flybuzzing");
         buzz.SetVariable("Volume", 0f);
         buzz.Play();
     }
     if ((double)Game1.fadeToBlackAlpha > 0.8 && Game1.fadeIn && buzz != null)
     {
         buzz.Stop(AudioStopOptions.AsAuthored);
     }
     else if (buzz != null)
     {
         buzz.SetVariable("Volume", Math.Max(0f, buzz.GetVariable("Volume") - 1f));
         float volume = Math.Max(0f, 100f - Vector2.Distance(base.Position, base.Player.Position) / 64f / 16f * 100f);
         if (volume > buzz.GetVariable("Volume"))
         {
             buzz.SetVariable("Volume", volume);
         }
     }
     if (wasHitCounter >= 0)
     {
         wasHitCounter -= time.ElapsedGameTime.Milliseconds;
     }
     Sprite.Animate(time, (FacingDirection == 0) ? 8 : ((FacingDirection != 2) ? (FacingDirection * 4) : 0), 4, 75f);
     if (spawningCounter >= 0)
     {
         spawningCounter -= time.ElapsedGameTime.Milliseconds;
         base.Scale       = 1f - (float)spawningCounter / 1000f;
     }
     else if ((withinPlayerThreshold() || Utility.isOnScreen(position, 256)) && invincibleCountdown <= 0)
     {
         faceDirection(0);
         float xSlope3 = -(base.Player.GetBoundingBox().Center.X - GetBoundingBox().Center.X);
         float ySlope3 = base.Player.GetBoundingBox().Center.Y - GetBoundingBox().Center.Y;
         float t       = Math.Max(1f, Math.Abs(xSlope3) + Math.Abs(ySlope3));
         if (t < 64f)
         {
             xVelocity = Math.Max(-7f, Math.Min(7f, xVelocity * 1.1f));
             yVelocity = Math.Max(-7f, Math.Min(7f, yVelocity * 1.1f));
         }
         xSlope3 /= t;
         ySlope3 /= t;
         if (wasHitCounter <= 0)
         {
             targetRotation = (float)Math.Atan2(0f - ySlope3, xSlope3) - (float)Math.PI / 2f;
             if ((double)(Math.Abs(targetRotation) - Math.Abs(rotation)) > Math.PI * 7.0 / 8.0 && Game1.random.NextDouble() < 0.5)
             {
                 turningRight = true;
             }
             else if ((double)(Math.Abs(targetRotation) - Math.Abs(rotation)) < Math.PI / 8.0)
             {
                 turningRight = false;
             }
             if (turningRight)
             {
                 rotation -= (float)Math.Sign(targetRotation - rotation) * ((float)Math.PI / 64f);
             }
             else
             {
                 rotation += (float)Math.Sign(targetRotation - rotation) * ((float)Math.PI / 64f);
             }
             rotation     %= (float)Math.PI * 2f;
             wasHitCounter = 5 + Game1.random.Next(-1, 2);
         }
         float maxAccel = Math.Min(7f, Math.Max(2f, 7f - t / 64f / 2f));
         xSlope3    = (float)Math.Cos((double)rotation + Math.PI / 2.0);
         ySlope3    = 0f - (float)Math.Sin((double)rotation + Math.PI / 2.0);
         xVelocity += (0f - xSlope3) * maxAccel / 6f + (float)Game1.random.Next(-10, 10) / 100f;
         yVelocity += (0f - ySlope3) * maxAccel / 6f + (float)Game1.random.Next(-10, 10) / 100f;
         if (Math.Abs(xVelocity) > Math.Abs((0f - xSlope3) * 7f))
         {
             xVelocity -= (0f - xSlope3) * maxAccel / 6f;
         }
         if (Math.Abs(yVelocity) > Math.Abs((0f - ySlope3) * 7f))
         {
             yVelocity -= (0f - ySlope3) * maxAccel / 6f;
         }
     }
     resetAnimationSpeed();
 }
コード例 #19
0
        public static void update(GameTime time)
        {
            if (sounds.Count == 0)
            {
                return;
            }
            if (volumeOverrideForLocChange < 1f)
            {
                volumeOverrideForLocChange += (float)time.ElapsedGameTime.Milliseconds * 0.0003f;
            }
            updateTimer -= time.ElapsedGameTime.Milliseconds;
            if (updateTimer > 0)
            {
                return;
            }
            for (int j = 0; j < shortestDistanceForCue.Length; j++)
            {
                shortestDistanceForCue[j] = 9999999f;
            }
            Vector2 farmerPosition = Game1.player.getStandingPosition();

            foreach (KeyValuePair <Vector2, int> pair in sounds)
            {
                float distance = Vector2.Distance(pair.Key, farmerPosition);
                if (shortestDistanceForCue[pair.Value] > distance)
                {
                    shortestDistanceForCue[pair.Value] = distance;
                }
            }
            if (volumeOverrideForLocChange >= 0f)
            {
                for (int i = 0; i < shortestDistanceForCue.Length; i++)
                {
                    if (shortestDistanceForCue[i] <= (float)farthestSoundDistance)
                    {
                        float volume = Math.Min(volumeOverrideForLocChange, Math.Min(1f, 1f - shortestDistanceForCue[i] / (float)farthestSoundDistance));
                        switch (i)
                        {
                        case 0:
                            if (babblingBrook != null)
                            {
                                babblingBrook.SetVariable("Volume", volume * 100f * Math.Min(Game1.ambientPlayerVolume, Game1.options.ambientVolumeLevel));
                                babblingBrook.Resume();
                            }
                            break;

                        case 1:
                            if (cracklingFire != null)
                            {
                                cracklingFire.SetVariable("Volume", volume * 100f * Math.Min(Game1.ambientPlayerVolume, Game1.options.ambientVolumeLevel));
                                cracklingFire.Resume();
                            }
                            break;

                        case 2:
                            if (engine != null)
                            {
                                engine.SetVariable("Volume", volume * 100f * Math.Min(Game1.ambientPlayerVolume, Game1.options.ambientVolumeLevel));
                                engine.Resume();
                            }
                            break;

                        case 3:
                            if (cricket != null)
                            {
                                cricket.SetVariable("Volume", volume * 100f * Math.Min(Game1.ambientPlayerVolume, Game1.options.ambientVolumeLevel));
                                cricket.Resume();
                            }
                            break;
                        }
                        continue;
                    }
                    switch (i)
                    {
                    case 0:
                        if (babblingBrook != null)
                        {
                            babblingBrook.Pause();
                        }
                        break;

                    case 1:
                        if (cracklingFire != null)
                        {
                            cracklingFire.Pause();
                        }
                        break;

                    case 2:
                        if (engine != null)
                        {
                            engine.Pause();
                        }
                        break;

                    case 3:
                        if (cricket != null)
                        {
                            cricket.Pause();
                        }
                        break;
                    }
                }
            }
            updateTimer = 100;
        }
コード例 #20
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)
         {
             setUpForReturnToShopMenu();
             Game1.playSound("smallSelect");
         }
         else
         {
             Game1.exitActiveMenu();
             Game1.playSound("bigDeSelect");
         }
     }
     if (onFarm)
     {
         Vector2  clickTile = new Vector2((x + Game1.viewport.X) / 64, (y + Game1.viewport.Y) / 64);
         Building selection = (Game1.getLocationFromName("Farm") as Farm).getBuildingAt(clickTile);
         if (selection != null && !namingAnimal)
         {
             if (selection.buildingType.Value.Contains(animalBeingPurchased.buildingTypeILiveIn.Value))
             {
                 if ((selection.indoors.Value as AnimalHouse).isFull())
                 {
                     Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11321"));
                 }
                 else if ((byte)animalBeingPurchased.harvestType != 2)
                 {
                     namingAnimal  = true;
                     newAnimalHome = selection;
                     if (animalBeingPurchased.sound.Value != null && Game1.soundBank != null)
                     {
                         ICue cue = Game1.soundBank.GetCue(animalBeingPurchased.sound.Value);
                         cue.SetVariable("Pitch", 1200 + Game1.random.Next(-200, 201));
                         cue.Play();
                     }
                     textBox.OnEnterPressed += e;
                     textBox.Text            = animalBeingPurchased.displayName;
                     Game1.keyboardDispatcher.Subscriber = textBox;
                     if (Game1.options.SnappyMenus)
                     {
                         currentlySnappedComponent = getComponentWithID(104);
                         snapCursorToCurrentSnappedComponent();
                     }
                 }
                 else if (Game1.player.Money >= priceOfAnimal)
                 {
                     newAnimalHome             = selection;
                     animalBeingPurchased.home = newAnimalHome;
                     animalBeingPurchased.homeLocation.Value = new Vector2((int)newAnimalHome.tileX, (int)newAnimalHome.tileY);
                     animalBeingPurchased.setRandomPosition(animalBeingPurchased.home.indoors);
                     (newAnimalHome.indoors.Value as AnimalHouse).animals.Add(animalBeingPurchased.myID, animalBeingPurchased);
                     (newAnimalHome.indoors.Value as AnimalHouse).animalsThatLiveHere.Add(animalBeingPurchased.myID);
                     newAnimalHome = null;
                     namingAnimal  = false;
                     if (animalBeingPurchased.sound.Value != null && Game1.soundBank != null)
                     {
                         ICue cue2 = Game1.soundBank.GetCue(animalBeingPurchased.sound.Value);
                         cue2.SetVariable("Pitch", 1200 + Game1.random.Next(-200, 201));
                         cue2.Play();
                     }
                     Game1.player.Money -= priceOfAnimal;
                     Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11324", animalBeingPurchased.displayType), Color.LimeGreen, 3500f));
                     animalBeingPurchased = new FarmAnimal(animalBeingPurchased.type, Game1.multiplayer.getNewID(), Game1.player.uniqueMultiplayerID);
                 }
                 else if (Game1.player.Money < priceOfAnimal)
                 {
                     Game1.dayTimeMoneyBox.moneyShakeTimer = 1000;
                 }
             }
             else
             {
                 Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11326", animalBeingPurchased.displayType));
             }
         }
         if (namingAnimal)
         {
             if (doneNamingButton.containsPoint(x, y))
             {
                 textBoxEnter(textBox);
                 Game1.playSound("smallSelect");
             }
             else if (namingAnimal && randomButton.containsPoint(x, y))
             {
                 animalBeingPurchased.Name        = Dialogue.randomName();
                 animalBeingPurchased.displayName = animalBeingPurchased.Name;
                 textBox.Text       = animalBeingPurchased.displayName;
                 randomButton.scale = randomButton.baseScale;
                 Game1.playSound("drumkit6");
             }
             textBox.Update();
         }
     }
     else
     {
         foreach (ClickableTextureComponent c in animalsToPurchase)
         {
             if (c.containsPoint(x, y) && (c.item as Object).Type == null)
             {
                 int price = c.item.salePrice();
                 if (Game1.player.Money >= price)
                 {
                     Game1.globalFadeToBlack(setUpForAnimalPlacement);
                     Game1.playSound("smallSelect");
                     onFarm = true;
                     animalBeingPurchased = new FarmAnimal(c.hoverText, Game1.multiplayer.getNewID(), Game1.player.UniqueMultiplayerID);
                     priceOfAnimal        = price;
                 }
                 else
                 {
                     Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11325"), Color.Red, 3500f));
                 }
             }
         }
     }
 }
コード例 #21
0
        public override void DoFunction(GameLocation location, int x, int y, int power, StardewValley.Farmer who)
        {
            base.DoFunction(location, x, y, power, who);
            who.Stamina -= ((float)4f - (float)who.FarmingLevel * 0.2f);
            if (this._animal != null && !MeatController.CanGetMeatFrom(this._animal))
            {
                return;
            }

            if (this._animal != null && this._animal.age.Value >= (int)this._animal.ageWhenMature.Value)
            {
                (this._animal.home.indoors.Value as AnimalHouse)?.animalsThatLiveHere.Remove(this._animal.myID.Value);
                this._animal.health.Value = -1;
                int         numClouds   = this._animal.frontBackSourceRect.Width / 2;
                int         cloudSprite = !DataLoader.ModConfig.Softmode ? 5 : 10;
                Multiplayer multiplayer = DataLoader.Helper.Reflection.GetField <Multiplayer>(typeof(Game1), "multiplayer").GetValue();
                for (int i = 0; i < numClouds; i++)
                {
                    int   nonRedness = Game1.random.Next(0, 80);
                    Color cloudColor = new Color(255, 255 - nonRedness, 255 - nonRedness);;



                    multiplayer.broadcastSprites(
                        Game1.player.currentLocation
                        , new TemporaryAnimatedSprite[1] {
                        new TemporaryAnimatedSprite
                        (
                            cloudSprite
                            , this._animal.position + new Vector2(Game1.random.Next(-Game1.tileSize / 2, this._animal.frontBackSourceRect.Width * 3)
                                                                  , Game1.random.Next(-Game1.tileSize / 2, this._animal.frontBackSourceRect.Height * 3))
                            , cloudColor
                            , 8
                            , false,
                            Game1.random.NextDouble() < .5 ? 50 : Game1.random.Next(30, 200), 0, Game1.tileSize
                            , -1
                            , Game1.tileSize, Game1.random.NextDouble() < .5 ? 0 : Game1.random.Next(0, 600)
                        )
                        {
                            scale  = Game1.random.Next(2, 5) * .25f,
                            alpha  = Game1.random.Next(2, 5) * .25f,
                            motion = new Vector2(0, (float)-Game1.random.NextDouble())
                        }
                    }
                        );
                }
                Color animalColor;
                float alfaFade;
                if (!DataLoader.ModConfig.Softmode)
                {
                    animalColor = Color.LightPink;
                    alfaFade    = .025f;
                }
                else
                {
                    animalColor = Color.White;
                    alfaFade    = .050f;
                }
                multiplayer.broadcastSprites(
                    Game1.player.currentLocation
                    , new TemporaryAnimatedSprite[1] {
                    new TemporaryAnimatedSprite
                    (
                        this._animal.Sprite.textureName.Value
                        , this._animal.Sprite.SourceRect
                        , this._animal.position
                        , this._animal.FacingDirection == Game1.left
                        , alfaFade
                        , animalColor
                    )
                    {
                        scale = 4f
                    }
                }
                    );
                if (!DataLoader.ModConfig.Softmode)
                {
                    Game1.playSound("killAnimal");
                }
                else
                {
                    ICue warptSound = Game1.soundBank.GetCue("wand");
                    warptSound.SetVariable("Pitch", 1800);
                    warptSound.Play();
                }

                MeatController.ThrowItem(MeatController.CreateMeat(this._animal), this._animal);
                who.gainExperience(0, 5);
                this._animal     = (FarmAnimal)null;
                this._tempAnimal = (FarmAnimal)null;
            }
        }
コード例 #22
0
        public bool tick(GameTime time)
        {
            if (hasQuit)
            {
                return(true);
            }
            if (quit && !hasQuit)
            {
                Game1.warpFarmer("BusStop", 12, 11, flip: false);
                if (roadNoise != null)
                {
                    roadNoise.Stop(AudioStopOptions.Immediate);
                }
                Game1.exitActiveMenu();
                hasQuit = true;
                return(true);
            }
            switch (currentState)
            {
            case 0:
                updateUpperClouds(time);
                break;

            case 1:
                globalYPanDY = Math.Min(4f, globalYPanDY + (float)time.ElapsedGameTime.Milliseconds * (speed / 140f));
                globalYPan  -= globalYPanDY;
                updateUpperClouds(time);
                if (globalYPan < -1f)
                {
                    globalYPan                  = screenHeight * 3;
                    currentState                = 2;
                    transformMatrix             = Matrix.CreateScale(3f);
                    transformMatrix.Translation = new Vector3(0f, globalYPan, 0f);
                    if (Game1.soundBank != null && roadNoise != null)
                    {
                        roadNoise.SetVariable("Volume", 0);
                        roadNoise.Play();
                    }
                    Game1.loadForNewGame();
                }
                break;

            case 2:
            {
                int startPanY = screenHeight * 3;
                int endPanY   = -Math.Max(0, 900 - (int)((float)Game1.viewport.Height * Game1.options.zoomLevel));
                globalYPanDY = Math.Max(0.5f, globalYPan / 100f);
                globalYPan  -= globalYPanDY;
                if (globalYPan <= (float)endPanY)
                {
                    globalYPan = endPanY;
                }
                transformMatrix             = Matrix.CreateScale(3f);
                transformMatrix.Translation = new Vector3(0f, globalYPan, 0f);
                updateRoad(time);
                if (Game1.soundBank != null && roadNoise != null)
                {
                    float vol = (globalYPan - (float)startPanY) / (float)(endPanY - startPanY) * 10f + 90f;
                    roadNoise.SetVariable("Volume", vol);
                }
                if (globalYPan <= (float)endPanY)
                {
                    currentState = 3;
                }
                break;
            }

            case 3:
                updateRoad(time);
                drivingTimer += time.ElapsedGameTime.Milliseconds;
                if (drivingTimer > 5700f)
                {
                    drivingTimer = 0f;
                    currentState = 4;
                }
                break;

            case 4:
                updateRoad(time);
                drivingTimer += time.ElapsedGameTime.Milliseconds;
                if (!(drivingTimer > 2000f))
                {
                    break;
                }
                busPosition.X += (float)time.ElapsedGameTime.Milliseconds / 8f;
                if (Game1.soundBank != null && roadNoise != null)
                {
                    roadNoise.SetVariable("Volume", Math.Max(0f, roadNoise.GetVariable("Volume") - 1f));
                }
                speed = Math.Max(0f, speed - (float)time.ElapsedGameTime.Milliseconds / 70000f);
                if (!addedSign)
                {
                    addedSign = true;
                    roadsideObjects.RemoveAt(roadsideObjects.Count - 1);
                    roadsideObjects.Add(5);
                    Game1.playSound("busDriveOff");
                }
                if (speed <= 0f && birdPosition.Equals(Vector2.Zero))
                {
                    int position = 0;
                    for (int i = 0; i < roadsideObjects.Count; i++)
                    {
                        if (roadsideObjects[i] == 5)
                        {
                            position = i;
                            break;
                        }
                    }
                    birdPosition = new Vector2((float)(position * 16) - roadPosition - 32f + 16f, -16f);
                    Game1.playSound("SpringBirds");
                    fadeAlpha = 0f;
                }
                if (!birdPosition.Equals(Vector2.Zero) && birdPosition.Y < 116f)
                {
                    float dy = Math.Max(0.5f, (116f - birdPosition.Y) / 116f * 2f);
                    birdPosition.Y += dy;
                    birdPosition.X += (float)Math.Sin((double)birdXTimer / (Math.PI * 16.0)) * dy / 2f;
                    birdTimer      += time.ElapsedGameTime.Milliseconds;
                    birdXTimer     += time.ElapsedGameTime.Milliseconds;
                    if (birdTimer >= 100)
                    {
                        birdFrame = (birdFrame + 1) % 4;
                        birdTimer = 0;
                    }
                }
                else if (!birdPosition.Equals(Vector2.Zero))
                {
                    birdFrame  = ((birdTimer > 1500) ? 5 : 4);
                    birdTimer += time.ElapsedGameTime.Milliseconds;
                    if (birdTimer > 2400 || (birdTimer > 1800 && Game1.random.NextDouble() < 0.006))
                    {
                        birdTimer = 0;
                        if (Game1.random.NextDouble() < 0.5)
                        {
                            Game1.playSound("SpringBirds");
                            birdPosition.Y -= 4f;
                        }
                    }
                }
                if (!(drivingTimer > 14000f))
                {
                    break;
                }
                fadeAlpha += (float)time.ElapsedGameTime.Milliseconds * 0.1f / 128f;
                if (fadeAlpha >= 1f)
                {
                    Game1.warpFarmer("BusStop", 12, 11, flip: false);
                    if (roadNoise != null)
                    {
                        roadNoise.Stop(AudioStopOptions.Immediate);
                    }
                    Game1.exitActiveMenu();
                    return(true);
                }
                break;
            }
            return(false);
        }
コード例 #23
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)
                            {
                                ICue 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)
                            {
                                ICue 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));
                        }
                    }
                }
            }
        }
コード例 #24
0
 public override void update(GameTime time)
 {
     if (sparkleText != null && sparkleText.update(time))
     {
         sparkleText = null;
     }
     if (everythingShakeTimer > 0f)
     {
         everythingShakeTimer -= time.ElapsedGameTime.Milliseconds;
         everythingShake       = new Vector2((float)Game1.random.Next(-10, 11) / 10f, (float)Game1.random.Next(-10, 11) / 10f);
         if (everythingShakeTimer <= 0f)
         {
             everythingShake = Vector2.Zero;
         }
     }
     if (fadeIn)
     {
         scale += 0.05f;
         if (scale >= 1f)
         {
             scale  = 1f;
             fadeIn = false;
         }
     }
     else if (fadeOut)
     {
         if (everythingShakeTimer > 0f || sparkleText != null)
         {
             return;
         }
         scale -= 0.05f;
         if (scale <= 0f)
         {
             scale   = 0f;
             fadeOut = false;
             int  bait         = (Game1.player.CurrentTool != null && Game1.player.CurrentTool is FishingRod && (Game1.player.CurrentTool as FishingRod).attachments[0] != null) ? ((int)(Game1.player.CurrentTool as FishingRod).attachments[0].parentSheetIndex) : (-1);
             bool caughtDouble = !bossFish && bait == 774 && Game1.random.NextDouble() < 0.25 + Game1.player.DailyLuck / 2.0;
             if (distanceFromCatching > 0.9f && Game1.player.CurrentTool is FishingRod)
             {
                 (Game1.player.CurrentTool as FishingRod).pullFishFromWater(whichFish, fishSize, fishQuality, (int)difficulty, treasureCaught, perfect, fromFishPond, caughtDouble);
             }
             else
             {
                 Game1.player.completelyStopAnimatingOrDoingAction();
                 if (Game1.player.CurrentTool != null && Game1.player.CurrentTool is FishingRod)
                 {
                     (Game1.player.CurrentTool as FishingRod).doneFishing(Game1.player, consumeBaitAndTackle: true);
                 }
             }
             Game1.exitActiveMenu();
             Game1.setRichPresence("location", Game1.currentLocation.Name);
         }
     }
     else
     {
         if (Game1.random.NextDouble() < (double)(difficulty * (float)((motionType != 2) ? 1 : 20) / 4000f) && (motionType != 2 || bobberTargetPosition == -1f))
         {
             float spaceBelow = 548f - bobberPosition;
             float spaceAbove = bobberPosition;
             float percent    = Math.Min(99f, difficulty + (float)Game1.random.Next(10, 45)) / 100f;
             bobberTargetPosition = bobberPosition + (float)Game1.random.Next(-(int)spaceAbove, (int)spaceBelow) * percent;
         }
         if (motionType == 4)
         {
             floaterSinkerAcceleration = Math.Max(floaterSinkerAcceleration - 0.01f, -1.5f);
         }
         else if (motionType == 3)
         {
             floaterSinkerAcceleration = Math.Min(floaterSinkerAcceleration + 0.01f, 1.5f);
         }
         if (Math.Abs(bobberPosition - bobberTargetPosition) > 3f && bobberTargetPosition != -1f)
         {
             bobberAcceleration = (bobberTargetPosition - bobberPosition) / ((float)Game1.random.Next(10, 30) + (100f - Math.Min(100f, difficulty)));
             bobberSpeed       += (bobberAcceleration - bobberSpeed) / 5f;
         }
         else if (motionType != 2 && Game1.random.NextDouble() < (double)(difficulty / 2000f))
         {
             bobberTargetPosition = bobberPosition + (float)((Game1.random.NextDouble() < 0.5) ? Game1.random.Next(-100, -51) : Game1.random.Next(50, 101));
         }
         else
         {
             bobberTargetPosition = -1f;
         }
         if (motionType == 1 && Game1.random.NextDouble() < (double)(difficulty / 1000f))
         {
             bobberTargetPosition = bobberPosition + (float)((Game1.random.NextDouble() < 0.5) ? Game1.random.Next(-100 - (int)difficulty * 2, -51) : Game1.random.Next(50, 101 + (int)difficulty * 2));
         }
         bobberTargetPosition = Math.Max(-1f, Math.Min(bobberTargetPosition, 548f));
         bobberPosition      += bobberSpeed + floaterSinkerAcceleration;
         if (bobberPosition > 532f)
         {
             bobberPosition = 532f;
         }
         else if (bobberPosition < 0f)
         {
             bobberPosition = 0f;
         }
         bobberInBar = (bobberPosition + 12f <= bobberBarPos - 32f + (float)bobberBarHeight && bobberPosition - 16f >= bobberBarPos - 32f);
         if (bobberPosition >= (float)(548 - bobberBarHeight) && bobberBarPos >= (float)(568 - bobberBarHeight - 4))
         {
             bobberInBar = true;
         }
         bool num = buttonPressed;
         buttonPressed = (Game1.oldMouseState.LeftButton == ButtonState.Pressed || Game1.isOneOfTheseKeysDown(Game1.oldKBState, Game1.options.useToolButton) || (Game1.options.gamepadControls && (Game1.oldPadState.IsButtonDown(Buttons.X) || Game1.oldPadState.IsButtonDown(Buttons.A))));
         if (!num && buttonPressed)
         {
             Game1.playSound("fishingRodBend");
         }
         float gravity = buttonPressed ? (-0.25f) : 0.25f;
         if (buttonPressed && gravity < 0f && (bobberBarPos == 0f || bobberBarPos == (float)(568 - bobberBarHeight)))
         {
             bobberBarSpeed = 0f;
         }
         if (bobberInBar)
         {
             gravity *= ((whichBobber == 691) ? 0.3f : 0.6f);
             if (whichBobber == 691)
             {
                 if (bobberPosition + 16f < bobberBarPos + (float)(bobberBarHeight / 2))
                 {
                     bobberBarSpeed -= 0.2f;
                 }
                 else
                 {
                     bobberBarSpeed += 0.2f;
                 }
             }
         }
         float oldPos = bobberBarPos;
         bobberBarSpeed += gravity;
         bobberBarPos   += bobberBarSpeed;
         if (bobberBarPos + (float)bobberBarHeight > 568f)
         {
             bobberBarPos   = 568 - bobberBarHeight;
             bobberBarSpeed = (0f - bobberBarSpeed) * 2f / 3f * ((whichBobber == 692) ? 0.1f : 1f);
             if (oldPos + (float)bobberBarHeight < 568f)
             {
                 Game1.playSound("shiny4");
             }
         }
         else if (bobberBarPos < 0f)
         {
             bobberBarPos   = 0f;
             bobberBarSpeed = (0f - bobberBarSpeed) * 2f / 3f;
             if (oldPos > 0f)
             {
                 Game1.playSound("shiny4");
             }
         }
         bool treasureInBar = false;
         if (treasure)
         {
             float oldTreasureAppearTimer = treasureAppearTimer;
             treasureAppearTimer -= time.ElapsedGameTime.Milliseconds;
             if (treasureAppearTimer <= 0f)
             {
                 if (treasureScale < 1f && !treasureCaught)
                 {
                     if (oldTreasureAppearTimer > 0f)
                     {
                         treasurePosition = ((bobberBarPos > 274f) ? Game1.random.Next(8, (int)bobberBarPos - 20) : Game1.random.Next(Math.Min(528, (int)bobberBarPos + bobberBarHeight), 500));
                         Game1.playSound("dwop");
                     }
                     treasureScale = Math.Min(1f, treasureScale + 0.1f);
                 }
                 treasureInBar = (treasurePosition + 12f <= bobberBarPos - 32f + (float)bobberBarHeight && treasurePosition - 16f >= bobberBarPos - 32f);
                 if (treasureInBar && !treasureCaught)
                 {
                     treasureCatchLevel += 0.0135f;
                     treasureShake       = new Vector2(Game1.random.Next(-2, 3), Game1.random.Next(-2, 3));
                     if (treasureCatchLevel >= 1f)
                     {
                         Game1.playSound("newArtifact");
                         treasureCaught = true;
                     }
                 }
                 else if (treasureCaught)
                 {
                     treasureScale = Math.Max(0f, treasureScale - 0.1f);
                 }
                 else
                 {
                     treasureShake      = Vector2.Zero;
                     treasureCatchLevel = Math.Max(0f, treasureCatchLevel - 0.01f);
                 }
             }
         }
         if (bobberInBar)
         {
             distanceFromCatching += 0.002f;
             reelRotation         += (float)Math.PI / 8f;
             fishShake.X           = (float)Game1.random.Next(-10, 11) / 10f;
             fishShake.Y           = (float)Game1.random.Next(-10, 11) / 10f;
             barShake              = Vector2.Zero;
             Rumble.rumble(0.1f, 1000f);
             if (unReelSound != null)
             {
                 unReelSound.Stop(AudioStopOptions.Immediate);
             }
             if (Game1.soundBank != null && (reelSound == null || reelSound.IsStopped || reelSound.IsStopping))
             {
                 reelSound = Game1.soundBank.GetCue("fastReel");
             }
             if (reelSound != null && !reelSound.IsPlaying && !reelSound.IsStopping)
             {
                 reelSound.Play();
             }
         }
         else if (!treasureInBar || treasureCaught || whichBobber != 693)
         {
             if (!fishShake.Equals(Vector2.Zero))
             {
                 Game1.playSound("tinyWhip");
                 perfect = false;
                 Rumble.stopRumbling();
             }
             fishSizeReductionTimer -= time.ElapsedGameTime.Milliseconds;
             if (fishSizeReductionTimer <= 0)
             {
                 fishSize = Math.Max(minFishSize, fishSize - 1);
                 fishSizeReductionTimer = 800;
             }
             if ((Game1.player.fishCaught != null && Game1.player.fishCaught.Count() != 0) || Game1.currentMinigame != null)
             {
                 distanceFromCatching -= ((whichBobber == 694 || beginnersRod) ? 0.002f : 0.003f);
             }
             float distanceAway = Math.Abs(bobberPosition - (bobberBarPos + (float)(bobberBarHeight / 2)));
             reelRotation -= (float)Math.PI / Math.Max(10f, 200f - distanceAway);
             barShake.X    = (float)Game1.random.Next(-10, 11) / 10f;
             barShake.Y    = (float)Game1.random.Next(-10, 11) / 10f;
             fishShake     = Vector2.Zero;
             if (reelSound != null)
             {
                 reelSound.Stop(AudioStopOptions.Immediate);
             }
             if (Game1.soundBank != null && (unReelSound == null || unReelSound.IsStopped))
             {
                 unReelSound = Game1.soundBank.GetCue("slowReel");
                 unReelSound.SetVariable("Pitch", 600);
             }
             if (unReelSound != null && !unReelSound.IsPlaying && !unReelSound.IsStopping)
             {
                 unReelSound.Play();
             }
         }
         distanceFromCatching = Math.Max(0f, Math.Min(1f, distanceFromCatching));
         if (Game1.player.CurrentTool != null)
         {
             Game1.player.CurrentTool.tickUpdate(time, Game1.player);
         }
         if (distanceFromCatching <= 0f)
         {
             fadeOut = true;
             everythingShakeTimer = 500f;
             Game1.playSound("fishEscape");
             handledFishResult = true;
             if (unReelSound != null)
             {
                 unReelSound.Stop(AudioStopOptions.Immediate);
             }
             if (reelSound != null)
             {
                 reelSound.Stop(AudioStopOptions.Immediate);
             }
         }
         else if (distanceFromCatching >= 1f)
         {
             everythingShakeTimer = 500f;
             Game1.playSound("jingle1");
             fadeOut           = true;
             handledFishResult = true;
             if (unReelSound != null)
             {
                 unReelSound.Stop(AudioStopOptions.Immediate);
             }
             if (reelSound != null)
             {
                 reelSound.Stop(AudioStopOptions.Immediate);
             }
             if (perfect)
             {
                 sparkleText = new SparklingText(Game1.dialogueFont, Game1.content.LoadString("Strings\\UI:BobberBar_Perfect"), Color.Yellow, Color.White, rainbow: false, 0.1, 1500);
                 if (Game1.isFestival())
                 {
                     Game1.CurrentEvent.perfectFishing();
                 }
             }
             else if (fishSize == maxFishSize)
             {
                 fishSize--;
             }
         }
     }
     if (bobberPosition < 0f)
     {
         bobberPosition = 0f;
     }
     if (bobberPosition > 548f)
     {
         bobberPosition = 548f;
     }
 }
コード例 #25
0
 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  tile       = new Vector2((float)((x + Game1.viewport.X) / Game1.tileSize), (float)((y + Game1.viewport.Y) / Game1.tileSize));
         Building buildingAt = currentFarm.getBuildingAt(tile);
         if (buildingAt != null && !this.namingAnimal)
         {
             if (buildingAt.buildingType.Contains(this.animalBeingPurchased.buildingTypeILiveIn.Value))
             {
                 if ((buildingAt.indoors.Value as AnimalHouse).isFull())
                 {
                     Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11321", new object[0]));
                 }
                 else if (this.animalBeingPurchased.harvestType.Value != 2)
                 {
                     this.namingAnimal  = true;
                     this.newAnimalHome = buildingAt;
                     if (this.animalBeingPurchased.sound.Value != null && Game1.soundBank != null)
                     {
                         ICue expr_15B = Game1.soundBank.GetCue(this.animalBeingPurchased.sound.Value);
                         expr_15B.SetVariable("Pitch", (float)(1200 + Game1.random.Next(-200, 201)));
                         expr_15B.Play();
                     }
                     this.textBox.OnEnterPressed        += this.e;
                     this.textBox.Text                   = this.animalBeingPurchased.displayName;
                     Game1.keyboardDispatcher.Subscriber = this.textBox;
                     if (Game1.options.SnappyMenus)
                     {
                         this.currentlySnappedComponent = base.getComponentWithID(104);
                         this.snapCursorToCurrentSnappedComponent();
                     }
                 }
                 else if (Game1.player.Money >= this.priceOfAnimal)
                 {
                     this.newAnimalHome             = buildingAt;
                     this.animalBeingPurchased.home = this.newAnimalHome;
                     this.animalBeingPurchased.homeLocation.Value = new Vector2((float)this.newAnimalHome.tileX.Value, (float)this.newAnimalHome.tileY.Value);
                     this.animalBeingPurchased.setRandomPosition(this.animalBeingPurchased.home.indoors.Value);
                     (this.newAnimalHome.indoors.Value as AnimalHouse).animals.Add(this.animalBeingPurchased.myID.Value, this.animalBeingPurchased);
                     (this.newAnimalHome.indoors.Value as AnimalHouse).animalsThatLiveHere.Add(this.animalBeingPurchased.myID.Value);
                     this.newAnimalHome = null;
                     this.namingAnimal  = false;
                     if (this.animalBeingPurchased.sound.Value != null && Game1.soundBank != null)
                     {
                         ICue expr_2DC = Game1.soundBank.GetCue(this.animalBeingPurchased.sound.Value);
                         expr_2DC.SetVariable("Pitch", (float)(1200 + Game1.random.Next(-200, 201)));
                         expr_2DC.Play();
                     }
                     Game1.player.Money -= this.priceOfAnimal;
                     Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11324", new object[]
                     {
                         this.animalBeingPurchased.displayType
                     }), Color.LimeGreen, 3500f));
                     this.animalBeingPurchased = new FarmAnimal(this.animalBeingPurchased.type.Value, ModEntry.ModHelper.Multiplayer.GetNewID(), Game1.player.UniqueMultiplayerID);
                 }
                 else if (Game1.player.Money < this.priceOfAnimal)
                 {
                     Game1.dayTimeMoneyBox.moneyShakeTimer = 1000;
                 }
             }
             else
             {
                 Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11326", new object[]
                 {
                     this.animalBeingPurchased.displayType
                 }));
             }
         }
         if (this.namingAnimal)
         {
             if (this.doneNamingButton.containsPoint(x, y))
             {
                 this.textBoxEnter(this.textBox);
                 Game1.playSound("smallSelect");
             }
             else if (this.namingAnimal && this.randomButton.containsPoint(x, y))
             {
                 this.animalBeingPurchased.Name        = Dialogue.randomName();
                 this.animalBeingPurchased.displayName = this.animalBeingPurchased.Name;
                 this.textBox.Text       = this.animalBeingPurchased.displayName;
                 this.randomButton.scale = this.randomButton.baseScale;
                 Game1.playSound("drumkit6");
             }
             this.textBox.Update();
             return;
         }
     }
     else
     {
         if (this.previousFarmButton.containsPoint(x, y))
         {
             currentFarm = framework.swapFarm(currentFarm);
             this.populateAnimalStock();
             this.previousFarmButton.scale = this.previousFarmButton.baseScale;
         }
         if (this.nextFarmButton.containsPoint(x, y))
         {
             currentFarm = framework.swapFarm(currentFarm);
             this.populateAnimalStock();
             this.nextFarmButton.scale = this.nextFarmButton.baseScale;
         }
         foreach (ClickableTextureComponent current in this.animalsToPurchase)
         {
             if (current.containsPoint(x, y) && (current.item as Object).Type == null)
             {
                 int num = current.item.salePrice();
                 if (Game1.player.Money >= num)
                 {
                     Game1.globalFadeToBlack(new Game1.afterFadeFunction(this.setUpForAnimalPlacement), 0.02f);
                     Game1.playSound("smallSelect");
                     this.onFarm = true;
                     this.animalBeingPurchased = new FarmAnimal(current.hoverText, ModEntry.ModHelper.Multiplayer.GetNewID(), Game1.player.UniqueMultiplayerID);
                     this.priceOfAnimal        = num;
                 }
                 else
                 {
                     Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11325", new object[0]), Color.Red, 3500f));
                 }
             }
         }
     }
 }
コード例 #26
0
        protected override void updateAnimation(GameTime time)
        {
            if (!sound.IsPlaying && currentLocation.Equals(Game1.currentLocation))
            {
                sound.SetVariable("Volume", 0f);
                Utilities.TryPlayCue(sound);
            }
            if (Game1.fadeToBlackAlpha > 0.8f && Game1.fadeIn)
            {
                Utilities.TryStopCue(sound);
            }
            else
            {
                sound.SetVariable("Volume",
                                  Math.Max(0f, sound.GetVariable("Volume") - 1f));
                float max = Math.Max(0f, 400f - Vector2.Distance(Position,
                                                                 Player.Position) / 64f / 16f * 150f);
                if (max > sound.GetVariable("Volume"))
                {
                    sound.SetVariable("Volume", max);
                }
            }

            if (wasHitCounter.Value >= 0)
            {
                wasHitCounter.Value -= time.ElapsedGameTime.Milliseconds;
            }

            Sprite.Animate(time, (FacingDirection == 0) ? 8
                                : ((FacingDirection != 2) ? (FacingDirection * 4) : 0), 4, 50f);

            if ((withinPlayerThreshold() || Utility.isOnScreen(position, 256)) &&
                invincibleCountdown <= 0)
            {
                faceDirection(0);

                float xDistance = -(Player.GetBoundingBox().Center.X -
                                    GetBoundingBox().Center.X);
                float yDistance = Player.GetBoundingBox().Center.Y -
                                  GetBoundingBox().Center.Y;
                float xyDistance = Math.Max(1f, Math.Abs(xDistance) +
                                            Math.Abs(yDistance));

                if (xyDistance < 64f)
                {
                    xVelocity = Math.Max(-maxSpeed, Math.Min(maxSpeed,
                                                             xVelocity * 1.1f));
                    yVelocity = Math.Max(-maxSpeed, Math.Min(maxSpeed,
                                                             yVelocity * 1.1f));
                }

                xDistance /= xyDistance;
                yDistance /= xyDistance;

                if (wasHitCounter.Value <= 0)
                {
                    float targetRotation = (float)Math.Atan2(0f - yDistance,
                                                             xDistance) - (float)Math.PI / 2f;

                    if ((double)(Math.Abs(targetRotation) - Math.Abs(rotation))
                        > Math.PI * 7.0 / 8.0 && Game1.random.NextDouble() < 0.5)
                    {
                        turningRight.Value = true;
                    }
                    else if ((double)(Math.Abs(targetRotation) - Math.Abs(rotation))
                             < Math.PI / 8.0)
                    {
                        turningRight.Value = false;
                    }

                    float rotationChange = (float)Math.Sign(targetRotation -
                                                            rotation) * ((float)Math.PI / 64f);
                    if (turningRight.Value)
                    {
                        rotation -= rotationChange;
                    }
                    else
                    {
                        rotation += rotationChange;
                    }
                    rotation %= (float)Math.PI * 2f;

                    wasHitCounter.Value = 5 + Game1.random.Next(-1, 2);
                }

                float factor = Math.Min(maxSpeed, Math.Max(2f, maxSpeed -
                                                           xyDistance / 64f / 2f));
                xDistance = (float)Math.Cos((double)rotation + Math.PI / 2.0);
                yDistance = 0f - (float)Math.Sin((double)rotation + Math.PI / 2.0);

                xVelocity += (0f - xDistance) * factor / 6f +
                             (float)Game1.random.Next(-10, 10) / 100f;
                if (Math.Abs(xVelocity) > Math.Abs((0f - xDistance) * maxSpeed))
                {
                    xVelocity -= (0f - xDistance) * factor / 6f;
                }

                yVelocity += (0f - yDistance) * factor / 6f +
                             (float)Game1.random.Next(-10, 10) / 100f;
                if (Math.Abs(yVelocity) > Math.Abs((0f - yDistance) * maxSpeed))
                {
                    yVelocity -= (0f - yDistance) * factor / 6f;
                }
            }
            resetAnimationSpeed();
        }
コード例 #27
0
        public static bool DoFunction(Axe __instance, GameLocation location, int x, int y, int power, StardewValley.Farmer who)
        {
            if (!IsMeatCleaver(__instance))
            {
                return(true);
            }

            string meatCleaverId = __instance.modData[MeatCleaverKey];

            BaseToolDoFunction(__instance, location, x, y, power, who);

            if (!__instance.IsEfficient)
            {
                who.Stamina -= ((float)4f - (float)who.FarmingLevel * 0.2f);
            }
            if (!Animals.ContainsKey(meatCleaverId))
            {
                return(false);
            }
            FarmAnimal farmAnimal = Animals[meatCleaverId];

            if (farmAnimal == null ||
                !MeatController.CanGetMeatFrom(Animals[meatCleaverId]) ||
                farmAnimal.age.Value < (int)farmAnimal.ageWhenMature.Value)
            {
                return(false);
            }

            (farmAnimal.home.indoors.Value as AnimalHouse)?.animalsThatLiveHere.Remove(farmAnimal.myID.Value);
            farmAnimal.health.Value = -1;
            int numClouds   = farmAnimal.frontBackSourceRect.Width / 2;
            int cloudSprite = !DataLoader.ModConfig.Softmode ? 5 : 10;

            for (int i = 0; i < numClouds; i++)
            {
                int   nonRedness = Game1.random.Next(0, 80);
                Color cloudColor = new Color(255, 255 - nonRedness, 255 - nonRedness);

                location.temporarySprites.Add(
                    new TemporaryAnimatedSprite
                    (
                        cloudSprite
                        , farmAnimal.position + new Vector2(Game1.random.Next(-Game1.tileSize / 2, farmAnimal.frontBackSourceRect.Width * 3), Game1.random.Next(-Game1.tileSize / 2, farmAnimal.frontBackSourceRect.Height * 3))
                        , cloudColor
                        , 8
                        , false,
                        Game1.random.NextDouble() < .5 ? 50 : Game1.random.Next(30, 200), 0, Game1.tileSize
                        , -1
                        , Game1.tileSize, Game1.random.NextDouble() < .5 ? 0 : Game1.random.Next(0, 600)
                    )
                {
                    scale  = Game1.random.Next(2, 5) * .25f,
                    alpha  = Game1.random.Next(2, 5) * .25f,
                    motion = new Vector2(0, (float)-Game1.random.NextDouble())
                }
                    );
            }

            Color animalColor;
            float alfaFade;

            if (!DataLoader.ModConfig.Softmode)
            {
                animalColor = Color.LightPink;
                alfaFade    = .025f;
            }
            else
            {
                animalColor = Color.White;
                alfaFade    = .050f;
            }

            location.temporarySprites.Add(
                new TemporaryAnimatedSprite
                (
                    farmAnimal.Sprite.textureName.Value
                    , farmAnimal.Sprite.SourceRect
                    , farmAnimal.position
                    , farmAnimal.FacingDirection == Game1.left
                    , alfaFade
                    , animalColor
                )
            {
                scale = 4f
            }
                );
            if (!DataLoader.ModConfig.Softmode)
            {
                location.playSound("killAnimal");
            }
            else
            {
                ICue warptSound = Game1.soundBank.GetCue("wand");
                warptSound.SetVariable("Pitch", 1800);
                warptSound.Play();
            }

            MeatController.ThrowItem(MeatController.CreateMeat(farmAnimal), farmAnimal);
            who.gainExperience(0, 5);
            Animals[meatCleaverId]     = (FarmAnimal)null;
            TempAnimals[meatCleaverId] = (FarmAnimal)null;
            return(false);
        }
コード例 #28
0
 public bool tick(GameTime time)
 {
     if (stateTimer > 0f)
     {
         stateTimer -= (float)time.ElapsedGameTime.TotalSeconds;
         if (stateTimer <= 0f)
         {
             stateTimer = 0f;
             if (currentGameState == GameState.ShowScore)
             {
                 if (lastHitAmount == 0)
                 {
                     if (dartCount <= 0)
                     {
                         SetGameState(GameState.Scoring);
                     }
                     else
                     {
                         SetGameState(GameState.Aiming);
                     }
                 }
                 else
                 {
                     nextPointTransferTime = 0.5f;
                     SetGameState(GameState.Scoring);
                 }
             }
             else if (currentGameState == GameState.GameOver)
             {
                 QuitGame();
                 return(true);
             }
         }
     }
     if (currentGameState == GameState.GameOver && WasButtonPressed())
     {
         QuitGame();
         return(true);
     }
     cursorPosition = (Utility.PointToVector2(Game1.getMousePosition()) - upperLeft) / GetPixelScale();
     if (currentGameState == GameState.Aiming)
     {
         chargeTime     = 1f;
         aimPosition    = cursorPosition;
         aimPosition.X += (float)Math.Sin(time.TotalGameTime.TotalSeconds * 0.75) * 32f;
         aimPosition.Y += (float)Math.Sin(time.TotalGameTime.TotalSeconds * 1.5) * 32f;
         if (WasButtonPressed() && IsAiming())
         {
             SetGameState(GameState.Charging);
         }
     }
     else if (currentGameState == GameState.Charging)
     {
         if (chargeSound != null)
         {
             chargeSound.SetVariable("Pitch", 2400f * (1f - chargeTime));
         }
         chargeTime += (float)time.ElapsedGameTime.TotalSeconds * chargeDirection;
         if (chargeDirection < 0f && chargeTime < 0f)
         {
             canCancelShot   = false;
             chargeTime      = 0f;
             chargeDirection = 1f;
         }
         else if (chargeDirection > 0f && chargeTime >= 1f)
         {
             chargeTime      = 1f;
             chargeDirection = -1f;
         }
         if (!WasButtonHeld())
         {
             if (chargeTime > 0.8f && canCancelShot)
             {
                 SetGameState(GameState.Aiming);
                 chargeTime = 0f;
             }
             else
             {
                 dartCount--;
                 throwsCount++;
                 FireDart(chargeTime);
             }
         }
     }
     else if (currentGameState == GameState.Firing)
     {
         if (hangTime > 0f)
         {
             hangTime -= (float)time.ElapsedGameTime.TotalSeconds;
             if (hangTime <= 0f)
             {
                 float random_angle = Utility.RandomFloat(0f, (float)Math.PI * 2f);
                 aimPosition += new Vector2((float)Math.Sin(random_angle), (float)Math.Cos(random_angle)) * Utility.RandomFloat(0f, GetRadiusFromCharge() * 32f);
                 Game1.playSound("cast");
                 dartTime     = 0f;
                 dartPosition = throwStartPosition;
             }
         }
         else if (dartTime >= 0f)
         {
             dartTime      += (float)time.ElapsedGameTime.TotalSeconds / 0.75f;
             dartPosition.X = Utility.Lerp(throwStartPosition.X, aimPosition.X, dartTime);
             dartPosition.Y = Utility.Lerp(throwStartPosition.Y, aimPosition.Y, dartTime);
             if (dartTime >= 1f)
             {
                 Game1.playSound("Cowboy_gunshot");
                 lastHitAmount = GetPointsForAim();
                 SetGameState(GameState.ShowScore);
             }
         }
     }
     else if (currentGameState == GameState.Scoring)
     {
         if (lastHitAmount > 0)
         {
             if (nextPointTransferTime > 0f)
             {
                 nextPointTransferTime -= (float)time.ElapsedGameTime.TotalSeconds;
                 if (nextPointTransferTime < 0f)
                 {
                     _          = points;
                     shakeScore = true;
                     int transfer_amount = 1;
                     if (lastHitAmount > 10 && points > 10)
                     {
                         transfer_amount = 10;
                     }
                     points        -= transfer_amount;
                     lastHitAmount -= transfer_amount;
                     Game1.playSound("moneyDial");
                     nextPointTransferTime = 0.05f;
                     if (points < 0)
                     {
                         alternateTextString = Game1.content.LoadString("Strings\\StringsFromCSFiles:CalicoJack.cs.11947");
                         Game1.playSound("fishEscape");
                         nextPointTransferTime = 1f;
                         lastHitAmount         = 0;
                     }
                 }
             }
         }
         else
         {
             if (nextPointTransferTime > 0f)
             {
                 nextPointTransferTime -= (float)time.ElapsedGameTime.TotalSeconds;
             }
             if (nextPointTransferTime <= 0f)
             {
                 nextPointTransferTime = 0f;
                 if (points == 0)
                 {
                     SetGameState(GameState.GameOver);
                 }
                 else
                 {
                     if (points < 0)
                     {
                         points = previousPoints;
                     }
                     if (dartCount <= 0)
                     {
                         SetGameState(GameState.GameOver);
                     }
                     else
                     {
                         SetGameState(GameState.Aiming);
                     }
                 }
             }
         }
     }
     if (IsAiming() || currentGameState == GameState.Charging)
     {
         Game1.mouseCursorTransparency = 0f;
     }
     else
     {
         Game1.mouseCursorTransparency = 1f;
     }
     return(false);
 }
コード例 #29
0
        /// <summary>The prefix for the ReceiveLieftClick method.</summary>
        /// <param name="x">The X position of the cursor.</param>
        /// <param name="y">The Y position of the cursor.</param>
        /// <param name="__instance">The <see cref="PurchaseAnimalsMenu"/> instance being patched.</param>
        /// <returns>False meaning the original method won't get ran.</returns>
        internal static bool ReceiveLeftClickPrefix(int x, int y, PurchaseAnimalsMenu __instance)
        {
            // get private members
            var freeze               = (bool)typeof(PurchaseAnimalsMenu).GetField("freeze", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var onFarm               = (bool)typeof(PurchaseAnimalsMenu).GetField("onFarm", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var namingAnimal         = (bool)typeof(PurchaseAnimalsMenu).GetField("namingAnimal", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var animalBeingPurchased = (FarmAnimal)typeof(PurchaseAnimalsMenu).GetField("animalBeingPurchased", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var e             = (TextBoxEvent)typeof(PurchaseAnimalsMenu).GetField("e", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var textBox       = (TextBox)typeof(PurchaseAnimalsMenu).GetField("textBox", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var newAnimalHome = (Building)typeof(PurchaseAnimalsMenu).GetField("newAnimalHome", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var priceOfAnimal = (int)typeof(PurchaseAnimalsMenu).GetField("priceOfAnimal", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var multiplayer   = (Multiplayer)typeof(Game1).GetField("multiplayer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);

            if (Game1.globalFade || freeze)
            {
                return(false);
            }

            if (__instance.okButton != null && __instance.okButton.containsPoint(x, y) && __instance.readyToClose())
            {
                if (onFarm)
                {
                    __instance.setUpForReturnToShopMenu();
                    Game1.playSound("smallSelect");
                }
                else
                {
                    Game1.exitActiveMenu();
                    Game1.playSound("bigDeSelect");
                }
            }

            if (onFarm) // player is picking a house for the animal or naming the animal
            {
                Building buildingAt = (Game1.getLocationFromName("Farm") as Farm).getBuildingAt(new Vector2(
                                                                                                    (x + Game1.viewport.X) / 64,
                                                                                                    (y + Game1.viewport.Y) / 64
                                                                                                    ));

                if (buildingAt != null && !namingAnimal) // picking a house for the animal and a building has been clicked
                {
                    var buildingValid = false;

                    // determine if building is valid
                    if (!string.IsNullOrEmpty(animalBeingPurchased.buildingTypeILiveIn.Value)) // if 'buildingTypeILiveIn' is used, it's a default game animal
                    {
                        if (buildingAt.buildingType.Value.Contains(animalBeingPurchased.buildingTypeILiveIn.Value))
                        {
                            buildingValid = true;
                        }
                    }
                    else // animal is a custom animal
                    {
                        // get animal data
                        var animal = ModEntry.Instance.Api.GetAnimalBySubTypeName(animalBeingPurchased.type);
                        if (animal != null)
                        {
                            foreach (var building in animal.Data.Buildings)
                            {
                                if (buildingAt.buildingType.Value.ToLower() == building.ToLower())
                                {
                                    buildingValid = true;
                                }
                            }
                        }
                    }

                    if (buildingValid)
                    {
                        // ensure building has space for animal
                        if ((buildingAt.indoors.Value as AnimalHouse).isFull())
                        {
                            // show 'That Building Is Full' message
                            Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11321"));
                        }
                        else if (animalBeingPurchased.harvestType.Value != 2) // animal 'lays' items
                        {
                            namingAnimal  = true;
                            newAnimalHome = buildingAt;

                            if (animalBeingPurchased.sound.Value != null && Game1.soundBank != null)
                            {
                                ICue cue = Game1.soundBank.GetCue(animalBeingPurchased.sound.Value);
                                cue.SetVariable("Pitch", 1200 + Game1.random.Next(-200, 201));
                                cue.Play();
                            }

                            textBox.OnEnterPressed += e;
                            textBox.Text            = animalBeingPurchased.displayName;
                            Game1.keyboardDispatcher.Subscriber = textBox;

                            if (Game1.options.SnappyMenus)
                            {
                                __instance.currentlySnappedComponent = __instance.getComponentWithID(104);
                                __instance.snapCursorToCurrentSnappedComponent();
                            }
                        }
                        else if (Game1.player.Money >= priceOfAnimal)
                        {
                            newAnimalHome             = buildingAt;
                            animalBeingPurchased.home = newAnimalHome;
                            animalBeingPurchased.homeLocation.Value = new Vector2(newAnimalHome.tileX, newAnimalHome.tileY);
                            animalBeingPurchased.setRandomPosition(animalBeingPurchased.home.indoors);
                            (newAnimalHome.indoors.Value as AnimalHouse).animals.Add(animalBeingPurchased.myID, animalBeingPurchased);
                            (newAnimalHome.indoors.Value as AnimalHouse).animalsThatLiveHere.Add(animalBeingPurchased.myID);
                            newAnimalHome = null;
                            namingAnimal  = false;

                            if (animalBeingPurchased.sound.Value != null && Game1.soundBank != null)
                            {
                                ICue cue = Game1.soundBank.GetCue(animalBeingPurchased.sound.Value);
                                cue.SetVariable("Pitch", 1200 + Game1.random.Next(-200, 201));
                                cue.Play();
                            }

                            Game1.player.Money -= priceOfAnimal;
                            Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11324", animalBeingPurchased.type), Color.LimeGreen, 3500f));
                            animalBeingPurchased = new FarmAnimal(animalBeingPurchased.type, multiplayer.getNewID(), Game1.player.uniqueMultiplayerID);
                        }
                        else if (Game1.player.Money < priceOfAnimal)
                        {
                            Game1.dayTimeMoneyBox.moneyShakeTimer = 1000;
                        }
                    }
                    else
                    {
                        // show '{0}s Can't Live There.'
                        Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11326", animalBeingPurchased.type));
                    }
                }
                if (!namingAnimal)
                {
                    return(false);
                }
                if (__instance.doneNamingButton.containsPoint(x, y))
                {
                    __instance.textBoxEnter(textBox);
                    Game1.playSound("smallSelect");
                }
                else if (namingAnimal && __instance.randomButton.containsPoint(x, y))
                {
                    animalBeingPurchased.Name        = Dialogue.randomName();
                    animalBeingPurchased.displayName = animalBeingPurchased.Name;
                    textBox.Text = animalBeingPurchased.displayName;
                    __instance.randomButton.scale = __instance.randomButton.baseScale;
                    Game1.playSound("drumkit6");
                }
                textBox.Update();
            }
            else
            {
                foreach (ClickableTextureComponent textureComponent in __instance.animalsToPurchase)
                {
                    if (textureComponent.containsPoint(x, y) && (textureComponent.item as StardewValley.Object).Type == null)
                    {
                        int num = textureComponent.item.salePrice();
                        if (Game1.player.Money >= num)
                        {
                            Game1.globalFadeToBlack(new Game1.afterFadeFunction(__instance.setUpForAnimalPlacement), 0.02f);
                            Game1.playSound("smallSelect");
                            onFarm = true;
                            animalBeingPurchased = new FarmAnimal(textureComponent.hoverText, multiplayer.getNewID(), Game1.player.UniqueMultiplayerID);
                            priceOfAnimal        = num;

                            // calculate all the valid builds for the camera panning feature
                            ValidBuildings = new List <Building>();
                            foreach (var building in Game1.getFarm().buildings)
                            {
                                // ensure the animal can live in the building
                                var buildingValid = false;
                                if (!string.IsNullOrEmpty(animalBeingPurchased.buildingTypeILiveIn.Value)) // if 'buildingTypeILiveIn' is used, it's a default game animal
                                {
                                    if (building.buildingType.Value.Contains(animalBeingPurchased.buildingTypeILiveIn.Value))
                                    {
                                        buildingValid = true;
                                    }
                                }
                                else // animal is a custom animal
                                {
                                    // get animal data
                                    var animal = ModEntry.Instance.Api.GetAnimalBySubTypeName(animalBeingPurchased.type);
                                    if (animal != null)
                                    {
                                        foreach (var animalBuilding in animal.Data.Buildings)
                                        {
                                            if (building.buildingType.Value.ToLower() == animalBuilding.ToLower())
                                            {
                                                buildingValid = true;
                                            }
                                        }

                                        break;
                                    }
                                }

                                // ensure the animal can live in the building
                                if (!buildingValid)
                                {
                                    continue;
                                }

                                // ensure the building isn't full
                                var animalHouse = building.indoors.Value as AnimalHouse;
                                if (animalHouse == null || animalHouse.isFull())
                                {
                                    continue;
                                }

                                ValidBuildings.Add(building);
                            }
                        }
                        else
                        {
                            Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11325"), Color.Red, 3500f));
                        }
                    }
                }
            }

            // reset potentially changed private members
            typeof(PurchaseAnimalsMenu).GetField("namingAnimal", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, namingAnimal);
            typeof(PurchaseAnimalsMenu).GetField("newAnimalHome", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, newAnimalHome);
            typeof(PurchaseAnimalsMenu).GetField("textBox", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, textBox);
            typeof(PurchaseAnimalsMenu).GetField("animalBeingPurchased", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, animalBeingPurchased);
            typeof(PurchaseAnimalsMenu).GetField("onFarm", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, onFarm);
            typeof(PurchaseAnimalsMenu).GetField("priceOfAnimal", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, priceOfAnimal);

            return(false);
        }