public override void update(GameTime time)
        {
            this.UpdateAnimationTimer(time);
            //this.UpdateHoldToDragTimer(time);

            bool wasRightDown = this.WasRightDown;
            bool isRightDown  = helper.Input.IsDown(SButton.MouseRight);

            this.WasRightDown = isRightDown;

            if (ShouldDragIcon(wasRightDown, isRightDown))
            {
                IsBeingDragged = true;

                this.xPositionOnScreen = Game1.getMouseX() - (int)iconPositionOffset.X;
                this.yPositionOnScreen = Game1.getMouseY() - (int)iconPositionOffset.Y;


                iconPositionOffset = new Vector2(Game1.getMouseX() - this.EmoteMenuButtonComponent.bounds.X, Game1.getMouseY() - this.EmoteMenuButtonComponent.bounds.Y);

                //Dont let the mouse grab the air, and set to grab at least the border
                //Horizontal position
                if (iconPositionOffset.X < 0)
                {
                    iconPositionOffset.X = 0;
                }
                else if (iconPositionOffset.X >= EmoteMenuButtonComponent.bounds.Width)
                {
                    iconPositionOffset.X = EmoteMenuButtonComponent.bounds.Width - 1;
                }

                //Vertical position
                if (iconPositionOffset.Y < 0)
                {
                    iconPositionOffset.Y = 0;
                }
                else if (iconPositionOffset.Y >= EmoteMenuButtonComponent.bounds.Height)
                {
                    iconPositionOffset.Y = EmoteMenuButtonComponent.bounds.Height - 1;
                }
            }
            else
            {
                IsBeingDragged = false;
            }

            if ((playAnimation && AnimatedEmoteIcon) /*|| (isHovering && AnimationOnHover)*/)
            {
                if (IsPlayingAnimation())
                {
                    AnimatedSpriteIcon.update(time);
                }
                else
                {
                    playAnimation = false;
                    AnimatedSpriteIcon.reset();
                }
            }
        }
 public override void update(GameTime time)
 {
     base.update(time);
     if (poof != null && poof.update(time))
     {
         poof = null;
     }
 }
Exemple #3
0
        }        //busLeftToValley

        public void update(GameTime time)
        {
            GameLocation world = Game1.currentLocation;

            if (drivingOff && !leaving)
            {
                busMotion.X -= 0.075f;
                if (busPosition.X + 512f < 0f)
                {
                    leaving = true;
                    Game1.globalFadeToBlack(busLeftToValley, 0.01f);
                }
            }

            if (driving_here && busMotion != Vector2.Zero)
            {
                Game1.player.Position    = busDoor.position;
                Game1.player.freezePause = 100;

                if (busPosition.X / 64f - defaultBusDoorPosition_X + busPositionOffset.X < 4f)
                {
                    busMotion.X = Math.Min(-1f, busMotion.X * 0.98f);
                }

                if (Math.Abs(busPosition.X - (defaultBusDoorPosition_X + busPositionOffset.X) * 64f) <= Math.Abs(busMotion.X * 1.5f))
                {
                    busPosition.X = (defaultBusDoorPosition_X + busPositionOffset.X) * 64f;
                    busMotion     = Vector2.Zero;
                    Game1.globalFadeToBlack(delegate {
                        driving_here     = false;
                        busDoor.Position = busPosition - busPositionOffset * 64f + busDoorPositionOffset * 64f;
                        busDoor.pingPong = true;
                        busDoor.interval = 70f;
                        busDoor.currentParentTileIndex = 5;
                        busDoor.endFunction            = exitBus;
                        world.localSound("trashcanlid");
                        Game1.globalFadeToClear();
                    });
                }
            }

            if (busMotion != Vector2.Zero)
            {
                busPosition += busMotion;
                if (busDoor != null)
                {
                    busDoor.Position += busMotion;
                }
            }

            if (busDoor != null)
            {
                busDoor.update(time);
            }
        }        //update
Exemple #4
0
        public override void update(GameTime time)
        {
            this.UpdateAnimationTimer(time);
            //this.UpdateHoldToDragTimer(time);

            if (ShouldDragIcon())
            {
                IsBeingDragged = true;

                this.targetRect.X = Game1.getMouseX() - (int)iconPositionOffset.X;
                this.targetRect.Y = Game1.getMouseY() - (int)iconPositionOffset.Y;


                iconPositionOffset = new Vector2(Game1.getMouseX() - this.emoteMenuIcon.bounds.X, Game1.getMouseY() - this.emoteMenuIcon.bounds.Y);

                //Dont let the mouse grab the air, and set to grab at least the border
                //Horizontal position
                if (iconPositionOffset.X < 0)
                {
                    iconPositionOffset.X = 0;
                }
                else if (iconPositionOffset.X >= emoteMenuIcon.bounds.Width)
                {
                    iconPositionOffset.X = emoteMenuIcon.bounds.Width - 1;
                }

                //Vertical position
                if (iconPositionOffset.Y < 0)
                {
                    iconPositionOffset.Y = 0;
                }
                else if (iconPositionOffset.Y >= emoteMenuIcon.bounds.Height)
                {
                    iconPositionOffset.Y = emoteMenuIcon.bounds.Height - 1;
                }
            }
            else
            {
                IsBeingDragged = false;
            }

            if ((playAnimation && AnimatedEmoteIcon) /*|| (isHovering && AnimationOnHover)*/)
            {
                if (IsPlayingAnimation())
                {
                    iconAnimation.update(time);
                }
                else
                {
                    playAnimation = false;
                    iconAnimation.reset();
                }
            }
        }
Exemple #5
0
 public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
 {
     base.draw(spriteBatch, x, y, alpha);
     if (screen != null)
     {
         screen.update(Game1.currentGameTime);
         screen.draw(spriteBatch);
         if (screenOverlay != null)
         {
             screenOverlay.update(Game1.currentGameTime);
             screenOverlay.draw(spriteBatch);
         }
     }
 }
 private void updateShippingBinLid(GameTime time)
 {
     if (isShippingBinLidOpen(requiredToBeFullyOpen: true) && shippingBinLid.pingPongMotion == 1)
     {
         shippingBinLid.paused = true;
     }
     else if (shippingBinLid.currentParentTileIndex == 0 && shippingBinLid.pingPongMotion == -1)
     {
         if (!shippingBinLid.paused && Game1.currentLocation.Equals(farm))
         {
             farm.localSound("woodyStep");
         }
         shippingBinLid.paused = true;
     }
     shippingBinLid.update(time);
 }
