Exemplo n.º 1
0
 public void draw(SpriteBatch b, Vector2 tileLocation, Color toTint, float rotation)
 {
     if ((bool)forageCrop)
     {
         b.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, drawPosition), sourceRect, Color.White, 0f, new Vector2(8f, 8f), 4f, SpriteEffects.None, layerDepth);
         return;
     }
     b.Draw(Game1.cropSpriteSheet, Game1.GlobalToLocal(Game1.viewport, drawPosition), sourceRect, toTint, rotation, new Vector2(8f, 24f), 4f, flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth);
     if (!tintColor.Equals(Color.White) && (int)currentPhase == phaseDays.Count - 1 && !dead)
     {
         b.Draw(Game1.cropSpriteSheet, Game1.GlobalToLocal(Game1.viewport, drawPosition), coloredSourceRect, tintColor, rotation, new Vector2(8f, 24f), 4f, flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, coloredLayerDepth);
     }
 }
Exemplo n.º 2
0
 public void drawWithOffset(SpriteBatch b, Vector2 tileLocation, Color toTint, float rotation, Vector2 offset)
 {
     if ((bool)forageCrop)
     {
         b.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, offset + new Vector2(tileLocation.X * 64f, tileLocation.Y * 64f)), sourceRect, Color.White, 0f, new Vector2(8f, 8f), 4f, SpriteEffects.None, (tileLocation.Y + 0.66f) * 64f / 10000f + tileLocation.X * 1E-05f);
         return;
     }
     b.Draw(Game1.cropSpriteSheet, Game1.GlobalToLocal(Game1.viewport, offset + new Vector2(tileLocation.X * 64f, tileLocation.Y * 64f)), sourceRect, toTint, rotation, new Vector2(8f, 24f), 4f, flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (tileLocation.Y + 0.66f) * 64f / 10000f + tileLocation.X * 1E-05f);
     if (!tintColor.Equals(Color.White) && (int)currentPhase == phaseDays.Count - 1 && !dead)
     {
         b.Draw(Game1.cropSpriteSheet, Game1.GlobalToLocal(Game1.viewport, offset + new Vector2(tileLocation.X * 64f, tileLocation.Y * 64f)), coloredSourceRect, tintColor, rotation, new Vector2(8f, 24f), 4f, flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (tileLocation.Y + 0.67f) * 64f / 10000f + tileLocation.X * 1E-05f);
     }
 }
Exemplo n.º 3
0
 public virtual void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f, bool local = false)
 {
     if ((bool)playerChest)
     {
         if (playerChoiceColor.Equals(Color.Black))
         {
             spriteBatch.Draw(Game1.bigCraftableSpriteSheet, local ? new Vector2(x, y - 64) : Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + ((shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0), (y - 1) * 64)), Game1.getSourceRectForStandardTileSheet(Game1.bigCraftableSpriteSheet, 130, 16, 32), tint.Value * alpha, 0f, Vector2.Zero, 4f, SpriteEffects.None, local ? 0.89f : ((float)(y * 64 + 4) / 10000f));
             return;
         }
         spriteBatch.Draw(Game1.bigCraftableSpriteSheet, local ? new Vector2(x, y - 64) : Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, (y - 1) * 64 + ((shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0))), Game1.getSourceRectForStandardTileSheet(Game1.bigCraftableSpriteSheet, 168, 16, 32), playerChoiceColor.Value * alpha, 0f, Vector2.Zero, 4f, SpriteEffects.None, local ? 0.9f : ((float)(y * 64 + 4) / 10000f));
         spriteBatch.Draw(Game1.bigCraftableSpriteSheet, local ? new Vector2(x, y - 64) : Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, (y - 1) * 64 + ((shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0))), Game1.getSourceRectForStandardTileSheet(Game1.bigCraftableSpriteSheet, currentLidFrame + 38, 16, 32), playerChoiceColor.Value * alpha * alpha, 0f, Vector2.Zero, 4f, SpriteEffects.None, local ? 0.9f : ((float)(y * 64 + 5) / 10000f));
         spriteBatch.Draw(Game1.bigCraftableSpriteSheet, local ? new Vector2(x, y + 20) : Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 + 20)), new Rectangle(0, 725, 16, 11), Color.White * alpha, 0f, Vector2.Zero, 4f, SpriteEffects.None, local ? 0.91f : ((float)(y * 64 + 6) / 10000f));
         spriteBatch.Draw(Game1.bigCraftableSpriteSheet, local ? new Vector2(x, y - 64) : Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, (y - 1) * 64 + ((shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0))), Game1.getSourceRectForStandardTileSheet(Game1.bigCraftableSpriteSheet, currentLidFrame + 46, 16, 32), Color.White * alpha, 0f, Vector2.Zero, 4f, SpriteEffects.None, local ? 0.91f : ((float)(y * 64 + 6) / 10000f));
     }
 }
