private void AddResourcesState(int x, int y)
        {
            PlantResourceInfo resInfo = PlantResourceInfo.GetInfo(m_Plant.PlantType, m_Plant.PlantHue);

            PlantSystem system         = m_Plant.PlantSystem;
            int         totalResources = system.AvailableResources + system.LeftResources;

            if (resInfo == null || totalResources == 0)
            {
                AddLabel(x + 5, y, 0x21, "X");
            }
            else
            {
                AddLabel(x, y, PlantHueInfo.GetInfo(m_Plant.PlantHue).GumpHue, string.Format("{0}/{1}", system.AvailableResources, totalResources));
            }
        }
Exemplo n.º 2
0
        private void Grow()
        {
            if (Health < PlantHealth.Healthy)
            {
                GrowthIndicator = PlantGrowthIndicator.NotHealthy;
            }
            else if (FertileDirt && Plant.PlantStatus <= PlantStatus.Stage5 && Utility.RandomDouble() < 0.1)
            {
                int curStage = (int)Plant.PlantStatus;
                Plant.PlantStatus = (PlantStatus)(curStage + 2);

                GrowthIndicator = PlantGrowthIndicator.DoubleGrown;
            }
            else if (Plant.PlantStatus < PlantStatus.Stage9)
            {
                int curStage = (int)Plant.PlantStatus;
                Plant.PlantStatus = (PlantStatus)(curStage + 1);

                GrowthIndicator = PlantGrowthIndicator.Grown;
            }
            else
            {
                if (Pollinated && LeftSeeds > 0 && Plant.Reproduces)
                {
                    LeftSeeds--;
                    AvailableSeeds++;
                }

                if (!Plant.MaginciaPlant && LeftResources > 0 && PlantResourceInfo.GetInfo(Plant.PlantType, Plant.PlantHue) != null)
                {
                    LeftResources--;
                    AvailableResources++;
                }

                GrowthIndicator = PlantGrowthIndicator.Grown;
            }

            if (Plant.PlantStatus >= PlantStatus.Stage9 && !Pollinated && !Plant.MaginciaPlant)
            {
                Pollinated = true;
                SeedType   = Plant.PlantType;
                SeedHue    = Plant.PlantHue;
            }
        }
Exemplo n.º 3
0
        private void Grow()
        {
            if (Health < PlantHealth.Healthy)
            {
                m_GrowthIndicator = PlantGrowthIndicator.NotHealthy;
            }
            else if (m_FertileDirt && m_Plant.PlantStatus <= PlantStatus.Stage5 && Utility.RandomDouble() < 0.1)
            {
                int curStage = (int)m_Plant.PlantStatus;
                m_Plant.PlantStatus = (PlantStatus)(curStage + 2);

                m_GrowthIndicator = PlantGrowthIndicator.DoubleGrown;
            }
            else if (m_Plant.PlantStatus < PlantStatus.Stage9)
            {
                int curStage = (int)m_Plant.PlantStatus;
                m_Plant.PlantStatus = (PlantStatus)(curStage + 1);

                m_GrowthIndicator = PlantGrowthIndicator.Grown;
            }
            else
            {
                if (Pollinated && LeftSeeds > 0 && m_Plant.IsCrossable)
                {
                    LeftSeeds--;
                    AvailableSeeds++;
                }

                if (LeftResources > 0 && PlantResourceInfo.GetInfo(m_Plant.PlantType, m_Plant.PlantHue) != null)
                {
                    LeftResources--;
                    AvailableResources++;
                }

                m_GrowthIndicator = PlantGrowthIndicator.Grown;
            }

            if (m_Plant.PlantStatus >= PlantStatus.Stage9 && !Pollinated)
            {
                Pollinated = true;
                SeedType   = m_Plant.PlantType;
                SeedHue    = m_Plant.PlantHue;
            }
        }
Exemplo n.º 4
0
        private void AddResourcesState(int x, int y)
        {
            var resInfo = PlantResourceInfo.GetInfo(m_Plant.PlantType, m_Plant.PlantHue);

            var system         = m_Plant.PlantSystem;
            var totalResources = system.AvailableResources + system.LeftResources;

            if (resInfo == null || totalResources == 0)
            {
                AddLabel(x + 5, y, 0x21, "X");
            }
            else
            {
                AddLabel(
                    x,
                    y,
                    PlantHueInfo.GetInfo(m_Plant.PlantHue).GumpHue,
                    $"{system.AvailableResources}/{totalResources}"
                    );
            }
        }