Exemple #7
0
 public override void UpdateWhenCurrentLocation(GameTime time)
 {
     base.UpdateWhenCurrentLocation(time);
     if (minecartSteam != null)
     {
         minecartSteam.update(time);
     }
     if ((bool)landslide && (int)((Game1.currentGameTime.TotalGameTime.TotalMilliseconds - 400.0) / 1600.0) % 2 != 0 && Utility.isOnScreen(new Point(landSlideRect.X / 64, landSlideRect.Y / 64), 128))
     {
         if (Game1.currentGameTime.TotalGameTime.TotalMilliseconds % 400.0 < (double)(oldTime % 400))
         {
             localSound("hammer");
         }
         oldTime = (int)time.TotalGameTime.TotalMilliseconds;
     }
 }
Exemple #8
0
 public bool Update(GameTime time, GameLocation location)
 {
     if (Game1.IsMasterGame)
     {
         position.X += (float)time.ElapsedGameTime.Milliseconds * speed;
     }
     wheelRotation += (float)time.ElapsedGameTime.Milliseconds * ((float)Math.PI / 256f);
     wheelRotation %= (float)Math.PI * 2f;
     if (!Game1.eventUp && location.Equals(Game1.currentLocation))
     {
         Farmer player = Game1.player;
         if (player.GetBoundingBox().Intersects(getBoundingBox()))
         {
             player.xVelocity = 8f;
             player.yVelocity = (float)(getBoundingBox().Center.Y - player.GetBoundingBox().Center.Y) / 4f;
             player.takeDamage(20, overrideParry: true, null);
             if (player.UsingTool)
             {
                 Game1.playSound("clank");
             }
         }
     }
     if (Game1.random.NextDouble() < 0.001 && location.Equals(Game1.currentLocation))
     {
         Game1.playSound("trainWhistle");
         whistleSteam = new TemporaryAnimatedSprite(27, new Vector2(position.X - 250f, 2624f), Color.White, 8, flipped: false, 100f, 0, 64, 1f, 64);
     }
     if (whistleSteam != null)
     {
         whistleSteam.Position = new Vector2(position.X - 258f, 2592f);
         if (whistleSteam.update(time))
         {
             whistleSteam = null;
         }
     }
     smokeTimer -= time.ElapsedGameTime.Milliseconds;
     if (smokeTimer <= 0f)
     {
         location.temporarySprites.Add(new TemporaryAnimatedSprite(25, new Vector2(position.X - 170f, 2496f), Color.White, 8, flipped: false, 100f, 0, 64, 1f, 128));
         smokeTimer = speed * 2000f;
     }
     if (position.X > (float)(cars.Count * 128 * 4 + 4480))
     {
         return(true);
     }
     return(false);
 }
Exemple #9
0
        public void Update(GameTime time)
        {
            sprite.update(time);

            if (completionTimer > 0 && EndgameBundleMenu.screenSwipe is null)
            {
                completionTimer -= time.ElapsedGameTime.Milliseconds;

                if (completionTimer <= 0)
                {
                    CompletionAnimation();
                }
            }

            if (Game1.random.NextDouble() < 0.005 && (complete || name.ToLower().Contains(Game1.currentSeason)))
            {
                Shake();
            }

            if (maxShake > 0f)
            {
                if (shakeLeft)
                {
                    sprite.rotation -= (float)Math.PI / 200f;

                    if (sprite.rotation <= 0f - maxShake)
                    {
                        shakeLeft = false;
                    }
                }
                else
                {
                    sprite.rotation += (float)Math.PI / 200f;

                    if (sprite.rotation >= maxShake)
                    {
                        shakeLeft = true;
                    }
                }
            }

            if (maxShake > 0f)
            {
                maxShake = Math.Max(0f, maxShake - 0.0007669904f);
            }
        }
