예제 #1
0
 static void Main(string[] args)
 {
     Apple[] apples = new[] { new Apple() };
     Fruit[] fruits = apples;
     fruits[0] = new Coconut(); // This line will throw at runtime
     apples[0].Peel();
 }
예제 #2
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))
             {
                 Coconut fruit = new Coconut(Utility.Random(m_yield + 2));
                 from.AddToBackpack(fruit);
                 int cnt  = Utility.Random(40) + 1;
                 Log logs = new Log(cnt);
                 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);
     }
 }
예제 #3
0
 protected void EatingCoconut()
 {
     if (Channeling(ItemList.Coconut, PlayerActions.Eat) == PlayerActions.Eat)
     {
         Coconut coco = (Coconut)(this.GetPlayerData().GetInventory()[Global.ItemNames[ItemList.Coconut]]);
         coco.Eat(this.GetPlayerData());
         Nourish.Play();
     }
 }
예제 #4
0
파일: CocoGun.cs 프로젝트: L4fter/CrocoDie
    public void Shoot(Vector3 dir)
    {
        var coconut = Instantiate(this.CoconutPrefab, this.transform.position, Quaternion.identity) as GameObject;

        projectile = coconut.GetComponent <Coconut>();
        projectile.Launch(dir);
        Destroy(projectile.gameObject, 4);
        if (game.OnlineGame && game.PlayerControlsMan)
        {
            networkView.RPC("Shoot", RPCMode.Others, dir);
        }
    }
예제 #5
0
 // Use this for initialization
 void Start()
 {
     if (gameObject.name == "Coconut(Clone)")
     {
         cocoScript = gameObject.GetComponent <Coconut> ();
     }
     else if (gameObject.name == "Rotten Coconut(Clone)")
     {
         rottenCocoScript = gameObject.GetComponent <RottenCoconut> ();
     }
     else
     {
         Debug.Log("Something is wrong in the Start method of DestoryOffscreen");
     }
 }
예제 #6
0
        public void Chop(Mobile from)
        {
            if (from.InRange(this.GetWorldLocation(), 2))
            {
                if ((chopTimer == null) || (!chopTimer.Running))
                {
                    if ((TreeHelper.TreeOrdinance) && (from.AccessLevel == AccessLevel.Player))
                    {
                        if (from.Region is Regions.GuardedRegion)
                        {
                            from.CriminalAction(true);
                        }
                    }

                    chopTimer = new TreeHelper.ChopAction(from);

                    Point3D pnt = this.Location;
                    Map     map = this.Map;

                    from.Direction = from.GetDirectionTo(this);
                    chopTimer.Start();

                    double lumberValue = from.Skills[SkillName.Lumberjacking].Value / 100;
                    if ((lumberValue > .5) && (Utility.RandomDouble() <= lumberValue))
                    {
                        Coconut fruit = new Coconut((int)Utility.Random(13) + m_yield);
                        from.AddToBackpack(fruit);

                        int cnt  = Utility.Random((int)(lumberValue * 10) + 1);
                        Log logs = new Log(cnt);                           // Fruitwood Logs ??
                        from.AddToBackpack(logs);

                        FruitTreeStump i_stump = new FruitTreeStump(typeof(CocoTree));
                        Timer          poof    = new StumpTimer(this, i_stump, from);
                        poof.Start();
                    }
                    else
                    {
                        from.SendLocalizedMessage(500495);                        // You hack at the tree for a while, but fail to produce any useable wood.
                    }
                    //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", lumberValue ));
                }
            }
            else
            {
                from.SendLocalizedMessage(500446);                 // That is too far away.
            }
        }
예제 #7
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;
                        }
                        Coconut crop = new Coconut(pick);
                        from.AddToBackpack(crop);
                        if (!regrowTimer.Running)
                        {
                            regrowTimer.Start();
                        }
                    }
                }
                else
                {
                    from.SendMessage("You are too far away to harvest anything.");
                }
            }
        }
