示例#1
0
 private void handleToGround(string from, string to, ServerRoom room, FreeData fd)
 {
     if (!from.StartsWith(Ground) && to.StartsWith(Ground))
     {
         FreeItemManager.DragItem(from, fd, room.FreeArgs, Ground);
     }
 }
示例#2
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);
                    }
                }
            }
        }
示例#3
0
        private static void DropPart(string inv, FreeData fd, ServerRoom room)
        {
            int           c3 = fd.freeInventory.GetInventoryManager().GetInventory(inv).posList.Count;
            ItemInventory w3 = fd.freeInventory.GetInventoryManager().GetInventory(inv);

            if (c3 > 0)
            {
                ItemPosition ip = w3.posList[0];

                w3.RemoveItem(room.FreeArgs, ip);

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

                if (BagCapacityUtil.CanAddToBag(room.FreeArgs, fd, ip))
                {
                    fd.freeInventory.GetInventoryManager().GetDefaultInventory().AddItem(room.FreeArgs, ip.key, true);
                }
                else
                {
                    if (info.cat > 0)
                    {
                        room.RoomContexts.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity(
                            (ECategory)info.cat,
                            info.id,
                            ip.GetCount(), fd.Player.position.Value);
                    }
                }
            }
        }
        public bool CanHandle(ServerRoom room, PlayerEntity player, SimpleProto message)
        {
            if (message.Key != FreeMessageConstant.PlayerSprayPaint)
            {
                return(false);
            }
            int serverTime = room.RoomContexts.session.currentTimeObject.CurrentTime;
            var config     = IndividuationConfigManager.GetInstance().GetConfigById(message.Ins[0]);
            int intervalCD = 0;

            if (null == config)
            {
                intervalCD = 0;
            }
            else
            {
                intervalCD = config.IntervalCD;
            }

            if (player.playerSpray.mLastCreateTime + intervalCD < serverTime)
            {
                return(true);
            }
            else
            {
                //TODO 喷漆CD提示
                return(false);
            }
        }
示例#5
0
        public FreeGameRule(ServerRoom room)
        {
            this.args   = (FreeRuleEventArgs)room.RoomContexts.session.commonSession.FreeArgs;
            this.mapId  = room.RoomContexts.session.commonSession.RoomInfo.MapId;
            this.ruleId = room.RoomContexts.session.commonSession.RoomInfo.ModeId;

            this.Room = room;

            RandomUtil.SetSeed(RandomUtil.Random(1, 10000000));

            SendMessageAction.sender = new FreeMessageSender();

            try
            {
                string         rule   = RuleMap.GetRuleName(ruleId);
                FreeRuleConfig config = FreeRuleConfig.GetRule(rule, SingletonManager.Get <ServerFileSystemConfigManager>().BootConfig.Mysql);
                args.Triggers.Merge(config.Triggers);
                args.ComponentMap = config.GameComponentMap;
                args.AddDefault(this);
                args.Functions.Merge(config.Functions);
                args.rule = this;
                args.FreeContext.TestCase.Merge(config.Triggers);
            }
            catch (Exception e)
            {
                Debug.LogError("加载模式" + RuleMap.GetRuleName(ruleId) + "失败.\n" + e.Message);
                _logger.Error("加载模式" + RuleMap.GetRuleName(ruleId) + "失败.\n", e);
            }

            this.paras = new SimpleParaList();
            paras.AddFields(new ObjectFields(this));

            this.paras.AddPara(new IntPara(StatePara, 0));
            this.paras.AddPara(new IntPara(EnterPara, 0));
        }
