Пример #1
0
		public virtual ItemPosition[] Select(SelectMethod sm)
		{
			IList<ItemPosition> items = new List<ItemPosition>();
			DataBlock bl = new DataBlock();
			foreach (string inv in inventoryManager.GetInventoryNames())
			{
				ItemInventory ii = inventoryManager.GetInventory(inv);
				foreach (ItemPosition ip in ii.GetItems())
				{
					bl.AddData(ip);
				}
			}
			if (sm != null)
			{
				foreach (IFeaturable fe in sm.Select(bl).GetAllDatas())
				{
					items.Add((ItemPosition)fe);
				}
			}
			else
			{
				foreach (IFeaturable fe in bl.GetDataList())
				{
					items.Add((ItemPosition)fe);
				}
			}
			return Sharpen.Collections.ToArray(items, new ItemPosition[0]);
		}
Пример #2
0
        public virtual IList <ParaList> Select(IList <ParaList> list, string order, int capacity)
        {
            ICollection <string> exists = new HashSet <string>();
            IList <ParaList>     result = new List <ParaList>();

            if (StringUtil.IsNullOrEmpty(order))
            {
                foreach (ParaList pl in list)
                {
                    string key = GetKey(pl);
                    if (StringUtil.IsNullOrEmpty(key) || !exists.Contains(key))
                    {
                        result.Add(pl);
                        if (!StringUtil.IsNullOrEmpty(key))
                        {
                            exists.Add(key);
                        }
                    }
                    if (capacity > 0 && result.Count >= capacity)
                    {
                        break;
                    }
                }
            }
            else
            {
                DataBlock bl = new DataBlock();
                foreach (ParaList pl in list)
                {
                    bl.AddData(new ParaListSet.ParaFeature(pl));
                }
                SelectMethod sm = new SelectMethod(order);
                int          i  = 1;
                foreach (IFeaturable fe in sm.Select(bl).GetAllDatas())
                {
                    ParaList pl_1 = ((ParaListSet.ParaFeature)fe).paraList;
                    pl_1.AddPara(new IntPara(PARA_ORDER, i++));
                    string key = GetKey(pl_1);
                    if (StringUtil.IsNullOrEmpty(key) || !exists.Contains(key))
                    {
                        result.Add(pl_1);
                        if (!StringUtil.IsNullOrEmpty(key))
                        {
                            exists.Add(key);
                        }
                    }
                    if (capacity > 0 && result.Count >= capacity)
                    {
                        break;
                    }
                }
            }
            return(result);
        }
Пример #3
0
        public virtual void Resort(ISkillArgs args, string order)
        {
            ItemPosition[] ips = GetItems();
            this.Clear();
            ItemPosition[] newOrder = ips;
            if (!StringUtil.IsNullOrEmpty(order))
            {
                IList <ItemPosition> ipList = new List <ItemPosition>();
                DataBlock            bl     = new DataBlock();
                foreach (ItemPosition ip in ips)
                {
                    bl.AddData(ip);
                }
                IList <IFeaturable> list = new SelectMethod(order).Select(bl).GetAllDatas();
                foreach (IFeaturable fe in list)
                {
                    ipList.Add((ItemPosition)fe);
                }
                newOrder = Sharpen.Collections.ToArray(ipList, new ItemPosition[0]);
            }
            bool canReorder = true;

            foreach (ItemPosition ip_1 in newOrder)
            {
                if (inventoryUI != null)
                {
                    inventoryUI.DeleteItem(args, this, ip_1);
                }
                ip_1.key.SetCount(ip_1.count);
                if (!AddItem(null, ip_1.key, false))
                {
                    canReorder = false;
                }
            }
            if (!canReorder)
            {
                this.Clear();
                foreach (ItemPosition ip in ips)
                {
                    AddItem(null, ip.key, false);
                }
            }
            if (inventoryUI != null)
            {
                inventoryUI.ReDraw(args, this, false);
            }
        }
Пример #4
0
        private void AddDataCore(byte[] data)
        {
            for (var offset = 0; offset < data.Length;)
            {
                /* 新規ブロック挿入 */
                if (block_last_ == null)
                {
                    blocks_.Enqueue(block_last_ = new DataBlock());
                }

                /* ブロックにデータを追加 */
                offset += block_last_.AddData(data, offset, data.Length);

                /* オフセットが終端に達していない場合はブロック満タン */
                if (offset < data.Length)
                {
                    block_last_ = null;
                }
            }

            data_size_ += data.Length;
        }
Пример #5
0
        public override void DoAction(IEventArgs args)
        {
            Ini(args);

            List <FreeData> list = new List <FreeData>();

            foreach (PlayerEntity unit in args.GameContext.player.GetInitializedPlayerEntities())
            {
                if (unit.hasFreeData)
                {
                    FreeData fd = (FreeData)unit.freeData.FreeData;
                    args.TempUse(selectedName, fd);
                    if (con == null || con.Meet(args))
                    {
                        list.Add(fd);
                    }
                    args.Resume(selectedName);
                }
            }

            if (!StringUtil.IsNullOrEmpty(order))
            {
                DataBlock bl = new DataBlock();
                foreach (FreeData fd in list)
                {
                    bl.AddData(fd);
                }
                if (method == null || FreeUtil.IsVar(order))
                {
                    method = new SelectMethod(order);
                }
                list.Clear();
                foreach (IFeaturable fe in method.Select(bl).GetAllDatas())
                {
                    list.Add((FreeData)fe);
                }
            }
            if (list.Count > 0)
            {
                if (count > 0)
                {
                    int[] ids = RandomUtil.Random(0, list.Count - 1, count);
                    if (!StringUtil.IsNullOrEmpty(order))
                    {
                        ids = new int[(int)MyMath.Min(count, list.Count)];
                        for (int i = 0; i < ids.Length; i++)
                        {
                            ids[i] = i;
                        }
                    }
                    for (int i = 0; i < ids.Length; i++)
                    {
                        int      id   = ids[i];
                        FreeData unit = list[id];
                        args.TempUsePara(new IntPara("index", i + 1));
                        args.TempUsePara(new IntPara("count", ids.Length));
                        args.TempUse(selectedName, unit);
                        action.Act(args);
                        args.Resume(selectedName);
                        args.ResumePara("index");
                        args.ResumePara("count");
                    }
                }
                else
                {
                    int i = 1;
                    foreach (FreeData unit in list)
                    {
                        args.TempUsePara(new IntPara("index", i++));
                        args.TempUsePara(new IntPara("count", list.Count));
                        args.TempUse(selectedName, unit);
                        action.Act(args);
                        args.Resume(selectedName);
                        args.ResumePara("index");
                        args.ResumePara("count");
                    }
                }
            }
            else
            {
                if (noneAction != null)
                {
                    noneAction.Act(args);
                }
            }
        }