Exemple #1
0
 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))
             {
                 Wheat fruit = new Wheat(Utility.Random(m_yield + 1));
                 from.AddToBackpack(fruit);
             }
             this.Delete();
             from.SendMessage("You chop the plant up");
         }
         else
         {
             from.SendMessage("You do not own this plant !!!");
         }
     }
     else
     {
         from.SendLocalizedMessage(500446);
     }
 }
        public override void PlaceBlock(Level world, Player player, BlockCoordinates targetCoordinates, BlockFace face, Vector3 faceCoords)
        {
            Block targetBlock = world.GetBlock(targetCoordinates);
            Block wheat       = new Wheat();

            wheat.Coordinates = targetBlock.IsReplacible ? targetCoordinates : GetNewCoordinatesFromFace(targetCoordinates, face);

            wheat.Metadata = (byte)Metadata;

            if (!wheat.CanPlace(world, targetCoordinates, face))
            {
                return;
            }

            if (wheat.PlaceBlock(world, player, targetCoordinates, face, faceCoords))
            {
                return;                                                                                   // Handled
            }
            world.SetBlock(wheat);
        }
Exemple #3
0
    public override void Init()
    {
        int animIndex = 0;

        Sprite[] animSprites =
        {
            Assets.Windmill0,
            Assets.Windmill1,
            Assets.Windmill2
        };

        animTask = Task.Run()
                   .Name("Windmill(anim)")
                   .Time(0.25f)
                   .Loop(-1)
                   .OnRepeat(t =>
        {
            tile.SetEntitySprite(animSprites[animIndex]);

            animIndex++;
            animIndex = animIndex %= animSprites.Length;
        });

        plantWheatTask = Task.Run()
                         .Name("Windmill(produce)")
                         .Time(5f)
                         .Loop(-1)
                         .Random(2.5f)
                         .OnRepeat(_ =>
        {
            Pos[] neighbours = Controller.Instance.grid.GetNeighbours(tile.pos);

            Pos randomNeighbour = neighbours[Random.Range(0, neighbours.Length)];

            Wheat w = new Wheat();
            w.level = level;

            Builder.Build(w, randomNeighbour.x, randomNeighbour.y);
        });
    }
        public static GameObject BuildGameObject(XmlElement element)
        {
            string type = element.GetAttribute("type");

            switch (type)
            {
            case "money": return(Money.Build(element));

            case "wood": return(Wood.Build(element));

            case "weapon": return(Weapon.Build(element));

            case "coal": return(Coal.Build(element));

            case "copper": return(Copper.Build(element));

            case "gold": return(Gold.Build(element));

            case "iron": return(Iron.Build(element));

            case "silver": return(Silver.Build(element));

            case "leather": return(Leather.Build(element));

            case "meat": return(Meat.Build(element));

            case "sand": return(Sand.Build(element));

            case "stone": return(Stone.Build(element));

            case "water": return(Water.Build(element));

            case "wheat": return(Wheat.Build(element));

            default: return(null);
            }
        }
        public override void OnDoubleClick(Mobile from)
        {
            if (m_sower == null || m_sower.Deleted)
            {
                m_sower = from;
            }

            if (from.Mounted && !CropHelper.CanWorkMounted)
            {
                from.SendMessage("You cannot harvest a crop while mounted.");
                return;
            }

            if (DateTime.Now > lastpicked.AddSeconds(3))               // 3 seconds between picking
            {
                lastpicked = DateTime.Now;

                int cookValue = (int)from.Skills[SkillName.Cooking].Value / 20;
                if (cookValue == 0)
                {
                    from.SendMessage("You have no idea how to harvest this crop.");
                    return;
                }

                if (from.InRange(this.GetWorldLocation(), 1))
                {
                    if (m_yield < 1)
                    {
                        from.SendMessage("There is nothing here to harvest.");

                        if (PlayerCanDestroy && !(m_sower.AccessLevel > AccessLevel.Counselor))
                        {
                            UpRootGump g = new UpRootGump(from, this);
                            from.SendGump(g);
                        }
                    }
                    else                     //check skill and sower
                    {
                        from.Direction = from.GetDirectionTo(this);

                        from.Animate(from.Mounted ? 29:32, 5, 1, true, false, 0);

                        if (from == m_sower)
                        {
                            cookValue  *= 2;
                            m_lastvisit = DateTime.Now;
                        }

                        if (cookValue > m_yield)
                        {
                            cookValue = m_yield + 1;
                        }

                        int pick = Utility.Random(cookValue);
                        if (pick == 0)
                        {
                            from.SendMessage("You do not manage to harvest any crops.");
                            return;
                        }

                        m_yield -= pick;
                        from.SendMessage("You harvest {0} crop{1}!", pick, (pick == 1 ? "" : "s"));

                        //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", m_yield )); // use for debuging
                        ((Item)this).ItemID = pickedGraphic;

                        // ********************************
                        // *** Wheat does not yet exist ***
                        // ********************************
                        // Wheat crop = new Wheat( pick );
                        Wheat crop = new Wheat(pick);
                        from.AddToBackpack(crop);

                        if (SowerPickTime != TimeSpan.Zero && m_lastvisit + SowerPickTime < DateTime.Now && !(m_sower.AccessLevel > AccessLevel.Counselor))
                        {
                            this.UpRoot(from);
                            return;
                        }

                        if (!regrowTimer.Running)
                        {
                            regrowTimer.Start();
                        }
                    }
                }
                else
                {
                    from.SendMessage("You are too far away to harvest anything.");
                }
            }
        }
