private void PlayerLoadedReceived(MessageReceivedEventArgs ev)
        {
            PlayerLoadedMessage message = (PlayerLoadedMessage) ev.Message;

            NetworkPlayer player = this.players.GetPlayers ().Where (p => p.NetworkID == message.NetworkID).FirstOrDefault ();

            if(player == null)
                return;

            PlayerInfoMessage infomsg = new PlayerInfoMessage ()
            {
                NetworkID = player.NetworkID,
                Name = player.Character.Name,
                Animation = player.Character.Animation,
                Moving = player.Character.Moving,
                TileSheet = player.Character.TileSheet,
                Location = new Point (player.Character.Location.IntX, player.Character.Location.IntY),
                WorldName = player.Character.WorldName
            };

            foreach(NetworkPlayer destPlayer in this.players.GetPlayers ())
            {
                if(destPlayer.Connection != player.Connection)
                    destPlayer.Connection.Send (infomsg);
            }
        }
Ejemplo n.º 2
0
        public void AsyncLoginPlayer(INetworkChannel channel, int messageType, object playerInfoObj)
        {
            IPlayerInfo playerInfo = (IPlayerInfo)playerInfoObj;

            logger.InfoFormat("Received LocalLogin Message ... playerName:{0}", playerInfo.PlayerName);

            if (channelToPlayer.Count == 0 && ContextsWrapper.contexts.player.count == 0)
            {
                ResetContexts(false);
                logger.InfoFormat("Reset All Entity Finish ...");
            }

            if (!channelToPlayer.ContainsKey(channel))
            {
                UpdateTestPlayerInfo(playerInfo);
                // 大厅传入错误RoleModelId
                if (null == SingletonManager.Get <RoleConfigManager>().GetRoleItemById(playerInfo.RoleModelId))
                {
                    logger.Error("RoleModelIdError:  " + playerInfo.RoleModelId);
                    playerInfo.RoleModelId = 2;
                }

                var player = CreateNewPlayerEntity(playerInfo);
                playerInfo.PlayerEntity = player;
                player.ReplaceNetwork(channel);

                playerInfo.StatisticsData = player.statisticsData.Statistics;
                if (ContextsWrapper.FreeArgs.Rule.GameStartTime > 0)
                {
                    playerInfo.StatisticsData.GameJoinTime =
                        ContextsWrapper.FreeArgs.Rule.ServerTime;
                }

                channelToPlayer[channel] = player;
                channel.MessageReceived += ChannelOnMessageReceived;
                channel.Disconnected    += ChannelOnDisonnected;


                if (!player.hasUpdateMessagePool)
                {
                    player.AddUpdateMessagePool();
                }
                player.updateMessagePool.LastestExecuteUserCmdSeq = -1;

                playerInfo.InitPosition = player.position.Value;

                NoticeHallPlayerLoginSucc(player);
                player.ReplaceStage(EPlayerLoginStage.CreateEntity);
                var msg = PlayerInfoMessage.Allocate();
                msg.ConvertFrom(playerInfo);
                channel.SendReliable((int)EServer2ClientMessage.PlayerInfo, msg);
                logger.InfoFormat("player login with name {0}, key {1}, game rule {2}, msp id {3}",
                                  playerInfo.PlayerName, player.entityKey, 0, 0);
                msg.ReleaseReference();
            }
            else
            {
                logger.ErrorFormat("player duplicate login from name:{0}, channe:{1}", playerInfo.PlayerName, channel);
            }
        }
