Exemplo n.º 1
0
    public static void C_EnterGameHandler(PacketSession session, IMessage packet)
    {
        C_EnterGame   enterGamePacket = packet as C_EnterGame;
        ClientSession clientSession   = session as ClientSession;

        clientSession.HandleEnterGame(enterGamePacket);
    }
Exemplo n.º 2
0
        // 게임입장
        public void HandleEnterGame(C_EnterGame enterGamePacket)
        {
            if (ServerState != PlayerServerState.ServerStateLobby)
            {
                return;
            }

            LobbyPlayerInfo playerInfo = LobbyPlayers.Find(p => p.Name == enterGamePacket.Name);

            if (playerInfo == null)
            {
                return;
            }

            // 로비에서 캐릭터 선택완료
            MyPlayer = Game.ObjectManager.Instance.Add <Player>();
            {
                MyPlayer.PlayerDbId           = playerInfo.PlayerDbId;
                MyPlayer.Info.Name            = playerInfo.Name;
                MyPlayer.Info.PosInfo.State   = CreatureState.Idle;
                MyPlayer.Info.PosInfo.MoveDir = MoveDir.Down;
                MyPlayer.Info.PosInfo.PosX    = 0;
                MyPlayer.Info.PosInfo.PosY    = 0;
                MyPlayer.Stat.MergeFrom(playerInfo.StatInfo);
                MyPlayer.Session = this;

                S_ItemList itemListPacket = new S_ItemList();

                using (AppDbContext db = new AppDbContext())
                {
                    List <ItemDb> items = db.Items
                                          .Where(i => i.OwnerDbId == playerInfo.PlayerDbId)
                                          .ToList();
                    foreach (ItemDb itemDb in items)
                    {
                        Item item = Item.MakeItem(itemDb);
                        if (item != null)
                        {
                            // 인벤에 넣어주기
                            MyPlayer.Inven.Add(item);

                            // 아이템 정보
                            ItemInfo info = new ItemInfo();
                            info.MergeFrom(item.info);
                            itemListPacket.Items.Add(info);
                        }
                    }
                    // 클라에게 아이템 목록보내기
                    Send(itemListPacket);
                }
            }

            ServerState = PlayerServerState.ServerStateGame;
            // TODO 룸번호 바꾸기
            GameLogic.Instance.Push(() =>
            {
                GameRoom room = GameLogic.Instance.Find(1);
                room.Push(room.EnterGame, MyPlayer, true);
            });
        }
Exemplo n.º 3
0
    public static void C_EnterGameHandler(PacketSession session, IMessage packet)
    {
        C_EnterGame   enterGamePacket = (C_EnterGame)packet;
        ClientSession clientSession   = (ClientSession)session;

        clientSession.HandleEnterGame(enterGamePacket);
    }
Exemplo n.º 4
0
    public static void S_LoginHandler(PacketSession session, IMessage packet)// 로그인 + 캐릭터 목록
    {
        S_Login loginPacket = packet as S_Login;

        // TODO 로그인 성공/실패

        Debug.Log($"loginOK({loginPacket.LoginOk})");

        // TODO : 로비에서 캐릭터 목록 보여주고, 선택
        if (loginPacket.Players == null || loginPacket.Players.Count == 0)
        {
            C_CreatePlayer createPacket = new C_CreatePlayer();
            createPacket.Name = $"Player_{Random.Range(0, 10000).ToString("0000")}";
            Managers.Network.Send(createPacket);
        }
        else
        {
            // 무조건 첫번쨰 캐릭터 로그인
            LobbyPlayerInfo info = loginPacket.Players[0];

            C_EnterGame enterGamePacket = new C_EnterGame();
            enterGamePacket.Name = info.Name;
            Managers.Network.Send(enterGamePacket);
        }
    }
Exemplo n.º 5
0
    // Step 3
    public static void S_CreatePlayerHandler(PacketSession session, IMessage packet)// 플레이어 생성
    {
        S_CreatePlayer createOkPacket = packet as S_CreatePlayer;
        ServerSession  serverSession  = session as ServerSession;

        if (createOkPacket.Player == null)
        {
            // 겹치는 더미클라는 없다
        }
        else
        {
            C_EnterGame enterGamePacket = new C_EnterGame();
            enterGamePacket.Name = createOkPacket.Player.Name;
            serverSession.Send(enterGamePacket);
        }
    }
