コード例 #1
0
 public virtual void SetGameState(GameState new_state)
 {
     if (currentGameState == GameState.Scoring)
     {
         previousPoints      = points;
         shakeScore          = false;
         alternateTextString = "";
     }
     if (currentGameState == GameState.Charging && chargeSound != null)
     {
         chargeSound.Stop(AudioStopOptions.Immediate);
         chargeSound = null;
     }
     currentGameState = new_state;
     if (currentGameState == GameState.Aiming)
     {
         dartTime = -1f;
         if (Game1.options.gamepadControls)
         {
             Game1.setMousePosition(Utility.Vector2ToPoint(TransformDraw(new Vector2(screenWidth / 2, screenHeight / 2))));
         }
     }
     else if (currentGameState == GameState.Charging)
     {
         if (chargeSound == null && Game1.soundBank != null)
         {
             chargeSound = Game1.soundBank.GetCue("SinWave");
             chargeSound.Play();
         }
         chargeTime      = 1f;
         chargeDirection = -1f;
         canCancelShot   = true;
     }
     else if (currentGameState == GameState.Firing)
     {
         throwStartPosition = dartBoardCenter + new Vector2(Utility.RandomFloat(-64f, 64f), 200f);
         Game1.playSound("FishHit");
         hangTime = 0.25f;
     }
     else if (currentGameState == GameState.ShowScore)
     {
         stateTimer = 1f;
     }
     else if (currentGameState == GameState.GameOver)
     {
         if (points == 0)
         {
             gameOverString = Game1.content.LoadString("Strings\\StringsFromCSFiles:CalicoJack.cs.11943");
             Game1.playSound("yoba");
         }
         else
         {
             gameOverString = Game1.content.LoadString("Strings\\StringsFromCSFiles:CalicoJack.cs.11946");
             Game1.playSound("slimedead");
         }
         stateTimer = 3f;
     }
 }
コード例 #2
0
 public override void cleanupBeforePlayerExit()
 {
     base.cleanupBeforePlayerExit();
     if (trainLoop != null)
     {
         trainLoop.Stop(AudioStopOptions.Immediate);
     }
     trainLoop = null;
 }
コード例 #3
0
ファイル: Beam.cs プロジェクト: somnomania/smapi-mod-dump
        private void update(object sender, UpdateTickedEventArgs e)
        {
            if (timer-- <= 0)
            {
                Mod.instance.Helper.Events.GameLoop.UpdateTicked -= update;
                Mod.instance.Helper.Events.Display.RenderedWorld -= render;
                sound.Stop(Microsoft.Xna.Framework.Audio.AudioStopOptions.Immediate);
            }

            Vector2 lineEnd = new Vector2(basePos.X + (float)Math.Cos(angle + Math.PI) * 10000, basePos.Y + (float)Math.Sin(angle + Math.PI) * 10000);

            Vector2 higher  = lineEnd.Y < basePos.Y ? lineEnd : basePos;
            Vector2 lower   = lineEnd.Y < basePos.Y ? basePos : lineEnd;
            Vector2 lefter  = lineEnd.X < basePos.X ? lineEnd : basePos;
            Vector2 righter = lineEnd.X < basePos.X ? basePos : lineEnd;

            foreach (var character in shooter.currentLocation.characters.ToList())
            {
                if (character is Monster mob)
                {
                    var bb = mob.GetBoundingBox();
                    var tl = new Vector2(bb.Left, bb.Top);
                    var tr = new Vector2(bb.Right, bb.Top);
                    var bl = new Vector2(bb.Left, bb.Bottom);
                    var br = new Vector2(bb.Right, bb.Bottom);

                    var i1 = LSegsIntersectionPoint(basePos, lineEnd, tl, tr);
                    var i2 = LSegsIntersectionPoint(basePos, lineEnd, tr, br);
                    var i3 = LSegsIntersectionPoint(basePos, lineEnd, bl, br);
                    var i4 = LSegsIntersectionPoint(basePos, lineEnd, tl, bl);

                    Vector2 cont = Vector2.Zero;
                    if (i1.HasValue && bb.Contains((int)i1.Value.X, (int)i1.Value.Y))
                    {
                        cont = i1.Value;
                    }
                    if (i2.HasValue && bb.Contains((int)i2.Value.X, (int)i2.Value.Y))
                    {
                        cont = i2.Value;
                    }
                    if (i3.HasValue && bb.Contains((int)i3.Value.X, (int)i3.Value.Y))
                    {
                        cont = i3.Value;
                    }
                    if (i4.HasValue && bb.Contains((int)i4.Value.X, (int)i4.Value.Y))
                    {
                        cont = i4.Value;
                    }
                    if (cont.X >= lefter.X && cont.X <= righter.X &&
                        cont.Y >= higher.Y && cont.Y <= lower.Y &&
                        bb.Contains((int)cont.X, (int)cont.Y))
                    {
                        shooter.currentLocation.damageMonster(bb, 6, 8, false, shooter);
                        //mob.takeDamage(3, 0, 0, false, 0, shooter);
                    }
                }
            }
        }
