private void CheckCardCount(Player_Behavior participant) { if (participant.GetHand().GetNumberOfCards() == 0) { participant.GetPlayerState().SetPassing(); } }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { clicks += 1; if (clicks == 1) { Debug.Log("Set timer"); lastTimer = Time.unscaledTime; } if (clicks >= 2) { currentTimer = Time.unscaledTime; float difference = currentTimer - lastTimer; if (difference <= 0.2f) { clicks = 0; if (!Player.GetPlayerState().isPlayersTurn()) { return; } selectedCard = GetClickedCard(); if (selectedCard != null) { if (selectedCard.transform.parent.tag.Contains("Enemy Hand")) { return; } if (Player.GetHand().CardIsInPile(selectedCard)) { playfield = Player.GetPlayField().GetComponent <SP_CardPile>(); AnimateCardToField(playfield); Invoke("TransferCard", .8f); } } } else { clicks = 0; } } } else { if (clicks < 2) { currentTimer = Time.unscaledTime; float difference = currentTimer - lastTimer; if (difference > .2f) { clicks = 0; } } } }
private void DetermineNewStates() { if (Player.GetPlayerState().isPlayersPassing() && !Opponent.GetPlayerState().isPlayersPassing()) { Opponent.GetPlayerState().SetBattleState(1); CheckCardCount(Opponent); CurrentTurnToken.GetComponent <TurnToken>().ActivateOpponentTurn(); CurrentPlayer = Opponent; NextPlayer = Player; } else if (!Player.GetPlayerState().isPlayersPassing() && Opponent.GetPlayerState().isPlayersPassing()) { Player.GetPlayerState().SetBattleState(1); CheckCardCount(Player); CurrentTurnToken.GetComponent <TurnToken>().ActivatePlayerTurn(); CurrentPlayer = Player; NextPlayer = Opponent; } else if (!Player.GetPlayerState().isPlayersTurn() && Opponent.GetPlayerState().isPlayersTurn()) { Opponent.GetPlayerState().SetBattleState(0); Player.GetPlayerState().SetBattleState(1); CheckCardCount(Player); CurrentTurnToken.GetComponent <TurnToken>().ActivatePlayerTurn(); CurrentPlayer = Player; NextPlayer = Opponent; } else if (Player.GetPlayerState().isPlayersTurn() && !Opponent.GetPlayerState().isPlayersTurn()) { int current_card_count = Player.GetHand().GetNumberOfCards(); if (player_cards != current_card_count) { player_cards = current_card_count; Player.GetPlayerState().SetBattleState(0); Opponent.GetPlayerState().SetBattleState(1); CheckCardCount(Opponent); CurrentTurnToken.GetComponent <TurnToken>().ActivateOpponentTurn(); CurrentPlayer = Opponent; NextPlayer = Player; } } }
private void move() { card = null; int seed = (int)(Time.realtimeSinceStartup * 100); Random.InitState(seed); roll = Random.Range(1, 100); if (roll <= PassChance) { Opponent.GetPlayerState().SetPassing(); } else { ChooseCard(); card.GetComponent <CQBCard>().ActivatePlayable(); CardSelection.GetComponent <CardPositionAnimator>().AnimateCardToPosition(card, Opponent.GetPlayField().transform.position); CardSelection.GetComponent <CardScaleAnimator>().AnimateCardToScale(card); Invoke("TransferCard", .8f); } }
public void NextTurn() { if (cardsDelt) { if (opponent.isPlayersTurn()) { if (Opponent.GetHand().GetNumberOfCards() > 0) { playedCard = Opponent.GetComponent <Player_Behavior>().make_a_move(); } else { Opponent.GetPlayerState().SetPassing(); } } else if (player.isPlayersPassing() && opponent.isPlayersPassing()) { playerCounter.Counter(); opponentCounter.Counter(); string outcome = DetermineRoundWinner(); if (Player.GetScore() == Num_to_Win || Opponent.GetScore() == Num_to_Win || games_played == Max_Games) { outcome = DetermineGameWinner(); cardsDelt = false; } Outcome.Display(outcome); Debug.Log(outcome); RollForInitiative(); Invoke("ResetBoard", 2); if (cardsDelt == false) { Invoke("MainMenuReturn", 2); } else if (RoundWinner != null) { RoundWinner.GetDeck().DealCards(1, RoundWinner.GetHand().gameObject); ApplyModifiers(RoundWinner); if (RoundWinner == Opponent) { Opponent.GetHand().ShowBack(); } else { player_cards = Player.GetHand().GetNumberOfCards(); } } return; } } if (playedCard != null) { ApplyCardModifiers(playedCard, CurrentPlayer, NextPlayer); playedCard = null; } DetermineNewStates(); playerCounter.Counter(); opponentCounter.Counter(); }
private void Update() { if (cardsDelt) { /*CurrentPlayer.GetPlayField().gameObject.GetComponent<SP_CardPile_Display>().UpdateDisplay(); * NextPlayer.GetPlayField().gameObject.GetComponent<SP_CardPile_Display>().UpdateDisplay();*/ CurrentPlayer.GetPlayField().gameObject.GetComponent <SP_CardPile_Display>().RefreshLayoutGroupsImmediateAndRecursive(CurrentPlayer.GetPlayField().gameObject); NextPlayer.GetPlayField().gameObject.GetComponent <SP_CardPile_Display>().RefreshLayoutGroupsImmediateAndRecursive(NextPlayer.GetPlayField().gameObject); if (!enemyBehavior.IsMakingMove() && opponent.isPlayersTurn()) { if (Opponent.GetHand().GetNumberOfCards() > 0) { enemyBehavior.make_a_move(); } else { Opponent.GetPlayerState().SetPassing(); } } else if (player.isPlayersPassing() && opponent.isPlayersPassing() && !waiting) { playerCounter.Counter(); opponentCounter.Counter(); string outcome = DetermineRoundWinner(); if (Player.GetScore() == Num_to_Win || Opponent.GetScore() == Num_to_Win || games_played == Max_Games) { outcome = DetermineGameWinner(); cardsDelt = false; } Outcome.Display(outcome); Debug.Log(outcome); waiting = true; Invoke("ResetBoard", 2); if (cardsDelt == false) { Invoke("MainMenuReturn", 2); } else if (RoundWinner != null) { RoundWinner.GetDeck().DealCards(1, RoundWinner.GetHand().gameObject); ApplyModifiers(RoundWinner); if (RoundWinner == Opponent) { Opponent.GetHand().ShowBack(); } else { player_cards = Player.GetHand().GetNumberOfCards(); } } return; } else if (Player.GetHand().GetNumberOfCards() == 0) { Player.GetPlayerState().SetPassing(); } else if (Player.GetPlayerState().isPlayersPassing() || Opponent.GetPlayerState().isPlayersPassing()) { DetermineNewStates(); } } }