Exemplo n.º 5
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            var from = sender.Mobile;

            if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus is >= PlantStatus.DecorativePlant or PlantStatus.BowlOfDirt)
            {
                return;
            }

            if (info.ButtonID >= 6 && info.ButtonID <= 8 && !from.InRange(m_Plant.GetWorldLocation(), 3))
            {
                from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 500446); // That is too far away.
                return;
            }

            if (!m_Plant.IsUsableBy(from))
            {
                m_Plant.LabelTo(from, 1061856); // You must have the item in your backpack or locked down in order to use it.
                return;
            }

            switch (info.ButtonID)
            {
            case 1:     // Main menu
            {
                from.SendGump(new MainPlantGump(m_Plant));

                break;
            }

            case 2:     // Set to decorative
            {
                if (m_Plant.PlantStatus == PlantStatus.Stage9)
                {
                    from.SendGump(new SetToDecorativeGump(m_Plant));
                }

                break;
            }

            case 3:     // Pollination
            {
                from.NetState.SendDisplayHelpTopic(HelpTopic.PollinationState);

                from.SendGump(new ReproductionGump(m_Plant));

                break;
            }

            case 4:     // Resources
            {
                from.NetState.SendDisplayHelpTopic(HelpTopic.ResourceProduction);

                from.SendGump(new ReproductionGump(m_Plant));

                break;
            }

            case 5:     // Seeds
            {
                from.NetState.SendDisplayHelpTopic(HelpTopic.SeedProduction);

                from.SendGump(new ReproductionGump(m_Plant));

                break;
            }

            case 6:     // Gather pollen
            {
                if (!m_Plant.IsCrossable)
                {
                    m_Plant.LabelTo(from, 1053050);         // You cannot gather pollen from a mutated plant!
                }
                else if (!m_Plant.PlantSystem.PollenProducing)
                {
                    // You cannot gather pollen from a plant in this stage of development!
                    m_Plant.LabelTo(from, 1053051);
                }
                else if (m_Plant.PlantSystem.Health < PlantHealth.Healthy)
                {
                    m_Plant.LabelTo(from, 1053052);         // You cannot gather pollen from an unhealthy plant!
                }
                else
                {
                    from.Target = new PollinateTarget(m_Plant);
                    from.SendLocalizedMessage(1053054);         // Target the plant you wish to cross-pollinate to.

                    break;
                }

                from.SendGump(new ReproductionGump(m_Plant));

                break;
            }

            case 7:     // Gather resources
            {
                var resInfo = PlantResourceInfo.GetInfo(m_Plant.PlantType, m_Plant.PlantHue);
                var system  = m_Plant.PlantSystem;

                if (resInfo == null)
                {
                    if (m_Plant.IsCrossable)
                    {
                        m_Plant.LabelTo(from, 1053056);         // This plant has no resources to gather!
                    }
                    else
                    {
                        m_Plant.LabelTo(from, 1053055);         // Mutated plants do not produce resources!
                    }
                }
                else if (system.AvailableResources == 0)
                {
                    m_Plant.LabelTo(from, 1053056);         // This plant has no resources to gather!
                }
                else
                {
                    var resource = resInfo.CreateResource();

                    if (from.PlaceInBackpack(resource))
                    {
                        system.AvailableResources--;
                        m_Plant.LabelTo(from, 1053059);         // You gather resources from the plant.
                    }
                    else
                    {
                        resource.Delete();
                        // You attempt to gather as many resources as you can hold, but your backpack is full.
                        m_Plant.LabelTo(from, 1053058);
                    }
                }

                from.SendGump(new ReproductionGump(m_Plant));

                break;
            }

            case 8:     // Gather seeds
            {
                var system = m_Plant.PlantSystem;

                if (!m_Plant.Reproduces)
                {
                    m_Plant.LabelTo(from, 1053060);         // Mutated plants do not produce seeds!
                }
                else if (system.AvailableSeeds == 0)
                {
                    m_Plant.LabelTo(from, 1053061);         // This plant has no seeds to gather!
                }
                else
                {
                    var seed = new Seed(system.SeedType, system.SeedHue, true);

                    if (from.PlaceInBackpack(seed))
                    {
                        system.AvailableSeeds--;
                        m_Plant.LabelTo(from, 1053063);         // You gather seeds from the plant.
                    }
                    else
                    {
                        seed.Delete();
                        // You attempt to gather as many seeds as you can hold, but your backpack is full.
                        m_Plant.LabelTo(from, 1053062);
                    }
                }

                from.SendGump(new ReproductionGump(m_Plant));

                break;
            }
            }
        }