示例#6
0
        public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message)
        {
            FreeData fd = (FreeData)player.freeData.FreeData;

            room.FreeArgs.TempUse(PARA_PLAYER_CURRENT, fd);

            string key   = message.Ss[0];
            int    count = message.Ins[0];

            if (key.StartsWith(ChickenConstant.BagDefault))
            {
                ItemPosition ip   = FreeItemManager.GetItemPosition(room.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager());
                FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey());

                if (ip.GetCount() > count)
                {
                    ip.SetCount(ip.GetCount() - count);
                    ip.GetInventory().GetInventoryUI().ReDraw((ISkillArgs)room.FreeArgs, ip.GetInventory(), true);
                }
                else
                {
                    ip.GetInventory().RemoveItem((ISkillArgs)room.FreeArgs, ip);
                }

                room.RoomContexts.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity(
                    (Assets.XmlConfig.ECategory)info.cat,
                    info.id,
                    count,
                    fd.Player.position.Value);
            }

            room.FreeArgs.Resume(PARA_PLAYER_CURRENT);
        }
示例#7
0
 public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message)
 {
     if (BagCapacityUtil.CanAddToBag(room.FreeArgs, (FreeData)player.freeData.FreeData, message.Ins[1], message.Ins[2], message.Ins[3]))
     {
         PickupItemUtil.AddItemToPlayer(room, player, message.Ins[0], message.Ins[1], message.Ins[2], message.Ins[3]);
     }
 }
示例#8
0
        public void TestRoomJoinInANotEmptyRoomRedLight()
        {
            Assert.That(server.GetNumberOfRoom(), Is.EqualTo(0));
            Packet packet = new Packet(0);

            transport.ClientEnqueue(packet, "tester", 0);
            server.SingleStep();
            Assert.That(server.GetAllClientsConnetedToThisServer(), Is.EqualTo(1));
            Assert.That(server.GetNumberOfRoom(), Is.Not.EqualTo(0));
            uint       roomID = BitConverter.ToUInt32(transport.ClientDequeue().data, 1);
            ServerRoom room   = server.GetRoomFromID(roomID);

            Assert.That(room, Is.Not.EqualTo(null));
            Assert.That(room.RoomID, Is.EqualTo(roomID));
            Assert.That(room.GetClientsNumber, Is.Not.EqualTo(0));


            Packet packetClient01 = new Packet(0);

            transport.ClientEnqueue(packetClient01, "foobar", 0);
            server.SingleStep();
            Assert.That(server.GetAllClientsConnetedToThisServer(), Is.EqualTo(2));
            Assert.That(server.GetNumberOfRoom(), Is.Not.EqualTo(2));
            Assert.That(room.GetClientsNumber, Is.Not.EqualTo(1));
        }
 public DebugMessageHandler(Contexts contexts, ServerRoom converter) : base(converter)
 {
     _contexts            = contexts;
     room                 = converter;
     _handler             = new ServerDebugCommandHandler(_contexts);
     _sessionStateMachine = converter.GetSessionStateMachine();
 }
        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);
        }
示例#11
0
 private void DragGroundOne(FreeData fd, ServerRoom room, string to)
 {
     if (to.StartsWith("default"))
     {
         FreeItemManager.DragItem("ground,0,0", fd, room.FreeArgs, "default");
     }
     else
     {
         FreeItemManager.DragItem("ground,0,0", fd, room.FreeArgs, to);
     }
 }
示例#12
0
 private void DragGroundOne(FreeData fd, ServerRoom room, string to)
 {
     if (to.StartsWith(ChickenConstant.BagDefault))
     {
         FreeItemManager.DragItem("ground,0,0", fd, room.ContextsWrapper.FreeArgs, ChickenConstant.BagDefault);
     }
     else
     {
         FreeItemManager.DragItem("ground,0,0", fd, room.ContextsWrapper.FreeArgs, to);
     }
 }