Ejemplo n.º 3
0
    void SpawnRedPlayer()
    {
        PlayerInfoMessage msg = new PlayerInfoMessage(PlayerClass.red);
        var connection        = NetworkManager.singleton.client.connection;

        ClientScene.AddPlayer(connection, 0, msg);
    }
    /// <summary>
    /// Called on the client when connected to a server.
    /// <para>The default implementation of this function sets the client as ready and adds a player. In this method we first determine if the connection is from the host or the client by checking if the connection is also a server.</para>
    /// <para>We do this because the host is a client and the server at the same time. If we don't check the server part of the host, the host get's the same PlayerInfoMessage as a normal client.</para>
    /// <para>For each outcome (host or client) we send a different PlayerInfoMessage. This is done by setting the isServer variable to false when we have send the PlayerInfoMessage from the host.</para>
    /// <para> </para>
    /// </summary>
    /// <param name="conn">Connection to the server.</param>
    public override void OnClientConnect(NetworkConnection conn)
    {
        base.OnClientConnect(conn);

        PlayerInfoMessage message;

        if (isServer)
        {
            message = new PlayerInfoMessage
            {
                playerClass = PlayerClass.Cow,
                description = "hostCow",
                isHost      = true
            };
        }
        else
        {
            message = new PlayerInfoMessage
            {
                playerClass = PlayerClass.Farmer,
                description = "clientFarmer",
                isHost      = false
            };
        }

        conn.Send(message);
        /// Set isServer to false when the hostmessage is send, we don't need it anymore
        isServer = false;
    }
Ejemplo n.º 5
0
    void SpawnBluePlayer()
    {
        PlayerInfoMessage msg = new PlayerInfoMessage(PlayerClass.blue);
        var connection        = NetworkManager.singleton.client.connection;

        Debug.Log(connection);
        ClientScene.AddPlayer(connection, 0, msg);
    }
    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId, NetworkReader extraMessagereader)
    {
        PlayerInfoMessage msg = extraMessagereader.ReadMessage <PlayerInfoMessage> ();

        Debug.Log(msg.playerClass);
        GameObject playerPrefab = spawnPlayerFromClass(msg.playerClass);

        NetworkServer.AddPlayerForConnection(conn, playerPrefab, playerControllerId);
    }
Ejemplo n.º 7
0
        internal async Task UpdatePlayerInfoAsync(Player player)
        {
            PlayerInfoMessage message = new PlayerInfoMessage();

            message.ApiKey   = ApiKey;
            message.Name     = player.Name;
            message.ShipType = player.ShipType;
            await _connection.InvokeAsync("UpdatePlayerInfo", message);
        }
Ejemplo n.º 8
0
    public void SendDataFromClient()
    {
        PlayerInfo pi = new PlayerInfo();

        pi.id         = myNetID;
        pi.name       = playerName;
        pi.team       = team;
        pi.chosenSlot = chosenSlot;
        pi.isReady    = isReady;
        PlayerInfoMessage pmsg = new PlayerInfoMessage();

        pmsg.p = pi;
        myClient.Send(recDataClient, pmsg);
    }
Ejemplo n.º 9
0
        public void Handle(INetworkChannel networkChannel, int messageType, object messageBody)
        {
            if (messageType == (int)EServer2ClientMessage.PlayerInfo)
            {
                PlayerInfoMessage msg = (PlayerInfoMessage)messageBody;
                _logger.InfoFormat("recv PlayerInfo {0}", msg);
                PlayerInfo info = new PlayerInfo();
                info.ConvertFrom(msg);
                _loginSuccReceived = true;

                var playerEntity = PlayerEntityFactory.CreateNewPlayerEntity(_contexts.player, info.InitPosition, info, true, false);
                playerEntity.ReplaceNetwork(networkChannel);
                _contexts.session.commonSession.InitPosition = info.InitPosition;
            }
        }
Ejemplo n.º 10
0
    public void FillInformation()
    {
        PlayerInfoMessage infos = new PlayerInfoMessage();

        infos.id            = JoueurStatic.Numero;
        infos.lastName      = nom.text;
        infos.firstName     = prenom.text;
        infos.age           = age.text;
        infos.specialty     = spec.text;
        infos.establishment = etab.text;


        JoueurStatic.Client.Send(playerInfoId, infos);
        joueur_infos.SetActive(false);
        joueur_choix_cartes.SetActive(true);
    }
Ejemplo n.º 11
0
        private void ProcessPlayerInfoMessage(NumericMessage numericMessage)
        {
            InfoLog.WriteInfo("Processing player info message", EPrefix.ServerProcessInfo);
            PlayerInfoMessage pimsg = (PlayerInfoMessage)MessageFactory.Create(MessageType.PlayerInfoResponse);
            Player            p     = _server.GetPlayer((short)numericMessage.Number);

            if (p == null)
            {
                pimsg.PlayerData = null;
            }
            else
            {
                pimsg.PlayerData = (PlayerData)p.PlayerData.Clone();
            }
            SendMessage(pimsg, numericMessage.SenderId);
        }
