Beispiel #1
0
        private void handleFromGround(string from, string to, ServerRoom room, FreeData fd)
        {
            if (from.StartsWith(Ground) && !to.StartsWith(Ground))
            {
                SimpleItemInfo info = PickupItemUtil.GetGroundItemInfo(room, fd, from);
                if (info.cat > 0)
                {
                    ItemInventory inv = fd.freeInventory.GetInventoryManager().GetInventory("ground");

                    if (inv != null)
                    {
                        inv.Clear();
                        FreeItem item = FreeItemManager.GetItem(room.FreeArgs, FreeItemConfig.GetItemKey(info.cat, info.id), info.count);
                        item.GetParameters().AddPara(new IntPara("entityId", info.entityId));
                        inv.AddItem(room.FreeArgs, item, false);

                        DragGroundOne(fd, room, to);
                    }
                    else
                    {
                        Debug.LogErrorFormat("inventory {0} not existed.", from);
                    }
                }
            }
        }
Beispiel #2
0
        private void CreateItemFromItemDrop(IEventArgs fr, Vector3 p, ItemDrop drop, string realName)
        {
            FreeMoveEntity en = fr.GameContext.freeMove.CreateEntity();

            en.AddEntityKey(new EntityKey(fr.GameContext.session.commonSession.EntityIdGenerator.GetNextEntityId(), (short)EEntityType.FreeMove));
            en.AddPosition();
            en.position.Value = new Vector3(p.x, p.y, p.z);

            en.AddFreeData(FreeUtil.ReplaceVar(name, fr), null);
            en.AddPositionFilter(Core.Components.PositionFilterType.Filter2D, 1000);
            if (type == 1)
            {
                en.freeData.Cat = FreeEntityConstant.DeadBox;
            }
            else if (type == 2)
            {
                en.freeData.Cat = FreeEntityConstant.DropBox;
            }

            en.AddFlagImmutability(fr.GameContext.session.currentTimeObject.CurrentTime);

            SimpleItemInfo info = new SimpleItemInfo(realName, drop.cat, drop.id, drop.count, en.entityKey.Value.EntityId);

            en.freeData.Value = SingletonManager.Get <DeadBoxParser>().ToString(info);

            en.isFlagSyncNonSelf = true;
        }
Beispiel #3
0
        void OnReceivedItemPurchaseConfirmation(SimpleItemInfo msg)
        {
            ReloadContainerItems();

            if (OnPurchasedItem != null)
            {
                OnPurchasedItem(msg);
            }
        }
Beispiel #4
0
        private void FillBox(Dictionary <string, List <FreeMoveEntity> > dic, Dictionary <int, ItemBar> cache, bool dead)
        {
            int index = 0;

            foreach (var name in dic.Keys)
            {
                ItemBar caseName = AddCaseName(name);
                if (caseName != null)
                {
                    if (dead)
                    {
                        cache.Add(-100 + index++, caseName);
                    }
                    else
                    {
                        cache.Add(-200 + index++, caseName);
                    }
                }

                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;
                    }
                    ItemBar prefab = AddChild(info.cat, info.id, count, info.entityId);

                    if (prefab != null)
                    {
                        cache.Add(info.entityId, prefab);
                    }
                }
            }
        }
        private bool CanChangeBag(ServerRoom room, FreeData fd, string key)
        {
            if (key.StartsWith(ChickenConstant.BagGround))
            {
                SimpleItemInfo info = PickupItemUtil.GetGroundItemInfo(room, fd, key);

                return(BagCapacityUtil.CanChangeBag(room.ContextsWrapper.FreeArgs, fd, info.cat, info.id));
            }
            return(true);
        }
        public static SimpleItemInfoDto ToDto(this SimpleItemInfo entity)
        {
            var dto = new SimpleItemInfoDto
            {
                ItemName = entity.ItemName,
                Date     = entity.Date
            };

            return(dto);
        }
        public static SimpleItemInfoDto ToDto(this SimpleItemInfo simpleItemInfo)
        {
            var dto = new SimpleItemInfoDto
            {
                ItemName = simpleItemInfo.ItemName,
                Date     = simpleItemInfo.Date
            };

            return(dto);
        }
        public static SimpleItemInfo MapSimpleItemInfo(this SimpleItemInfoDto simpleItemInfoDto, string itemName = "")
        {
            var simpleItemInfo = new SimpleItemInfo
            {
                ItemName = itemName.Equals("") ? simpleItemInfoDto.ItemName : itemName,
                Date     = simpleItemInfoDto.Date
            };

            return(simpleItemInfo);
        }
