Ejemplo n.º 1
0
        public override void tickUpdate(GameTime time, Farmer who)
        {
            lastUser = who;
            finishEvent.Poll();
            if (!who.usingSlingshot)
            {
                return;
            }
            if (who.IsLocalPlayer)
            {
                updateAimPos();
                int mouseX = aimPos.X;
                int mouseY = aimPos.Y;
                Game1.debugOutput = "playerPos: " + who.getStandingPosition().ToString() + ", mousePos: " + mouseX + ", " + mouseY;
                mouseDragAmount++;
                who.faceGeneralDirection(new Vector2(mouseX, mouseY), 0, opposite: true);
                if (canPlaySound && (Math.Abs(mouseX - lastClickX) > 8 || Math.Abs(mouseY - lastClickY) > 8) && mouseDragAmount > 4)
                {
                    who.currentLocation.playSound("slingshot");
                    canPlaySound = false;
                }
                lastClickX        = mouseX;
                lastClickY        = mouseY;
                Game1.mouseCursor = -1;
            }
            int offset = (who.FacingDirection == 3 || who.FacingDirection == 1) ? 1 : ((who.FacingDirection == 0) ? 2 : 0);

            who.FarmerSprite.setCurrentFrame(42 + offset);
        }
Ejemplo n.º 2
0
 public virtual void UpdateEvenIfFarmerIsntHere(GameTime time)
 {
     animationEvent.Poll();
     upgradeCompleteEvent.Poll();
     upgradeMutex.Update(locationRef.Value);
     if (!Game1.IsMasterGame)
     {
         return;
     }
     if (stateTimer > 0f)
     {
         stateTimer -= (float)time.ElapsedGameTime.TotalSeconds;
     }
     if ((UpgradeState)currentState == UpgradeState.StartBuilding && stateTimer <= 0f)
     {
         currentState.Value = UpgradeState.Building;
         stateTimer         = 5f;
         if ((string)upgradeName == "Hut")
         {
             stateTimer = 0.1f;
         }
     }
     if ((UpgradeState)currentState == UpgradeState.Building && stateTimer <= 0f)
     {
         ApplyUpgrade();
         currentState.Value = UpgradeState.Complete;
         upgradeMutex.ReleaseLock();
         upgradeCompleteEvent.Fire();
     }
 }
Ejemplo n.º 3
0
 public override void UpdateWhenCurrentLocation(GameTime time)
 {
     base.UpdateWhenCurrentLocation(time);
     hitTreeEvent.Poll();
     parrotBoyEvent.Poll();
     if (hintDialogues.Count <= 0)
     {
         return;
     }
     hintShowTime  -= (float)time.ElapsedGameTime.TotalSeconds;
     hintShakeTime -= (float)time.ElapsedGameTime.TotalSeconds;
     if (!(hintShowTime <= 0f))
     {
         return;
     }
     hintDialogues.RemoveAt(0);
     if (hintDialogues.Count > 0)
     {
         if (hintDialogues.Count == 2)
         {
             hintShowTime = 3f;
         }
         else
         {
             hintShowTime = 1.5f;
         }
         hintShakeTime = 0.5f;
         Squawk();
     }
     else
     {
         hintShowTime = -1f;
     }
 }
Ejemplo n.º 4
0
 public override void updateWhenCurrentLocation(GameTime time, GameLocation environment)
 {
     if (Game1.currentLocation == environment)
     {
         if (fishDirty)
         {
             fishDirty = false;
             UpdateDecorAndFish();
         }
         foreach (TankFish item in tankFish)
         {
             item.Update(time);
         }
         for (int i = 0; i < bubbles.Count; i++)
         {
             Vector4 bubble = bubbles[i];
             bubble.W += 0.05f;
             if (bubble.W > 1f)
             {
                 bubble.W = 1f;
             }
             bubble.Y  += bubble.W;
             bubbles[i] = bubble;
             if (bubble.Y >= (float)GetTankBounds().Height)
             {
                 bubbles.RemoveAt(i);
                 i--;
             }
         }
     }
     base.updateWhenCurrentLocation(time, environment);
     refreshFishEvent.Poll();
 }