Ejemplo n.º 12
0
    void Awake()
    {
        Instance = this;
        UIManager._Instance.OpenWindow(WindowName.Battle);
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        playerDic.Add(NetworkTools.GetLocalIP(), player.GetComponent <PlayerBase>());
        foreach (string item in RoomSingle.GetInfos().Keys)
        {
            if (!item.Equals(NetworkTools.GetLocalIP()))
            {
                PlayerInfoMessage m = RoomSingle.GetInfos()[item];
                InstancePlayerAI(item, m.ID, m.gun1ID, m.gun2ID);
            }
        }

        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;
    }
    /// <summary>
    /// The OnCreatePlayer method
    /// <para>This method is called when a client starts.</para>
    /// <para>It requires a variable from the type GameObject to make the player prefab. We check if the message is coming from the host or from the client.
    /// For each different type of player we instantiate a different playerprefab from the spawnPrefabs list. This spawnPrefabs list refers to the "Registered Spawnable Prefabs"
    /// option in the NetworkManager.</para>
    /// </summary>
    /// <param name="conn">The connection to the server.</param>
    /// <param name="message">The PlayerInfoMessage network message.</param>
    void OnCreatePlayer(NetworkConnection conn, PlayerInfoMessage message)
    {
        GameObject gameobject;

        if (!message.isHost)
        {
            gameobject = Instantiate(spawnPrefabs[1]);
        }
        else
        {
            gameobject = Instantiate(spawnPrefabs[0]);
        }

        // Player player = gameobject.GetComponent<Player>();
        // player.playerClass = message.playerClass;
        // player.description = message.description;

        NetworkServer.AddPlayerForConnection(conn, gameobject);
    }
        private void PlayerRequestReceived(MessageReceivedEventArgs ev)
        {
            var msg = (PlayerRequestMessage) ev.Message;

            NetworkPlayer player = this.players.GetPlayers ().Where (p => p.NetworkID == msg.RequestedPlayerNetworkID).FirstOrDefault ();

            if(player == null)
                return;

            PlayerInfoMessage infomsg = new PlayerInfoMessage ()
            {
                NetworkID = player.NetworkID,
                Name = player.Character.Name,
                Animation = player.Character.Animation,
                Moving = player.Character.Moving,
                TileSheet = player.Character.TileSheet,
                Location = new Point (player.Character.Location.IntX, player.Character.Location.IntY),
                WorldName = player.Character.WorldName
            };

            ev.Connection.Send (infomsg);
        }
        private void PlayersRequestReceived(MessageReceivedEventArgs ev)
        {
            // Get the player, figure out which players are around, and send send those players
            var playerlist = this.players.GetPlayers ();

            foreach(NetworkPlayer player in playerlist)
            {
                if(player.Connection == ev.Connection)
                    continue;

                PlayerInfoMessage infomsg = new PlayerInfoMessage ()
                {
                    NetworkID = player.NetworkID,
                    Name = player.Character.Name,
                    Animation = player.Character.Animation,
                    Moving = player.Character.Moving,
                    TileSheet = player.Character.TileSheet,
                    Location = new Point (player.Character.Location.IntX, player.Character.Location.IntY),
                    WorldName = player.Character.WorldName
                };

                ev.Connection.Send (infomsg);
            }
        }
Ejemplo n.º 16
0
    public override void OnClientSceneChanged(NetworkConnection conn)
    {
        // I need to call this when the scene preparation on the client is completed
        ClientScene.Ready(conn);

        // Create a PlayerInfoMessage object and store player information
        PlayerInfoMessage msg = new PlayerInfoMessage();

        if (isTeacher)
        {
            msg.isTeacher = true;
        }
        else
        {
            msg.isTeacher = false;
        }

        //SpawnPoint scelto dal player
        msg.spawnPoint = spawnPointIndex;

        // Send the AddPlayer message to the server.
        // At that time, add additional information (PlayerInfoMessage) to the third argument.
        ClientScene.AddPlayer(conn, 0, msg);
    }