Beispiel #9
0
        private void HandleAuto(string from, string to, ServerRoom room, FreeData fd)
        {
            SimpleItemInfo info = PickupItemUtil.GetGroundItemInfo(room, fd, from);

            if (PickupItemUtil.AddItemToPlayer(room, fd.Player, info.entityId, info.cat, info.id, info.count, to))
            {
                SimpleProto sp = FreePool.Allocate();
                sp.Key = FreeMessageConstant.PlaySound;
                sp.Ks.Add(2);
                sp.Ins.Add(5018);
                sp.Bs.Add(false);
                FreeMessageSender.SendMessage(fd.Player, sp);
            }
        }
        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);
                }
            }
        }
Beispiel #11
0
        private bool HandleBag(string from, string to, ServerRoom room, FreeData fd)
        {
            FreeItemInfo info = null;

            if (from.StartsWith(ChickenConstant.BagGround))
            {
                SimpleItemInfo sinfo = PickupItemUtil.GetGroundItemInfo(room, fd, from);
                info = FreeItemConfig.GetItemInfo(sinfo.cat, sinfo.id);
            }
            else
            {
                ItemPosition ip = FreeItemManager.GetItemPosition(room.ContextsWrapper.FreeArgs, from, fd.freeInventory.GetInventoryManager());
                if (ip == null)
                {
                    ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory(from.Trim());
                    if (ii != null && ii.posList.Count > 0)
                    {
                        ip = ii.posList[0];
                    }
                }
                if (ip != null)
                {
                    info = FreeItemConfig.GetItemInfo(ip.key.GetKey());
                }
            }

            if (info != null && info.cat == 9)
            {
                RoleAvatarConfigItem avatar = SingletonManager.Get <RoleAvatarConfigManager>().GetConfigById(info.id);
                if (avatar.Capacity > 0)
                {
                    if (from.StartsWith(ChickenConstant.BagGround) && !to.StartsWith(ChickenConstant.BagGround))
                    {
                        return(BagCapacityUtil.CanAddToBag(room.ContextsWrapper.FreeArgs, fd, info.cat, info.id, 1));
                    }

                    if (to.StartsWith(ChickenConstant.BagGround) && !from.StartsWith(ChickenConstant.BagGround))
                    {
                        return(BagCapacityUtil.CanTakeOff(room.ContextsWrapper.FreeArgs, fd, info.cat, info.id));
                    }
                }
            }

            return(true);
        }
        private int CreateItemFromInventory(IEventArgs fr, FreeData fd, ItemInventory ii, Vector3 p, string realName, int entityId)
        {
            int itemAdded = 0;

            if (ii != null && ii.name != ChickenConstant.BagGround)
            {
                foreach (ItemPosition ip in ii.GetItems())
                {
                    FreeMoveEntity en = fr.GameContext.freeMove.CreateEntity();
                    en.AddEntityKey(new EntityKey(fr.GameContext.session.commonSession.EntityIdGenerator.GetNextEntityId(), (short)EEntityType.FreeMove));
                    en.AddPosition();
                    en.position.Value = new Vector3(p.x, p.y, p.z);

                    en.AddFreeData(FreeUtil.ReplaceVar(name, fr), null);
                    en.AddPositionFilter(Core.Components.PositionFilterType.Filter2D, 1000);
                    en.freeData.Cat = FreeEntityConstant.DeadBox;

                    FreeItemInfo itemInfo = FreeItemConfig.GetItemInfo(ip.GetKey().GetKey());

                    if (itemInfo.cat == (int)ECategory.Weapon)
                    {
                        int key = CarryClipUtil.GetWeaponKey(ii.name, fd);
                        if (key >= 1 && key <= 3)
                        {
                            CarryClipUtil.AddCurrentClipToBag(key, fd, fr);
                        }
                    }

                    en.AddFlagImmutability(fr.GameContext.session.currentTimeObject.CurrentTime);

                    SimpleItemInfo info = new SimpleItemInfo(realName, itemInfo.cat, itemInfo.id, ip.GetCount(), en.entityKey.Value.EntityId);
                    en.freeData.Value    = SingletonManager.Get <DeadBoxParser>().ToString(info);
                    en.freeData.IntValue = entityId;

                    en.isFlagSyncNonSelf = true;

                    itemAdded++;
                }
            }

            return(itemAdded);
        }