Ejemplo n.º 5
0
 public override void UpdateWhenCurrentLocation(GameTime time)
 {
     base.UpdateWhenCurrentLocation(time);
     if (gourmand != null)
     {
         gourmand.update(time, this);
         if (time.TotalGameTime.TotalMilliseconds % 1000.0 < 500.0)
         {
             gourmand.Sprite.CurrentFrame = 1;
         }
         else
         {
             gourmand.Sprite.CurrentFrame = 0;
         }
     }
     requestGourmandCheckEvent.Poll();
     gourmandResponseEvent.Poll();
     smokeTimer -= time.ElapsedGameTime.Milliseconds;
     if (smokeTimer <= 0f && smokeTexture != null)
     {
         temporarySprites.Add(new TemporaryAnimatedSprite
         {
             texture               = smokeTexture,
             sourceRect            = new Microsoft.Xna.Framework.Rectangle(0, 180, 9, 11),
             sourceRectStartingPos = new Vector2(0f, 180f),
             layerDepth            = 1f,
             interval              = 250f,
             position              = new Vector2(2f, 4f) * 64f + new Vector2(5f, 5f) * 4f,
             scale           = 4f,
             scaleChange     = 0.005f,
             alpha           = 0.75f,
             alphaFade       = 0.005f,
             motion          = new Vector2(0f, -0.5f),
             acceleration    = new Vector2((float)(Game1.random.NextDouble() - 0.5) / 100f, 0f),
             animationLength = 3,
             holdLastFrame   = true
         });
         temporarySprites.Add(new TemporaryAnimatedSprite
         {
             texture               = smokeTexture,
             sourceRect            = new Microsoft.Xna.Framework.Rectangle(0, 180, 9, 11),
             sourceRectStartingPos = new Vector2(0f, 180f),
             layerDepth            = 1f,
             interval              = 250f,
             position              = new Vector2(7f, 4f) * 64f + new Vector2(5f, 5f) * 4f,
             scale           = 4f,
             scaleChange     = 0.005f,
             alpha           = 0.75f,
             alphaFade       = 0.005f,
             motion          = new Vector2(0f, -0.5f),
             acceleration    = new Vector2((float)(Game1.random.NextDouble() - 0.5) / 100f, 0f),
             animationLength = 3,
             holdLastFrame   = true
         });
         smokeTimer = 1250f;
     }
 }
Ejemplo n.º 6
0
		public override void update(GameTime time, GameLocation location)
		{
			base.update(time, location);
			cutsceneEvent.Poll();
			eatEvent.Poll();
			if (showWantBubbleTimer > 0)
			{
				showWantBubbleTimer -= (int)time.ElapsedGameTime.TotalMilliseconds;
			}
		}
Ejemplo n.º 7
0
 public override void updateEvenIfFarmerIsntHere(GameTime time, bool ignoreWasUpdatedFlush = false)
 {
     base.updateEvenIfFarmerIsntHere(time, ignoreWasUpdatedFlush);
     bundleMutex.Update(this);
     if (bundleMutex.IsLockHeld() && Game1.activeClickableMenu == null)
     {
         bundleMutex.ReleaseLock();
     }
     restoreAreaCutsceneEvent.Poll();
 }
Ejemplo n.º 8
0
 public override void UpdateWhenCurrentLocation(GameTime time)
 {
     base.UpdateWhenCurrentLocation(time);
     bananaShrineEvent.Poll();
     if (_parrots != null)
     {
         _parrots.Update(time);
     }
     if (bananaShrineComplete.Value && Game1.random.NextDouble() < 0.005)
     {
         TemporaryAnimatedSprite t = getTemporarySpriteByID(888);
         if (t != null && t.motion.Equals(Vector2.Zero))
         {
             temporarySprites.Add(new TemporaryAnimatedSprite("TileSheets\\critters", new Microsoft.Xna.Framework.Rectangle(128, 352, 32, 32), 200 + ((Game1.random.NextDouble() < 0.1) ? Game1.random.Next(1000, 3000) : 0), 1, 1, t.position, flicker: false, flipped: false, 0.12224f, 0f, Color.White, 4f, 0f, 0f, 0f));
         }
     }
 }
