Esempio n. 1
0
        public void Draw(SpriteBatch spriteBatch, Planter planter, Vector2 offset, float depth)
        {
            const float zStep     = 0.0001f;
            float       leafDepth = 0f;

            foreach (VineTile vine in Vines)
            {
                leafDepth += zStep;
                DrawBranch(vine, spriteBatch, planter.Item.DrawPosition + offset, depth, leafDepth);
            }

            if (GameMain.DebugDraw)
            {
                foreach (Rectangle rect in FailedRectangles)
                {
                    Rectangle wRect = rect;
                    wRect.Y  = -wRect.Y;
                    wRect.Y -= wRect.Height;
                    GUI.DrawRectangle(spriteBatch, wRect, Color.Red);
                }
            }
        }
Esempio n. 2
0
        public void CreateDebugHUD(Planter planter, PlantSlot slot)
        {
            Vector2       relativeSize = new Vector2(0.3f, 0.6f);
            GUIMessageBox msgBox       = new GUIMessageBox(item.Name, "", new[] { TextManager.Get("applysettingsbutton") }, relativeSize);

            GUILayoutGroup content = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.85f), msgBox.Content.RectTransform))
            {
                Stretch = true
            };
            GUINumberInput seedInput         = CreateIntEntry("Random Seed", seed, content.RectTransform);
            GUINumberInput vineTileSizeInput = CreateIntEntry("Vine Tile Size (Global)", VineTile.Size, content.RectTransform);

            GUINumberInput[] leafScaleRangeInput   = CreateMinMaxEntry("Leaf Scale Range (Global)", new [] { MinLeafScale, MaxLeafScale }, 1.5f, content.RectTransform);
            GUINumberInput[] flowerScaleRangeInput = CreateMinMaxEntry("Flower Scale Range (Global)", new [] { MinFlowerScale, MaxFlowerScale }, 1.5f, content.RectTransform);
            GUINumberInput   vineCountInput        = CreateIntEntry("Vine Count", MaximumVines, content.RectTransform);
            GUINumberInput   vineScaleInput        = CreateFloatEntry("Vine Scale", VineScale, content.RectTransform);
            GUINumberInput   flowerInput           = CreateIntEntry("Flower Quantity", FlowerQuantity, content.RectTransform);
            GUINumberInput   flowerScaleInput      = CreateFloatEntry("Flower Scale", BaseFlowerScale, content.RectTransform);
            GUINumberInput   leafScaleInput        = CreateFloatEntry("Leaf Scale", BaseLeafScale, content.RectTransform);
            GUINumberInput   leafProbabilityInput  = CreateFloatEntry("Leaf Probability", LeafProbability, content.RectTransform);

            GUINumberInput[] leafTintInputs   = CreateMinMaxEntry("Leaf Tint", new [] { LeafTint.R / 255f, LeafTint.G / 255f, LeafTint.B / 255f }, 1.0f, content.RectTransform);
            GUINumberInput[] flowerTintInputs = CreateMinMaxEntry("Flower Tint", new [] { FlowerTint.R / 255f, FlowerTint.G / 255f, FlowerTint.B / 255f }, 1.0f, content.RectTransform);
            GUINumberInput[] vineTintInputs   = CreateMinMaxEntry("Branch Tint", new [] { VineTint.R / 255f, VineTint.G / 255f, VineTint.B / 255f }, 1.0f, content.RectTransform);

            // Apply
            msgBox.Buttons[0].OnClicked = (button, o) =>
            {
                seed            = seedInput.IntValue;
                MaximumVines    = vineCountInput.IntValue;
                FlowerQuantity  = flowerInput.IntValue;
                BaseFlowerScale = flowerScaleInput.FloatValue;
                VineScale       = vineScaleInput.FloatValue;
                BaseLeafScale   = leafScaleInput.FloatValue;
                LeafProbability = leafProbabilityInput.FloatValue;
                VineTile.Size   = vineTileSizeInput.IntValue;

                MinFlowerScale = flowerScaleRangeInput[0].FloatValue;
                MaxFlowerScale = flowerScaleRangeInput[1].FloatValue;
                MinLeafScale   = leafScaleRangeInput[0].FloatValue;
                MaxLeafScale   = leafScaleRangeInput[1].FloatValue;

                LeafTint   = new Color(leafTintInputs[0].FloatValue, leafTintInputs[1].FloatValue, leafTintInputs[2].FloatValue);
                FlowerTint = new Color(flowerTintInputs[0].FloatValue, flowerTintInputs[1].FloatValue, flowerTintInputs[2].FloatValue);
                VineTint   = new Color(vineTintInputs[0].FloatValue, vineTintInputs[1].FloatValue, vineTintInputs[2].FloatValue);

                if (FlowerQuantity >= MaximumVines - 1)
                {
                    vineCountInput.Flash(Color.Red);
                    flowerInput.Flash(Color.Red);
                    return(false);
                }

                if (MinFlowerScale > MaxFlowerScale)
                {
                    foreach (GUINumberInput input in flowerScaleRangeInput)
                    {
                        input.Flash(Color.Red);
                    }

                    return(false);
                }

                if (MinLeafScale > MaxLeafScale)
                {
                    foreach (GUINumberInput input in leafScaleRangeInput)
                    {
                        input.Flash(Color.Red);
                    }

                    return(false);
                }

                msgBox.Close();

                Random random       = new Random(seed);
                Random flowerRandom = new Random(seed);
                Vines.Clear();
                GenerateFlowerTiles(flowerRandom);
                GenerateStem();

                Decayed    = false;
                FullyGrown = false;
                while (MaximumVines > Vines.Count)
                {
                    if (!CanGrowMore())
                    {
                        Decayed = true;
                        break;
                    }

                    TryGenerateBranches(planter, slot, random, flowerRandom);
                }

                if (!Decayed)
                {
                    FullyGrown = true;
                }

                foreach (VineTile vineTile in Vines)
                {
                    vineTile.GrowthStep = 2.0f;
                }

                return(true);
            };
        }