Exemplo n.º 4
0
        public override List <Item> getExtraDropItems()
        {
            List <Item> extra = new List <Item>();

            if ((string)name != "Tiger Slime")
            {
                if (color.R < 80 && color.G < 80 && color.B < 80)
                {
                    extra.Add(new Object(382, 1));
                    Random random = new Random((int)base.Position.X * 777 + (int)base.Position.Y * 77 + (int)Game1.stats.DaysPlayed);
                    if (random.NextDouble() < 0.05)
                    {
                        extra.Add(new Object(553, 1));
                    }
                    if (random.NextDouble() < 0.05)
                    {
                        extra.Add(new Object(539, 1));
                    }
                }
                else if (color.R > 200 && color.G > 180 && color.B < 50)
                {
                    extra.Add(new Object(384, 2));
                }
                else if (color.R > 220 && color.G > 90 && color.G < 150 && color.B < 50)
                {
                    extra.Add(new Object(378, 2));
                }
                else if (color.R > 230 && color.G > 230 && color.B > 230)
                {
                    if ((int)color.R % 2 == 1)
                    {
                        extra.Add(new Object(338, 1));
                        if ((int)color.G % 2 == 1)
                        {
                            extra.Add(new Object(338, 1));
                        }
                    }
                    else
                    {
                        extra.Add(new Object(380, 1));
                    }
                    if (((int)color.R % 2 == 0 && (int)color.G % 2 == 0 && (int)color.B % 2 == 0) || color.Equals(Color.White))
                    {
                        extra.Add(new Object(72, 1));
                    }
                }
                else if (color.R > 150 && color.G > 150 && color.B > 150)
                {
                    extra.Add(new Object(390, 2));
                }
                else if (color.R > 150 && color.B > 180 && color.G < 50 && (int)specialNumber % (firstGeneration ? 4 : 2) == 0)
                {
                    extra.Add(new Object(386, 2));
                    if ((bool)firstGeneration && Game1.random.NextDouble() < 0.005)
                    {
                        extra.Add(new Object(485, 1));
                    }
                }
            }
            if (Game1.MasterPlayer.mailReceived.Contains("slimeHutchBuilt") && (int)specialNumber == 1)
            {
                switch (base.Name)
                {
                case "Green Slime":
                    extra.Add(new Object(680, 1));
                    break;

                case "Frost Jelly":
                    extra.Add(new Object(413, 1));
                    break;

                case "Tiger Slime":
                    extra.Add(new Object(857, 1));
                    break;
                }
            }
            if (base.Name == "Tiger Slime")
            {
                if (Game1.random.NextDouble() < 0.001)
                {
                    extra.Add(new Hat(91));
                }
                if (Game1.random.NextDouble() < 0.1)
                {
                    extra.Add(new Object(831, 1));
                    while (Game1.random.NextDouble() < 0.5)
                    {
                        extra.Add(new Object(831, 1));
                    }
                }
                else if (Game1.random.NextDouble() < 0.1)
                {
                    extra.Add(new Object(829, 1));
                }
                else if (Game1.random.NextDouble() < 0.02)
                {
                    extra.Add(new Object(833, 1));
                    while (Game1.random.NextDouble() < 0.5)
                    {
                        extra.Add(new Object(833, 1));
                    }
                }
                else if (Game1.random.NextDouble() < 0.006)
                {
                    extra.Add(new Object(835, 1));
                }
            }
            if (prismatic.Value && Game1.player.team.specialOrders.Where((SpecialOrder x) => (string)x.questKey == "Wizard2") != null)
            {
                Object o = new Object(876, 1)
                {
                    specialItem = true
                };
                o.questItem.Value = true;
                return(new List <Item>
                {
                    o
                });
            }
            return(extra);
        }