示例#13
0
        public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message)
        {
            FreeData fd = (FreeData)player.freeData.FreeData;

            room.ContextsWrapper.FreeArgs.TempUse(PARA_PLAYER_CURRENT, fd);

            string key   = message.Ss[0];
            int    count = message.Ins[0];

            if (key.StartsWith(ChickenConstant.BagDefault))
            {
                ItemPosition ip   = FreeItemManager.GetItemPosition(room.ContextsWrapper.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager());
                FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey());

                if (ip.GetCount() > count)
                {
                    if (info.cat == (int)ECategory.Weapon && SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(info.id).Type == (int)EWeaponType_Config.ThrowWeapon)
                    {
                        CarryClipUtil.DeleteGrenade(count, info.id, fd, room.ContextsWrapper.FreeArgs);
                        for (int i = 0; i < count; i++)
                        {
                            player.WeaponController().RemoveGreande(info.id);
                        }
                    }
                    else
                    {
                        ip.SetCount(ip.GetCount() - count);
                        ip.GetInventory().GetInventoryUI().ReDraw((ISkillArgs)room.ContextsWrapper.FreeArgs, ip.GetInventory(), true);
                    }
                }
                else
                {
                    ip.GetInventory().RemoveItem((ISkillArgs)room.ContextsWrapper.FreeArgs, ip);
                }

                room.RoomContexts.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleObjectEntity(
                    (ECategory)info.cat, info.id, count, fd.Player.position.Value);

                if (info.cat == (int)ECategory.GameItem && SingletonManager.Get <GameItemConfigManager>().GetConfigById(info.id).Type == (int)GameItemType.Bullet)
                {
                    player.WeaponController().SetReservedBullet((EBulletCaliber)info.id, CarryClipUtil.GetClipCount(info.id, fd, room.ContextsWrapper.FreeArgs));
                }

                SimpleProto sp = FreePool.Allocate();
                sp.Key = FreeMessageConstant.PlaySound;
                sp.Ks.Add(2);
                sp.Ins.Add(5017);
                sp.Bs.Add(false);
                FreeMessageSender.SendMessage(fd.Player, sp);
            }

            room.ContextsWrapper.FreeArgs.Resume(PARA_PLAYER_CURRENT);
        }
示例#14
0
        public static bool CanExchangeAttachment(ServerRoom room, FreeData fd, FreeItemInfo fromPart, FreeItemInfo toPart, WeaponBaseAgent fromAgent, WeaponBaseAgent toAgent)
        {
            double capacity = Math.Round(GetCapacity(fd) - GetWeight(fd), 3);

            int toBullet   = SingletonManager.Get <WeaponPartsConfigManager>().GetConfigById(WeaponPartUtil.GetWeaponFstMatchedPartId(toPart.id, fromAgent.ConfigId)).Bullet;
            int fromBullet = SingletonManager.Get <WeaponPartsConfigManager>().GetConfigById(WeaponPartUtil.GetWeaponFstMatchedPartId(fromPart.id, toAgent.ConfigId)).Bullet;

            if (toBullet == fromBullet)
            {
                return(true);
            }

            int overBulletFrom = fromAgent.BaseComponent.Bullet - fromAgent.WeaponConfigAssy.PropertyCfg.Bullet - toBullet;
            int overBulletTo   = toAgent.BaseComponent.Bullet - toAgent.WeaponConfigAssy.PropertyCfg.Bullet - fromBullet;

            float bulletWeight = 0f;

            if (overBulletFrom > 0)
            {
                bulletWeight += SingletonManager.Get <GameItemConfigManager>().GetConfigById((int)fromAgent.Caliber).Weight *overBulletFrom;
            }

            if (overBulletTo > 0)
            {
                bulletWeight += SingletonManager.Get <GameItemConfigManager>().GetConfigById((int)toAgent.Caliber).Weight *overBulletTo;
            }

            if (capacity < bulletWeight)
            {
                SimpleProto msg = FreePool.Allocate();
                msg.Key = FreeMessageConstant.ChickenTip;
                msg.Ss.Add("word79");
                FreeMessageSender.SendMessage(fd.Player, msg);
                return(false);
            }

            if (overBulletFrom > 0)
            {
                fromAgent.BaseComponent.Bullet = fromAgent.WeaponConfigAssy.PropertyCfg.Bullet + toBullet;
                CarryClipUtil.AddClip(overBulletFrom, (int)fromAgent.Caliber, fd, room.ContextsWrapper.FreeArgs);
                fd.Player.WeaponController().SetReservedBullet(fromAgent.Caliber, CarryClipUtil.GetClipCount((int)fromAgent.Caliber, fd, room.ContextsWrapper.FreeArgs));
            }

            if (overBulletTo > 0)
            {
                toAgent.BaseComponent.Bullet = toAgent.WeaponConfigAssy.PropertyCfg.Bullet + fromBullet;
                CarryClipUtil.AddClip(overBulletTo, (int)toAgent.Caliber, fd, room.ContextsWrapper.FreeArgs);
                fd.Player.WeaponController().SetReservedBullet(toAgent.Caliber, CarryClipUtil.GetClipCount((int)toAgent.Caliber, fd, room.ContextsWrapper.FreeArgs));
            }

            return(true);
        }