예제 #8
0
        public override void OnDoubleClick(Mobile from)
        {
            if (from.Mounted && !TreeHelper.CanPickMounted)
            {
                from.SendMessage(AgriTxt.CannotWorkMounted);
                return;
            }

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

                int lumberValue = (int)from.Skills[SkillName.Lumberjacking].Value / 5;
                if (from.Mounted)
                {
                    ++lumberValue;
                }

                if (lumberValue < 3)
                {
                    from.SendMessage(AgriTxt.DunnoHowTo);
                    return;
                }

                if (from.InRange(this.GetWorldLocation(), 2))
                {
                    if (m_yield < 1)
                    {
                        from.SendMessage(AgriTxt.NoCrop);
                    }
                    else                     //check skill
                    {
                        from.Direction = from.GetDirectionTo(this);

                        from.Animate(from.Mounted ? 26:17, 7, 1, true, false, 0);

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

                        int pick = Utility.Random(lumberValue);
                        if (pick == 0)
                        {
                            from.SendMessage(AgriTxt.ZeroPicked);
                            return;
                        }

                        m_yield -= pick;
                        from.SendMessage(AgriTxt.YouPick + " {0} noix de coco!", pick);

                        //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", m_yield ));

                        Coconut crop = new Coconut(pick);
                        from.AddToBackpack(crop);

                        if (!regrowTimer.Running)
                        {
                            regrowTimer.Start();
                        }
                    }
                }
                else
                {
                    from.SendLocalizedMessage(500446);                       // That is too far away.
                }
            }
        }
예제 #9
0
 public Coconut(Coconut s) : base(s)
 {
 }
예제 #10
0
/*
 *              public override void OnAfterDelete()
 *              {
 *                      if (( i_trunk != null ) && ( !i_trunk.Deleted ))
 *                                      i_trunk.Delete();
 *
 *                      base.OnAfterDelete();
 *              }
 */
        public override void OnDoubleClick(Mobile from)
        {
            if (from.Mounted && !TreeHelper.CanPickMounted)
            {
                from.SendMessage("You cannot pick fruit while mounted.");
                return;
            }

/* To Kill Tree
 *                      if ( Utility.RandomDouble() <= .05 ) //.5 is 5% Chance
 *                      {
 *                      from.SendMessage( "The crop withers away." );
 *                      if ( regrowTimer.Running )
 *                              regrowTimer.Stop();
 *
 *                      this.Delete();
 *                      }
 */
            if (DateTime.Now > lastpicked.AddSeconds(3))               // 3 seconds between picking
            {
                lastpicked = DateTime.Now;

                int lumberValue = (int)from.Skills[SkillName.Lumberjacking].Value / 20;
                if (from.Mounted)
                {
                    ++lumberValue;
                }

                if (lumberValue < 0)                                                                            //Changed lumberValue == 0 to lv < 0
                {
                    from.SendMessage("You have no idea how to pick this fruit.");
                    return;
                }

                if (from.InRange(this.GetWorldLocation(), 2))
                {
                    if (m_yield < 1)
                    {
                        from.SendMessage("There is nothing here to harvest.");
                    }
                    else                     //check skill
                    {
                        from.Direction = from.GetDirectionTo(this);

                        from.Animate(from.Mounted ? 26:17, 7, 1, true, false, 0);

                        if (lumberValue < m_yield)                                                                                              //Changed lumberValue > to lv < 0
                        {
                            lumberValue = m_yield + 1;
                        }

                        int pick = Utility.Random(lumberValue);
                        if (pick == 0)
                        {
                            from.SendMessage("You do not manage to gather any fruit.");
                            return;
                        }

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

                        //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", m_yield ));

                        Coconut crop = new Coconut(pick);
                        from.AddToBackpack(crop);

                        if (!regrowTimer.Running)
                        {
                            regrowTimer.Start();
                        }
                    }
                }
                else
                {
                    from.SendLocalizedMessage(500446);                       // That is too far away.
                }
            }
        }
