Beispiel #1
0
        public void Enter(ClientSession session)
        {
            // 플레이어 추가하고
            _sessions.Add(session);
            session.Room = this;

            // 신입 플레이어에게 모든 플레이어 목록 전송
            PlayerList players = new PlayerList();

            foreach (ClientSession s in _sessions)
            {
                players.players.Add(new PlayerList.Player()
                {
                    isSelf   = (s == session),
                    playerId = s.SessionId,
                    position = new PlayerList.Player.Position()
                    {
                        posX = s.PosX,
                        posY = s.PosY,
                        posZ = s.PosZ
                    }
                });
            }
            session.Send(players.Write());

            // 신입 플레이어의 입장을 모두에게 알린다.
            BroadcastEnterGame enter = new BroadcastEnterGame();

            enter.playerId      = session.SessionId;
            enter.position.posX = 0;
            enter.position.posY = 0;
            enter.position.posZ = 0;

            Broadcast(enter.Write());
        }
Beispiel #2
0
    public static void BroadcastEnterGameHandler(PacketSession session, IPacket packet)
    {
        BroadcastEnterGame pkt           = packet as BroadcastEnterGame;
        ServerSession      serverSession = session as ServerSession;

        Debug.Log($"BroadcastEnterGameHandler {pkt}");
        PlayerManager.Instance.EnterGame(pkt);
    }
Beispiel #3
0
    public void EnterGame(BroadcastEnterGame packet)
    {
        Debug.Log("Enter1");
        if (packet.playerId == _myPlayer.PlayerId)
        {
            return;
        }

        Debug.Log("Enter2");
        Object     obj = Resources.Load("Player");
        GameObject go  = Object.Instantiate(obj) as GameObject;

        Player player = go.AddComponent <Player>();

        player.transform.position = new Vector3(packet.position.posX, packet.position.posY, packet.position.posZ);
        _players.Add(packet.playerId, player);
    }
Beispiel #4
0
 public static void BroadcastEnterGameHandler(PacketSession session, IPacket packet)
 {
     BroadcastEnterGame pkt           = packet as BroadcastEnterGame;
     ServerSession      serverSession = session as ServerSession;
 }