示例#15
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        deckButton = GameObject.Find("DeckMakeButton");
    }
示例#16
0
        private void handleToGround(string from, string to, ServerRoom room, FreeData fd)
        {
            PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, fd.Player.gamePlay);
            FreeItemManager.DragItem(from, fd, room.ContextsWrapper.FreeArgs, ChickenConstant.BagGround);

            SimpleProto sp = FreePool.Allocate();

            sp.Key = FreeMessageConstant.PlaySound;
            sp.Ks.Add(2);
            sp.Ins.Add(5017);
            sp.Bs.Add(false);
            FreeMessageSender.SendMessage(fd.Player, sp);
        }
示例#17
0
        public static void Handle(ServerRoom room, DebugCommand message, PlayerEntity player)
        {
            if (commandDic.ContainsKey(message.Command.ToLower()))
            {
                FreeLog.Reset();

                IGameAction action = commandDic[message.Command.ToLower()];

                if (FreeLog.IsEnable())
                {
                    FreeLog.SetTrigger(string.Format("命令行 {0}: {1}", message.Command, string.Join(" ", message.Args)));
                }

                if (commandPara == null)
                {
                    commandPara = new StringPara("command", "");
                }

                if (message.Args != null)
                {
                    for (int i = 1; i <= message.Args.Length; i++)
                    {
                        room.FreeArgs.TempUsePara(new StringPara("arg" + i, message.Args[i - 1]));
                    }
                }


                room.FreeArgs.TempUsePara(commandPara);
                room.FreeArgs.TempUse("current", (FreeData)player.freeData.FreeData);

                action.Act(room.FreeArgs);

                if (message.Command == "relive")
                {
                    player.isFlagCompensation = true;
                }

                room.FreeArgs.Resume("current");
                room.FreeArgs.ResumePara("command");

                if (message.Args != null)
                {
                    for (int i = 1; i <= message.Args.Length; i++)
                    {
                        room.FreeArgs.ResumePara("arg" + i);
                    }
                }

                FreeLog.Print();
            }
        }
示例#18
0
        public ServerGamePlayModule(Contexts contexts, ServerRoom room)
        {
            var gameRule = contexts.session.serverSessionObjects.GameRule;

            //AddSystem(new SimplePlayerLifeSystem(contexts, contexts.serverSession.sessionObjects));
            AddSystem(new BulletReloadSystem(contexts, contexts.session.commonSession));
            AddSystem(new FreePlayerCmdSystem(contexts, room));
            AddSystem(new RigidbodyDebugInfoSystem(contexts));
            AddSystem(new MapObjectDebugInfoSystem(contexts));
            AddSystem(new LocalEventPlaySystem(contexts, true));
            AddSystem(new FreePredictCmdSystem(contexts));

            AddSystem(new ObserveSystem(contexts));
        }
    private void InitializeServer(ServerRoom roomConfiguration)
    {
        ConsoleConfiguration.Initailize();

        //Fill in our Network Manager Details from our configuration
        networkPort    = roomConfiguration.Port;
        networkAddress = roomConfiguration.HostAddress;
        offlineScene   = m_ClientSettings.OfflineScene;
        onlineScene    = roomConfiguration.HostOnlineScene;

        StartServer();

        Debug.Log("The server has successfully started!");
    }