Ejemplo n.º 9
0
 public override void update(GameTime time, GameLocation location)
 {
     parryEvent.Poll();
     trajectoryEvent.Poll();
     deathAnimEvent.Poll();
     position.UpdateExtrapolation(base.speed + base.addedSpeed);
     if (invincibleCountdown > 0)
     {
         invincibleCountdown -= time.ElapsedGameTime.Milliseconds;
         if (invincibleCountdown <= 0)
         {
             stopGlowing();
         }
     }
     if (location.farmers.Count != 0)
     {
         if (!Player.isRafting || !withinPlayerThreshold(4))
         {
             base.update(time, location);
         }
         if (Game1.IsMasterGame)
         {
             behaviorAtGameTick(time);
         }
         updateAnimation(time);
         if (controller != null && withinPlayerThreshold(3))
         {
             controller = null;
         }
         if (!isGlider && (base.Position.X < 0f || base.Position.X > (float)(location.Map.GetLayer("Back").LayerWidth * 64) || base.Position.Y < 0f || base.Position.Y > (float)(location.map.GetLayer("Back").LayerHeight * 64)))
         {
             location.characters.Remove(this);
         }
         else if ((bool)isGlider && base.Position.X < -2000f)
         {
             Health = -500;
         }
     }
 }
Ejemplo n.º 10
0
 public virtual void UpdateWhenCurrentLocation(GameTime time, GameLocation location)
 {
     openEvent.Poll();
     pressEvent.Poll();
     if (localPressedSwitches != pressedSwitches.Value)
     {
         localPressedSwitches = pressedSwitches.Value;
         ApplyTiles();
     }
     if (!localOpened && opened.Value)
     {
         localOpened = true;
         ApplyTiles();
     }
     foreach (Point key in switches.Keys)
     {
         if (switches[key] && !localSwitches[key])
         {
             localSwitches[key] = true;
             ApplyTiles();
         }
     }
 }
Ejemplo n.º 11
0
 public override void update(GameTime time, GameLocation location)
 {
     base.update(time, location);
     firedEvent.Poll();
 }