コード例 #4
0
ファイル: Fly.cs プロジェクト: s-yi/StardewValley
        public override int takeDamage(int damage, int xTrajectory, int yTrajectory, bool isBomb, double addedPrecision, Farmer who)
        {
            int actualDamage = Math.Max(1, damage - (int)resilience);

            if (Game1.random.NextDouble() < (double)missChance - (double)missChance * addedPrecision)
            {
                actualDamage = -1;
            }
            else
            {
                base.Health -= actualDamage;
                setTrajectory(xTrajectory / 3, yTrajectory / 3);
                wasHitCounter = 500;
                if (base.currentLocation != null)
                {
                    base.currentLocation.playSound("hitEnemy");
                }
                if (base.Health <= 0)
                {
                    if (base.currentLocation != null)
                    {
                        base.currentLocation.playSound("monsterdead");
                        Utility.makeTemporarySpriteJuicier(new TemporaryAnimatedSprite(44, base.Position, Color.HotPink, 10)
                        {
                            interval = 70f
                        }, base.currentLocation);
                    }
                    if (Game1.soundBank != null && buzz != null)
                    {
                        buzz.Stop(AudioStopOptions.AsAuthored);
                    }
                }
            }
            base.addedSpeed = Game1.random.Next(-1, 1);
            return(actualDamage);
        }
コード例 #5
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);
        }
コード例 #6
0
 private void AfterWarpPause()
 {
     //Game1.drawObjectDialogue(destinationMessage);
     Game1.playSound("trainWhistle");
     cue.Stop(Microsoft.Xna.Framework.Audio.AudioStopOptions.AsAuthored);
 }
コード例 #7
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;
     }
 }
