Ejemplo n.º 1
0
        public static void Handle_GameStart(ClientConnection Client, PacketReader reader, byte last)
        {
            Account User = Client.CurrentAccount;
            //.sendStartGame(65), currentTick=0
            //FF C0 02 FF 13 03 41 00 00 00 60 6C 32 48 3B 04 00 00 C8 00 00 00 6E 00 00 00 80
            int iGameStartTick = reader.ReadLEInt32();

            reader.ReadLEInt32(); //unk1
            reader.ReadLEInt32(); //unk2
            int iNumberOfItem = reader.ReadLEInt32();

            reader.ReadLEInt32(); //unk3

            NormalRoom room = Rooms.GetRoom(User.CurrentRoomId);

            //onRecvStartGame: iGameStartTick=65, iNumberOfItem=200 (CurTick=2)
            //room.StartTime = Utility.CurrentTimeMilliseconds();
            room.Survival   = (byte)room.PlayerCount();
            room.CapsuleNum = iNumberOfItem;
            room.StartGame();
            room.Players.ForEach((RoomPlayer) => {
                RoomPlayer.Connection.SendAsync(new GameRoom_START_GAME_RES(RoomPlayer, iGameStartTick, iNumberOfItem, last));
                RoomPlayer.Connection.SendAsync(new GameRoom_Hex("FFA80500000000", last));
                RoomPlayer.GameEndType = 0;
                RoomPlayer.GameOver    = false;
            });
            if (room.PlayingMapNum == 1606)
            {
                for (byte i = 0; i <= 7; i++)
                {
                    Account Hare = room.Players.Find(p => p.RoomPos == i);
                    if (Hare.Partner > 7)
                    {
                        Account Tortoise = room.Players.Where(p => p.Team == Hare.Team && p.Partner > 7 && p.RoomPos != i).OrderBy(_ => Guid.NewGuid()).Take(1).ToArray()[0];
                        Hare.Animal         = 0;
                        Hare.Partner        = Tortoise.RoomPos;
                        Hare.TeamLeader     = true;
                        Tortoise.Animal     = 1;
                        Tortoise.Partner    = Hare.RoomPos;
                        Tortoise.TeamLeader = false;
                    }
                }
                room.BroadcastToAll(new AllocatePartner(room, last));
                room.StartHareAndTortoiseThread();
            }

            if (room.RuleType == 8)
            {
                int startlaptime = 100 * 1000;
                room.Players.ForEach((RoomPlayer) => {
                    RoomPlayer.CurrentLapTime = startlaptime;
                    RoomPlayer.LastLapTime    = 0;
                    RoomPlayer.Connection.SendAsync(new Amsan_LapTimeControl(0, startlaptime, startlaptime, false, last));
                });
            }
        }