Beispiel #13
0
        public static SimpleItemInfo GetGroundItemInfo(ServerRoom room, FreeData fd, string key)
        {
            SimpleItemInfo freeItem = new SimpleItemInfo();

            string[] xy = StringUtil.Split(key, ParaConstant.SPLITER_COMMA);
            if (xy.Length == 3)
            {
                string name = xy[0];
                int    x    = NumberUtil.GetInt(xy[1]);
                int    y    = NumberUtil.GetInt(xy[2]);

                if (x == 0)
                {
                    SceneObjectEntity entity = room.RoomContexts.sceneObject.GetEntityWithEntityKey(new EntityKey(y, (short)EEntityType.SceneObject));
                    if (entity != null)
                    {
                        freeItem.entityId = entity.entityKey.Value.EntityId;
                        freeItem.cat      = entity.simpleEquipment.Category;
                        freeItem.id       = entity.simpleEquipment.Id;
                        freeItem.count    = entity.simpleEquipment.Count;
                    }
                    else
                    {
                        FreeMoveEntity moveEntity = room.RoomContexts.freeMove.GetEntityWithEntityKey(new EntityKey(y, (short)EEntityType.FreeMove));
                        if (moveEntity != null)
                        {
                            SimpleItemInfo info = (SimpleItemInfo)SingletonManager.Get <DeadBoxParser>().FromString(moveEntity.freeData.Value);
                            freeItem.entityId = moveEntity.entityKey.Value.EntityId;
                            freeItem.cat      = info.cat;
                            freeItem.id       = info.id;
                            freeItem.count    = info.count;
                        }
                        else
                        {
                            Debug.LogErrorFormat("entity {0} not existed.", key);
                        }
                    }
                }
            }

            return(freeItem);
        }
Beispiel #14
0
        public static TestRunDto ToDto(this TestRun testRun, SimpleItemInfo testOutputInfo)
        {
            var testRunDto = new TestRunDto
            {
                Categories  = testRun.Categories,
                Description = testRun.Description,
                Events      = testRun.Events.Select(teDto => new TestEventDto
                {
                    Started   = teDto.Started,
                    Finished  = teDto.Finished,
                    Comment   = teDto.Comment,
                    EventInfo = teDto.EventInfo.ToDto()
                }).ToList(),
                FullName    = testRun.FullName,
                Name        = testRun.Name,
                Output      = testOutputInfo.ToDto(),
                Priority    = testRun.Priority,
                Result      = testRun.Result,
                RunGuid     = testRun.RunGuid,
                Screenshots = testRun.Screenshots.Select(s => s.ToDto()).ToList(),
                TestInfo    = testRun.TestInfo.ToDto(),
                Duration    = testRun.Duration.Equals(0.0)
                    ? (testRun.TestInfo.Finish - testRun.TestInfo.Start).TotalSeconds
                    : testRun.Duration,
                TestMessage    = testRun.TestMessage,
                TestStackTrace = testRun.TestStackTrace,
                TestType       = testRun.TestType,
                TestData       = testRun.TestData.Select(tdDto => new TestDataDto
                {
                    Actual       = tdDto.Actual,
                    Expected     = tdDto.Expected,
                    Comment      = tdDto.Comment,
                    TestDataInfo = tdDto.TestDataInfo.ToDto()
                }).ToList()
            };

            return(testRunDto);
        }
 void UnityUIItemPurchase_OnPurchasedItem(SimpleItemInfo obj)
 {
     UpdateLabels();
 }