コード例 #8
0
ファイル: ModEntry.cs プロジェクト: somnomania/smapi-mod-dump
 public static bool AbigailGame_updateBullets_Prefix(AbigailGame __instance, GameTime time, ICue ___outlawSong)
 {
     for (int i = __instance.bullets.Count - 1; i >= 0; i--)
     {
         AbigailGame.CowboyBullet cowboyBullet = __instance.bullets[i];
         cowboyBullet.position.X = cowboyBullet.position.X + __instance.bullets[i].motion.X;
         AbigailGame.CowboyBullet cowboyBullet2 = __instance.bullets[i];
         cowboyBullet2.position.Y = cowboyBullet2.position.Y + __instance.bullets[i].motion.Y;
         if (__instance.bullets[i].position.X <= 0 || __instance.bullets[i].position.Y <= 0 || __instance.bullets[i].position.X >= 768 || __instance.bullets[i].position.Y >= 768)
         {
             __instance.bullets.RemoveAt(i);
         }
         else if (AbigailGame.map[__instance.bullets[i].position.X / 16 / 3, __instance.bullets[i].position.Y / 16 / 3] == 7)
         {
             __instance.bullets.RemoveAt(i);
         }
         else
         {
             int j = AbigailGame.monsters.Count - 1;
             while (j >= 0)
             {
                 if (AbigailGame.monsters[j].position.Intersects(new Rectangle(__instance.bullets[i].position.X, __instance.bullets[i].position.Y, 12, 12)))
                 {
                     int monsterhealth = AbigailGame.monsters[j].health;
                     int monsterAfterDamageHealth;
                     if (AbigailGame.monsters[j].takeDamage(__instance.bullets[i].damage))
                     {
                         monsterAfterDamageHealth = AbigailGame.monsters[j].health;
                         AbigailGame.addGuts(AbigailGame.monsters[j].position.Location, AbigailGame.monsters[j].type);
                         int loot = AbigailGame.monsters[j].getLootDrop();
                         hundredIndex6++;
                         hundredIndex6 %= 100;
                         if (__instance.whichRound == 1 && hundred6[hundredIndex6] < 50)
                         {
                             loot = -1;
                         }
                         if (__instance.whichRound > 0 && (loot == 5 || loot == 8))
                         {
                             hundredIndex7++;
                             hundredIndex7 %= 100;
                             if (hundred7[hundredIndex7] < 40)
                             {
                                 loot = -1;
                             }
                         }
                         if (loot != -1 && AbigailGame.whichWave != 12)
                         {
                             AbigailGame.powerups.Add(new AbigailGame.CowboyPowerup(loot, AbigailGame.monsters[j].position.Location, __instance.lootDuration));
                         }
                         if (AbigailGame.shootoutLevel)
                         {
                             if (AbigailGame.whichWave == 12 && AbigailGame.monsters[j].type == -2)
                             {
                                 Game1.playSound("cowboy_explosion");
                                 AbigailGame.powerups.Add(new AbigailGame.CowboyPowerup(-3, new Point(8 * AbigailGame.TileSize, 10 * AbigailGame.TileSize), 9999999));
                                 __instance.noPickUpBox = new Rectangle(8 * AbigailGame.TileSize, 10 * AbigailGame.TileSize, AbigailGame.TileSize, AbigailGame.TileSize);
                                 if (___outlawSong != null && ___outlawSong.IsPlaying)
                                 {
                                     ___outlawSong.Stop(AudioStopOptions.Immediate);
                                 }
                                 AbigailGame.screenFlash = 200;
                                 for (int k = 0; k < 30; k++)
                                 {
                                     AbigailGame.temporarySprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(512, 1696, 16, 16), 70f, 6, 0, new Vector2((float)(AbigailGame.monsters[j].position.X + Game1.random.Next(-AbigailGame.TileSize, AbigailGame.TileSize)), (float)(AbigailGame.monsters[j].position.Y + Game1.random.Next(-AbigailGame.TileSize, AbigailGame.TileSize))) + AbigailGame.topLeftScreenCoordinate + new Vector2((float)(AbigailGame.TileSize / 2), (float)(AbigailGame.TileSize / 2)), false, false, 1f, 0f, Color.White, 3f, 0f, 0f, 0f, true)
                                     {
                                         delayBeforeAnimationStart = k * 75
                                     });
                                     if (k % 4 == 0)
                                     {
                                         AbigailGame.addGuts(new Point(AbigailGame.monsters[j].position.X + Game1.random.Next(-AbigailGame.TileSize, AbigailGame.TileSize), AbigailGame.monsters[j].position.Y + Game1.random.Next(-AbigailGame.TileSize, AbigailGame.TileSize)), 7);
                                     }
                                     if (k % 4 == 0)
                                     {
                                         AbigailGame.temporarySprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(464, 1792, 16, 16), 80f, 5, 0, new Vector2((float)(AbigailGame.monsters[j].position.X + Game1.random.Next(-AbigailGame.TileSize, AbigailGame.TileSize)), (float)(AbigailGame.monsters[j].position.Y + Game1.random.Next(-AbigailGame.TileSize, AbigailGame.TileSize))) + AbigailGame.topLeftScreenCoordinate + new Vector2((float)(AbigailGame.TileSize / 2), (float)(AbigailGame.TileSize / 2)), false, false, 1f, 0f, Color.White, 3f, 0f, 0f, 0f, true)
                                         {
                                             delayBeforeAnimationStart = k * 75
                                         });
                                     }
                                     if (k % 3 == 0)
                                     {
                                         AbigailGame.temporarySprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(544, 1728, 16, 16), 100f, 4, 0, new Vector2((float)(AbigailGame.monsters[j].position.X + Game1.random.Next(-AbigailGame.TileSize, AbigailGame.TileSize)), (float)(AbigailGame.monsters[j].position.Y + Game1.random.Next(-AbigailGame.TileSize, AbigailGame.TileSize))) + AbigailGame.topLeftScreenCoordinate + new Vector2((float)(AbigailGame.TileSize / 2), (float)(AbigailGame.TileSize / 2)), false, false, 1f, 0f, Color.White, 3f, 0f, 0f, 0f, true)
                                         {
                                             delayBeforeAnimationStart = k * 75
                                         });
                                     }
                                 }
                             }
                             else if (AbigailGame.whichWave != 12)
                             {
                                 AbigailGame.powerups.Add(new AbigailGame.CowboyPowerup((AbigailGame.world == 0) ? -1 : -2, new Point(8 * AbigailGame.TileSize, 10 * AbigailGame.TileSize), 9999999));
                                 if (___outlawSong != null && ___outlawSong.IsPlaying)
                                 {
                                     ___outlawSong.Stop(AudioStopOptions.Immediate);
                                 }
                                 AbigailGame.map[8, 8]   = 10;
                                 AbigailGame.screenFlash = 200;
                                 for (int l = 0; l < 15; l++)
                                 {
                                     AbigailGame.temporarySprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(464, 1792, 16, 16), 80f, 5, 0, new Vector2((float)(AbigailGame.monsters[j].position.X + Game1.random.Next(-AbigailGame.TileSize, AbigailGame.TileSize)), (float)(AbigailGame.monsters[j].position.Y + Game1.random.Next(-AbigailGame.TileSize, AbigailGame.TileSize))) + AbigailGame.topLeftScreenCoordinate + new Vector2((float)(AbigailGame.TileSize / 2), (float)(AbigailGame.TileSize / 2)), false, false, 1f, 0f, Color.White, 3f, 0f, 0f, 0f, true)
                                     {
                                         delayBeforeAnimationStart = l * 75
                                     });
                                 }
                             }
                         }
                         AbigailGame.monsters.RemoveAt(j);
                         Game1.playSound("Cowboy_monsterDie");
                     }
                     else
                     {
                         monsterAfterDamageHealth = AbigailGame.monsters[j].health;
                     }
                     __instance.bullets[i].damage -= monsterhealth - monsterAfterDamageHealth;
                     if (__instance.bullets[i].damage <= 0)
                     {
                         __instance.bullets.RemoveAt(i);
                         break;
                     }
                     break;
                 }
                 else
                 {
                     j--;
                 }
             }
         }
     }
     for (int m = AbigailGame.enemyBullets.Count - 1; m >= 0; m--)
     {
         AbigailGame.CowboyBullet cowboyBullet3 = AbigailGame.enemyBullets[m];
         cowboyBullet3.position.X = cowboyBullet3.position.X + AbigailGame.enemyBullets[m].motion.X;
         AbigailGame.CowboyBullet cowboyBullet4 = AbigailGame.enemyBullets[m];
         cowboyBullet4.position.Y = cowboyBullet4.position.Y + AbigailGame.enemyBullets[m].motion.Y;
         if (AbigailGame.enemyBullets[m].position.X <= 0 || AbigailGame.enemyBullets[m].position.Y <= 0 || AbigailGame.enemyBullets[m].position.X >= 762 || AbigailGame.enemyBullets[m].position.Y >= 762)
         {
             AbigailGame.enemyBullets.RemoveAt(m);
         }
         else if (AbigailGame.map[(AbigailGame.enemyBullets[m].position.X + 6) / 16 / 3, (AbigailGame.enemyBullets[m].position.Y + 6) / 16 / 3] == 7)
         {
             AbigailGame.enemyBullets.RemoveAt(m);
         }
         else if (AbigailGame.playerInvincibleTimer <= 0 && AbigailGame.deathTimer <= 0f && __instance.playerBoundingBox.Intersects(new Rectangle(AbigailGame.enemyBullets[m].position.X, AbigailGame.enemyBullets[m].position.Y, 15, 15)))
         {
             __instance.playerDie();
             return(false);
         }
     }
     return(false);
 }
