Exemple #1
0
        public override bool Harvest(PlayerObject player)
        {
            if (RemainingSkinCount == 0)
            {
                for (int i = _drops.Count - 1; i >= 0; i--)
                {
                    if (player.CheckGroupQuestItem(_drops[i]))
                    {
                        _drops.RemoveAt(i);
                    }
                    else
                    {
                        if (player.CanGainItem(_drops[i]))
                        {
                            player.GainItem(_drops[i]);
                            _drops.RemoveAt(i);
                        }
                    }
                }

                if (_drops.Count == 0)
                {
                    Harvested = true;
                    _drops    = null;
                    Broadcast(new S.ObjectHarvested {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation
                    });
                }
                else
                {
                    player.ReceiveChat("你拿不动了.", ChatType.System);
                }

                return(true);
            }

            if (--RemainingSkinCount > 0)
            {
                return(true);
            }


            _drops = new List <UserItem>();

            for (int i = 0; i < Info.Drops.Count; i++)
            {
                DropInfo drop = Info.Drops[i];

                int rate = (int)(drop.Chance / Settings.DropRate); if (rate < 1)
                {
                    rate = 1;
                }
                if (drop.Gold > 0 || Envir.Random.Next(rate) != 0)
                {
                    continue;
                }

                UserItem item = Envir.CreateDropItem(drop.Item);
                if (item == null)
                {
                    continue;
                }

                if (drop.QuestRequired)
                {
                    if (!player.CheckGroupQuestItem(item, false))
                    {
                        continue;
                    }
                }

                if (item.Info.Type == ItemType.Meat)
                {
                    item.CurrentDura = (ushort)Math.Max(0, item.CurrentDura + Quality);
                }

                _drops.Add(item);
            }


            if (_drops.Count == 0)
            {
                player.ReceiveChat("什么都没找到.", ChatType.System);
                Harvested = true;
                _drops    = null;
                Broadcast(new S.ObjectHarvested {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation
                });
            }


            return(true);
        }
Exemple #2
0
        public override bool Harvest(PlayerObject player)
        {
            if (RemainingSkinCount == 0)
            {
                for (int i = _drops.Count - 1; i >= 0; i--)
                {
                    if (player.CheckGroupQuestItem(_drops[i]))
                    {
                        _drops.RemoveAt(i);
                    }
                    else
                    {
                        if (player.CanGainItem(_drops[i]))
                        {
                            player.GainItem(_drops[i]);
                            _drops.RemoveAt(i);
                        }
                    }
                }

                if (_drops.Count == 0)
                {
                    Harvested = true;
                    _drops    = null;
                    Broadcast(new S.ObjectHarvested {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation
                    });
                }
                else
                {
                    player.ReceiveChat("You cannot carry anymore.", ChatType.System);
                }

                return(true);
            }

            if (--RemainingSkinCount > 0)
            {
                return(true);
            }


            _drops = new List <UserItem>();

            for (int i = 0; i < Info.Drops.Count; i++)
            {
                DropInfo drop = Info.Drops[i];

                var reward = drop.AttemptDrop(EXPOwner?.Stats[Stat.ItemDropRatePercent] ?? 0, EXPOwner?.Stats[Stat.GoldDropRatePercent] ?? 0);

                if (reward != null)
                {
                    foreach (var dropItem in reward.Items)
                    {
                        UserItem item = Envir.CreateDropItem(dropItem);
                        if (item == null)
                        {
                            continue;
                        }

                        if (drop.QuestRequired)
                        {
                            if (!player.CheckGroupQuestItem(item, false))
                            {
                                continue;
                            }
                        }

                        if (item.Info.Type == ItemType.Meat)
                        {
                            item.CurrentDura = (ushort)Math.Max(0, item.CurrentDura + Quality);
                        }

                        _drops.Add(item);
                    }
                }
            }

            if (_drops.Count == 0)
            {
                player.ReceiveChat("Nothing was found.", ChatType.System);
                Harvested = true;
                _drops    = null;
                Broadcast(new S.ObjectHarvested {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation
                });
            }

            return(true);
        }