public override void RunImpl() { Channel channel = getClient().getPlayer().getChannel(); Room room = getClient().getPlayer().getRoom(); Player player = getClient().getPlayer(); if (room.getLeader().Equals(getClient().getPlayer())) { if (room.isFigth() == 0) { room.setFigth(1); room.setTimeLost(room.getKillTime() * 60); } if (room.getPlayers() != null) { if (getClient().getPlayer().getRoom().getPlayers() != null) { foreach (Player member in getClient().getPlayer().getRoom().getPlayers().Values) { SLOT slot = room.getRoomSlotByPlayer(member); if (slot.getState() == SLOT_STATE.SLOT_STATE_READY && !room.getLeader().Equals(member)) { slot.setState(SLOT_STATE.SLOT_STATE_LOAD); member.getClient().SendPacket(new PROTOCOL_BATTLE_READYBATTLE_ACK(room,getClient().getPlayer())); } else if (room.getLeader().Equals(member)) { slot.setState(SLOT_STATE.SLOT_STATE_LOAD); member.getClient().SendPacket(new PROTOCOL_BATTLE_READYBATTLE_ACK(room,member)); } } } } } else { SLOT slotLeader = room.getRoomSlotByPlayer(room.getLeader()); SLOT slot = room.getRoomSlotByPlayer(getClient().getPlayer()); if (slotLeader.getState() == SLOT_STATE.SLOT_STATE_LOAD || slotLeader.getState() == SLOT_STATE.SLOT_STATE_RENDEZVOUS || slotLeader.getState() == SLOT_STATE.SLOT_STATE_PRESTART || slotLeader.getState() == SLOT_STATE.SLOT_STATE_BATTLE_READY || slotLeader.getState() == SLOT_STATE.SLOT_STATE_BATTLE) { slot.setState(SLOT_STATE.SLOT_STATE_LOAD); getClient().SendPacket(new PROTOCOL_BATTLE_READYBATTLE_ACK(room,getClient().getPlayer())); } if (slot.getState() == SLOT_STATE.SLOT_STATE_READY) { slot.setState(SLOT_STATE.SLOT_STATE_NORMAL); } else if (slot.getState() == SLOT_STATE.SLOT_STATE_NORMAL) { slot.setState(SLOT_STATE.SLOT_STATE_READY); } } // слать пакет ROOM_INFO всем игрокам foreach (Player member in getClient().getPlayer().getRoom().getPlayers().Values) { member.getClient().SendPacket(new PROTOCOL_ROOM_INFO_ACK(room)); } }
public override void RunImpl() { SLOT slot = getClient().getPlayer().getRoom().getRoomSlots()[slotId]; if (slot.getState() == SLOT_STATE.SLOT_STATE_CLOSE) { slot.setState(SLOT_STATE.SLOT_STATE_EMPTY); } else { slot.setState(SLOT_STATE.SLOT_STATE_CLOSE); } foreach (Player member in getClient().getPlayer().getRoom().getPlayers().Values) { member.getClient().SendPacket(new PROTOCOL_ROOM_INFO_ACK(getClient().getPlayer().getRoom())); } }
public override void WriteImpl() { WriteH(0xF25); WriteC(0); WriteC((byte)leaderSlot.getId()); WriteC(1);//(byte)slotcount if (slotcount > 1) { foreach (int slot in Room.RED_TEAM) { SLOT oldSlot = room.getRoomSlots()[slot]; SLOT newSlot = room.getRoomSlots()[slot + 1]; SLOT_STATE oldState = oldSlot.getState(); oldSlot.setState(newSlot.getState()); newSlot.setState(oldState); Player oldPlayer = oldSlot.getPlayer(); oldSlot.setPlayer(newSlot.getPlayer()); newSlot.setPlayer(oldPlayer); WriteC((byte)oldSlot.getId()); WriteC((byte)newSlot.getId()); WriteC((byte)(int)oldSlot.getState()); WriteC((byte)(int)newSlot.getState()); } } else { SLOT oldSlot = room.getRoomSlotByPlayer(sender); SLOT newSlot = room.changeTeam(sender,newTeam); WriteC((byte)oldSlot.getId()); WriteC((byte)newSlot.getId()); WriteC((byte)(int)oldSlot.getState()); WriteC((byte)(int)newSlot.getState()); } }
/*public static void ChangeRoomState(ROOM_STATE RoomState, Player p, Room room) * { * if (room.getState() == ROOM_STATE.ROOM_STATE_PRE_BATTLE) * { * if (p.PlayerID == room.getLeader().PlayerID) * { * // фраги * } * * for (int slot = 0; slot < 15; ++slot) * { * Player playerBySlot = room.getPlayerBySlot(slot); * GameNetwork playerFromPlayerId2 = RoomManager.getPlayer(playerBySlot.getRoom().getRoomId(), playerBySlot.PlayerID); * if (room.Slots[slot].State == SLOT_STATE.SLOT_STATE_BATTLE_READY && room.Slots[slot].PlayerID > 0 && playerBySlot != null) * { * room.СhangeSlotState(slot, SLOT_STATE.SLOT_STATE_BATTLE); * // GameNetwork playerFromPlayerId2 = RoomManager.getPlayer(playerBySlot.getRoom().getRoomId(), playerBySlot.PlayerID); * playerFromPlayerId2.SendPacket(new opcode_3879_ACK(playerBySlot.getRoom())); * playerFromPlayerId2.SendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK()); * if (p.PlayerID != playerBySlot.PlayerID) * { * playerFromPlayerId2.SendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK()); * } * playerFromPlayerId2.SendPacket(new opcode_3865_ACK()); * playerFromPlayerId2.SendPacket(new opcode_3867_ACK()); * } * } * room.setState(ROOM_STATE.ROOM_STATE_BATTLE); * } * else * { * GameNetwork player = RoomManager.getPlayer(p.getRoom().getRoomId(), p.PlayerID); * room.СhangeSlotState(p.getSlot(), SLOT_STATE.SLOT_STATE_BATTLE); * player.SendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK()); // TODO: Player * for (int slot = 0; slot < 15; ++slot) * { * Player playerBySlot = room.getPlayerBySlot(slot); * GameNetwork playerFromPlayerId2 = RoomManager.getPlayer(playerBySlot.getRoom().getRoomId(), playerBySlot.PlayerID); * if (room.Slots[slot].State == SLOT_STATE.SLOT_STATE_BATTLE_READY && room.Slots[slot].PlayerID > 0) * { * if (p.PlayerID != playerBySlot.PlayerID) * { * playerFromPlayerId2.SendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK()); * } * player.SendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK()); * } * * } * player.SendPacket(new opcode_3865_ACK()); * player.SendPacket(new opcode_3867_ACK()); * } * }*/ public static void RoomTask(int channel, Room room) { int countPlayerPrestart = 0; foreach (GameNetwork player in getPlayers(room.getId()).ToArray()) { SLOT slot = room.ROOM_SLOT[player.getPlayer().getSlot()]; if ((int)slot.getState() > 8 && (int)slot.getState() < 12) { countPlayerPrestart++; } } SLOT leader = room.ROOM_SLOT[room.getLeader().getSlot()]; if ((int)leader.getState() < 13) { if (countPlayerPrestart == 0) { if ((int)leader.getState() < 13) { foreach (GameNetwork member in getPlayers(room.getId()).ToArray()) { SLOT playerSlot = room.ROOM_SLOT[member.getPlayer().getSlot()]; if (playerSlot.getState() == SLOT_STATE.SLOT_STATE_BATTLE_READY) { playerSlot.setState(SLOT_STATE.SLOT_STATE_BATTLE); member.SendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK(room,member.getPlayer())); foreach (GameNetwork toSend in getPlayers(room.getId()).ToArray()) { if (!toSend.Equals(member)) { SLOT toSendplayerSlot = room.ROOM_SLOT[toSend.getPlayer().getSlot()]; if ((int)toSendplayerSlot.getState() > 11) { member.SendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK(room,toSend.getPlayer())); } } } member.SendPacket(new opcode_3865_ACK()); member.SendPacket(new PROTOCOL_BATTLE_ROUND_START(room)); } } } } } else { foreach (GameNetwork player in getPlayers(room.getId()).ToArray()) { SLOT playerSlot = room.ROOM_SLOT[player.getPlayer().getSlot()]; if ((int)playerSlot.getState() == 12) { player.SendPacket(new opcode_3890_ACK(room)); playerSlot.setState(SLOT_STATE.SLOT_STATE_BATTLE); player.SendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK(room,player.getPlayer())); foreach (GameNetwork player1 in getPlayers(room.getId()).ToArray()) { SLOT why = room.ROOM_SLOT[player1.getPlayer().getSlot()]; if ((int)why.getState() == 13 && !player.Equals(player1)) { player1.SendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK(room,player.getPlayer())); player.SendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK(room,player1.getPlayer())); } } player.SendPacket(new opcode_3865_ACK()); player.SendPacket(new PROTOCOL_BATTLE_ROUND_START(room)); } } } }
public override void RunImpl() { Room room = getClient().getPlayer().getRoom(); room.setTimeLost(timeLost); Player player = getClient().getPlayer(); if (room != null) { if (timeLost < 1 & getClient().getPlayer().getRoom().getBombState() == 0) { if (room.getLeader().Equals(player)) { if (room.getType() == 2) { room.setBlueWinRounds(room.getBlueWinRounds() + 1); } if (room.getType() == 2 && room.getBlueWinRounds() != room.getKillsByMask()) { foreach (Player member in getClient().getPlayer().getRoom().getPlayers().Values) { SLOT slot = room.getRoomSlotByPlayer(member); slot.setKillMessage(0); slot.setLastKillMessage(0); slot.setOneTimeKills(0); member.getClient().SendPacket(new PROTOCOL_BATTLE_ROUND_END_ACK(1,2,getClient().getPlayer().getRoom())); } Thread.Sleep(10000); foreach (Player member in getClient().getPlayer().getRoom().getPlayers().Values) { member.getClient().SendPacket(new opcode_3865_ACK()); member.getClient().SendPacket(new PROTOCOL_BATTLE_ROUND_START(member.getRoom())); } } else { foreach (Player member in getClient().getPlayer().getRoom().getPlayers().Values) { SLOT slot = room.getRoomSlotByPlayer(member); if (slot.getState() == SLOT_STATE.SLOT_STATE_BATTLE || slot.getState() == SLOT_STATE.SLOT_STATE_BATTLE_READY || slot.getState() == SLOT_STATE.SLOT_STATE_PRESTART || slot.getState() == SLOT_STATE.SLOT_STATE_LOAD || slot.getState() == SLOT_STATE.SLOT_STATE_RENDEZVOUS) { slot.setState(SLOT_STATE.SLOT_STATE_NORMAL); /* Подсчет статистики */ stats = PlayersStatsTable.statistics[member.getClient().getPlayer().AccountID]; stats.setSeasonKills(stats.getSeasonKills() + slot.getAllKills()); //подсчет убийств stats.setSeasonDeaths(stats.getSeasonDeaths() + slot.getAllDeath()); //подсчет смертей stats.setHeadshots(stats.getHeadshots() + slot.getHeadshots()); //подсчет попаданий в голову PlayersStatsTable.UpdateStats(member.getClient().getPlayer().PlayerID,stats.getSeasonKills(),stats.getHeadshots(),stats.getSeasonDeaths()); member.getClient().SendPacket(new PROTOCOL_ROOM_INFO_ACK(room)); member.getClient().SendPacket(new PROTOCOL_BATTLE_END_ACK(member,getClient().getPlayer().getRoom())); member.getClient().SendPacket(new PROTOCOL_ROOM_INFO_ACK(room)); } } for (int i = 0; i < 16; i++) { SLOT slot = room.getRoomSlot(i); slot.setKillMessage(0); slot.setLastKillMessage(0); slot.setOneTimeKills(0); slot.setAllKills(0); slot.setAllDeahts(0); slot.setBotScore(0); } room.setRedKills(0); room.setRedDeaths(0); room.setBlueKills(0); room.setBlueDeaths(0); room.setFigth(0); } } } } }