Ejemplo n.º 17
0
    public override void OnClientConnect(NetworkConnection conn)
    {
        base.OnClientConnect(conn);

        state = State.CONNECTED;

        PlayerType        playerType = FileUtils.GetPlayerType();
        PlayerInfoMessage info       = new PlayerInfoMessage();

        info.nickName = "a";
        Debug.Log("on Client===" + playerType);
        switch (playerType)
        {
        case PlayerType.HOST:
            info.nickName = "b";
            ClientScene.AddPlayer(conn, 0, info);
            break;

        case PlayerType.CLIENT:
            info.nickName = "c";
            ClientScene.AddPlayer(conn, 1, info);
            break;
        }
    }
Ejemplo n.º 18
0
        public void ProcessMessage(Message message)
        {
            handlerSuspender.WaitOne();
            switch (message.Type)
            {
            case MessageType.Result:
            {
                ResultMessage result = message as ResultMessage;
                switch ((ResponseType)result.ResponseType)
                {
                case ResponseType.Login:
                    if (LoginRequestReply != null)
                    {
                        LoginRequestReply(this, new RequestReplyEventArgs(!Convert.ToBoolean(result.Result), ((ResultType)(result.Result)).ToString()));
                    }
                    break;

                case ResponseType.Register:
                    if (RegisterRequestReply != null)
                    {
                        RegisterRequestReply(this, new RequestReplyEventArgs(!Convert.ToBoolean(result.Result), ((ResultType)(result.Result)).ToString()));
                    }
                    break;

                case ResponseType.Remind:
                    if (RemindRequestReply != null)
                    {
                        RemindRequestReply(this, new RequestReplyEventArgs(!Convert.ToBoolean(result.Result), ((ResultType)(result.Result)).ToString()));
                    }
                    break;

                case ResponseType.CreateGame:
                    if (CreateGameRequestReply != null)
                    {
                        CreateGameRequestReply(this, new RequestReplyEventArgs(!Convert.ToBoolean(result.Result), ((ResultType)(result.Result)).ToString()));
                    }
                    break;

                case ResponseType.JoinGame:
                    if (JoinGameRequestReply != null)
                    {
                        JoinGameRequestReply(this, new RequestReplyEventArgs(!Convert.ToBoolean(result.Result), ((ResultType)(result.Result)).ToString()));
                    }
                    break;

                case ResponseType.StartGame:
                    if (StartGameRequestReply != null)
                    {
                        StartGameRequestReply(this, new RequestReplyEventArgs(!Convert.ToBoolean(result.Result), ((ResultType)(result.Result)).ToString()));
                    }
                    break;
                }
            }
            break;

            case MessageType.IdInformation:
            {
                NumericMessage numericMessage = message as NumericMessage;
                ClientPlayerInfo.SenderId = (short)numericMessage.Number;
            }
            break;

            case MessageType.ChatUsers:
            {
                ChatUsersMessage chatMessage = message as ChatUsersMessage;
                switch ((MessageOperation)chatMessage.Option)
                {
                case MessageOperation.Add:
                    if (NewChatUsers != null)
                    {
                        NewChatUsers(this, new ChatEventArgs(chatMessage.ChatUsers.ToArray()));
                    }
                    break;

                case MessageOperation.Remove:
                    if (DeleteChatUsers != null)
                    {
                        DeleteChatUsers(this, new ChatEventArgs(chatMessage.ChatUsers.ToArray()));
                    }
                    break;

                case MessageOperation.List:
                    if (ResetChatUsers != null)
                    {
                        ResetChatUsers(this, new ChatEventArgs(chatMessage.ChatUsers.ToArray()));
                    }
                    break;
                }
            }
            break;

            case MessageType.ChatText:
                if (ChatTextReceive != null)
                {
                    TextMessage textMessage = message as TextMessage;
                    ChatTextReceive(this, new ChatEventArgs(textMessage.Text));
                }
                break;

            case MessageType.PlayerInfoResponse:
                if (PlayerInfoRequestReply != null)
                {
                    PlayerInfoMessage playerInfoMessage = message as PlayerInfoMessage;
                    PlayerInfoRequestReply(this, new RequestReplyEventArgs(true, playerInfoMessage.PlayerData.ToString()));
                }
                break;

            case MessageType.Games:
            {
                GamesMessage gamesMessage = message as GamesMessage;
                switch ((MessageOperation)gamesMessage.Operation)
                {
                case MessageOperation.Add:
                    if (NewGamesInfo != null)
                    {
                        NewGamesInfo(this, new GameEventArgs(gamesMessage.ListGameInfo.ToArray()));
                    }
                    break;

                case MessageOperation.Remove:
                    if (DeleteGamesInfo != null)
                    {
                        DeleteGamesInfo(this, new GameEventArgs(gamesMessage.ListGameInfo.ToArray()));
                    }
                    break;

                case MessageOperation.List:
                    if (ResetGamesInfo != null)
                    {
                        ResetGamesInfo(this, new GameEventArgs(gamesMessage.ListGameInfo.ToArray()));
                    }
                    break;
                }
            }
            break;

            case MessageType.GameParams:
            {
                GameInfoMessage gameInfoMessage = message as GameInfoMessage;
                ClientPlayerInfo.GameInfo = gameInfoMessage.GameInfo;
                if (GameParamsRequestReply != null)
                {
                    GameParamsRequestReply(this, new RequestReplyEventArgs(true, gameInfoMessage.GameInfo.Description));
                }
            }
            break;

            case MessageType.Players:
            {
                PlayersMessage playersMessage = message as PlayersMessage;
                switch ((MessageOperation)playersMessage.Operation)
                {
                case MessageOperation.Add:
                    ClientPlayerInfo.Enemies.Add(playersMessage.PlayerList.ToArray());
                    if (NewPlayers != null)
                    {
                        NewPlayers(this, new PlayerEventArgs(playersMessage.PlayerList.ToArray()));
                    }
                    break;

                case MessageOperation.Remove:
                    ClientPlayerInfo.Enemies.Remove(playersMessage.PlayerList.ToArray());
                    if (DeletePlayers != null)
                    {
                        DeletePlayers(this, new PlayerEventArgs(playersMessage.PlayerList.ToArray()));
                    }
                    break;

                case MessageOperation.Modify:
                {
                    PlayerInfo[] players = playersMessage.PlayerList.ToArray();
                    for (int i = 0; i < players.Length; i++)
                    {
                        if (ClientPlayerInfo.Player.Id == players[i].Id)
                        {
                            ClientPlayerInfo.Player = players[i];
                            break;
                        }
                    }
                    ClientPlayerInfo.Enemies.Modify(players);
                    if (UpdatePlayers != null)
                    {
                        UpdatePlayers(this, new PlayerEventArgs(players));
                    }
                }
                break;

                case MessageOperation.List:
                    ClientPlayerInfo.Enemies.Clear();
                    ClientPlayerInfo.Enemies.Add(playersMessage.PlayerList.ToArray());
                    if (ResetPlayers != null)
                    {
                        ResetPlayers(this, new PlayerEventArgs(playersMessage.PlayerList.ToArray()));
                    }
                    break;
                }
            }
            break;

            default:
                InfoLog.WriteInfo("MenuMessageHandler received unknown message type: " + message.Type, EPrefix.ClientInformation);
                break;
            }
            handlerSuspender.Release();
        }
        public void SendPlayerInfo(int matchId, ushort playerId, Dictionary <int, ushort> entityIds)
        {
            var message = new PlayerInfoMessage(entityIds);

            SendUdp(matchId, playerId, message, true);
        }
