예제 #1
0
        public virtual void UpdateFish()
        {
            List <Item> fish_items = new List <Item>();
            Dictionary <int, string> aquarium_data = GetAquariumData();

            foreach (Item item2 in heldItems)
            {
                if (item2 != null && Utility.IsNormalObjectAtParentSheetIndex(item2, item2.ParentSheetIndex) && aquarium_data.ContainsKey(item2.ParentSheetIndex))
                {
                    fish_items.Add(item2);
                }
            }
            List <Item> items_to_remove = new List <Item>();

            foreach (Item key in _fishLookup.Keys)
            {
                if (!heldItems.Contains(key))
                {
                    items_to_remove.Add(key);
                }
            }
            for (int i = 0; i < fish_items.Count; i++)
            {
                Item item = fish_items[i];
                if (!_fishLookup.ContainsKey(item))
                {
                    TankFish fish = new TankFish(this, item);
                    tankFish.Add(fish);
                    _fishLookup[item] = fish;
                }
            }
            foreach (Item removed_item in items_to_remove)
            {
                tankFish.Remove(_fishLookup[removed_item]);
                heldItems.Remove(removed_item);
            }
        }
예제 #2
0
        public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
        {
            Vector2 shake = Vector2.Zero;

            if (isTemporarilyInvisible)
            {
                return;
            }
            Vector2 draw_position = drawPosition.Value;

            if (!Furniture.isDrawingLocationFurniture)
            {
                draw_position    = new Vector2(x, y) * 64f;
                draw_position.Y -= sourceRect.Height * 4 - boundingBox.Height;
            }
            if (shakeTimer > 0)
            {
                shake = new Vector2(Game1.random.Next(-1, 2), Game1.random.Next(-1, 2));
            }
            spriteBatch.Draw(Furniture.furnitureTexture, Game1.GlobalToLocal(Game1.viewport, draw_position + shake), new Rectangle(sourceRect.Value.X + sourceRect.Value.Width, sourceRect.Value.Y, sourceRect.Value.Width, sourceRect.Value.Height), Color.White * alpha, 0f, Vector2.Zero, 4f, flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, GetGlassDrawLayer());
            if (Furniture.isDrawingLocationFurniture)
            {
                int hatsDrawn = 0;
                for (int i = 0; i < tankFish.Count; i++)
                {
                    TankFish fish       = tankFish[i];
                    float    fish_layer = Utility.Lerp(GetFishSortRegion().Y, GetFishSortRegion().X, fish.zPosition / 20f);
                    fish_layer += 1E-07f * (float)i;
                    fish.Draw(spriteBatch, alpha, fish_layer);
                    if (fish.fishIndex != 86)
                    {
                        continue;
                    }
                    int hatsSoFar = 0;
                    foreach (Item h in heldItems)
                    {
                        if (h is Hat)
                        {
                            if (hatsSoFar == hatsDrawn)
                            {
                                h.drawInMenu(spriteBatch, Game1.GlobalToLocal(fish.GetWorldPosition() + new Vector2(-30 + (fish.facingLeft ? (-4) : 0), -55f)), 0.75f, 1f, fish_layer + 1E-08f, StackDrawType.Hide);
                                hatsDrawn++;
                                break;
                            }
                            hatsSoFar++;
                        }
                    }
                }
                for (int j = 0; j < floorDecorations.Count; j++)
                {
                    if (floorDecorations[j].HasValue)
                    {
                        KeyValuePair <Rectangle, Vector2> decoration = floorDecorations[j].Value;
                        Vector2   decoration_position    = decoration.Value;
                        Rectangle decoration_source_rect = decoration.Key;
                        float     decoration_layer       = Utility.Lerp(GetFishSortRegion().Y, GetFishSortRegion().X, decoration_position.Y / 20f) - 1E-06f;
                        spriteBatch.Draw(GetAquariumTexture(), Game1.GlobalToLocal(new Vector2((float)GetTankBounds().Left + decoration_position.X * 4f, (float)(GetTankBounds().Bottom - 4) - decoration_position.Y * 4f)), decoration_source_rect, Color.White * alpha, 0f, new Vector2(decoration_source_rect.Width / 2, decoration_source_rect.Height - 4), 4f, SpriteEffects.None, decoration_layer);
                    }
                }
                foreach (Vector4 bubble in bubbles)
                {
                    float layer = Utility.Lerp(GetFishSortRegion().Y, GetFishSortRegion().X, bubble.Z / 20f) - 1E-06f;
                    spriteBatch.Draw(GetAquariumTexture(), Game1.GlobalToLocal(new Vector2((float)GetTankBounds().Left + bubble.X, (float)(GetTankBounds().Bottom - 4) - bubble.Y - bubble.Z * 4f)), new Rectangle(0, 240, 16, 16), Color.White * alpha, 0f, new Vector2(8f, 8f), 4f * bubble.W, SpriteEffects.None, layer);
                }
            }
            base.draw(spriteBatch, x, y, alpha);
        }