示例#20
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);
            }
        }
示例#21
0
        public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message)
        {
            int serverTime = room.RoomContexts.session.currentTimeObject.CurrentTime;

            ClientEffectFactory.CreateSprayPaint(room.RoomContexts.clientEffect,
                                                 room.RoomContexts.session.commonSession.EntityIdGenerator,
                                                 new Vector3(message.Fs[0], message.Fs[1], message.Fs[2]),
                                                 new Vector3(message.Fs[3], message.Fs[4], message.Fs[5]),
                                                 1,
                                                 new Vector3(message.Fs[6], message.Fs[7], message.Fs[8]),
                                                 XmlConfig.ESprayPrintType.TypeBounds_1,
                                                 message.Ins[0], message.Ins[1]);
            player.playerSpray.mLastCreateTime = (float)serverTime;
        }
示例#22
0
        private OutgoingMessage CreateSyncRoomMessage(ServerRoom room)
        {
            OutgoingMessage roomSyncMsg = null;

            var somethingToSync = room?.NeedSync ?? false;

            if (somethingToSync)
            {
                roomSyncMsg = this.CreateServerMessage(ClientIncomingMessageTypes.RefreshCurrentRoomProperties);
                room.WriteSyncMessage(roomSyncMsg);
            }

            return(roomSyncMsg);
        }
示例#23
0
        public void TestGameServerRoomCreationRedLigth()
        {
            Assert.That(server.GetNumberOfRoom(), Is.EqualTo(0));
            Packet packet = new Packet(0);

            transport.ClientEnqueue(packet, "tester", 0);
            server.SingleStep();
            Assert.That(server.GetAllClientsConnetedToThisServer(), Is.Not.EqualTo(0));

            Assert.That(server.GetNumberOfRoom(), Is.Not.EqualTo(0));
            uint       roomID = BitConverter.ToUInt32(transport.ClientDequeue().data, 1);
            ServerRoom room   = server.GetRoomFromID(roomID);

            Assert.That(room, Is.Not.EqualTo(null));
        }
示例#24
0
        public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message)
        {
            bool witness = message.Bs[0];

            player.gamePlay.Witness = witness;
            if (witness)
            {
                player.playerMask.SelfMask = (byte)EPlayerMask.Invincible;
            }
            else
            {
                player.playerMask.SelfMask   = (byte)EPlayerMask.TeamA | (byte)EPlayerMask.TeamB;
                player.playerMask.TargetMask = (byte)EPlayerMask.TeamA | (byte)EPlayerMask.TeamB;
            }
        }
示例#25
0
        private void MovePartToWeapon(ServerRoom room, FreeData fd, ItemPosition ip, string to, FreeItemInfo info)
        {
            string inv = PickupItemUtil.AutoPutPart(fd, info, to, room);

            if (inv != null && inv != "default")
            {
                ItemInventory toInv = fd.freeInventory.GetInventoryManager().GetInventory(inv);
                int[]         xy    = toInv.GetNextEmptyPosition(ip.key);
                ItemInventoryUtil.MovePosition(ip,
                                               toInv, xy[0], xy[1], room.FreeArgs);
            }
            else
            {
                FuntionUtil.Call(room.FreeArgs, "showBottomTip", "msg", "{desc:10076}");
            }
        }
示例#26
0
        public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message)
        {
            room.GameRule.HandleFreeEvent(room.RoomContexts, player, 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);

            FreeItemManager.MoveItem(message.Ss[0], fd, room.FreeArgs, message.Ins[0], message.Ins[1], message.Ins[2], message.Ins[3],
                                     message.Ins[4], message.Ins[5], message.Ins[6], message.Ins[7]);

            room.FreeArgs.Resume(PARA_PLAYER_CURRENT);
            room.FreeArgs.GetDefault().GetParameters().Resume(PARA_EVENT_KEY);
        }