Exemple #10
0
        public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1)
        {
            SetScreenScale();
            TemporaryAnimatedSprite sprite = (TemporaryAnimatedSprite)typeof(TV).GetField("screen", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this);

            if (sprite != null)
            {
                spriteBatch.Draw(backgroundTexture, ModEntry.api.GetScreenRectangle(), Color.White);
                sprite.scale = GetScale(sprite.sourceRect);
                typeof(TV).GetField("screen", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(this, sprite);
                sprite.update(Game1.currentGameTime);
                sprite.draw(spriteBatch, true, 0, 0, 1f);
                TemporaryAnimatedSprite sprite2 = (TemporaryAnimatedSprite)typeof(TV).GetField("screenOverlay", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this);
                if (sprite2 != null)
                {
                    sprite2.scale = GetScale(sprite2.sourceRect);
                    typeof(TV).GetField("screenOverlay", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(this, sprite2);
                    sprite2.update(Game1.currentGameTime);
                    sprite2.draw(spriteBatch, true, 0, 0, 1f);
                }
            }
        }
Exemple #11
0
 public override void UpdateWhenCurrentLocation(GameTime time)
 {
     base.UpdateWhenCurrentLocation(time);
     if (forceWarpTimer > 0)
     {
         forceWarpTimer -= time.ElapsedGameTime.Milliseconds;
         if (forceWarpTimer <= 0)
         {
             playerReachedBusDoor(Game1.player, this);
         }
     }
     if (minecartSteam != null)
     {
         minecartSteam.update(time);
     }
     if (drivingOff && !leaving)
     {
         busMotion.X -= 0.075f;
         if (busPosition.X + 512f < 0f)
         {
             leaving = true;
             busLeftToDesert();
         }
     }
     if (drivingBack && busMotion != Vector2.Zero)
     {
         Game1.player.Position = busPosition;
         if (busPosition.X - 704f < 256f)
         {
             busMotion.X = Math.Min(-1f, busMotion.X * 0.98f);
         }
         if (Math.Abs(busPosition.X - 704f) <= Math.Abs(busMotion.X * 1.5f))
         {
             busPosition.X = 704f;
             busMotion     = Vector2.Zero;
             Game1.globalFadeToBlack(delegate
             {
                 drivingBack      = false;
                 busDoor.Position = busPosition + new Vector2(16f, 26f) * 4f;
                 busDoor.pingPong = true;
                 busDoor.interval = 70f;
                 busDoor.currentParentTileIndex = 5;
                 busDoor.endFunction            = doorOpenAfterReturn;
                 localSound("trashcanlid");
                 if (Game1.player.horseName.Value != null && Game1.player.horseName.Value != "")
                 {
                     for (int i = 0; i < characters.Count; i++)
                     {
                         if (characters[i] is Horse && (characters[i] as Horse).getOwner() == Game1.player)
                         {
                             if (characters[i].Name == null || characters[i].Name.Length == 0)
                             {
                                 Game1.showGlobalMessage(Game1.content.LoadString("Strings\\Locations:BusStop_ReturnToHorse2", characters[i].displayName));
                             }
                             else
                             {
                                 Game1.showGlobalMessage(Game1.content.LoadString("Strings\\Locations:BusStop_ReturnToHorse" + (Game1.random.Next(2) + 1), characters[i].displayName));
                             }
                             break;
                         }
                     }
                 }
                 Game1.globalFadeToClear();
             });
         }
     }
     if (!busMotion.Equals(Vector2.Zero))
     {
         busPosition += busMotion;
         if (busDoor != null)
         {
             busDoor.Position += busMotion;
         }
     }
     if (busDoor != null)
     {
         busDoor.update(time);
     }
 }
Exemple #12
0
 public void Update(xTile.Dimensions.Rectangle viewport)
 {
     //offset += new Vector2( 25, 0 );
     planet?.update(Game1.currentGameTime);
 }
Exemple #13
0
        public override void update(GameTime time)
        {
            base.update(time);
            for (var index = _fluffSprites.Count - 1;
                 index >= 0;
                 --index)
            {
                if (_fluffSprites[index]
                    .update(time))
                {
                    _fluffSprites.RemoveAt(index);
                }
            }

            if (_alertTimer > 0)
            {
                _alertTimer -= time.ElapsedGameTime.Milliseconds;
            }
            if (GeodeAnimationTimer <= 0)
            {
                return;
            }
            GeodeAnimationTimer -= time.ElapsedGameTime.Milliseconds;
            if (GeodeAnimationTimer <= 0)
            {
                _geodeDestructionAnimation = null;
                GeodeSpot.item             = null;
                Game1.player.addItemToInventoryBool(_geodeTreasure);
                _geodeTreasure  = null;
                _yPositionOfGem = 0;
                _fluffSprites.Clear();
                _delayBeforeShowArtifactTimer = 0.0f;
            }
            else
            {
                var currentFrame = _clint.currentFrame;
                _clint.animateOnce(time);
                if (_clint.currentFrame == 11 && currentFrame != 11)
                {
                    if (GeodeSpot.item != null && GeodeSpot.item.ParentSheetIndex == 275)
                    {
                        Game1.playSound("hammer");
                        Game1.playSound("woodWhack");
                    }
                    else
                    {
                        Game1.playSound("hammer");
                        Game1.playSound("stoneCrack");
                    }

                    Game1.player.gainExperience(Farmer.miningSkill,
                                                3);
                    ++Game1.stats.GeodesCracked;
                    var y = 448;
                    if (GeodeSpot.item != null)
                    {
                        switch (((Object)GeodeSpot.item).ParentSheetIndex)
                        {
                        case 536:
                            y += 64;
                            break;

                        case 537:
                            y += 128;
                            break;
                        }

                        _geodeDestructionAnimation = new TemporaryAnimatedSprite("TileSheets\\animations",
                                                                                 new Rectangle(0,
                                                                                               y,
                                                                                               64,
                                                                                               64),
                                                                                 100f,
                                                                                 8,
                                                                                 0,
                                                                                 new Vector2(GeodeSpot.bounds.X + 285 - 32,
                                                                                             GeodeSpot.bounds.Y + 150 - 32),
                                                                                 false,
                                                                                 false);
                        if (GeodeSpot.item != null && GeodeSpot.item.ParentSheetIndex == 275)
                        {
                            _geodeDestructionAnimation = new TemporaryAnimatedSprite
                            {
                                texture    = Game1.temporaryContent.Load <Texture2D>("LooseSprites//temporary_sprites_1"),
                                sourceRect = new Rectangle(388,
                                                           123,
                                                           18,
                                                           21),
                                sourceRectStartingPos = new Vector2(388f,
                                                                    123f),
                                animationLength = 6,
                                position        = new Vector2(GeodeSpot.bounds.X + 273 - 32,
                                                              GeodeSpot.bounds.Y + 150 - 32),
                                holdLastFrame = true,
                                interval      = 100f,
                                id            = 777f,
                                scale         = 4f
                            };
                            for (var index = 0;
                                 index < 6;
                                 ++index)
                            {
                                _fluffSprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors",
                                                                              new Rectangle(372,
                                                                                            1956,
                                                                                            10,
                                                                                            10),
                                                                              new Vector2(GeodeSpot.bounds.X + 285 - 32 + Game1.random.Next(21),
                                                                                          GeodeSpot.bounds.Y + 150 - 16),
                                                                              false,
                                                                              1f / 500f,
                                                                              new Color(byte.MaxValue,
                                                                                        222,
                                                                                        198))
                                {
                                    alphaFade = 0.02f,
                                    motion    = new Vector2(Game1.random.Next(-20,
                                                                              21) /
                                                            10f,
                                                            Game1.random.Next(5,
                                                                              20) /
                                                            10f),
                                    interval       = 99999f,
                                    layerDepth     = 0.9f,
                                    scale          = 3f,
                                    scaleChange    = 0.01f,
                                    rotationChange = (float)(Game1.random.Next(-5,
                                                                               6) *
                                                             3.14159274101257 /
                                                             256.0),
                                    delayBeforeAnimationStart = index * 20
                                });
                                _fluffSprites.Add(new TemporaryAnimatedSprite
                                {
                                    texture = Game1.temporaryContent.Load <Texture2D>(
                                        "LooseSprites//temporary_sprites_1"),
                                    sourceRect = new Rectangle(499,
                                                               132,
                                                               5,
                                                               5),
                                    sourceRectStartingPos = new Vector2(499f,
                                                                        132f),
                                    motion = new Vector2(Game1.random.Next(-30,
                                                                           31) /
                                                         10f,
                                                         Game1.random.Next(-7,
                                                                           -4)),
                                    acceleration = new Vector2(0.0f,
                                                               0.25f),
                                    totalNumberOfLoops = 1,
                                    interval           = 1000f,
                                    alphaFade          = 0.015f,
                                    animationLength    = 1,
                                    layerDepth         = 1f,
                                    scale          = 4f,
                                    rotationChange = (float)(Game1.random.Next(-5,
                                                                               6) *
                                                             3.14159274101257 /
                                                             256.0),
                                    delayBeforeAnimationStart = index * 10,
                                    position = new Vector2(GeodeSpot.bounds.X + 285 - 32 + Game1.random.Next(21),
                                                           GeodeSpot.bounds.Y + 150 - 16)
                                });
                                _delayBeforeShowArtifactTimer = 100f;
                            }
                        }

                        _geodeTreasure = Utility.getTreasureFromGeode(GeodeSpot.item);
                        if (GeodeSpot.item.ParentSheetIndex == 275)
                        {
                            Game1.player.foundArtifact(_geodeTreasure.ParentSheetIndex,
                                                       1);
                        }
                        else if (_geodeTreasure.Type.Contains("Mineral"))
                        {
                            Game1.player.foundMineral(_geodeTreasure.ParentSheetIndex);
                        }
                        else if (_geodeTreasure.Type.Contains("Arch") &&
                                 !Game1.player.hasOrWillReceiveMail("artifactFound"))
                        {
                            _geodeTreasure = new Object(390,
                                                        5);
                        }
                    }
                }

                if (_geodeDestructionAnimation != null &&
                    (_geodeDestructionAnimation.id != 777f && _geodeDestructionAnimation.currentParentTileIndex < 7 ||
                     _geodeDestructionAnimation.id == 777f && _geodeDestructionAnimation.currentParentTileIndex < 5))
                {
                    _geodeDestructionAnimation.update(time);
                    if (_delayBeforeShowArtifactTimer > 0.0)
                    {
                        _delayBeforeShowArtifactTimer -= (float)time.ElapsedGameTime.TotalMilliseconds;
                        if (_delayBeforeShowArtifactTimer <= 0.0)
                        {
                            _fluffSprites.Add(_geodeDestructionAnimation);
                            _fluffSprites.Reverse();
                            _geodeDestructionAnimation = new TemporaryAnimatedSprite
                            {
                                interval        = 50f,
                                animationLength = 2,
                                alpha           = 1f / 1000f,
                                id = 777f
                            };
                        }
                    }
                    else
                    {
                        if (_geodeDestructionAnimation.currentParentTileIndex < 3)
                        {
                            --_yPositionOfGem;
                        }
                        --_yPositionOfGem;
                        if ((_geodeDestructionAnimation.currentParentTileIndex == 7 ||
                             _geodeDestructionAnimation.id == 777f &&
                             _geodeDestructionAnimation.currentParentTileIndex == 5) &&
                            _geodeTreasure.Price > 75)
                        {
                            _sparkle = new TemporaryAnimatedSprite("TileSheets\\animations",
                                                                   new Rectangle(0,
                                                                                 640,
                                                                                 64,
                                                                                 64),
                                                                   100f,
                                                                   8,
                                                                   0,
                                                                   new Vector2(GeodeSpot.bounds.X + 285 - 32,
                                                                               GeodeSpot.bounds.Y + 150 + _yPositionOfGem - 32),
                                                                   false,
                                                                   false);
                            Game1.playSound("discoverMineral");
                        }
                        else if ((_geodeDestructionAnimation.currentParentTileIndex == 7 ||
                                  _geodeDestructionAnimation.id == 777f &&
                                  _geodeDestructionAnimation.currentParentTileIndex == 5) &&
                                 _geodeTreasure.Price <= 75)
                        {
                            Game1.playSound("newArtifact");
                        }
                    }
                }

                if (_sparkle == null || !_sparkle.update(time))
                {
                    return;
                }
                _sparkle = null;
            }
        }
