Example #1
0
        private Vector2 CalculateSize()
        {
            if (GrowableSeeds.All(s => s == null))
            {
                return(Vector2.Zero);
            }

            Point     pos  = item.DrawPosition.ToPoint();
            Rectangle rect = new Rectangle(pos, Point.Zero);

            for (int i = 0; i < GrowableSeeds.Length; i++)
            {
                Growable  seed = GrowableSeeds[i];
                PlantSlot slot = PlantSlots.ContainsKey(i) ? PlantSlots[i] : NullSlot;
                if (seed == null)
                {
                    continue;
                }

                foreach (VineTile vine in seed.Vines)
                {
                    Rectangle worldRect = vine.Rect;
                    worldRect.Location += slot.Offset.ToPoint();
                    worldRect.Location += pos;
                    rect = Rectangle.Union(rect, worldRect);
                }
            }

            Vector2 result = new Vector2(MaxDistance(pos.X, rect.Left, rect.Right) * 2, MaxDistance(pos.Y, rect.Top, rect.Bottom) * 2);

            return(result);
Example #2
0
        public static FoliageConfig CreateRandomConfig(int maxVariants, float minScale, float maxScale, Random?random = null)
        {
            int   flowerVariant  = Growable.RandomInt(0, maxVariants, random);
            float flowerScale    = (float)Growable.RandomDouble(minScale, maxScale, random);
            float flowerRotation = (float)Growable.RandomDouble(0, MathHelper.TwoPi, random);

            return(new FoliageConfig {
                Variant = flowerVariant, Scale = flowerScale, Rotation = flowerRotation
            });
        }