public void BanSpecificCard(Card newCard) { for (int i = 0; i < L_Cards_visible.Count; i++) { if (L_Cards_visible [i].GetComponent <CardPanel> ().card.uId == newCard.uId) { CardPanel cardScript = L_Cards_visible [i].GetComponent <CardPanel> (); cardScript.RemoveCard(killCardPos); this.UpdateCardList(newCard); return; } } }
public void ChangeTurn(int newTurnState) { if (newTurnState == 1 || newTurnState == 3) { for (int i = 0; i < L_Cards_visible.Count; i++) { CardPanel cardScript = L_Cards_visible [i].GetComponent <CardPanel> (); cardScript.RemoveCard(killCardPos); } L_Cards_visible.Clear(); for (int i = 0; i < L_Cards_hidden.Count; i++) { Destroy(L_Cards_hidden [i]); } L_Cards_hidden.Clear(); } }
void Update() { if (players[playerTurnIndex].Skip) { players[playerTurnIndex].Skip = false; playerTurnIndex++; if (playerTurnIndex == players.Count) { playerTurnIndex = 0; } } if (upgradeTile) { bool check = false; foreach (Transform waypoint in waypoints) { if (waypoint.GetComponent <Waypoint>().OwnByPlayer&& waypoint.GetComponent <Waypoint>().PlayerIndex == playerTurnIndex) { check = true; } } if (!check) { //Spawn a warning message GameObject message = Instantiate(warningPrefab, gameCanvas.transform); message.GetComponent <WarningMessage>().SetWarningText("You have no tiles to upgrade!"); upgradeTile = false; isLookingAtBoard = false; cardPanel.DeselectCard(); } else { isLookingAtBoard = true; cardPanel.gameObject.SetActive(false); lookAtBoardButton.gameObject.SetActive(false); cardPanel.RemoveCard(); } } if (playerSelectionEnabled && !playerIsSelected) { foreach (GameObject hud in selectionHUDS) { if (hud.GetComponent <PlayerHUD>().Selected&& playerSelectionEnabled) { playerIsSelected = true; hud.GetComponent <PlayerHUD>().Selected = false; selectedPlayerIndex = hud.GetComponent <PlayerHUD>().ImgIndex; //If the player cannot pick themselves if (!selectSelf) { if (playerTurnIndex == selectedPlayerIndex) { //Spawn a warning message GameObject message = Instantiate(warningPrefab, playerSelectionCanvas.gameObject.transform); message.GetComponent <WarningMessage>().SetWarningText("You cannot select yourself for this card!"); playerIsSelected = false; } } if (playerIsSelected) { //Checking card selection cards if (interactionIndex == (int)NetworkCard.CardIndex.DISCARDCARD || interactionIndex == (int)NetworkCard.CardIndex.STEALCARD || interactionIndex == (int)NetworkCard.CardIndex.SWITCHCARD || interactionIndex == (int)NetworkCard.CardIndex.SKIPTURN) { //Checking if the player already has a skipped turn if (interactionIndex == (int)NetworkCard.CardIndex.SKIPTURN && players[selectedPlayerIndex].Skip) { GameObject message = Instantiate(warningPrefab, playerSelectionCanvas.gameObject.transform); message.GetComponent <WarningMessage>().SetWarningText("You cannot skip a players turn twice!"); playerIsSelected = false; } //Checking if the player has any cards to begin with else if (cardPanel.GetNumberCards(selectedPlayerIndex) == 0) { //Spawn a warning message GameObject message = Instantiate(warningPrefab, playerSelectionCanvas.gameObject.transform); message.GetComponent <WarningMessage>().SetWarningText("Player selected has no cards to pick from!"); playerIsSelected = false; } //Checking if the player has any card to swap (excluding the switch card itself) else if (interactionIndex == (int)NetworkCard.CardIndex.SWITCHCARD && cardPanel.GetNumberCards(playerTurnIndex) == 1) { GameObject message = Instantiate(warningPrefab, playerSelectionCanvas.gameObject.transform); message.GetComponent <WarningMessage>().SetWarningText("You have no cards to switch!"); playerIsSelected = false; } } //Double check because of the condition above if (playerIsSelected) { playerIsSelected = false; TurnOnPlayerSelection(false); DoAction(); } } } } } if (moveInteracting) { MovePlayerAction(selectedPlayerIndex); } else if (movePlayer && players[playerTurnIndex].GetComponent <TutorialPlayer>().WaypointIndex < waypoints.Length && !turnFinished && !IsMiniGameRunning) { //Smooth player moving transition players[playerTurnIndex].transform.position = Vector2.MoveTowards(players[playerTurnIndex].transform.position, waypoints[nextSpace].position, playerMoveSpeed * Time.deltaTime); players[playerTurnIndex].GetComponent <TutorialPlayer>().WalkAnimation(true); //This makes the player move from one waypoint to the next if (players[playerTurnIndex].transform.position == waypoints[nextSpace].position) { players[playerTurnIndex].GetComponent <TutorialPlayer>().WalkAnimation(false); //Once the player has reach the waypoint if (players[playerTurnIndex].GetComponent <TutorialPlayer>().WaypointIndex == nextSpace) { //Check if the waypoint is owned by a player if (waypoints[nextSpace].GetComponent <Waypoint>().OwnByPlayer&& playerTurnIndex != waypoints[nextSpace].GetComponent <Waypoint>().PlayerIndex) { pointSystem.MinusPoints(playerTurnIndex, waypoints[nextSpace].GetComponent <Waypoint>().Points); pointSystem.AddPoints(waypoints[nextSpace].GetComponent <Waypoint>().PlayerIndex, waypoints[nextSpace].GetComponent <Waypoint>().Points); } else { waypoints[nextSpace].GetComponent <Waypoint>().SetPlayer(playerTurnIndex); } playerTurnIndex++; turnFinished = true; } nextSpace++; //Once the player makes one full rotation around the map if (nextSpace == waypoints.Length) { nextSpace = 0; } //Switch players if (playerTurnIndex == players.Count) { currentRound++; playerTurnIndex = 0; StartCoroutine(RoundFinished()); } //Check if the game is finish if (currentRound == (maxTurns + 1)) { //TODO: //Game is finish } } } }
private void HandleMessage(GameMessage message) { if (message is PlayerActionMessage) { PlayerActionMessage actionMessage = (PlayerActionMessage)message; CardPanel relevantCardPanel = actionMessage.Player == _game.PlayerOne ? pYourHand : pOpponentsHand; switch (actionMessage.PlayerActionValue) { case PlayerActionMessage.PlayerAction.DrawDiscard: relevantCardPanel.AddCard(actionMessage.Card); pStacks.DiscardCount--; pStacks.VisibleDiscard = _game.GetVisibleDiscard(); pActions.AllowDraw = false; pActions.AllowTake = false; pActions.AllowDiscard = true; break; case PlayerActionMessage.PlayerAction.DrawStock: pStacks.StockCount--; relevantCardPanel.AddCard(actionMessage.Card); pActions.AllowDraw = false; pActions.AllowTake = false; pActions.AllowDiscard = true; break; case PlayerActionMessage.PlayerAction.SetDiscard: pStacks.DiscardCount++; pStacks.VisibleDiscard = actionMessage.Card; relevantCardPanel.RemoveCard(actionMessage.Card); pActions.AllowDraw = false; pActions.AllowTake = false; pActions.AllowDiscard = false; break; case PlayerActionMessage.PlayerAction.Knock: // TODO: handle Knock message break; default: break; } } else if (message is GameStatusMessage) { GameStatusMessage statusMessage = (GameStatusMessage)message; switch (statusMessage.GameStatusChangeValue) { case GameStatusMessage.GameStatusChange.GameInitialised: // TODO: assumes PlayerOne is always the human player pYourHand.Clear(); InitialisePlayerCardPanel(pYourHand); foreach (Card c in _game.PlayerOne.GetCards()) { pYourHand.AddCard(c); } pOpponentsHand.Clear(); InitialiseOpponentCardPanel(pOpponentsHand); foreach (Card c in _game.PlayerTwo.GetCards()) { pOpponentsHand.AddCard(c); } InitialiseStacks(_game.GetStockCount(), _game.GetVisibleDiscard()); InitialisePlayerActions(); break; case GameStatusMessage.GameStatusChange.StartTurn: if (statusMessage.Player == _game.PlayerOne) { pActions.AllowTake = true; pActions.AllowDraw = true; } else { pActions.AllowTake = false; pActions.AllowDraw = false; } break; default: break; } } }