Exemple #14
0
        public override void update(GameTime time)
        {
            base.update(time);
            for (int j = fluffSprites.Count - 1; j >= 0; j--)
            {
                if (fluffSprites[j].update(time))
                {
                    fluffSprites.RemoveAt(j);
                }
            }
            if (alertTimer > 0)
            {
                alertTimer -= time.ElapsedGameTime.Milliseconds;
            }
            if (geodeAnimationTimer <= 0)
            {
                return;
            }
            Game1.changeMusicTrack("none");
            geodeAnimationTimer -= time.ElapsedGameTime.Milliseconds;
            if (geodeAnimationTimer <= 0)
            {
                geodeDestructionAnimation = null;
                geodeSpot.item            = null;
                Game1.player.addItemToInventoryBool(geodeTreasure);
                geodeTreasure  = null;
                yPositionOfGem = 0;
                fluffSprites.Clear();
                delayBeforeShowArtifactTimer = 0f;
                return;
            }
            int frame = clint.currentFrame;

            clint.animateOnce(time);
            if (clint.currentFrame == 11 && frame != 11)
            {
                if (geodeSpot.item != null && (int)geodeSpot.item.parentSheetIndex == 275)
                {
                    Game1.playSound("hammer");
                    Game1.playSound("woodWhack");
                }
                else
                {
                    Game1.playSound("hammer");
                    Game1.playSound("stoneCrack");
                }
                Game1.stats.GeodesCracked++;
                int geodeDestructionYOffset = 448;
                if (geodeSpot.item != null)
                {
                    switch ((int)(geodeSpot.item as Object).parentSheetIndex)
                    {
                    case 536:
                        geodeDestructionYOffset += 64;
                        break;

                    case 537:
                        geodeDestructionYOffset += 128;
                        break;
                    }
                    geodeDestructionAnimation = new TemporaryAnimatedSprite("TileSheets\\animations", new Rectangle(0, geodeDestructionYOffset, 64, 64), 100f, 8, 0, new Vector2(geodeSpot.bounds.X + 392 - 32, geodeSpot.bounds.Y + 192 - 32), flicker: false, flipped: false);
                    if (geodeSpot.item != null && (int)geodeSpot.item.parentSheetIndex == 275)
                    {
                        geodeDestructionAnimation = new TemporaryAnimatedSprite
                        {
                            texture               = Game1.temporaryContent.Load <Texture2D>("LooseSprites//temporary_sprites_1"),
                            sourceRect            = new Rectangle(388, 123, 18, 21),
                            sourceRectStartingPos = new Vector2(388f, 123f),
                            animationLength       = 6,
                            position              = new Vector2(geodeSpot.bounds.X + 380 - 32, geodeSpot.bounds.Y + 192 - 32),
                            holdLastFrame         = true,
                            interval              = 100f,
                            id    = 777f,
                            scale = 4f
                        };
                        for (int i = 0; i < 6; i++)
                        {
                            fluffSprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(372, 1956, 10, 10), new Vector2(geodeSpot.bounds.X + 392 - 32 + Game1.random.Next(21), geodeSpot.bounds.Y + 192 - 16), flipped: false, 0.002f, new Color(255, 222, 198))
                            {
                                alphaFade                 = 0.02f,
                                motion                    = new Vector2((float)Game1.random.Next(-20, 21) / 10f, (float)Game1.random.Next(5, 20) / 10f),
                                interval                  = 99999f,
                                layerDepth                = 0.9f,
                                scale                     = 3f,
                                scaleChange               = 0.01f,
                                rotationChange            = (float)Game1.random.Next(-5, 6) * (float)Math.PI / 256f,
                                delayBeforeAnimationStart = i * 20
                            });
                            fluffSprites.Add(new TemporaryAnimatedSprite
                            {
                                texture               = Game1.temporaryContent.Load <Texture2D>("LooseSprites//temporary_sprites_1"),
                                sourceRect            = new Rectangle(499, 132, 5, 5),
                                sourceRectStartingPos = new Vector2(499f, 132f),
                                motion             = new Vector2((float)Game1.random.Next(-30, 31) / 10f, Game1.random.Next(-7, -4)),
                                acceleration       = new Vector2(0f, 0.25f),
                                totalNumberOfLoops = 1,
                                interval           = 1000f,
                                alphaFade          = 0.015f,
                                animationLength    = 1,
                                layerDepth         = 1f,
                                scale                     = 4f,
                                rotationChange            = (float)Game1.random.Next(-5, 6) * (float)Math.PI / 256f,
                                delayBeforeAnimationStart = i * 10,
                                position                  = new Vector2(geodeSpot.bounds.X + 392 - 32 + Game1.random.Next(21), geodeSpot.bounds.Y + 192 - 16)
                            });
                            delayBeforeShowArtifactTimer = 500f;
                        }
                    }
                    geodeTreasure = Utility.getTreasureFromGeode(geodeSpot.item);
                    if ((int)geodeSpot.item.parentSheetIndex == 275)
                    {
                        Game1.player.foundArtifact(geodeTreasure.parentSheetIndex, 1);
                    }
                    else if (geodeTreasure.Type.Contains("Mineral"))
                    {
                        Game1.player.foundMineral(geodeTreasure.parentSheetIndex);
                    }
                    else if (geodeTreasure.Type.Contains("Arch") && !Game1.player.hasOrWillReceiveMail("artifactFound"))
                    {
                        geodeTreasure = new Object(390, 5);
                    }
                }
            }
            if (geodeDestructionAnimation != null && ((geodeDestructionAnimation.id != 777f && geodeDestructionAnimation.currentParentTileIndex < 7) || (geodeDestructionAnimation.id == 777f && geodeDestructionAnimation.currentParentTileIndex < 5)))
            {
                geodeDestructionAnimation.update(time);
                if (delayBeforeShowArtifactTimer > 0f)
                {
                    delayBeforeShowArtifactTimer -= (float)time.ElapsedGameTime.TotalMilliseconds;
                    if (delayBeforeShowArtifactTimer <= 0f)
                    {
                        fluffSprites.Add(geodeDestructionAnimation);
                        fluffSprites.Reverse();
                        geodeDestructionAnimation = new TemporaryAnimatedSprite
                        {
                            interval        = 100f,
                            animationLength = 6,
                            alpha           = 0.001f,
                            id = 777f
                        };
                    }
                }
                else
                {
                    if (geodeDestructionAnimation.currentParentTileIndex < 3)
                    {
                        yPositionOfGem--;
                    }
                    yPositionOfGem--;
                    if ((geodeDestructionAnimation.currentParentTileIndex == 7 || (geodeDestructionAnimation.id == 777f && geodeDestructionAnimation.currentParentTileIndex == 5)) && (int)geodeTreasure.price > 75)
                    {
                        sparkle = new TemporaryAnimatedSprite("TileSheets\\animations", new Rectangle(0, 640, 64, 64), 100f, 8, 0, new Vector2(geodeSpot.bounds.X + 392 - 32, geodeSpot.bounds.Y + 192 + yPositionOfGem - 32), flicker: false, flipped: false);
                        Game1.playSound("discoverMineral");
                    }
                    else if ((geodeDestructionAnimation.currentParentTileIndex == 7 || (geodeDestructionAnimation.id == 777f && geodeDestructionAnimation.currentParentTileIndex == 5)) && (int)geodeTreasure.price <= 75)
                    {
                        Game1.playSound("newArtifact");
                    }
                }
            }
            if (sparkle != null && sparkle.update(time))
            {
                sparkle = null;
            }
        }
 public void update(GameTime time)
 {
     sprite.update(time);
 }
