示例#1
0
        public override void OnDoubleClick(Mobile f)
        {
            NubiaPlayer from = f as NubiaPlayer;

            if (!from.InRange(this.GetWorldLocation(), 1))
            {
                from.SendMessage("C'est trop loin");
                return;
            }

            if (m_State == EnumPlanteState.Graine)
            {
                CheckPlantation(from);
            }
            else if (m_State == EnumPlanteState.GrainePlante)
            {
                from.Emote("*Ecrase la graine*");
                this.Delete();
            }
            else if (m_State == EnumPlanteState.Naissante)
            {
                from.Emote("*Saccage la plante*");
                this.Delete();
            }
            else if (m_State == EnumPlanteState.Jeune)
            {
                int rollGraine = from.Competences[CompType.Agriculture].intRoll();
                if (rollGraine <= DD)
                {
                    from.Emote("*Saccage la plante*");
                    this.Delete();
                }
                else
                {
                    from.Emote("*Cueille et récupère les graines*");
                    Type       type   = this.GetType();
                    BasePlante plante = (BasePlante)Activator.CreateInstance(type);
                    int        amount = (int)rollGraine / 5;
                    if (amount < 1)
                    {
                        amount = 1;
                    }
                    from.SendMessage("Vous récupérez {0} graines", amount);
                    plante.Amount = amount;
                    plante.Hue    = Hue;
                    if (from.Backpack != null)
                    {
                        from.Backpack.DropItem(plante);
                    }
                }
            }
            else if (m_State == EnumPlanteState.Mature)
            {
                int rollRecolte = from.Competences[CompType.Agriculture].intRoll();
                if (rollRecolte <= DD)
                {
                    from.Emote("*Saccage la plante*");
                    this.Delete();
                }
                else
                {
                    from.Emote("*Récolte*");
                    Item item = AgriHelper.GetRecolteItem(m_Plante);
                    if (item == null)
                    {
                        NubiaRecolte plante = new NubiaRecolte(m_Plante, rollRecolte, CanEat);
                        plante.Hue = Hue;
                        if (from.Backpack != null)
                        {
                            from.Backpack.DropItem(plante);
                        }
                    }
                    else
                    {
                        if (item.Stackable && (int)m_rollResult > 1)
                        {
                            item.Amount = (int)m_rollResult;
                        }
                        if (from.Backpack != null)
                        {
                            from.Backpack.DropItem(item);
                        }
                    }
                    this.Delete();
                }
            }
            else if (m_State == EnumPlanteState.Pourri)
            {
                from.Emote("*Déffriche*");
                this.Delete();
            }
        }