示例#27
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);
        }
示例#28
0
    void Start()
    {
        foreach (ServerSortSettings sss in sortListItems)
        {
            sss.sortDirection     = -1;
            sss.sortArrow.enabled = false;
        }

        onlinePageNumber = 1;
        localPageNumber  = 1;
        maximumPages     = 1;
        curSelection     = null; oldSelection = null;
        isOnlineList     = true;
        runOnce          = true;
        quickJoin        = false;
        refreshTime      = -1;
        PopulateList(serversPerPage);
    }
示例#29
0
        private void MovePartToWeapon(ServerRoom room, FreeData fd, ItemPosition ip, string to, FreeItemInfo info)
        {
            string inv = PickupItemUtil.AutoPutPart(fd, info, to, room);

            if (inv != null && inv != ChickenConstant.BagDefault)
            {
                ItemInventory toInv = fd.freeInventory.GetInventoryManager().GetInventory(inv);
                int[]         xy    = toInv.GetNextEmptyPosition(ip.key);
                ItemInventoryUtil.MovePosition(ip, toInv, xy[0], xy[1], room.ContextsWrapper.FreeArgs);
            }
            else
            {
                SimpleProto msg = FreePool.Allocate();
                msg.Key = FreeMessageConstant.ChickenTip;
                msg.Ss.Add("word76");
                FreeMessageSender.SendMessage(fd.Player, msg);
            }
        }
示例#30
0
        public void TestRoomJoinInAFullRoomGreenLight()
        {
            Assert.That(server.GetNumberOfRoom(), Is.EqualTo(0));
            Packet packetClient00 = new Packet(0);

            transport.ClientEnqueue(packetClient00, "tester", 0);
            server.SingleStep();
            Assert.That(server.GetAllClientsConnetedToThisServer(), Is.EqualTo(1));
            Assert.That(server.GetNumberOfRoom(), Is.EqualTo(1));
            uint       roomID = BitConverter.ToUInt32(transport.ClientDequeue().data, 1);
            ServerRoom room   = server.GetRoomFromID(roomID);

            Assert.That(room, Is.Not.EqualTo(null));
            Assert.That(room.RoomID, Is.EqualTo(roomID));
            Assert.That(room.GetClientsNumber, Is.EqualTo(1));

            Assert.That(room.IsOccupy, Is.EqualTo(false));

            Packet packetClient01 = new Packet(0);

            transport.ClientEnqueue(packetClient01, "foobar", 0);
            server.SingleStep();
            Assert.That(server.GetAllClientsConnetedToThisServer(), Is.EqualTo(2));
            Assert.That(server.GetNumberOfRoom(), Is.EqualTo(1));
            Assert.That(room.GetClientsNumber, Is.EqualTo(2));

            Packet packetClient02 = new Packet(0);

            transport.ClientEnqueue(packetClient02, "anotherTester", 0);
            server.SingleStep();
            Assert.That(server.GetAllClientsConnetedToThisServer(), Is.EqualTo(3));
            Assert.That(server.GetNumberOfRoom(), Is.EqualTo(2));
            Assert.That(room.GetClientsNumber, Is.EqualTo(2));

            Assert.That(room.IsOccupy, Is.EqualTo(true));

            uint       newRoomID = BitConverter.ToUInt32(transport.ClientDequeue().data, 0);
            ServerRoom newRoom   = server.GetRoomFromID(newRoomID);

            Assert.That(newRoom, Is.Not.EqualTo(null));
            Assert.That(newRoom.RoomID, Is.EqualTo(newRoomID));
            Assert.That(newRoom.GetClientsNumber, Is.EqualTo(1));
            Assert.That(newRoom.IsOccupy, Is.EqualTo(false));
        }