Exemple #16
0
 public override void UpdateWhenCurrentLocation(GameTime time)
 {
     base.UpdateWhenCurrentLocation(time);
     if (drivingOff && !leaving)
     {
         busMotion.X -= 0.075f;
         if (busPosition.X + 512f < 0f)
         {
             leaving = true;
             Game1.globalFadeToBlack(busLeftToValley, 0.01f);
         }
     }
     if (drivingBack && busMotion != Vector2.Zero)
     {
         Game1.player.Position    = busDoor.position;
         Game1.player.freezePause = 100;
         if (busPosition.X - 1088f < 256f)
         {
             busMotion.X = Math.Min(-1f, busMotion.X * 0.98f);
         }
         if (Math.Abs(busPosition.X - 1088f) <= Math.Abs(busMotion.X * 1.5f))
         {
             busPosition.X = 1088f;
             busMotion     = Vector2.Zero;
             Game1.globalFadeToBlack(delegate
             {
                 drivingBack      = false;
                 busDoor.Position = busPosition + new Vector2(16f, 26f) * 4f;
                 busDoor.pingPong = true;
                 busDoor.interval = 70f;
                 busDoor.currentParentTileIndex = 5;
                 busDoor.endFunction            = doorOpenAfterReturn;
                 localSound("trashcanlid");
                 Game1.globalFadeToClear();
             });
         }
     }
     if (!busMotion.Equals(Vector2.Zero))
     {
         busPosition += busMotion;
         if (busDoor != null)
         {
             busDoor.Position += busMotion;
         }
     }
     if (busDoor != null)
     {
         busDoor.update(time);
     }
     if (isTravelingDeserteMerchantHere())
     {
         chimneyTimer -= time.ElapsedGameTime.Milliseconds;
         if (chimneyTimer <= 0)
         {
             chimneyTimer = 500;
             Vector2 smokeSpot = new Vector2(670f, 308f) * 4f;
             temporarySprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Microsoft.Xna.Framework.Rectangle(372, 1956, 10, 10), smokeSpot, flipped: false, 0.002f, new Color(255, 222, 198))
             {
                 alpha          = 0.05f,
                 alphaFade      = -0.01f,
                 alphaFadeFade  = -8E-05f,
                 motion         = new Vector2(0f, -0.5f),
                 acceleration   = new Vector2(0.002f, 0f),
                 interval       = 99999f,
                 layerDepth     = 1f,
                 scale          = 3f,
                 scaleChange    = 0.01f,
                 rotationChange = (float)Game1.random.Next(-5, 6) * (float)Math.PI / 256f
             });
         }
     }
 }
        public override void update(GameTime time)
        {
            base.update(time);
            for (var j = _fluffSprites.Count - 1; j >= 0; j--)
            {
                if (_fluffSprites[j].update(time))
                {
                    _fluffSprites.RemoveAt(j);
                }
            }

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

            if (GeodeAnimationTimer <= 0)
            {
                return;
            }

            Game1.changeMusicTrack("none");
            GeodeAnimationTimer -= time.ElapsedGameTime.Milliseconds;
            if (GeodeAnimationTimer <= 0)
            {
                _geodeDestructionAnimation = null;
                GeodeSpot.item             = null;
                if (_geodeTreasure != null && Utility.IsNormalObjectAtParentSheetIndex(_geodeTreasure, 73))
                {
                    Game1.netWorldState.Value.GoldenCoconutCracked.Value = true;
                }

                Game1.player.addItemToInventoryBool(_geodeTreasure);
                _geodeTreasure  = null;
                _yPositionOfGem = 0;
                _fluffSprites.Clear();
                _delayBeforeShowArtifactTimer = 0f;
                return;
            }

            var frame = _clint.currentFrame;

            _clint.animateOnce(time);
            if (_clint.currentFrame == 11 && frame != 11)
            {
                if (GeodeSpot.item != null && GeodeSpot.item.ParentSheetIndex == 275)
                {
                    Game1.playSound("hammer");
                    Game1.playSound("woodWhack");
                }
                else
                {
                    Game1.playSound("hammer");
                    Game1.playSound("stoneCrack");
                }

                Game1.stats.GeodesCracked++;
                var geodeDestructionYOffset = 448;
                if (GeodeSpot.item != null)
                {
                    switch (((Object)GeodeSpot.item).ParentSheetIndex)
                    {
                    case 536:
                        geodeDestructionYOffset += 64;
                        break;

                    case 537:
                        geodeDestructionYOffset += 128;
                        break;
                    }

                    _geodeDestructionAnimation = new TemporaryAnimatedSprite("TileSheets\\animations",
                                                                             new Rectangle(0, geodeDestructionYOffset, 64, 64), 100f, 8, 0,
                                                                             new Vector2(GeodeSpot.bounds.X + 285 - 32, GeodeSpot.bounds.Y + 150 - 32), false,
                                                                             false);
                    if (GeodeSpot.item != null && GeodeSpot.item.ParentSheetIndex == 275)
                    {
                        _geodeDestructionAnimation = new TemporaryAnimatedSprite
                        {
                            texture               = Game1.temporaryContent.Load <Texture2D>("LooseSprites//temporary_sprites_1"),
                            sourceRect            = new Rectangle(388, 123, 18, 21),
                            sourceRectStartingPos = new Vector2(388f, 123f),
                            animationLength       = 6,
                            position              = new Vector2(GeodeSpot.bounds.X + 273 - 32, GeodeSpot.bounds.Y + 150 - 32),
                            holdLastFrame         = true,
                            interval              = 100f,
                            id    = 777f,
                            scale = 4f
                        };
                        for (var i = 0; i < 6; i++)
                        {
                            _fluffSprites.Add(
                                new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(372, 1956, 10, 10),
                                                            new Vector2(GeodeSpot.bounds.X + 285 - 32 + Game1.random.Next(21),
                                                                        GeodeSpot.bounds.Y + 150 - 16), false, 0.002f,
                                                            new Color(255, 222, 198))
                            {
                                alphaFade = 0.02f,
                                motion    =
                                    new Vector2(Game1.random.Next(-20, 21) / 10f, Game1.random.Next(5, 20) / 10f),
                                interval                  = 99999f,
                                layerDepth                = 0.9f,
                                scale                     = 3f,
                                scaleChange               = 0.01f,
                                rotationChange            = Game1.random.Next(-5, 6) * (float)Math.PI / 256f,
                                delayBeforeAnimationStart = i * 20
                            });
                            _fluffSprites.Add(new TemporaryAnimatedSprite
                            {
                                texture =
                                    Game1.temporaryContent.Load <Texture2D>("LooseSprites//temporary_sprites_1"),
                                sourceRect            = new Rectangle(499, 132, 5, 5),
                                sourceRectStartingPos = new Vector2(499f, 132f),
                                motion             = new Vector2(Game1.random.Next(-30, 31) / 10f, Game1.random.Next(-7, -4)),
                                acceleration       = new Vector2(0f, 0.25f),
                                totalNumberOfLoops = 1,
                                interval           = 1000f,
                                alphaFade          = 0.015f,
                                animationLength    = 1,
                                layerDepth         = 1f,
                                scale                     = 4f,
                                rotationChange            = Game1.random.Next(-5, 6) * (float)Math.PI / 256f,
                                delayBeforeAnimationStart = i * 10,
                                position                  = new Vector2(GeodeSpot.bounds.X + 285 - 32 + Game1.random.Next(21),
                                                                        GeodeSpot.bounds.Y + 150 - 16)
                            });
                            _delayBeforeShowArtifactTimer = 500f;
                        }
                    }

                    if (_geodeTreasureOverride != null)
                    {
                        _geodeTreasure         = _geodeTreasureOverride;
                        _geodeTreasureOverride = null;
                    }
                    else
                    {
                        _geodeTreasure = Utility.getTreasureFromGeode(GeodeSpot.item);
                    }

                    if (GeodeSpot.item.ParentSheetIndex == 275)
                    {
                        Game1.player.foundArtifact(_geodeTreasure.ParentSheetIndex, 1);
                    }
                    else
                    {
                        switch (_geodeTreasure)
                        {
                        case Object o when o.Type.Contains("Mineral"):
                            Game1.player.foundMineral(o.ParentSheetIndex);

                            break;

                        case Object o when o.Type.Contains("Arch") &&
                            !Game1.player.hasOrWillReceiveMail("artifactFound"):
                            _geodeTreasure = new Object(390, 5);

                            break;
                        }
                    }
                }
            }

            if (_geodeDestructionAnimation != null &&
                (_geodeDestructionAnimation.id != 777f && _geodeDestructionAnimation.currentParentTileIndex < 7 ||
                 _geodeDestructionAnimation.id == 777f && _geodeDestructionAnimation.currentParentTileIndex < 5))
            {
                _geodeDestructionAnimation.update(time);
                if (_delayBeforeShowArtifactTimer > 0f)
                {
                    _delayBeforeShowArtifactTimer -= (float)time.ElapsedGameTime.TotalMilliseconds;
                    if (_delayBeforeShowArtifactTimer <= 0f)
                    {
                        _fluffSprites.Add(_geodeDestructionAnimation);
                        _fluffSprites.Reverse();
                        _geodeDestructionAnimation = new TemporaryAnimatedSprite
                        {
                            interval = 100f, animationLength = 6, alpha = 0.001f, id = 777f
                        };
                    }
                }
                else
                {
                    if (_geodeDestructionAnimation.currentParentTileIndex < 3)
                    {
                        _yPositionOfGem--;
                    }

                    _yPositionOfGem--;
                    if ((_geodeDestructionAnimation.currentParentTileIndex == 7 ||
                         _geodeDestructionAnimation.id == 777f && _geodeDestructionAnimation.currentParentTileIndex == 5
                         ) && (!(_geodeTreasure is Object) || ((Object)_geodeTreasure).Price > 75))
                    {
                        _sparkle = new TemporaryAnimatedSprite("TileSheets\\animations", new Rectangle(0, 640, 64, 64),
                                                               100f, 8, 0,
                                                               new Vector2(GeodeSpot.bounds.X + 285 - 32, GeodeSpot.bounds.Y + 150 + _yPositionOfGem - 32),
                                                               false, false);
                        Game1.playSound("discoverMineral");
                    }
                    else if ((_geodeDestructionAnimation.currentParentTileIndex == 7 ||
                              _geodeDestructionAnimation.id == 777f &&
                              _geodeDestructionAnimation.currentParentTileIndex == 5) && _geodeTreasure is Object o &&
                             o.Price <= 75)
                    {
                        Game1.playSound("newArtifact");
                    }
                }
            }

            if (_sparkle != null && _sparkle.update(time))
            {
                _sparkle = null;
            }
        }