Ejemplo n.º 20
0
        public static byte[] Serialize(object message)
        {
            PlayerInfoMessage playerInfoMessage = message as PlayerInfoMessage;

            return(Encoding.ASCII.GetBytes(playerInfoMessage.PlayerName));
        }
Ejemplo n.º 21
0
        public void Message_PlayerInfoReceived(PlayerInfoMessage message)
        {
            PokePlayer player = null;

            if(!this.network.ContainsPlayer(message.NetworkID))
            {
                player = new PokePlayer();
                player.ID = message.NetworkID;
                this.network.AddPlayer(message.NetworkID, player);
            }
            else
            {
                player = (PokePlayer)this.network.GetPlayer(message.NetworkID);
            }

            player.Sprite = this.context.TextureManager.GetTexture(message.TileSheet);
            player.Name = message.Name;
            player.CurrentAnimationName = message.Animation;
            player.Location = new ScreenPoint(message.Location.X, message.Location.Y);
            player.WorldName = message.WorldName;

            if(!player.IsLoaded)
                player.IsLoaded = true;
        }
Ejemplo n.º 22
0
    void Start()
    {
        //Debug.Log(GetComponent<NetworkIdentity>().netId.Value);
        score = GetComponent <ScoreKeeper>();

        if (isServer)
        {
            PlayerInfo p = new PlayerInfo();
            p.id   = (int)GetComponent <NetworkIdentity>().netId.Value;
            p.name = "Player" + numberOfPlayers;
            numberOfPlayers++;
            Debug.Log("amount of players" + NATTraversal.NetworkManager.singleton.numPlayers);
            p.team       = 100;
            p.chosenSlot = 100;
            p.isReady    = false;
            playerChoices.Add(p.id, p);
            playerName = p.name;
            team       = p.team;
            chosenSlot = p.chosenSlot;
            isReady    = false;
            myNetID    = p.id;
            UpdateUI();


            //NetworkServer.RegisterHandler(testMessageFromClient, ReceiveTestMessageFromClient);
            NetworkServer.RegisterHandler(initMessage, ReceiveInitClient);
            NetworkServer.RegisterHandler(recDataClient, ReceivePlayerDataFromClient);
            matchSize = (int)NATTraversal.NetworkManager.singleton.matchSize;
        }
        else
        {
            myClient = NATTraversal.NetworkManager.singleton.client;

            Debug.Log("amount of players" + myClient.connection.playerControllers.Count);
            //myClient.RegisterHandler(testMessageFromServer, ReceiveTestMessage);
            myClient.RegisterHandler(confirmInit, RecInitConfirm);
            myClient.RegisterHandler(recDataServ, ReceivePlayerDataFromServer);
            myClient.RegisterHandler(startGame, ReceiveStartGame);
            //StringMessage msg = new StringMessage();
            PlayerData msg = new PlayerData();
            msg.p              = new Players();
            msg.p.player1      = new PlayerInfo();
            msg.p.player2      = new PlayerInfo();
            msg.p.player1.id   = 2;
            msg.p.player1.name = "Daniel";
            msg.p.player2.id   = 3;
            msg.p.player2.name = "Anders";
            Debug.Log(NATTraversal.NetworkManager.singleton.matchSize);
            //myClient.Send(testMessageFromClient, msg);
            PlayerInfoMessage playermsg = new PlayerInfoMessage();
            playermsg.p            = new PlayerInfo();
            playermsg.p.id         = (int)GetComponent <NetworkIdentity>().netId.Value;
            playermsg.p.name       = "Player" + playermsg.p.id;
            playermsg.p.chosenSlot = 100;
            playermsg.p.team       = 100;
            playermsg.p.isReady    = false;
            playerName             = playermsg.p.name;
            chosenSlot             = 100;
            team    = 100;
            isReady = false;
            myNetID = playermsg.p.id;

            myClient.Send(initMessage, playermsg);
        }
    }
