Example #1
0
    public static void S_EnterRoomHandler(PacketSession session, IMessage packet)
    {
        S_EnterRoom   enterGamePacket = packet as S_EnterRoom;
        ServerSession serverSession   = session as ServerSession;

        Debug.Log("S_EnterGameHandler");
    }
    public static void C_JoinRoomHandler(PacketSession session, IMessage packet)
    {
        ClientSession clientSession = session as ClientSession;
        C_JoinRoom    joinPacket    = packet as C_JoinRoom;

        Console.WriteLine("Joinroom " + joinPacket.RoomId);
        GameRoom gameRoom = RoomManager.Instance.Find(joinPacket.RoomId);

        if (gameRoom.isCreating || gameRoom.isPlaying)
        {
            return;
        }
        //TODO 비밀번호 체크
        clientSession.MyPlayer.Info.ChNum = joinPacket.ChNum;
        gameRoom.EnterRoom(clientSession.MyPlayer);
        S_EnterRoom enterRoomPacket = new S_EnterRoom();

        enterRoomPacket.Player = clientSession.MyPlayer.Info;
        clientSession.Send(enterRoomPacket);
        S_MapSaveDataSend mapSendPacket = new S_MapSaveDataSend();
        int index = 0;

        foreach (MapSave m in clientSession.MyPlayer.Room.MData.Map)
        {
            mapSendPacket.Map   = m;
            mapSendPacket.Index = index;
            clientSession.Send(mapSendPacket);
            index++;
            Console.WriteLine("MapSend : " + m.MapCell.Count);
        }
        S_MobSpawn mobSpawnPacket = new S_MobSpawn();

        foreach (Monster m in clientSession.MyPlayer.Room._Monsters)
        {
            mobSpawnPacket.Mobs.Add(m.Info);
        }
        clientSession.Send(mobSpawnPacket);
    }