Beispiel #16
0
        public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message)
        {
            FreeData fd = (FreeData)player.freeData.FreeData;

            room.FreeArgs.TempUse(PARA_PLAYER_CURRENT, fd);
            eventKey.SetValue(message.Ss[0]);
            room.FreeArgs.GetDefault().GetParameters().TempUse(eventKey);

            room.GameRule.HandleFreeEvent(room.RoomContexts, player, message);

            string key = message.Ss[0];

            Debug.LogFormat("click item {0}. ", key);
            if (message.Bs[0])
            {
                // 显示拆分UI
                if (message.Bs[1])
                {
                    PickupItemUtil.ShowSplitUI(room, fd, key);
                    return;
                }
                if (key.StartsWith("ground"))
                {
                    SimpleItemInfo info = PickupItemUtil.GetGroundItemInfo(room, fd, key);
                    if (info.cat > 0)
                    {
                        if (CanChangeBag(room, fd, key))
                        {
                            PickupItemUtil.AddItemToPlayer(room, player, info.entityId, info.cat, info.id, info.count);
                        }
                    }
                }
                else if (key.StartsWith("default"))
                {
                    ItemPosition ip   = FreeItemManager.GetItemPosition(room.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager());
                    FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey());
                    if (info.cat == (int)ECategory.WeaponPart)
                    {
                        string inv = PickupItemUtil.AutoPutPart(fd, FreeItemConfig.GetItemInfo(info.cat, info.id));
                        if (inv != null && inv != "default")
                        {
                            ItemInventoryUtil.MovePosition(ip,
                                                           fd.GetFreeInventory().GetInventoryManager().GetInventory(inv), 0, 0, room.FreeArgs);
                        }
                    }
                    else
                    {
                        FreeItemManager.UseItem(key, fd, room.FreeArgs);
                    }
                }
                // 点击装配好的配件,自动进背包
                else if (key.StartsWith("w") && key.Length == 3)
                {
                    ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory(key);
                    ItemInventory defaultInventory = fd.GetFreeInventory().GetInventoryManager().GetDefaultInventory();

                    if (ii != null && ii.posList.Count > 0)
                    {
                        ItemPosition ip = ii.posList[0];
                        if (BagCapacityUtil.CanAddToBag(room.FreeArgs, fd, ip))
                        {
                            int[] xy = defaultInventory.GetNextEmptyPosition(ip.GetKey());
                            ItemInventoryUtil.MovePosition(ip,
                                                           defaultInventory, xy[0], xy[1], room.FreeArgs);
                        }
                    }
                }
                else
                {
                    FreeItemManager.UseItem(key, fd, room.FreeArgs);
                }
            }

            room.FreeArgs.Resume(PARA_PLAYER_CURRENT);
            room.FreeArgs.GetDefault().GetParameters().Resume(PARA_EVENT_KEY);
        }
Beispiel #17
0
 void UnityUIItemPurchase_OnPurchasedItem(SimpleItemInfo obj)
 {
     purchasePopup.SetActive(true);
     purchasePopup.GetComponentInChildren <Text>().text = "Purchase Successful";
 }