예제 #11
0
        protected override void OnTarget(Mobile from, object targeted)
        {
            if (m_Item.Deleted)
            {
                return;
            }

            if (targeted is ICarvable)
            {
                ((ICarvable)targeted).Carve(from, m_Item);
            }
            else if (targeted is Container)
            {
                Container body = (Container)targeted;

                if (body.ItemID >= 0x4B5A && body.ItemID <= 0x4BAB)
                {
                    body.ItemID = Utility.RandomList(0xECA, 0xECB, 0xECC, 0xECD, 0xECE, 0xECF, 0xED0, 0xED1, 0xED2);
                    body.Hue    = 0;

                    from.CriminalAction(true);
                    Misc.Titles.AwardKarma(from, -50, true);

                    body.DropItem(new BodyPart(0x1D9F));
                    body.DropItem(new BodyPart(0x1DA4));
                    body.DropItem(new BodyPart(0x1DA2));
                    body.DropItem(new BodyPart(0x1DA3));
                    body.DropItem(new BodyPart(0x1DA1));
                    body.DropItem(new BodyPart(0x1DA0));

                    from.SendMessage("You hack up the body into bloody pieces.");
                }
            }
            else if (targeted is SwampDragon && ((SwampDragon)targeted).HasBarding)
            {
                SwampDragon pet = (SwampDragon)targeted;

                if (!pet.Controlled || pet.ControlMaster != from)
                {
                    from.SendLocalizedMessage(1053022);                       // You cannot remove barding from a swamp dragon you do not own.
                }
                else
                {
                    pet.HasBarding = false;
                }
            }
            else
            {
                HarvestSystem     system = Lumberjacking.System;
                HarvestDefinition def    = Lumberjacking.System.Definition;

                int     tileID;
                Map     map;
                Point3D loc;

                if (!system.GetHarvestDetails(from, m_Item, targeted, out tileID, out map, out loc))
                {
                    from.SendLocalizedMessage(500494);                       // You can't use a bladed item on that!
                }
                else if (!def.Validate(tileID))
                {
                    from.SendLocalizedMessage(500494);                       // You can't use a bladed item on that!
                }
                else
                {
                    HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

                    if (bank == null)
                    {
                        return;
                    }

                    if (bank.Current < 5)
                    {
                        from.SendMessage("There is not enough here to harvest.");
                        //from.SendLocalizedMessage( 500493 ); // There's not enough wood here to harvest.
                    }
                    else
                    {
                        bank.Consume(5, from);

                        if (tileID == 0x4D96 || tileID == 0x4D9A)                           // apples
                        {
                            Item item = new Apple();

                            if (from.PlaceInBackpack(item))
                            {
                                from.SendMessage("You put an apple into your backpack.");
                            }
                            else
                            {
                                from.SendMessage("You can't place any apples into your backpack!");
                                item.Delete();
                            }
                        }
                        else if (tileID == 0x4DA6 || tileID == 0x4DAA)                           // pears
                        {
                            Item item = new Pear();

                            if (from.PlaceInBackpack(item))
                            {
                                from.SendMessage("You put a pear into your backpack.");
                            }
                            else
                            {
                                from.SendMessage("You can't place any pears into your backpack!");
                                item.Delete();
                            }
                        }
                        else if (tileID == 0x4D9E || tileID == 0x4DA2)                           // peaches
                        {
                            Item item = new Peach();

                            if (from.PlaceInBackpack(item))
                            {
                                from.SendMessage("You put a peach into your backpack.");
                            }
                            else
                            {
                                from.SendMessage("You can't place any peaches into your backpack!");
                                item.Delete();
                            }
                        }
                        else if (tileID == 0x4CDA || tileID == 0x4CDB || tileID == 0x4CDC || tileID == 0x4CDD || tileID == 0x4CDE || tileID == 0x4CDF)                           // acorns
                        {
                            Item item = new Acorn();

                            if (from.PlaceInBackpack(item))
                            {
                                from.SendMessage("You put an acorn into your backpack.");
                            }
                            else
                            {
                                from.SendMessage("You can't place any acorns into your backpack!");
                                item.Delete();
                            }
                        }
                        else if (tileID == 0x4CA8 || tileID == 0x4CAA || tileID == 0x4CAB)                           // bananas
                        {
                            Item item = new Banana();

                            if (from.PlaceInBackpack(item))
                            {
                                from.SendMessage("You put a banana into your backpack.");
                            }
                            else
                            {
                                from.SendMessage("You can't place any bananas into your backpack!");
                                item.Delete();
                            }
                        }
                        else if (tileID == 0x4C95)                           // coconut
                        {
                            Item item = new Coconut();

                            if (from.PlaceInBackpack(item))
                            {
                                from.SendMessage("You put a coconut into your backpack.");
                            }
                            else
                            {
                                from.SendMessage("You can't place any coconuts into your backpack!");
                                item.Delete();
                            }
                        }
                        else if (tileID == 0x4C96)                           // dates
                        {
                            Item item = new Dates();

                            if (from.PlaceInBackpack(item))
                            {
                                from.SendMessage("You put some dates into your backpack.");
                            }
                            else
                            {
                                from.SendMessage("You can't place any dates into your backpack!");
                                item.Delete();
                            }
                        }
                        else
                        {
                            Item item = new Kindling();

                            if (from.PlaceInBackpack(item))
                            {
                                from.SendLocalizedMessage(500491);                                   // You put some kindling into your backpack.
                                from.SendLocalizedMessage(500492);                                   // An axe would probably get you more wood.
                            }
                            else
                            {
                                from.SendLocalizedMessage(500490);                                   // You can't place any kindling into your backpack!

                                item.Delete();
                            }
                        }
                    }
                }
            }
        }