public void Chop(Mobile from) { if (from.InRange(this.GetWorldLocation(), 1)) { if (from == m_sower) { from.Direction = from.GetDirectionTo(this); double lumberValue = from.Skills[SkillName.Lumberjacking].Value / 100; if ((lumberValue > .5) && (Utility.RandomDouble() <= lumberValue)) { RedPepper fruit = new RedPepper(Utility.Random(m_yield + 2)); from.AddToBackpack(fruit); if (Utility.RandomDouble() <= .1) { Vines logs = new Vines(); from.AddToBackpack(logs); } } this.Delete(); from.SendMessage("You chop the plant up"); } else { from.SendMessage("You do not own this plant !!!"); } } else { from.SendLocalizedMessage(500446); } }
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime) { Health = msg.ReadRangedSingle(0, MaxHealth, 8); int startOffset = msg.ReadRangedInteger(-1, MaximumVines); if (startOffset > -1) { int vineCount = msg.ReadRangedInteger(0, VineChunkSize); List <VineTile> tiles = new List <VineTile>(); for (int i = 0; i < vineCount; i++) { VineTileType vineType = (VineTileType)msg.ReadRangedInteger(0b0000, 0b1111); int flowerConfig = msg.ReadRangedInteger(0, 0xFFF); int leafConfig = msg.ReadRangedInteger(0, 0xFFF); sbyte posX = (sbyte)msg.ReadByte(), posY = (sbyte)msg.ReadByte(); Vector2 pos = new Vector2(posX * VineTile.Size, posY * VineTile.Size); tiles.Add(new VineTile(this, pos, vineType, FoliageConfig.Deserialize(flowerConfig), FoliageConfig.Deserialize(leafConfig))); } // is this even needed?? lock (mutex) { for (var i = 0; i < vineCount; i++) { int index = i + startOffset; if (index >= Vines.Count) { Vines.Add(tiles[i]); continue; } VineTile oldVine = Vines[index]; VineTile newVine = tiles[i]; newVine.GrowthStep = oldVine.GrowthStep; Vines[index] = newVine; } } } UpdateBranchHealth(); ResetPlanterSize(); }
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); }; }