public void updateSlotType(PreGameSlotInfo slot, IPeer peer) { PreGamePlayerSlot oldSlot = playerSlots[slot.slotID]; if (isAdminOrHost(peer) == false && oldSlot.peer != null && peer.Id != oldSlot.peer.peer.Id) //Only allow admin or the same peer to change slot { return; } PreGamePeer localPeer = getMatchingPeer(peer.Id); if (localPeer == null) //Quick fix to wait until player joins game { MainThread.createTimedAction(() => { updateSlotType(slot, peer); }, 0.1f); return; } if (slot.type == PreGameSlotType.Player) { localPeer.removePlayerSlot(slot.slotID); setplayerSlotEmpty(slot.slotID); } else { localPeer.addPlayerSlot(slot.slotID); changePlayerSlot(slot.slotID, slot.type, slot.playerInfo, getMatchingPeer(peer.Id), getIsPreReady(slot.type, localPeer)); } broadcastUpdate(); }
private void initPlayerslots(int maxPlayers) { playerSlots = new PreGamePlayerSlot[maxPlayers]; for (int i = 0; i < maxPlayers; i++) { PreGameSlotInfo temp = new PreGameSlotInfo() { playerInfo = new PlayerInfo { }, type = PreGameSlotType.Empty, slotID = i }; playerSlots[i].info = temp; } }