/// <summary> /// Playes "stands" (no more cards required). /// </summary> public void Stand() { if (RoundState != RoundStates.PlayersTurn) { return; } RoundState = RoundStates.DealersTurn; _dealerStrategy.Play(_dealersHand, _cardsProvider); OnPropertyChanged(nameof(DealersCards)); if (_dealersHand.GetValue() > BlackJack.TwentyOne) { RoundResult = RoundResults.DealerHasBusted; } else if (_dealersHand.GetValue() > _playersHand.GetValue()) { RoundResult = RoundResults.DealerHasWon; } else if (_dealersHand.GetValue() < _playersHand.GetValue()) { RoundResult = RoundResults.PlayerHasWon; } else { RoundResult = RoundResults.Push; } RoundState = RoundStates.RoundIsOver; }
public void EnterGame() { //statusText = GameObject.Find("status").GetComponent<Text>(); priceText = GameObject.Find("price").GetComponent <Text>(); timeText = GameObject.Find("time").GetComponent <Text>(); retryButton = GameObject.Find("Retry").GetComponent <Button>(); retryButton.onClick.AddListener(delegate { theRoundState = RoundStates.Uninitialized; God.levelTransition.BreakOut(startPrice, baseTimeLimit, theLevel, nextSceneName); }); continueButton = GameObject.Find("Continue").GetComponent <Button>(); continueButton.onClick.AddListener(delegate { var p = 0.0f; if (God.playerStats.money >= price) { p = price; } God.playerStats.AddItemToInventory(startPrice, price); God.levelTransition.Platformer(-p, nextSceneName); }); God.SpawnAt(theLevel, new Vector3(8.5f, 0.5f)); var bricks = GameObject.FindGameObjectsWithTag("Brick"); totalNumberOfBricks = bricks.Length; numberOfBricks = bricks.Length; OnWaitForPlayerStart(); }
IEnumerator RoundSpawn(Round round) { Debug.Log("Spawning Round: " + round.name); for (int i = 0; i < round.enemies.Length; i++) { yield return(new WaitForSeconds(round.rate)); // the number of counts should dictate how many times you runt spawn enemies for (int j = 0; j < round.count; j++) { if (j > 0) { GameObject enemyTemp = round.enemies[Random.Range(0, round.enemies.Length)]; PreventOverlapingSpawn(enemyTemp, enemyTemp.GetComponent <EnemyMovement>()._lifeTime); } else { PreventOverlapingSpawn(round.enemies[i], round.enemies[i].GetComponent <EnemyMovement>()._lifeTime); } yield return(new WaitForSeconds(round.spawnRate)); } } //change the state _currentRoundState = RoundStates.RoundWaiting; yield break; }
// Updates the state and calls appropriate method public void UpdateStates(RoundStates newRoundState) { _currentRoundState = newRoundState; switch (_currentRoundState) { case RoundStates.RoundStart: RoundStart(); break; case RoundStates.RoundTransition: RoundTransition(); break; case RoundStates.NewRound: StartCoroutine(NewRound()); break; case RoundStates.RoundSpawn: StartCoroutine(RoundSpawn(rounds[_nextRound])); break; case RoundStates.RoundWaiting: break; case RoundStates.RoundTutorial: break; } }
// we are entering, telling the whole scene to start the player countdown public void OnWaitForPlayerStart() { theRoundState = RoundStates.WaitForPlayerStarted; retryButton.gameObject.SetActive(false); continueButton.gameObject.SetActive(false); priceText.text = "HAGGLE"; timeText.text = "CLICK TO DROP PRICES"; }
public void OnRoundStart() { theRoundState = RoundStates.RoundStarted; price = startPrice; time = baseTimeLimit; SetMoneyText(price); SetTimeText(time); }
private async Task <RoundState> GetRoundState(RoundStates state) { RoundState roundState = await AppDbContext.FindGenericElementByIdAsync <RoundState>((long)state); if (roundState == null) { throw new WebApiException(System.Net.HttpStatusCode.InternalServerError, "round state not found!"); } return(roundState); }
/// <summary> /// Player "hits" (asks for another card). /// </summary> public void Hit() { if (RoundState != RoundStates.PlayersTurn) { return; } _playersHand.AddCard(_cardsProvider.Deal()); OnPropertyChanged(nameof(PlayersCards)); if (_playersHand.GetValue() > BlackJack.TwentyOne) { RoundResult = RoundResults.PlayerHasBusted; RoundState = RoundStates.RoundIsOver; } }
public void OnRoundFinish() { theRoundState = RoundStates.RoundFinished; retryButton.gameObject.SetActive(true); if (God.playerStats.money >= price) { continueButton.gameObject.SetActive(true); OnRoundWin(); } else { continueButton.gameObject.SetActive(false); OnRoundFail(); } }
/// <summary> /// Starts new round of game. /// </summary> public void StartRound() { DealInitialCards(); if (_playersHand.GetValue() == BlackJack.TwentyOne) { if (_dealersHand.GetValue() == BlackJack.TwentyOne) { RoundState = RoundStates.RoundIsOver; RoundResult = RoundResults.Push; } else { RoundState = RoundStates.RoundIsOver; RoundResult = RoundResults.BlackJack; } } else { RoundState = RoundStates.PlayersTurn; RoundResult = RoundResults.RoundIsInProgress; } }
public void OnWaitForPlayerFinish() { theRoundState = RoundStates.WaitForPlayerFinished; OnRoundStart(); }
public void OnRoundFail() { theRoundState = RoundStates.RoundFailed; timeText.text = "INSUFFICIENT FUNDS"; }
public void OnRoundWin() { theRoundState = RoundStates.RoundWon; timeText.text = "ALL SALES FINAL"; }
/// <summary> /// Player "hits" (asks for another card). /// </summary> public void Hit() { if (RoundState != RoundStates.PlayersTurn) return; _playersHand.AddCard(_cardsProvider.Deal()); OnPropertyChanged(nameof(PlayersCards)); if (_playersHand.GetValue() > BlackJack.TwentyOne) { RoundResult = RoundResults.PlayerHasBusted; RoundState = RoundStates.RoundIsOver; } }
/// <summary> /// Playes "stands" (no more cards required). /// </summary> public void Stand() { if (RoundState != RoundStates.PlayersTurn) return; RoundState = RoundStates.DealersTurn; _dealerStrategy.Play(_dealersHand, _cardsProvider); OnPropertyChanged(nameof(DealersCards)); if (_dealersHand.GetValue() > BlackJack.TwentyOne) { RoundResult = RoundResults.DealerHasBusted; } else if (_dealersHand.GetValue() > _playersHand.GetValue()) { RoundResult = RoundResults.DealerHasWon; } else if (_dealersHand.GetValue() < _playersHand.GetValue()) { RoundResult = RoundResults.PlayerHasWon; } else { RoundResult = RoundResults.Push; } RoundState = RoundStates.RoundIsOver; }