コード例 #9
0
        public bool tick(GameTime time)
        {
            if (!reachedFinish && (livesLeft > 0 || gameMode == 2) && screenDarkness > 0f)
            {
                screenDarkness -= (float)time.ElapsedGameTime.Milliseconds * 0.002f;
            }
            int trackLine = ((track.ElementAt(6).X == 0) ? 9999 : (track.ElementAt(6).Y *tileSize + (int)((track.ElementAt(6).X == 3) ? (0f - speedAccumulator) : ((track.ElementAt(6).X == 4) ? (speedAccumulator - 16f) : 0f))));

            if (respawnCounter <= 0 || track[6].X == 0 || obstacles[6].X == 1 || obstacles[7].X == 1)
            {
                speedAccumulator += (float)time.ElapsedGameTime.Milliseconds * speed;
                trackLine         = ((track.ElementAt(6).X == 0) ? 9999 : (track.ElementAt(6).Y *tileSize + (int)((track.ElementAt(6).X == 3) ? (0f - speedAccumulator) : ((track.ElementAt(6).X == 4) ? (speedAccumulator - 16f) : 0f))));
                if (speedAccumulator >= (float)tileSize)
                {
                    if (!isJumping && movingOnSlope == 0 && Game1.random.NextDouble() < 0.5)
                    {
                        minecartBumpOffset = Game1.random.Next(1, 3);
                    }
                    if ((totalMotion + 1) % 1000 == 0)
                    {
                        Game1.playSound("newArtifact");
                    }
                    else if ((totalMotion + 1) % 100 == 0)
                    {
                        Game1.playSound("Pickup_Coin15");
                    }
                    totalMotion++;
                    if (totalMotion > Game1.minecartHighScore)
                    {
                        Game1.minecartHighScore = totalMotion;
                    }
                    if (distanceToTravel != -1 && totalMotion >= distanceToTravel + screenWidth / tileSize)
                    {
                        if (!reachedFinish)
                        {
                            Game1.playSound("reward");
                        }
                        reachedFinish = true;
                    }
                    track.RemoveAt(0);
                    ceiling.RemoveAt(0);
                    obstacles.RemoveAt(0);
                    if (distanceToTravel == -1 || totalMotion < distanceToTravel)
                    {
                        double noiseValue = NoiseGenerator.Noise(totalMotion, noiseSeed);
                        Point  trackToAdd = Point.Zero;
                        if (noiseValue > heightChangeThreshold && lastNoiseValue <= heightChangeThreshold)
                        {
                            currentTrackY = Math.Max(currentTrackY - Game1.random.Next(1, 2), -6);
                        }
                        else if (noiseValue < heightChangeThreshold && lastNoiseValue >= heightChangeThreshold)
                        {
                            currentTrackY = Math.Min(currentTrackY + Game1.random.Next(1, (currentTrackY <= -3) ? 6 : 3), 4);
                        }
                        else if (Math.Abs(noiseValue - lastNoiseValue) > heightFluctuationsThreshold)
                        {
                            if (track[track.Count - 1].X == 0)
                            {
                                currentTrackY = Math.Max(-6, Math.Min(6, currentTrackY + Game1.random.Next(1, 1)));
                            }
                            else
                            {
                                currentTrackY = Math.Max(Math.Min(4, currentTrackY + Game1.random.Next(-3, 3)), -6);
                            }
                        }
                        if (!(noiseValue < -0.5))
                        {
                            trackToAdd = new Point(Game1.random.Next(1, 3), currentTrackY);
                        }
                        else
                        {
                            bool foundTrack = false;
                            for (int j = 0; j < 4 - ((Game1.random.NextDouble() < 0.1) ? 1 : 0); j++)
                            {
                                if (track[track.Count - 1 - j].X != 0)
                                {
                                    foundTrack = true;
                                    break;
                                }
                            }
                            trackToAdd = (foundTrack ? new Point(0, 999) : new Point(Game1.random.Next(1, 3), (Game1.random.NextDouble() < 0.5 && currentTrackY < 6) ? currentTrackY : (currentTrackY + 1)));
                        }
                        if (track[track.Count - 1].X == 0 && trackToAdd.X != 0)
                        {
                            trackToAdd.Y = Math.Min(6, trackToAdd.Y + 1);
                        }
                        if (trackToAdd.Y == track[track.Count - 1].Y - 1)
                        {
                            track.RemoveAt(track.Count - 1);
                            track.Add(new Point(3, currentTrackY + 1));
                        }
                        else if (trackToAdd.Y == track[track.Count - 1].Y + 1)
                        {
                            trackToAdd.X = 4;
                        }
                        track.Add(trackToAdd);
                        ceiling.Add(new Point(Game1.random.Next(200), Math.Min(currentTrackY - 5 + ytileOffset, Math.Max(0, ceiling.Last().Y + ((Game1.random.NextDouble() < 0.15) ? Game1.random.Next(-1, 2) : 0)))));
                        bool foundGap = false;
                        for (int k = 0; k < 2; k++)
                        {
                            if (track[track.Count - 1 - k].X == 0 || track[track.Count - 1 - k - 1].Y != track[track.Count - 1 - k].Y)
                            {
                                foundGap = true;
                                break;
                            }
                        }
                        if (!foundGap && Game1.random.NextDouble() < obstacleOccurance && currentTrackY > -2 && track.Last().X != 3 && track.Last().X != 4)
                        {
                            obstacles.Add(new Point(1, currentTrackY));
                        }
                        else
                        {
                            obstacles.Add(Point.Zero);
                        }
                        lastNoiseValue = noiseValue;
                    }
                    else
                    {
                        track.Add(new Point(Game1.random.Next(1, 3), currentTrackY));
                        ceiling.Add(new Point(Game1.random.Next(200), ceiling.Last().Y));
                        obstacles.Add(Point.Zero);
                        lakeDecor.Add(new Point(Game1.random.Next(2), Game1.random.Next(ytileOffset + 1, screenHeight / tileSize)));
                    }
                    speedAccumulator %= tileSize;
                }
                lakeSpeedAccumulator += (float)time.ElapsedGameTime.Milliseconds * (speed / 4f);
                if (lakeSpeedAccumulator >= (float)tileSize)
                {
                    lakeSpeedAccumulator %= tileSize;
                    lakeDecor.RemoveAt(0);
                    lakeDecor.Add(new Point(Game1.random.Next(2), Game1.random.Next(ytileOffset + 3, screenHeight / tileSize)));
                }
                backBGPosition    += (float)time.ElapsedGameTime.Milliseconds * (speed / 5f);
                backBGPosition    %= 96f;
                midBGPosition     += (float)time.ElapsedGameTime.Milliseconds * (speed / 4f);
                midBGPosition     %= 96f;
                waterFallPosition += (float)time.ElapsedGameTime.Milliseconds * (speed * 6f / 5f);
                if (waterFallPosition > (float)(screenWidth * 3 / 2))
                {
                    waterFallPosition %= screenWidth * 3 / 2;
                    waterfallWidth     = Game1.random.Next(6);
                }
            }
            else
            {
                respawnCounter   -= time.ElapsedGameTime.Milliseconds;
                mineCartYPosition = trackLine;
            }
            if (Math.Abs(mineCartYPosition - (float)trackLine) <= 6f && minecartDY >= 0f && movingOnSlope == 0)
            {
                if (minecartDY > 0f)
                {
                    mineCartYPosition = trackLine;
                    minecartDY        = 0f;
                    if (Game1.soundBank != null)
                    {
                        Game1.soundBank.GetCue("parry").Play();
                        minecartLoop = Game1.soundBank.GetCue("minecartLoop");
                        minecartLoop.Play();
                    }
                    isJumping       = false;
                    reachedJumpApex = false;
                    createSparkShower();
                }
                if (track[6].X == 3)
                {
                    movingOnSlope = 1;
                    createSparkShower();
                }
                else if (track[6].X == 4)
                {
                    movingOnSlope = 2;
                    createSparkShower();
                }
            }
            else if (!isJumping && Math.Abs(mineCartYPosition - (float)trackLine) <= 6f && (track[6].X == 3 || track[6].X == 4))
            {
                mineCartYPosition = trackLine;
                if (mineCartYPosition == (float)trackLine && track[6].X == 3)
                {
                    movingOnSlope = 1;
                    if (respawnCounter <= 0)
                    {
                        createSparkShower(Game1.random.Next(2));
                    }
                }
                else if (mineCartYPosition == (float)trackLine && track[6].X == 4)
                {
                    movingOnSlope = 2;
                    if (respawnCounter <= 0)
                    {
                        createSparkShower(Game1.random.Next(2));
                    }
                }
                minecartDY = 0f;
            }
            else
            {
                movingOnSlope = 0;
                minecartDY   += (((reachedJumpApex || !isJumping) && mineCartYPosition != (float)trackLine) ? 0.21f : 0f);
                if (minecartDY > 0f)
                {
                    minecartDY = Math.Min(minecartDY, 9f);
                }
                if (minecartDY > 0f || minecartPositionBeforeJump - mineCartYPosition <= maxJumpHeight)
                {
                    mineCartYPosition += minecartDY;
                }
            }
            if (minecartDY > 0f && minecartLoop != null && minecartLoop.IsPlaying)
            {
                minecartLoop.Stop(AudioStopOptions.Immediate);
            }
            if (reachedFinish)
            {
                mineCartXOffset += speed * (float)time.ElapsedGameTime.Milliseconds;
                if (Game1.random.NextDouble() < 0.25)
                {
                    createSparkShower();
                }
            }
            if (mineCartXOffset > (float)(screenWidth - 6 * tileSize + tileSize))
            {
                switch (gameMode)
                {
                case 0:
                    screenDarkness += (float)time.ElapsedGameTime.Milliseconds / 2000f;
                    if (screenDarkness >= 1f)
                    {
                        if (Game1.mine != null)
                        {
                            Game1.enterMine(Game1.CurrentMineLevel + 3);
                            Game1.fadeToBlackAlpha = 1f;
                        }
                        return(true);
                    }
                    break;

                case 3:
                    screenDarkness += (float)time.ElapsedGameTime.Milliseconds / 2000f;
                    if (!(screenDarkness >= 1f))
                    {
                        break;
                    }
                    reachedFinish = false;
                    currentTheme  = (currentTheme + 1) % 6;
                    levelsBeat++;
                    if (levelsBeat == 6)
                    {
                        if (!Game1.player.hasOrWillReceiveMail("JunimoKart"))
                        {
                            Game1.addMailForTomorrow("JunimoKart");
                        }
                        Game1.multiplayer.globalChatInfoMessage("JunimoKart", Game1.player.Name);
                        unload();
                        Game1.currentMinigame = null;
                        DelayedAction.playSoundAfterDelay("discoverMineral", 1000);
                        Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:OldMineCart.cs.12106"));
                    }
                    else
                    {
                        setUpTheme(currentTheme);
                        restartLevel();
                    }
                    break;
                }
            }
            if (speedAccumulator >= (float)(tileSize / 2) && ((int)(mineCartYPosition / (float)tileSize) == obstacles[7].Y || (int)(mineCartYPosition / (float)tileSize - (float)(tileSize - 1)) == obstacles[7].Y))
            {
                switch (obstacles[7].X)
                {
                case 1:
                    Game1.playSound("woodWhack");
                    mineCartYPosition = screenHeight;
                    break;

                case 2:
                    Game1.playSound("money");
                    obstacles.RemoveAt(6);
                    obstacles.Insert(6, Point.Zero);
                    break;
                }
            }
            if (mineCartYPosition > (float)screenHeight)
            {
                mineCartYPosition = -999999f;
                livesLeft--;
                Game1.playSound("fishEscape");
                if (gameMode == 0 && (float)livesLeft < 0f)
                {
                    mineCartYPosition = 999999f;
                    livesLeft++;
                    screenDarkness += (float)time.ElapsedGameTime.Milliseconds * 0.001f;
                    if (screenDarkness >= 1f)
                    {
                        if (Game1.player.health > 1)
                        {
                            Game1.player.health = 1;
                            Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:OldMineCart.cs.12108"));
                        }
                        else
                        {
                            Game1.player.health = 0;
                        }
                        return(true);
                    }
                }
                else if (gameMode == 4 || (gameMode == 3 && livesLeft < 0))
                {
                    if (gameMode == 3)
                    {
                        levelsBeat = 0;
                        setUpTheme(5);
                    }
                    restartLevel();
                }
                else
                {
                    respawnCounter  = 1400;
                    minecartDY      = 0f;
                    isJumping       = false;
                    reachedJumpApex = false;
                    if (gameMode == 2)
                    {
                        totalMotion = 0;
                    }
                }
            }
            minecartBumpOffset = Math.Max(0f, minecartBumpOffset - 0.5f);
            for (int i = sparkShower.Count - 1; i >= 0; i--)
            {
                sparkShower[i].dy += 0.105f;
                sparkShower[i].x  += sparkShower[i].dx;
                sparkShower[i].y  += sparkShower[i].dy;
                sparkShower[i].c.B = (byte)(0.0 + Math.Max(0.0, Math.Sin((double)time.TotalGameTime.Milliseconds / (Math.PI * 20.0 / (double)sparkShower[i].dx)) * 255.0));
                if (reachedFinish)
                {
                    sparkShower[i].c.R = (byte)(0.0 + Math.Max(0.0, Math.Sin((double)(time.TotalGameTime.Milliseconds + 50) / (Math.PI * 20.0 / (double)sparkShower[i].dx)) * 255.0));
                    sparkShower[i].c.G = (byte)(0.0 + Math.Max(0.0, Math.Sin((double)(time.TotalGameTime.Milliseconds + 100) / (Math.PI * 20.0 / (double)sparkShower[i].dx)) * 255.0));
                    if (sparkShower[i].c.R == 0)
                    {
                        sparkShower[i].c.R = byte.MaxValue;
                    }
                    if (sparkShower[i].c.G == 0)
                    {
                        sparkShower[i].c.G = byte.MaxValue;
                    }
                }
                if (sparkShower[i].y > (float)screenHeight)
                {
                    sparkShower.RemoveAt(i);
                }
            }
            return(false);
        }