Exemplo n.º 6
0
    // Step3
    public static void S_CreatePlayerHandler(PacketSession session, IMessage packet)
    {
        S_CreatePlayer createOkPacket = (S_CreatePlayer)packet;
        ServerSession  serverSession  = (ServerSession)session;

        if (createOkPacket.Player == null)
        {
            // 생략
        }
        else
        {
            C_EnterGame enterGamePacket = new C_EnterGame();
            enterGamePacket.Name = createOkPacket.Player.Name;
            serverSession.Send(enterGamePacket);
        }
    }
Exemplo n.º 7
0
    public static void S_CreatePlayerHandler(PacketSession session, IMessage packet)
    {
        S_CreatePlayer createOkPacket = (S_CreatePlayer)packet;

        if (createOkPacket.Player == null)
        {
            C_CreatePlayer createPacket = new C_CreatePlayer();
            createPacket.Name = $"Player_{Random.Range(0, 10000).ToString("0000")}";
            Managers.Network.Send(createPacket);
        }
        else
        {
            C_EnterGame enterGamePacket = new C_EnterGame();
            enterGamePacket.Name = createOkPacket.Player.Name;
            Managers.Network.Send(enterGamePacket);
        }
    }
Exemplo n.º 8
0
    public static void S_CreatePlayerHandler(PacketSession session, IMessage packet)// 플레이어 생성
    {
        S_CreatePlayer createOkPacket = packet as S_CreatePlayer;

        Debug.Log("CreatePlayer");
        if (createOkPacket.Player == null)
        {
            // 플레이어 만들기 실패
            C_CreatePlayer createPacket = new C_CreatePlayer();
            createPacket.Name = $"Player_{Random.Range(0, 10000).ToString("0000")}";
            Managers.Network.Send(createPacket);
        }
        else
        {
            C_EnterGame enterGamePacket = new C_EnterGame();
            enterGamePacket.Name = createOkPacket.Player.Name;
            Managers.Network.Send(enterGamePacket);
        }
    }
Exemplo n.º 9
0
    // Step 2
    public static void S_LoginHandler(PacketSession session, IMessage packet)// 로그인 + 캐릭터 목록
    {
        S_Login       loginPacket   = packet as S_Login;
        ServerSession serverSession = session as ServerSession;

        if (loginPacket.Players == null || loginPacket.Players.Count == 0)
        {
            C_CreatePlayer createPacket = new C_CreatePlayer();
            createPacket.Name = $"DummyPlayer_{serverSession.DummyID.ToString("0000")}";
            serverSession.Send(createPacket);
        }
        else
        {
            // 무조건 첫번쨰 캐릭터 로그인
            LobbyPlayerInfo info = loginPacket.Players[0];

            C_EnterGame enterGamePacket = new C_EnterGame();
            enterGamePacket.Name = info.Name;
            serverSession.Send(enterGamePacket);
        }
    }
Exemplo n.º 10
0
    // Step2
    // 로그인 통과 + 캐릭터 목록
    public static void S_LoginHandler(PacketSession session, IMessage packet)
    {
        S_Login       loginPacket   = packet as S_Login;
        ServerSession serverSession = (ServerSession)session;

        // TODO : 로비 UI에서 케릭터 보여주고, 선택할 수 있도록
        if (loginPacket.Players == null || loginPacket.Players.Count == 0)
        {
            C_CreatePlayer createPacket = new C_CreatePlayer();
            createPacket.Name = $"Player_{serverSession.DummyId.ToString("0000")}";
            serverSession.Send(createPacket);
        }
        else
        {
            // 무조건 첫번째 캐릭터 로그인
            LobbyPlayerInfo info            = loginPacket.Players[0];
            C_EnterGame     enterGamePacket = new C_EnterGame();
            enterGamePacket.Name = info.Name;
            serverSession.Send(enterGamePacket);
        }
    }
Exemplo n.º 11
0
    // 로그인 OK + 캐릭터 목록
    public static void S_LoginHandler(PacketSession session, IMessage packet)
    {
        S_Login loginPacket = (S_Login)packet;

        Debug.Log($"LoginOk({loginPacket.LoginOk})");

        // TODO : 로비 UI에서 캐릭터 보여주고, 선택할 수 있도록
        if (loginPacket.Players == null || loginPacket.Players.Count == 0)
        {
            C_CreatePlayer createPacket = new C_CreatePlayer();
            createPacket.Name = $"Player_{Random.Range(0, 10000).ToString("0000")}";
            Managers.Network.Send(createPacket);
        }
        else
        {
            // 무조건 첫번째 로그인
            LobbyPlayerInfo info            = loginPacket.Players[0];
            C_EnterGame     enterGamePacket = new C_EnterGame();
            enterGamePacket.Name = info.Name;
            Managers.Network.Send(enterGamePacket);
        }
    }