Beispiel #18
0
        private void HandleAuto(string from, string to, ServerRoom room, FreeData fd)
        {
            SimpleItemInfo info = PickupItemUtil.GetGroundItemInfo(room, fd, from);

            PickupItemUtil.AddItemToPlayer(room, fd.Player, info.entityId, info.cat, info.id, info.count, to);
        }
        public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message)
        {
            FreeData fd = (FreeData)player.freeData.FreeData;

            room.ContextsWrapper.FreeArgs.TempUse(PARA_PLAYER_CURRENT, fd);
            eventKey.SetValue(message.Ss[0]);
            room.ContextsWrapper.FreeArgs.GetDefault().GetParameters().TempUse(eventKey);

            room.GameRule.HandleFreeEvent(room.RoomContexts, player, message);

            string key = message.Ss[0];

            Debug.LogFormat("click item {0}. ", key);
            if (message.Bs[0])
            {
                // 显示拆分UI
                if (message.Bs[1])
                {
                    PickupItemUtil.ShowSplitUI(room, fd, key);
                    return;
                }
                if (key.StartsWith(ChickenConstant.BagGround))
                {
                    SimpleItemInfo info = PickupItemUtil.GetGroundItemInfo(room, fd, key);
                    if (info.cat > 0)
                    {
                        if (CanChangeBag(room, fd, key))
                        {
                            if (PickupItemUtil.AddItemToPlayer(room, player, info.entityId, info.cat, info.id, info.count))
                            {
                                SimpleProto sp = FreePool.Allocate();
                                sp.Key = FreeMessageConstant.PlaySound;
                                sp.Ks.Add(2);
                                sp.Ins.Add(5018);
                                sp.Bs.Add(false);
                                FreeMessageSender.SendMessage(player, sp);
                            }
                        }
                    }
                }
                else if (key.StartsWith(ChickenConstant.BagDefault))
                {
                    ItemPosition ip   = FreeItemManager.GetItemPosition(room.ContextsWrapper.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager());
                    FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey());
                    if (info.cat == (int)ECategory.WeaponPart)
                    {
                        string inv = PickupItemUtil.AutoPutPart(fd, FreeItemConfig.GetItemInfo(info.cat, info.id));
                        if (inv != null && inv != ChickenConstant.BagDefault)
                        {
                            ItemInventoryUtil.MovePosition(ip,
                                                           fd.GetFreeInventory().GetInventoryManager().GetInventory(inv), 0, 0, room.ContextsWrapper.FreeArgs);
                        }
                    }
                    else
                    {
                        FreeItemManager.UseItem(key, fd, room.ContextsWrapper.FreeArgs);
                    }
                }
                // 点击装配好的配件,自动进背包
                else if (key.StartsWith("w") && key.IndexOf(",") == 3)
                {
                    ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory(key.Substring(0, 3));
                    ItemInventory defaultInventory = fd.GetFreeInventory().GetInventoryManager().GetDefaultInventory();

                    if (ii != null && ii.posList.Count > 0)
                    {
                        ItemPosition ip = ii.posList[0];
                        if (BagCapacityUtil.CanDemountAttachment(room, fd, FreeItemConfig.GetItemInfo(ip.key.GetKey()), key, false))
                        {
                            int[] xy = defaultInventory.GetNextEmptyPosition(ip.GetKey());
                            ItemInventoryUtil.MovePosition(ip,
                                                           defaultInventory, xy[0], xy[1], room.ContextsWrapper.FreeArgs);
                        }
                    }
                }
                else
                {
                    FreeItemManager.UseItem(key, fd, room.ContextsWrapper.FreeArgs);
                }
            }

            room.ContextsWrapper.FreeArgs.Resume(PARA_PLAYER_CURRENT);
            room.ContextsWrapper.FreeArgs.GetDefault().GetParameters().Resume(PARA_EVENT_KEY);
        }