Ejemplo n.º 23
0
        public static void ConvertFrom(this PlayerInfoMessage message, ICreatePlayerInfo info)
        {
            message.Camp        = info.Camp;
            message.Level       = info.Level;
            message.Num         = info.Num;
            message.BackId      = info.BackId;
            message.BadgeId     = info.BadgeId;
            message.EntityId    = info.EntityId;
            message.PlayerId    = info.PlayerId;
            message.PlayerName  = info.PlayerName;
            message.TeamId      = info.TeamId;
            message.TitleId     = info.TitleId;
            message.RoleModelId = info.RoleModelId;
            foreach (var id in info.AvatarIds)
            {
                message.AvatarIds.Add(id);
            }

            foreach (var id in info.WeaponAvatarIds)
            {
                message.WeaponAvatarIds.Add(id);
            }

            foreach (var id in info.SprayLacquers)
            {
                message.SprayLacquers.Add(id);
            }

            foreach (var bag in info.WeaponBags)
            {
                if (null == bag)
                {
                    continue;
                }

                PlayerWeaponBagData bagData = PlayerWeaponBagData.Allocate();
                bagData.BagIndex = bag.BagIndex;
                foreach (var weapon in bag.weaponList)
                {
                    var weaponData = PlayerWeaponData.Allocate();
                    weaponData.Index             = weapon.Index;
                    weaponData.WeaponTplId       = weapon.WeaponTplId;
                    weaponData.WeaponAvatarTplId = weapon.WeaponAvatarTplId;
                    if (weapon.LowerRail > 0)
                    {
                        weaponData.WeaponPartTplId.Add(weapon.LowerRail);
                    }
                    if (weapon.Magazine > 0)
                    {
                        weaponData.WeaponPartTplId.Add(weapon.Magazine);
                    }
                    if (weapon.UpperRail > 0)
                    {
                        weaponData.WeaponPartTplId.Add(weapon.UpperRail);
                    }
                    if (weapon.Muzzle > 0)
                    {
                        weaponData.WeaponPartTplId.Add(weapon.Muzzle);
                    }
                    if (weapon.Stock > 0)
                    {
                        weaponData.WeaponPartTplId.Add(weapon.Stock);
                    }

                    bagData.WeaponList.Add(weaponData);
                }

                message.WeaponBags.Add(bagData);
            }

            message.InitPosition   = Vector3.Allocate();
            message.InitPosition.X = info.InitPosition.x;
            message.InitPosition.Y = info.InitPosition.y;
            message.InitPosition.Z = info.InitPosition.z;
        }
