Пример #1
0
        private void FillBox(Dictionary <string, List <FreeMoveEntity> > dic, bool dead)
        {
            int index = 0;

            foreach (var name in dic.Keys)
            {
                var titleData = new ChickenBagItemUiData {
                    isBagTitle = true, title = name
                };
                _groundItemDataList.Add(titleData);
                List <SimpleItemInfo> infos = new List <SimpleItemInfo>();
                foreach (var item in dic[name])
                {
                    object obj = SingletonManager.Get <DeadBoxParser>().FromString(item.freeData.Value);
                    if (obj == null)
                    {
                        continue;
                    }

                    SimpleItemInfo info = (SimpleItemInfo)obj;
                    info.entityId = item.entityKey.Value.EntityId;

                    infos.Add(info);
                }

                infos.Sort(new ItemInfoSorter());

                foreach (SimpleItemInfo info in infos)
                {
                    int count = info.count;
                    if (info.cat == (int)ECategory.Weapon)
                    {
                        count = 0;
                    }
                    if (info.cat == (int)ECategory.Avatar)
                    {
                        count = 0;
                    }

                    var data = new ChickenBagItemUiData
                    {
                        cat   = info.cat,
                        id    = info.id,
                        count = count,
                        key   = "1|" + info.entityId
                    };
                    _groundItemDataList.Add(data);
                }
            }
        }
Пример #2
0
        public bool RefreshGround()
        {
            HashSet <int> current = new HashSet <int>();

            foreach (var item in _contexts.sceneObject.GetEntities())
            {
                if (item.hasPosition &&
                    IsNear(item.position.Value, Player.position.Value) &&
                    item.hasSimpleItem && item.simpleItem.Category > 0 &&
                    HasNoObstacle(item, Player))
                {
                    current.Add(item.entityKey.Value.EntityId);
                }
            }

            foreach (var item in _contexts.freeMove.GetEntities())
            {
                if (item.hasPosition &&
                    item.hasFreeData &&
                    IsNear(item.position.Value, Player.position.Value) &&
                    HasNoObstacle(item, Player))
                {
                    current.Add(item.entityKey.Value.EntityId);
                }
            }

            if (current.SetEquals(groundEntitySet))
            {
                return(false);
            }

            List <SceneObjectEntity> list = new List <SceneObjectEntity>();
            Dictionary <string, List <FreeMoveEntity> > deadList = new Dictionary <string, List <FreeMoveEntity> >();
            Dictionary <string, List <FreeMoveEntity> > dropList = new Dictionary <string, List <FreeMoveEntity> >();

            foreach (var id in current)
            {
                var sceneEntity =
                    _contexts.sceneObject.GetEntityWithEntityKey(
                        new Core.EntityComponent.EntityKey(id, (short)EEntityType.SceneObject));
                if (null != sceneEntity)
                {
                    list.Add(sceneEntity);
                    continue;
                }

                var freeMoveEntity =
                    _contexts.freeMove.GetEntityWithEntityKey(
                        new Core.EntityComponent.EntityKey(id, (short)EEntityType.FreeMove));
                {
                    if (freeMoveEntity.freeData.Cat == FreeEntityConstant.DeadBox)
                    {
                        if (!deadList.ContainsKey(freeMoveEntity.freeData.Key))
                        {
                            deadList.Add(freeMoveEntity.freeData.Key, new List <FreeMoveEntity>());
                        }

                        deadList[freeMoveEntity.freeData.Key].Add(freeMoveEntity);
                    }

                    if (freeMoveEntity.freeData.Cat == FreeEntityConstant.DropBox)
                    {
                        if (!dropList.ContainsKey(freeMoveEntity.freeData.Key))
                        {
                            dropList.Add(freeMoveEntity.freeData.Key, new List <FreeMoveEntity>());
                        }

                        dropList[freeMoveEntity.freeData.Key].Add(freeMoveEntity);
                    }
                }
            }

            _groundItemDataList.Clear();
            FillBox(dropList, false);
            FillBox(deadList, true);
            list.Sort(new SceneObjectSorter());
            if (list.Count > 0)
            {
                var titleData = new ChickenBagItemUiData {
                    isBagTitle = true, title = "地面"
                };
                _groundItemDataList.Add(titleData);
            }
            foreach (var item in list)
            {
                var data = new ChickenBagItemUiData
                {
                    cat   = item.simpleItem.Category,
                    id    = item.simpleItem.Id,
                    count = item.simpleItem.Category == (int)ECategory.Weapon ? 1:
                            item.simpleItem.Count,
                    key = "1|" + item.entityKey.Value.EntityId
                };
                _groundItemDataList.Add(data);
            }
            groundEntitySet = current;

            return(true);
        }