コード例 #1
0
ファイル: FertileDirtGump.cs プロジェクト: Crome696/ServUO
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 0)
                return;

            Mobile from = state.Mobile;
            bool fertile = info.ButtonID == 1;

            if (fertile && (from.Backpack == null || !from.Backpack.ConsumeTotal(typeof(FertileDirt), 20, false)))
            {
                from.SendLocalizedMessage(1150366); // You don't have enough fertile dirt in the top level of your backpack.
                return;
            }

            GardenAddonComponent comp = m_AttachTo as GardenAddonComponent;
            LandTarget lt = m_AttachTo as LandTarget;

            if (comp != null && m_Seed != null)
            {
                RaisedGardenPlantItem dirt = new RaisedGardenPlantItem(fertile);
                dirt.MoveToWorld(new Point3D(comp.X, comp.Y, comp.Z + 5), comp.Map);
                dirt.Component = comp;
                comp.Plant = dirt;
                dirt.PlantSeed(from, m_Seed);
            }
            else if (lt != null)
            {
                MaginciaPlantItem dirt = new MaginciaPlantItem(fertile);
                dirt.MoveToWorld(((LandTarget)m_AttachTo).Location, from.Map);
                dirt.Owner = from;
                dirt.StartTimer();
            }
        }
コード例 #2
0
ファイル: FertileDirtGump.cs プロジェクト: zmazza/ServUO
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 0)
            {
                return;
            }

            Mobile from    = state.Mobile;
            bool   fertile = info.ButtonID == 1;

            if (fertile && (from.Backpack == null || !from.Backpack.ConsumeTotal(typeof(FertileDirt), 20, false)))
            {
                from.SendLocalizedMessage(1150366); // You don't have enough fertile dirt in the top level of your backpack.
                return;
            }

            GardenAddonComponent comp = m_AttachTo as GardenAddonComponent;
            LandTarget           lt   = m_AttachTo as LandTarget;

            if (comp != null && m_Seed != null)
            {
                RaisedGardenPlantItem dirt = new RaisedGardenPlantItem(fertile);
                dirt.MoveToWorld(new Point3D(comp.X, comp.Y, comp.Z + 5), comp.Map);
                dirt.Component = comp;
                comp.Plant     = dirt;
                dirt.PlantSeed(from, m_Seed);
            }
            else if (lt != null)
            {
                MaginciaPlantItem dirt = new MaginciaPlantItem(fertile);
                dirt.MoveToWorld(((LandTarget)m_AttachTo).Location, from.Map);
                dirt.Owner = from;
                dirt.StartTimer();
            }
        }
コード例 #3
0
ファイル: Hoe.cs プロジェクト: Crome696/ServUO
            protected override void OnTarget(Mobile from, object targeted)
            {
                Map map = from.Map;

                if (targeted is LandTarget && map != null)
                {
                    LandTarget lt = (LandTarget)targeted;
                    Region r = Region.Find(lt.Location, map);

                    if (r != null && r.IsPartOf("Magincia") && (lt.Name == "dirt" || lt.Name == "grass"))
                    {
                        if (!MaginciaPlantSystem.Enabled)
                            from.SendMessage("Magincia plant placement is currently disabled.");
                        else if (MaginciaPlantSystem.CanAddPlant(from, lt.Location))
                        {
                            int fertileDirt = from.Backpack == null ? 0 : from.Backpack.GetAmount(typeof(FertileDirt), false);

                            if (fertileDirt > 0)
                                from.SendGump(new FertileDirtGump(null, fertileDirt, lt));
                            else
                            {
                                if (from.Body.IsHuman && !from.Mounted)
                                    from.Animate(11, 5, 1, true, false, 0);

                                from.PlaySound(0x125);

                                MaginciaPlantItem dirt = new MaginciaPlantItem();
                                dirt.StartTimer();

                                Timer.DelayCall(TimeSpan.FromSeconds(.7), new TimerStateCallback(MoveItem_Callback), new object[] { dirt, lt.Location, map } );
                            }
                        }
                    }
                    else
                        from.SendLocalizedMessage(1150457); // The ground here is not good for gardening.
                    
                }
            }