//called from a PlayerOhHell Command to run on server public void BidChosen(PlayerOhHell pl) { bool allPlayersBid = true; foreach (PlayerOhHell player in players) { if (player.CurrentRoundBid == -1) { allPlayersBid = false; } } if (allPlayersBid) { this.StartCoroutine(() => { InitiateBidPhase(); }, 0.1f); this.StartCoroutine(() => { StartRoundAfterBids(); }, 6.5f); } UpdateAllPlayerUIs(); }
public override void OnServerAddPlayer(NetworkConnection conn) { if (numPlayers == 0) { GameObject gameManagerOb = Instantiate(spawnPrefabs.Find(prefab => prefab.name == "GameManager")); NetworkServer.Spawn(gameManagerOb); gameManager = gameManagerOb.GetComponent <GameManager>(); lobbyUI = Instantiate(spawnPrefabs.Find(prefab => prefab.name == "LobbyUI")); lobbyUI.GetComponent <LobbyUIBehavior>().StartEvent = new UnityEvent(); lobbyUI.GetComponent <LobbyUIBehavior>().StartEvent.AddListener(StartGame); NetworkServer.Spawn(lobbyUI); } GameObject player = Instantiate(playerPrefab); NetworkServer.AddPlayerForConnection(conn, player); PlayerOhHell newPlayerScript = player.GetComponent <PlayerOhHell>(); gameManager.players.Add(newPlayerScript); gameManager.playerIds.Add(newPlayerScript.netId); newPlayerScript.RpcGetInputPlayerName(); Invoke("UpdateLobbyNames", 0.1f); }
public Vector3 GetPlayerHandPosition(PlayerOhHell player) { int index = GetPlayerPositionIndex(player); if (player.isLocalPlayer) { index = -1; } return(spawnPointBehavior.GetHandPoint(NumPlayers(), index)); }
public string GetTrickLeaderName() { List <PlayerOhHell> localList = GetLocalPlayerList(); PlayerOhHell player = localList[roundFirstLeader]; if (player.isLocalPlayer) { return("You"); } return(localList[roundFirstLeader].PlayerName); }
private int GetPlayerIndex(PlayerOhHell player) { List <PlayerOhHell> localList = GetLocalPlayerList(); for (int i = 0; i < localList.Count; i++) { if (localList[i] == player) { return(i); } } return(-1); }
private int GetPlayerPositionIndex(PlayerOhHell player) { int playerListIndex = GetPlayerIndex(player); int localPlayerListIndex = GetPlayerIndex(GetLocalPlayer()); int numPlayers = GetLocalPlayerList().Count; int playerIndexToUse = playerListIndex - localPlayerListIndex - 1; //index in spawnpoint arr if (playerIndexToUse < 0) { playerIndexToUse = playerIndexToUse + numPlayers; } return(playerIndexToUse); }
public string GetTrickWinnerName() { List <PlayerOhHell> localList = GetLocalPlayerList(); PlayerOhHell winner = null; foreach (PlayerOhHell p in localList) { if (p.netId == trickWinningPlayerId) { winner = p; } } if (winner == null) { return(null); } if (winner.isLocalPlayer) { return("You"); } return(winner.PlayerName); }
public bool PlayerIsTrickWinner(PlayerOhHell pl) { return(pl.netId == trickWinningPlayerId); }
//called from a PlayerOhHell Command to run on server public void CardChosen(PlayerOhHell pl, Card card) { if (!isServer) { return; } int oldTurnPlayerIndex = currentTurnPlayerIndex; int newTurnPlayerIndex = currentTurnPlayerIndex; bool trickEnd = false, roundEnd = false; cardsInCenter.Add(card); if (GetLeadingSuit() == null) { SetLeadingSuit(card.Suit); } if (card.IsStronger(TrickWinningCard, GetLeadingSuit(), GetTrumpSuit())) { TrickWinningCard = card; TrickWinningPlayer = pl; } if (cardsInCenter.Count < players.Count) { //advance turn currentTurnPlayerIndex++; if (currentTurnPlayerIndex >= players.Count) { currentTurnPlayerIndex = 0; } newTurnPlayerIndex = currentTurnPlayerIndex; } else { TricksPlayedThisRound++; currentTurnPlayerIndex = GetPlayerIndex(TrickWinningPlayer); TrickWinningPlayer.TricksThisRound++; newTurnPlayerIndex = currentTurnPlayerIndex; trickWinningPlayerId = TrickWinningPlayer.netId; TrickWinningPlayer = null; TrickWinningCard = null; SetLeadingSuit(null); trickEnd = true; cardsInCenter.Clear(); if (TricksPlayedThisRound >= CurrentRoundCardNum) { roundEnd = true; } } float delay = 0.1f; if (trickEnd) { players[oldTurnPlayerIndex].IsMyTurn = false; delay = 3.8f; //time for 'X won the trick to show' before clearing middle cards } this.StartCoroutine(() => { UpdateAllPlayerUIs(); }, 0.01f); this.StartCoroutine(() => { CardChosen2(oldTurnPlayerIndex, newTurnPlayerIndex, trickEnd, roundEnd); }, delay); }
public Vector3 GetPlayerCardTargetPosition(PlayerOhHell player) { return(spawnPointBehavior.GetCardTarget(NumPlayers(), GetPlayerPositionIndex(player))); }