Ejemplo n.º 12
0
 public override void update(GameTime time, GameLocation location)
 {
     base.currentLocation = location;
     setReturnToJunimoHutToFetchStarControllerEvent.Poll();
     setBringBundleBackToHutControllerEvent.Poll();
     setJunimoReachedHutToFetchStarControllerEvent.Poll();
     starDoneSpinningEvent.Poll();
     returnToJunimoHutToFetchFinalStarEvent.Poll();
     base.update(time, location);
     forceUpdateTimer = 99999;
     if ((bool)sayingGoodbye)
     {
         flip = false;
         if ((int)whichArea % 2 == 0)
         {
             Sprite.Animate(time, 16, 8, 50f);
         }
         else
         {
             Sprite.Animate(time, 28, 4, 80f);
         }
         if (!base.IsInvisible && Game1.random.NextDouble() < 0.0099999997764825821 && yJumpOffset == 0)
         {
             jump();
             if (Game1.random.NextDouble() < 0.15 && Game1.player.getTileX() == 29 && Game1.player.getTileY() == 11)
             {
                 showTextAboveHead((Game1.random.NextDouble() < 0.5) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Junimo.cs.6625") : Game1.content.LoadString("Strings\\StringsFromCSFiles:Junimo.cs.6626"));
             }
         }
         alpha.Value += alphaChange;
         if (alpha.Value > 1f)
         {
             alpha.Value       = 1f;
             alphaChange.Value = 0f;
         }
         if ((float)alpha < 0f)
         {
             alpha.Value      = 0f;
             base.IsInvisible = true;
             base.HideShadow  = true;
         }
     }
     else if ((bool)temporaryJunimo)
     {
         Sprite.Animate(time, 12, 4, 100f);
         if (Game1.random.NextDouble() < 0.001)
         {
             jumpWithoutSound();
             location.localSound("junimoMeep1");
         }
     }
     else
     {
         if ((bool)eventActor)
         {
             return;
         }
         alpha.Value += alphaChange;
         if ((float)alpha > 1f)
         {
             alpha.Value     = 1f;
             base.HideShadow = false;
         }
         else if ((float)alpha < 0f)
         {
             alpha.Value      = 0f;
             base.IsInvisible = true;
             base.HideShadow  = true;
         }
         soundTimer--;
         farmerCloseCheckTimer -= time.ElapsedGameTime.Milliseconds;
         if ((bool)sayingGoodbye || (bool)temporaryJunimo || !Game1.IsMasterGame)
         {
             return;
         }
         if (!base.IsInvisible && farmerCloseCheckTimer <= 0 && controller == null && (float)alpha >= 1f && !stayPut && Game1.IsMasterGame)
         {
             farmerCloseCheckTimer = 100;
             if (holdingStar.Value)
             {
                 setJunimoReachedHutToFetchStarController();
             }
             else
             {
                 Farmer f = Utility.isThereAFarmerWithinDistance(getTileLocation(), 5, base.currentLocation);
                 if (f != null)
                 {
                     if ((bool)friendly && Vector2.Distance(base.Position, f.Position) > (float)(base.speed * 4))
                     {
                         if (motion.Equals(Vector2.Zero) && soundTimer <= 0)
                         {
                             jump();
                             location.localSound("junimoMeep1");
                             soundTimer = 400;
                         }
                         if (Game1.random.NextDouble() < 0.007)
                         {
                             jumpWithoutSound(Game1.random.Next(6, 9));
                         }
                         setMoving(Utility.getVelocityTowardPlayer(new Point((int)base.Position.X, (int)base.Position.Y), base.speed, f));
                     }
                     else if (!friendly)
                     {
                         fadeAway();
                         Vector2 v = Utility.getAwayFromPlayerTrajectory(GetBoundingBox(), f);
                         v.Normalize();
                         v.Y *= -1f;
                         setMoving(v * base.speed);
                     }
                     else if ((float)alpha >= 1f)
                     {
                         motion.Value = Vector2.Zero;
                     }
                 }
                 else if ((float)alpha >= 1f)
                 {
                     motion.Value = Vector2.Zero;
                 }
             }
         }
         if (!base.IsInvisible && controller == null)
         {
             nextPosition.Value = GetBoundingBox();
             nextPosition.X    += (int)motion.X;
             bool sparkle = false;
             if (!location.isCollidingPosition(nextPosition, Game1.viewport, this))
             {
                 position.X += (int)motion.X;
                 sparkle     = true;
             }
             nextPosition.X -= (int)motion.X;
             nextPosition.Y += (int)motion.Y;
             if (!location.isCollidingPosition(nextPosition, Game1.viewport, this))
             {
                 position.Y += (int)motion.Y;
                 sparkle     = true;
             }
             if (!motion.Equals(Vector2.Zero) && sparkle && Game1.random.NextDouble() < 0.005)
             {
                 location.temporarySprites.Add(new TemporaryAnimatedSprite((Game1.random.NextDouble() < 0.5) ? 10 : 11, base.Position, color)
                 {
                     motion     = motion.Value / 4f,
                     alphaFade  = 0.01f,
                     layerDepth = 0.8f,
                     scale      = 0.75f,
                     alpha      = 0.75f
                 });
             }
         }
         if (controller != null || !motion.Equals(Vector2.Zero))
         {
             if ((bool)holdingStar || (bool)holdingBundle)
             {
                 Sprite.Animate(time, 44, 4, 200f);
             }
             else if (moveRight || (Math.Abs(motion.X) > Math.Abs(motion.Y) && motion.X > 0f))
             {
                 flip = false;
                 Sprite.Animate(time, 16, 8, 50f);
             }
             else if (moveLeft || (Math.Abs(motion.X) > Math.Abs(motion.Y) && motion.X < 0f))
             {
                 Sprite.Animate(time, 16, 8, 50f);
                 flip = true;
             }
             else if (moveUp || (Math.Abs(motion.Y) > Math.Abs(motion.X) && motion.Y < 0f))
             {
                 Sprite.Animate(time, 32, 8, 50f);
             }
             else
             {
                 Sprite.Animate(time, 0, 8, 50f);
             }
         }
         else
         {
             Sprite.Animate(time, 8, 4, 100f);
         }
     }
 }
Ejemplo n.º 13
0
        public void Update()
        {
            requestLeoMove.Poll();
            requestMovieEndEvent.Poll();
            endMovieEvent.Poll();
            ringPhoneEvent.Poll();
            festivalPropRemovalEvent.Poll();
            demolishStableEvent.Poll();
            requestSpouseSleepEvent.Poll();
            requestHorseWarpEvent.Poll();
            kickOutOfMinesEvent.Poll();
            requestPetWarpHomeEvent.Poll();
            requestNutDrop.Poll();
            requestAddCharacterEvent.Poll();
            addCharacterEvent.Poll();
            addQiGemsToTeam.Poll();
            grangeMutex.Update(Game1.getOnlineFarmers());
            returnedDonationsMutex.Update(Game1.getOnlineFarmers());
            ordersBoardMutex.Update(Game1.getOnlineFarmers());
            qiChallengeBoardMutex.Update(Game1.getOnlineFarmers());
            junimoChestMutex.Update(Game1.getOnlineFarmers());
            demolishLock.Update();
            buildLock.Update(Game1.getOnlineFarmers());
            movieMutex.Update(Game1.getOnlineFarmers());
            goldenCoconutMutex.Update(Game1.getOnlineFarmers());
            if (grangeMutex.IsLockHeld() && Game1.activeClickableMenu == null)
            {
                grangeMutex.ReleaseLock();
            }
            foreach (SpecialOrder specialOrder in specialOrders)
            {
                specialOrder.Update();
            }
            foreach (ReadyCheck value in readyChecks.Values)
            {
                value.Update();
            }
            if (Game1.IsMasterGame && proposals.Count() > 0)
            {
                proposals.Filter((KeyValuePair <long, Proposal> pair) => playerIsOnline(pair.Key) && playerIsOnline(pair.Value.receiver.UID));
            }
            Proposal proposal = GetIncomingProposal();

            if (proposal != null && proposal.canceled.Value)
            {
                proposal.cancelConfirmed.Value = true;
            }
            if (Game1.dialogueUp)
            {
                return;
            }
            if (proposal != null)
            {
                if (!handleIncomingProposal(proposal))
                {
                    proposal.responseMessageKey.Value = genderedKey("Strings\\UI:Proposal_PlayerBusy", Game1.player);
                    proposal.response.Value           = ProposalResponse.Rejected;
                }
            }
            else if (Game1.activeClickableMenu == null && GetOutgoingProposal() != null)
            {
                Game1.activeClickableMenu = new PendingProposalDialog();
            }
        }
Ejemplo n.º 14
0
		public override void tickUpdate(GameTime time, Farmer who)
		{
			lastUser = who;
			base.tickUpdate(time, who);
			finishEvent.Poll();
		}
Ejemplo n.º 15
0
 public override void updateEvenIfFarmerIsntHere(GameTime time, bool skipWasUpdatedFlush = false)
 {
     base.updateEvenIfFarmerIsntHere(time, skipWasUpdatedFlush);
     statueAnimationEvent.Poll();
 }
Ejemplo n.º 16
0
        public override void tickUpdate(GameTime time, Farmer who)
        {
            lastUser = who;
            finishEvent.Poll();
            if (!who.usingSlingshot)
            {
                return;
            }
            if (who.IsLocalPlayer)
            {
                updateAimPos();
                int mouseX = aimPos.X;
                int mouseY = aimPos.Y;
                Game1.debugOutput = "playerPos: " + who.getStandingPosition().ToString() + ", mousePos: " + mouseX + ", " + mouseY;
                mouseDragAmount++;
                if (!Game1.options.useLegacySlingshotFiring)
                {
                    Vector2 shoot_origin = GetShootOrigin(who);
                    Vector2 aim_offset   = AdjustForHeight(new Vector2(mouseX, mouseY)) - shoot_origin;
                    if (Math.Abs(aim_offset.X) > Math.Abs(aim_offset.Y))
                    {
                        if (aim_offset.X < 0f)
                        {
                            who.faceDirection(3);
                        }
                        if (aim_offset.X > 0f)
                        {
                            who.faceDirection(1);
                        }
                    }
                    else
                    {
                        if (aim_offset.Y < 0f)
                        {
                            who.faceDirection(0);
                        }
                        if (aim_offset.Y > 0f)
                        {
                            who.faceDirection(2);
                        }
                    }
                }
                else
                {
                    who.faceGeneralDirection(new Vector2(mouseX, mouseY), 0, opposite: true);
                }
                if (!Game1.options.useLegacySlingshotFiring)
                {
                    if (canPlaySound && GetSlingshotChargeTime() >= 1f)
                    {
                        who.currentLocation.playSound("slingshot");
                        canPlaySound = false;
                    }
                }
                else if (canPlaySound && (Math.Abs(mouseX - lastClickX) > 8 || Math.Abs(mouseY - lastClickY) > 8) && mouseDragAmount > 4)
                {
                    who.currentLocation.playSound("slingshot");
                    canPlaySound = false;
                }
                if (!CanAutoFire())
                {
                    lastClickX = mouseX;
                    lastClickY = mouseY;
                }
                if (Game1.options.useLegacySlingshotFiring)
                {
                    Game1.mouseCursor = -1;
                }
                if (CanAutoFire())
                {
                    bool first_fire = false;
                    if (GetBackArmDistance(who) >= 20 && nextAutoFire < 0f)
                    {
                        nextAutoFire = 0f;
                        first_fire   = true;
                    }
                    if (nextAutoFire > 0f || first_fire)
                    {
                        nextAutoFire -= (float)time.ElapsedGameTime.TotalSeconds;
                        if (nextAutoFire <= 0f)
                        {
                            PerformFire(who.currentLocation, who);
                            nextAutoFire = GetAutoFireRate();
                        }
                    }
                }
            }
            int offset = ((who.FacingDirection == 3 || who.FacingDirection == 1) ? 1 : ((who.FacingDirection == 0) ? 2 : 0));

            who.FarmerSprite.setCurrentFrame(42 + offset);
        }
Ejemplo n.º 17
0
        public override void UpdateWhenCurrentLocation(GameTime time)
        {
            base.UpdateWhenCurrentLocation(time);
            moveTurtleEvent.Poll();
            if (boatLight != null)
            {
                boatLight.position.Value = new Vector2(3f, 1f) * 64f + GetBoatPosition();
            }
            if (boatStringLight != null)
            {
                boatStringLight.position.Value = new Vector2(3f, 4f) * 64f + GetBoatPosition();
            }
            if (_parrotBoyHiding && Utility.isThereAFarmerWithinDistance(new Vector2(29f, 16f), 4, this) == Game1.player)
            {
                TemporaryAnimatedSprite v = getTemporarySpriteByID(777);
                if (v != null)
                {
                    v.sourceRect.X            = 0;
                    v.sourceRectStartingPos.X = 0f;
                    v.motion          = new Vector2(3f, -10f);
                    v.acceleration    = new Vector2(0f, 0.4f);
                    v.yStopCoordinate = 992;
                    v.shakeIntensity  = 2f;
                    v.id = 888f;
                    v.reachedStopCoordinate = parrotBoyLands;
                    localSound("parrot_squawk");
                }
            }
            if (!_exitsBlocked && !_sawFlameSprite && Utility.isThereAFarmerWithinDistance(new Vector2(18f, 11f), 5, this) == Game1.player)
            {
                Game1.addMailForTomorrow("Saw_Flame_Sprite_South", noLetter: true);
                TemporaryAnimatedSprite v2 = getTemporarySpriteByID(999);
                if (v2 != null)
                {
                    v2.yPeriodic               = false;
                    v2.xPeriodic               = false;
                    v2.sourceRect.Y            = 0;
                    v2.sourceRectStartingPos.Y = 0f;
                    v2.motion       = new Vector2(0f, -4f);
                    v2.acceleration = new Vector2(0f, -0.04f);
                }
                localSound("magma_sprite_spot");
                v2 = getTemporarySpriteByID(998);
                if (v2 != null)
                {
                    v2.yPeriodic    = false;
                    v2.xPeriodic    = false;
                    v2.motion       = new Vector2(0f, -4f);
                    v2.acceleration = new Vector2(0f, -0.04f);
                }
                _sawFlameSprite = true;
            }
            if (currentEvent == null || currentEvent.id != -157039427)
            {
                return;
            }
            if (_boatDirection != 0)
            {
                _boatOffset += _boatDirection;
                foreach (NPC actor in currentEvent.actors)
                {
                    actor.shouldShadowBeOffset = true;
                    actor.drawOffset.Y         = _boatOffset;
                }
                foreach (Farmer farmerActor in currentEvent.farmerActors)
                {
                    farmerActor.shouldShadowBeOffset = true;
                    farmerActor.drawOffset.Y         = _boatOffset;
                }
            }
            if ((float)_boatDirection != 0f)
            {
                if (_nextBubble > 0f)
                {
                    _nextBubble -= (float)time.ElapsedGameTime.TotalSeconds;
                }
                else
                {
                    Microsoft.Xna.Framework.Rectangle back_rectangle = new Microsoft.Xna.Framework.Rectangle(64, 256, 192, 64);
                    back_rectangle.X += (int)GetBoatPosition().X;
                    back_rectangle.Y += (int)GetBoatPosition().Y;
                    Vector2 position2 = Utility.getRandomPositionInThisRectangle(back_rectangle, Game1.random);
                    TemporaryAnimatedSprite sprite2 = new TemporaryAnimatedSprite("TileSheets\\animations", new Microsoft.Xna.Framework.Rectangle(0, 0, 64, 64), 50f, 9, 1, position2, flicker: false, flipped: false, 0f, 0.025f, Color.White, 1f, 0f, 0f, 0f);
                    sprite2.acceleration = new Vector2(0f, -0.25f * (float)Math.Sign(_boatDirection));
                    temporarySprites.Add(sprite2);
                    _nextBubble = 0.01f;
                }
                if (_nextSlosh > 0f)
                {
                    _nextSlosh -= (float)time.ElapsedGameTime.TotalSeconds;
                }
                else
                {
                    Game1.playSound("waterSlosh");
                    _nextSlosh = 0.5f;
                }
            }
            if (_nextSmoke > 0f)
            {
                _nextSmoke -= (float)time.ElapsedGameTime.TotalSeconds;
                return;
            }
            Vector2 position = new Vector2(2f, 2.5f) * 64f + GetBoatPosition();
            TemporaryAnimatedSprite sprite = new TemporaryAnimatedSprite("TileSheets\\animations", new Microsoft.Xna.Framework.Rectangle(0, 1600, 64, 128), 200f, 9, 1, position, flicker: false, flipped: false, 1f, 0.025f, Color.White, 1f, 0.025f, 0f, 0f);

            sprite.acceleration = new Vector2(-0.25f, -0.15f);
            temporarySprites.Add(sprite);
            _nextSmoke = 0.2f;
        }
Ejemplo n.º 18
0
 public override void update(GameTime time, GameLocation location)
 {
     if (Game1.IsMasterGame && !initializedForLocation && location != null)
     {
         InitializeForLocation(location);
         initializedForLocation = true;
     }
     parryEvent.Poll();
     trajectoryEvent.Poll();
     deathAnimEvent.Poll();
     position.UpdateExtrapolation(base.speed + base.addedSpeed);
     if (invincibleCountdown > 0)
     {
         invincibleCountdown -= time.ElapsedGameTime.Milliseconds;
         if (invincibleCountdown <= 0)
         {
             stopGlowing();
         }
     }
     if (!location.farmers.Any())
     {
         return;
     }
     if (!Player.isRafting || !withinPlayerThreshold(4))
     {
         base.update(time, location);
     }
     if (Game1.IsMasterGame)
     {
         if (stunTime <= 0)
         {
             behaviorAtGameTick(time);
         }
         else
         {
             stunTime -= (int)time.ElapsedGameTime.TotalMilliseconds;
             if (stunTime < 0)
             {
                 stunTime = 0;
             }
         }
     }
     updateAnimation(time);
     if (Game1.IsMasterGame)
     {
         synchedRotation.Value = rotation;
     }
     else
     {
         rotation = synchedRotation.Value;
     }
     if (controller != null && withinPlayerThreshold(3))
     {
         controller = null;
     }
     if (!isGlider && (base.Position.X < 0f || base.Position.X > (float)(location.Map.GetLayer("Back").LayerWidth * 64) || base.Position.Y < 0f || base.Position.Y > (float)(location.map.GetLayer("Back").LayerHeight * 64)))
     {
         location.characters.Remove(this);
     }
     else if ((bool)isGlider && base.Position.X < -2000f)
     {
         Health = -500;
     }
 }
Ejemplo n.º 19
0
        public override void UpdateWhenCurrentLocation(GameTime time)
        {
            base.UpdateWhenCurrentLocation(time);
            mermaidPuzzleSuccess.Poll();
            fishWalnutEvent.Poll();
            if (!fishedWalnut && Game1.random.NextDouble() < 0.005)
            {
                playSound("waterSlosh");
                temporarySprites.Add(new TemporaryAnimatedSprite("TileSheets\\animations", new Microsoft.Xna.Framework.Rectangle(0, 0, 64, 64), 150f, 8, 0, new Vector2(1216f, 1344f), flicker: false, Game1.random.NextDouble() < 0.5, 0.001f, 0.01f, Color.White, 1f, 0.003f, 0f, 0f));
            }
            if (!MermaidIsHere())
            {
                return;
            }
            bool should_wave = false;

            if (mermaidPuzzleFinished.Value)
            {
                foreach (Farmer farmer in farmers)
                {
                    Point point = farmer.getTileLocationPoint();
                    if (point.X > 24 && point.Y > 25)
                    {
                        should_wave = true;
                        break;
                    }
                }
            }
            if (should_wave && (currentMermaidAnimation == null || currentMermaidAnimation == mermaidIdle))
            {
                currentMermaidAnimation = mermaidWave;
                mermaidFrameIndex       = 0;
                mermaidFrameTimer       = 0f;
            }
            if (mermaidDanceTime > 0f)
            {
                if (currentMermaidAnimation == null || currentMermaidAnimation == mermaidIdle)
                {
                    currentMermaidAnimation = mermaidDance;
                    mermaidFrameTimer       = 0f;
                }
                mermaidDanceTime -= (float)time.ElapsedGameTime.TotalSeconds;
                if (mermaidDanceTime < 0f && currentMermaidAnimation == mermaidDance)
                {
                    currentMermaidAnimation = mermaidIdle;
                    mermaidFrameTimer       = 0f;
                }
            }
            mermaidFrameTimer += (float)time.ElapsedGameTime.TotalSeconds;
            if (!(mermaidFrameTimer > 0.25f))
            {
                return;
            }
            mermaidFrameTimer = 0f;
            mermaidFrameIndex++;
            if (currentMermaidAnimation == null)
            {
                mermaidFrameIndex = 0;
            }
            else
            {
                if (mermaidFrameIndex < currentMermaidAnimation.Length)
                {
                    return;
                }
                mermaidFrameIndex = 0;
                if (currentMermaidAnimation == mermaidReward)
                {
                    if (should_wave)
                    {
                        currentMermaidAnimation = mermaidWave;
                    }
                    else
                    {
                        currentMermaidAnimation = mermaidIdle;
                    }
                }
                else if (!should_wave && currentMermaidAnimation == mermaidWave)
                {
                    currentMermaidAnimation = mermaidIdle;
                }
            }
        }