Exemple #6
0
        public override void OnDoubleClick(Mobile from)
        {
            if (m_sower == null || m_sower.Deleted)
            {
                m_sower = from;
            }
            if (from != m_sower)
            {
                from.SendMessage("You do not own this plant !!!"); return;
            }

            if (from.Mounted && !CropHelper.CanWorkMounted)
            {
                from.SendMessage("You cannot harvest a crop while mounted."); return;
            }
            if (DateTime.UtcNow > lastpicked.AddSeconds(3))
            {
                lastpicked = DateTime.UtcNow;
                int cookValue = (int)from.Skills[SkillName.Cooking].Value / 20;
                if (cookValue == 0)
                {
                    from.SendMessage("You have no idea how to harvest this crop."); return;
                }
                if (from.InRange(this.GetWorldLocation(), 1))
                {
                    if (m_yield < 1)
                    {
                        from.SendMessage("There is nothing here to harvest.");
                    }
                    else
                    {
                        from.Direction = from.GetDirectionTo(this);
                        from.Animate(from.Mounted ? 29:32, 5, 1, true, false, 0);
                        m_lastvisit = DateTime.UtcNow;
                        if (cookValue > m_yield)
                        {
                            cookValue = m_yield + 1;
                        }
                        int pick = Utility.RandomMinMax(cookValue - 4, cookValue);
                        if (pick < 0)
                        {
                            pick = 0;
                        }
                        if (pick == 0)
                        {
                            from.SendMessage("You do not manage to harvest any crops."); return;
                        }
                        m_yield -= pick;
                        from.SendMessage("You harvest {0} crop{1}!", pick, (pick == 1 ? "" : "s"));
                        if (m_yield < 1)
                        {
                            ((Item)this).ItemID = pickedGraphic;
                        }
                        Wheat crop = new Wheat(pick);
                        from.AddToBackpack(crop);
                        if (!regrowTimer.Running)
                        {
                            regrowTimer.Start();
                        }
                    }
                }
                else
                {
                    from.SendMessage("You are too far away to harvest anything.");
                }
            }
        }
Exemple #7
0
 public void TestTeardown()
 {
     wheat = null;
 }
Exemple #8
0
 public void TestSetup()
 {
     wheat = new Wheat(0);
 }
 public PlayerResources()
 {
     Corn  = new Corn();
     Wheat = new Wheat();
 }