Exemplo n.º 5
0
        public bool updateChunks(GameTime time, GameLocation location)
        {
            if (chunks.Count == 0)
            {
                return(true);
            }
            timeSinceDoneBouncing += time.ElapsedGameTime.Milliseconds;
            if (timeSinceDoneBouncing >= (floppingFish ? 2500f : (((DebrisType)debrisType == DebrisType.SPRITECHUNKS || (DebrisType)debrisType == DebrisType.NUMBERS) ? 1800f : 600f)))
            {
                if ((DebrisType)debrisType == DebrisType.LETTERS || (DebrisType)debrisType == DebrisType.NUMBERS || (DebrisType)debrisType == DebrisType.SQUARES || (DebrisType)debrisType == DebrisType.SPRITECHUNKS || ((DebrisType)debrisType == DebrisType.CHUNKS && chunks[0].debrisType - chunks[0].debrisType % 2 != 8))
                {
                    return(true);
                }
                if ((DebrisType)debrisType == DebrisType.ARCHAEOLOGY || (DebrisType)debrisType == DebrisType.OBJECT || (DebrisType)debrisType == DebrisType.RESOURCE || (DebrisType)debrisType == DebrisType.CHUNKS)
                {
                    chunksMoveTowardPlayer = true;
                }
                timeSinceDoneBouncing = 0f;
            }
            if (!location.farmers.Any() && !location.isTemp())
            {
                return(false);
            }
            Vector2 position = approximatePosition();
            Farmer  farmer   = player.Value;

            if (isEssentialItem() && shouldControlThis(location) && farmer == null)
            {
                farmer = findBestPlayer(location);
            }
            if (chunksMoveTowardPlayer && !isEssentialItem())
            {
                if (player.Value != null && player.Value == Game1.player && !playerInRange(position, player.Value))
                {
                    player.Value = null;
                    farmer       = null;
                }
                if (shouldControlThis(location))
                {
                    if (player.Value != null && player.Value.currentLocation != location)
                    {
                        player.Value = null;
                        farmer       = null;
                    }
                    if (farmer == null)
                    {
                        farmer = findBestPlayer(location);
                    }
                }
            }
            bool anyCouldMove = false;

            for (int i = chunks.Count - 1; i >= 0; i--)
            {
                Chunk chunk = chunks[i];
                chunk.position.UpdateExtrapolation(chunk.getSpeed());
                if (chunk.alpha > 0.1f && ((DebrisType)debrisType == DebrisType.SPRITECHUNKS || (DebrisType)debrisType == DebrisType.NUMBERS) && timeSinceDoneBouncing > 600f)
                {
                    chunk.alpha = (1800f - timeSinceDoneBouncing) / 1000f;
                }
                if (chunk.position.X < -128f || chunk.position.Y < -64f || chunk.position.X >= (float)(location.map.DisplayWidth + 64) || chunk.position.Y >= (float)(location.map.DisplayHeight + 64))
                {
                    chunks.RemoveAt(i);
                }
                else
                {
                    bool canMoveTowardPlayer = farmer != null;
                    if (canMoveTowardPlayer)
                    {
                        switch (debrisType.Value)
                        {
                        case DebrisType.ARCHAEOLOGY:
                        case DebrisType.OBJECT:
                            if (item != null)
                            {
                                canMoveTowardPlayer = farmer.couldInventoryAcceptThisItem(item);
                                break;
                            }
                            canMoveTowardPlayer = ((chunk.debrisType >= 0) ? farmer.couldInventoryAcceptThisObject(chunk.debrisType, 1, itemQuality) : farmer.couldInventoryAcceptThisItem(new Object(Vector2.Zero, chunk.debrisType * -1)));
                            if (chunk.debrisType == 102 && (bool)farmer.hasMenuOpen)
                            {
                                canMoveTowardPlayer = false;
                            }
                            break;

                        case DebrisType.RESOURCE:
                            canMoveTowardPlayer = farmer.couldInventoryAcceptThisObject(chunk.debrisType - chunk.debrisType % 2, 1);
                            break;

                        default:
                            canMoveTowardPlayer = true;
                            break;
                        }
                        anyCouldMove |= canMoveTowardPlayer;
                        if (canMoveTowardPlayer && shouldControlThis(location))
                        {
                            player.Value = farmer;
                        }
                    }
                    if (((chunksMoveTowardPlayer || isFishable) & canMoveTowardPlayer) && player.Value != null)
                    {
                        if (player.Value.IsLocalPlayer)
                        {
                            if (chunk.position.X < player.Value.Position.X - 12f)
                            {
                                chunk.xVelocity.Value = Math.Min((float)chunk.xVelocity + 0.8f, 8f);
                            }
                            else if (chunk.position.X > player.Value.Position.X + 12f)
                            {
                                chunk.xVelocity.Value = Math.Max((float)chunk.xVelocity - 0.8f, -8f);
                            }
                            if (chunk.position.Y + 32f < (float)(player.Value.getStandingY() - 12))
                            {
                                chunk.yVelocity.Value = Math.Max((float)chunk.yVelocity - 0.8f, -8f);
                            }
                            else if (chunk.position.Y + 32f > (float)(player.Value.getStandingY() + 12))
                            {
                                chunk.yVelocity.Value = Math.Min((float)chunk.yVelocity + 0.8f, 8f);
                            }
                            chunk.position.X += chunk.xVelocity;
                            chunk.position.Y -= chunk.yVelocity;
                            if (Math.Abs(chunk.position.X + 32f - (float)player.Value.getStandingX()) <= 64f && Math.Abs(chunk.position.Y + 32f - (float)player.Value.getStandingY()) <= 64f)
                            {
                                Item old = item;
                                if (collect(player, chunk))
                                {
                                    if (Game1.debrisSoundInterval <= 0f)
                                    {
                                        Game1.debrisSoundInterval = 10f;
                                        if ((old == null || (int)old.parentSheetIndex != 73) && chunk.debrisType != 73)
                                        {
                                            location.localSound("coin");
                                        }
                                    }
                                    chunks.RemoveAt(i);
                                }
                            }
                        }
                    }
                    else
                    {
                        if ((DebrisType)debrisType == DebrisType.NUMBERS && toHover != null)
                        {
                            relativeXPosition += chunk.xVelocity;
                            chunk.position.X   = toHover.Position.X + 32f + relativeXPosition;
                            chunk.scale        = Math.Min(2f, Math.Max(1f, 0.9f + Math.Abs(chunk.position.Y - (float)chunkFinalYLevel) / 128f));
                            chunkFinalYLevel   = toHover.getStandingY() + 8;
                            if (timeSinceDoneBouncing > 250f)
                            {
                                chunk.alpha = Math.Max(0f, chunk.alpha - 0.033f);
                            }
                            if (!(toHover is Farmer) && !nonSpriteChunkColor.Equals(Color.Yellow) && !nonSpriteChunkColor.Equals(Color.Green))
                            {
                                nonSpriteChunkColor.R = (byte)Math.Max(Math.Min(255, 200 + (int)chunkType), Math.Min(Math.Min(255, 220 + (int)chunkType), 400.0 * Math.Sin((double)timeSinceDoneBouncing / (Math.PI * 256.0) + Math.PI / 12.0)));
                                nonSpriteChunkColor.G = (byte)Math.Max(150 - (int)chunkType, Math.Min(255 - (int)chunkType, (nonSpriteChunkColor.R > 220) ? (300.0 * Math.Sin((double)timeSinceDoneBouncing / (Math.PI * 256.0) + Math.PI / 12.0)) : 0.0));
                                nonSpriteChunkColor.B = (byte)Math.Max(0, Math.Min(255, (nonSpriteChunkColor.G > 200) ? (nonSpriteChunkColor.G - 20) : 0));
                            }
                        }
                        chunk.position.X += chunk.xVelocity;
                        chunk.position.Y -= chunk.yVelocity;
                        if (movingFinalYLevel)
                        {
                            chunkFinalYLevel -= (int)Math.Ceiling((float)chunk.yVelocity / 2f);
                            if (chunkFinalYLevel <= chunkFinalYTarget)
                            {
                                chunkFinalYLevel  = chunkFinalYTarget;
                                movingFinalYLevel = false;
                            }
                        }
                        if ((DebrisType)debrisType == DebrisType.SQUARES && chunk.position.Y < (float)(chunkFinalYLevel - 96) && Game1.random.NextDouble() < 0.1)
                        {
                            chunk.position.Y      = chunkFinalYLevel - Game1.random.Next(1, 21);
                            chunk.yVelocity.Value = (float)Game1.random.Next(30, 80) / 40f;
                            chunk.position.X      = Game1.random.Next((int)(chunk.position.X - chunk.position.X % 64f + 1f), (int)(chunk.position.X - chunk.position.X % 64f + 64f));
                        }
                        if ((DebrisType)debrisType != DebrisType.SQUARES && chunk.bounces <= (floppingFish ? 65 : 2))
                        {
                            chunk.yVelocity.Value -= 0.4f;
                        }
                        bool destroyThisChunk = false;
                        if (chunk.position.Y >= (float)chunkFinalYLevel && (bool)chunk.hasPassedRestingLineOnce && chunk.bounces <= (floppingFish ? 65 : 2))
                        {
                            Point tile_point = new Point((int)chunk.position.X / 64, chunkFinalYLevel / 64);
                            if (Game1.currentLocation is IslandNorth && (debrisType.Value == DebrisType.ARCHAEOLOGY || debrisType.Value == DebrisType.OBJECT || debrisType.Value == DebrisType.RESOURCE || debrisType.Value == DebrisType.CHUNKS) && Game1.currentLocation.isTileOnMap(tile_point.X, tile_point.Y) && Game1.currentLocation.getTileIndexAt(tile_point, "Back") == -1)
                            {
                                chunkFinalYLevel += 48;
                            }
                            if ((DebrisType)debrisType != DebrisType.LETTERS && (DebrisType)debrisType != DebrisType.NUMBERS && (DebrisType)debrisType != DebrisType.SPRITECHUNKS && ((DebrisType)debrisType != 0 || chunk.debrisType - chunk.debrisType % 2 == 8) && shouldControlThis(location))
                            {
                                location.playSound("shiny4");
                            }
                            chunk.bounces++;
                            if ((bool)floppingFish)
                            {
                                chunk.yVelocity.Value = Math.Abs(chunk.yVelocity) * ((movingUp && chunk.bounces < 2) ? 0.6f : 0.9f);
                                chunk.xVelocity.Value = (float)Game1.random.Next(-250, 250) / 100f;
                            }
                            else
                            {
                                chunk.yVelocity.Value  = Math.Abs((float)chunk.yVelocity * 2f / 3f);
                                chunk.rotationVelocity = ((Game1.random.NextDouble() < 0.5) ? (chunk.rotationVelocity / 2f) : ((0f - chunk.rotationVelocity) * 2f / 3f));
                                chunk.xVelocity.Value -= (float)chunk.xVelocity / 2f;
                            }
                            Vector2 chunkTile = new Vector2((int)((chunk.position.X + 32f) / 64f), (int)((chunk.position.Y + 32f) / 64f));
                            if ((DebrisType)debrisType != DebrisType.LETTERS && (DebrisType)debrisType != DebrisType.SPRITECHUNKS && (DebrisType)debrisType != DebrisType.NUMBERS && location.doesTileSinkDebris((int)chunkTile.X, (int)chunkTile.Y, debrisType))
                            {
                                destroyThisChunk = location.sinkDebris(this, chunkTile, chunk.position);
                            }
                        }
                        int tile_x = (int)((chunk.position.X + 32f) / 64f);
                        int tile_y = (int)((chunk.position.Y + 32f) / 64f);
                        if ((!chunk.hitWall && location.Map.GetLayer("Buildings").Tiles[tile_x, tile_y] != null && location.doesTileHaveProperty(tile_x, tile_y, "Passable", "Buildings") == null) || location.Map.GetLayer("Back").Tiles[tile_x, tile_y] == null)
                        {
                            chunk.xVelocity.Value = 0f - (float)chunk.xVelocity;
                            chunk.hitWall         = true;
                        }
                        if (chunk.position.Y < (float)chunkFinalYLevel)
                        {
                            chunk.hasPassedRestingLineOnce.Value = true;
                        }
                        if (chunk.bounces > (floppingFish ? 65 : 2))
                        {
                            chunk.yVelocity.Value  = 0f;
                            chunk.xVelocity.Value  = 0f;
                            chunk.rotationVelocity = 0f;
                        }
                        chunk.rotation += chunk.rotationVelocity;
                        if (destroyThisChunk)
                        {
                            chunks.RemoveAt(i);
                        }
                    }
                }
            }
            if (!anyCouldMove && shouldControlThis(location))
            {
                player.Value = null;
            }
            if (chunks.Count == 0)
            {
                return(true);
            }
            return(false);
        }