Exemple #18
0
 public override void Update(GameTime t)
 {
     Sprite.update(t);
 }
Exemple #19
0
 public override void update(GameTime time)
 {
     base.update(time);
     if (Game1.options.SnappyMenus && !Game1.lastCursorMotionWasMouse)
     {
         Game1.mouseCursorTransparency = 0f;
     }
     else
     {
         Game1.mouseCursorTransparency = 1f;
     }
     if (isQuestion && characterIndexInDialogue >= getCurrentString().Length - 1 && !transitioning)
     {
         Game1.mouseCursorTransparency = 1f;
         if (!_showedOptions)
         {
             _showedOptions = true;
             if (responses != null)
             {
                 responseCC = new List <ClickableComponent>();
                 int responseY = y - (heightForQuestions - height) + SpriteText.getHeightOfString(getCurrentString(), width) + 48;
                 for (int i = 0; i < responses.Count; i++)
                 {
                     responseCC.Add(new ClickableComponent(new Rectangle(x + 8, responseY, width - 8, SpriteText.getHeightOfString(responses[i].responseText, width) + 16), "")
                     {
                         myID           = i,
                         downNeighborID = ((i < responses.Count - 1) ? (i + 1) : (-1)),
                         upNeighborID   = ((i > 0) ? (i - 1) : (-1))
                     });
                     responseY += SpriteText.getHeightOfString(responses[i].responseText, width) + 16;
                 }
             }
             populateClickableComponentList();
             if (Game1.options.gamepadControls)
             {
                 snapToDefaultClickableComponent();
                 selectedResponse = currentlySnappedComponent.myID;
             }
         }
     }
     if (safetyTimer > 0)
     {
         safetyTimer -= time.ElapsedGameTime.Milliseconds;
     }
     if (questionFinishPauseTimer > 0)
     {
         questionFinishPauseTimer -= time.ElapsedGameTime.Milliseconds;
         return;
     }
     if (transitioning)
     {
         if (!transitionInitialized)
         {
             transitionInitialized = true;
             transitionX           = x + width / 2;
             transitionY           = y + height / 2;
             transitionWidth       = 0;
             transitionHeight      = 0;
         }
         if (transitioningBigger)
         {
             int num = transitionWidth;
             transitionX      -= (int)((float)time.ElapsedGameTime.Milliseconds * 3f);
             transitionY      -= (int)((float)time.ElapsedGameTime.Milliseconds * 3f * ((float)(isQuestion ? heightForQuestions : height) / (float)width));
             transitionX       = Math.Max(x, transitionX);
             transitionY       = Math.Max(isQuestion ? (y + height - heightForQuestions) : y, transitionY);
             transitionWidth  += (int)((float)time.ElapsedGameTime.Milliseconds * 3f * 2f);
             transitionHeight += (int)((float)time.ElapsedGameTime.Milliseconds * 3f * ((float)(isQuestion ? heightForQuestions : height) / (float)width) * 2f);
             transitionWidth   = Math.Min(width, transitionWidth);
             transitionHeight  = Math.Min(isQuestion ? heightForQuestions : height, transitionHeight);
             if (num == 0 && transitionWidth > 0)
             {
                 playOpeningSound();
             }
             if (transitionX == x && transitionY == (isQuestion ? (y + height - heightForQuestions) : y))
             {
                 transitioning         = false;
                 characterAdvanceTimer = 90;
                 setUpIcons();
                 transitionX      = x;
                 transitionY      = y;
                 transitionWidth  = width;
                 transitionHeight = height;
             }
         }
         else
         {
             transitionX      += (int)((float)time.ElapsedGameTime.Milliseconds * 3f);
             transitionY      += (int)((float)time.ElapsedGameTime.Milliseconds * 3f * ((float)height / (float)width));
             transitionX       = Math.Min(x + width / 2, transitionX);
             transitionY       = Math.Min(y + height / 2, transitionY);
             transitionWidth  -= (int)((float)time.ElapsedGameTime.Milliseconds * 3f * 2f);
             transitionHeight -= (int)((float)time.ElapsedGameTime.Milliseconds * 3f * ((float)height / (float)width) * 2f);
             transitionWidth   = Math.Max(0, transitionWidth);
             transitionHeight  = Math.Max(0, transitionHeight);
             if (transitionWidth == 0 && transitionHeight == 0)
             {
                 closeDialogue();
             }
         }
     }
     if (!transitioning && characterIndexInDialogue < getCurrentString().Length)
     {
         characterAdvanceTimer -= time.ElapsedGameTime.Milliseconds;
         if (characterAdvanceTimer <= 0)
         {
             characterAdvanceTimer = 30;
             int old = characterIndexInDialogue;
             characterIndexInDialogue = Math.Min(characterIndexInDialogue + 1, getCurrentString().Length);
             if (characterIndexInDialogue != old && characterIndexInDialogue == getCurrentString().Length)
             {
                 Game1.playSound("dialogueCharacterClose");
             }
             if (characterIndexInDialogue > 1 && characterIndexInDialogue < getCurrentString().Length&& Game1.options.dialogueTyping)
             {
                 Game1.playSound("dialogueCharacter");
             }
         }
     }
     if (!transitioning && dialogueIcon != null)
     {
         dialogueIcon.update(time);
     }
     if (!transitioning && newPortaitShakeTimer > 0)
     {
         newPortaitShakeTimer -= time.ElapsedGameTime.Milliseconds;
     }
 }
        public override void draw(SpriteBatch b, int x, int y, float alpha = 1f)
        {
            if (!isTVOn)
            {
                return;
            }

            // Use this as a convenient point to intercept and wrap CustomTVMod's
            // question response handler.
            if (Game1.activeClickableMenu != null &&
                Game1.currentLocation.afterQuestion != null &&
                !hasWrappedAfterDialogues)
            {
                var originalCallback = Game1.currentLocation.afterQuestion;
                Game1.currentLocation.afterQuestion =
                    (Farmer who, string answer) =>
                {
                    hasWrappedAfterDialogues = false;
                    if (answer == "leave")
                    {
                        turnOffTV();
                    }
                    originalCallback(who, answer);
                };
                hasWrappedAfterDialogues = true;
            }

            // Draw the device itself. Calculate how far off course it landed.
            deviceSprite.update(Game1.currentGameTime);
            deviceSprite.draw(b, false, Game1.viewport.X, Game1.viewport.Y);
            int fudge = (int)(deviceSprite.Position.Y - getDevicePosition().Y);

            // Draw the light on the power button.
            lightSprite.update(Game1.currentGameTime);
            lightSprite.draw(b, false, Game1.viewport.X,
                             Game1.viewport.Y + fudge);

            // Draw the screen elements from the base class.
            if (screen != null)
            {
                screen.update(Game1.currentGameTime);
                screen.draw(b, false, Game1.viewport.X,
                            Game1.viewport.Y + fudge);

                if (screenOverlay != null)
                {
                    screenOverlay.update(Game1.currentGameTime);
                    screenOverlay.draw(b, false, Game1.viewport.X,
                                       Game1.viewport.Y + fudge);
                }

                // Ensure the static has been tamped down.
                if (staticSprite.alpha > 0.05f)
                {
                    staticSprite.alpha = 0.05f;
                }
            }

            // Draw the static over the screen.
            if (Config.Static && (Config.Animate || screen != null))
            {
                staticSprite.update(Game1.currentGameTime);
                staticSprite.draw(b, false, Game1.viewport.X,
                                  Game1.viewport.Y + fudge);
            }
        }