示例#1
0
        public void ProcessGoods(bool clear = false)
        {
            if (!Settings.GoodsOn)
            {
                return;
            }

            var script = NPCScript.Get(ScriptID);

            List <UserItem> deleteList = new List <UserItem>();

            foreach (var playerGoods in BuyBack)
            {
                List <UserItem> items = playerGoods.Value;

                for (int i = 0; i < items.Count; i++)
                {
                    UserItem item = items[i];

                    if (DateTime.Compare(item.BuybackExpiryDate.AddMinutes(Settings.GoodsBuyBackTime), Envir.Now) <= 0 || clear)
                    {
                        deleteList.Add(BuyBack[playerGoods.Key][i]);

                        if (script.UsedTypes.Count != 0 && !script.UsedTypes.Contains(item.Info.Type))
                        {
                            continue;
                        }

                        var multiCount = UsedGoods.Count(x => x.Info.Index == item.Info.Index);

                        if (multiCount >= Settings.GoodsMaxStored)
                        {
                            UserItem nonAddedItem = UsedGoods.FirstOrDefault(e => e.IsAdded == false);

                            if (nonAddedItem != null)
                            {
                                UsedGoods.Remove(nonAddedItem);
                            }
                            else
                            {
                                UsedGoods.RemoveAt(0);
                            }
                        }

                        UsedGoods.Add(item);
                        NeedSave = true;
                    }
                }

                for (int i = 0; i < deleteList.Count; i++)
                {
                    BuyBack[playerGoods.Key].Remove(deleteList[i]);
                }
            }
        }
示例#2
0
文件: NPCObject.cs 项目: xiaoweb/mir2
        public void LoadScript()
        {
            if (ScriptID > 0)
            {
                Envir.Scripts.Remove(ScriptID);
            }

            var script = new NPCScript(ObjectID, Info.FileName, NPCScriptType.Normal);

            ScriptID = script.ScriptID;
        }
示例#3
0
        private void LoadScript()
        {
            var script = NPCScript.GetOrAdd(ObjectID, Info.FileName, NPCScriptType.Normal);

            ScriptID = script.ScriptID;
        }