Ejemplo n.º 24
0
        public static void ConvertFrom(this ICreatePlayerInfo info, PlayerInfoMessage message)
        {
            info.Token       = "local";
            info.Camp        = message.Camp;
            info.Level       = message.Level;
            info.Num         = message.Num;
            info.BackId      = message.BackId;
            info.BadgeId     = message.BadgeId;
            info.EntityId    = message.EntityId;
            info.PlayerId    = message.PlayerId;
            info.PlayerName  = message.PlayerName;
            info.TeamId      = message.TeamId;
            info.TitleId     = message.TitleId;
            info.RoleModelId = message.RoleModelId;
            info.AvatarIds   = new List <int>();
            info.AvatarIds.AddRange(message.AvatarIds);
            info.WeaponAvatarIds = new List <int>();
            info.WeaponAvatarIds.AddRange(message.WeaponAvatarIds);
            info.SprayLacquers = new List <int>();
            info.SprayLacquers.AddRange(message.SprayLacquers);
            info.WeaponBags = new Core.Room.PlayerWeaponBagData[message.WeaponBags.Count];
            for (var i = message.WeaponBags.Count - 1; i >= 0; i--)
            {
                info.WeaponBags[i]            = new Core.Room.PlayerWeaponBagData();
                info.WeaponBags[i].BagIndex   = message.WeaponBags[i].BagIndex;
                info.WeaponBags[i].weaponList = new List <Core.Room.PlayerWeaponData>();
                Core.Room.PlayerWeaponData weaponData;
                foreach (var playerWeaponData in message.WeaponBags[i].WeaponList)
                {
                    //info.WeaponBags[i].weaponList.Add(
                    weaponData = new Core.Room.PlayerWeaponData
                    {
                        Index             = playerWeaponData.Index,
                        WeaponTplId       = playerWeaponData.WeaponTplId,
                        WeaponAvatarTplId = playerWeaponData.WeaponAvatarTplId
                    };
                    foreach (var part in playerWeaponData.WeaponPartTplId)
                    {
                        var type = SingletonManager.Get <WeaponPartsConfigManager>().GetPartType(part);
                        switch (type)
                        {
                        case EWeaponPartType.LowerRail:
                            weaponData.LowerRail = part;
                            break;

                        case EWeaponPartType.Magazine:
                            weaponData.Magazine = part;
                            break;

                        case EWeaponPartType.Muzzle:
                            weaponData.Muzzle = part;
                            break;

                        case EWeaponPartType.SideRail:
                            break;

                        case EWeaponPartType.Stock:
                            weaponData.Stock = part;
                            break;

                        case EWeaponPartType.UpperRail:
                            weaponData.UpperRail = part;
                            break;
                        }
                    }

                    info.WeaponBags[i].weaponList.Add(weaponData);
                }
            }

            info.InitPosition =
                new UnityEngine.Vector3(message.InitPosition.X, message.InitPosition.Y,
                                        message.InitPosition.Z);
        }