Exemplo n.º 1
0
        protected virtual void HandleUpdatePartyAtClient(LiteNetLibMessageHandler messageHandler)
        {
            UpdatePartyMessage message = messageHandler.ReadMessage <UpdatePartyMessage>();

            if (message.type == UpdatePartyMessage.UpdateType.Create)
            {
                ClientParty = new PartyData(message.id, message.shareExp, message.shareItem, message.characterId);
            }
            else if (ClientParty != null && ClientParty.id == message.id)
            {
                switch (message.type)
                {
                case UpdatePartyMessage.UpdateType.ChangeLeader:
                    ClientParty.SetLeader(message.characterId);
                    break;

                case UpdatePartyMessage.UpdateType.Setting:
                    ClientParty.Setting(message.shareExp, message.shareItem);
                    break;

                case UpdatePartyMessage.UpdateType.Terminate:
                    ClientParty = null;
                    break;
                }
            }
            if (onClientUpdateParty != null)
            {
                onClientUpdateParty.Invoke(ClientParty);
            }
        }
        public static void SendPartyTerminate(this TransportHandler transportHandler, long?connectionId, ushort msgType, int id)
        {
            var netMessage = new UpdatePartyMessage();

            netMessage.type = UpdatePartyMessage.UpdateType.Terminate;
            netMessage.id   = id;
            Send(transportHandler, connectionId, msgType, netMessage);
        }
        public static void SendChangePartyLeader(this TransportHandler transportHandler, long?connectionId, ushort msgType, int id, string characterId)
        {
            var netMessage = new UpdatePartyMessage();

            netMessage.type        = UpdatePartyMessage.UpdateType.ChangeLeader;
            netMessage.id          = id;
            netMessage.characterId = characterId;
            Send(transportHandler, connectionId, msgType, netMessage);
        }
        public static void SendPartySetting(this TransportHandler transportHandler, long?connectionId, ushort msgType, int id, bool shareExp, bool shareItem)
        {
            var netMessage = new UpdatePartyMessage();

            netMessage.type      = UpdatePartyMessage.UpdateType.Setting;
            netMessage.id        = id;
            netMessage.shareExp  = shareExp;
            netMessage.shareItem = shareItem;
            Send(transportHandler, connectionId, msgType, netMessage);
        }
        public static void SendCreateParty(this TransportHandler transportHandler, long?connectionId, ushort msgType, int id, bool shareExp, bool shareItem, string characterId)
        {
            var netMessage = new UpdatePartyMessage();

            netMessage.type        = UpdatePartyMessage.UpdateType.Create;
            netMessage.id          = id;
            netMessage.shareExp    = shareExp;
            netMessage.shareItem   = shareItem;
            netMessage.characterId = characterId;
            Send(transportHandler, connectionId, msgType, netMessage);
        }