Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
    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();
    }
Exemplo n.º 3
0
    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;
    }
Exemplo n.º 4
0
    // 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;
        }
    }
Exemplo n.º 5
0
 // 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";
 }
Exemplo n.º 6
0
 public void OnRoundStart()
 {
     theRoundState = RoundStates.RoundStarted;
     price         = startPrice;
     time          = baseTimeLimit;
     SetMoneyText(price);
     SetTimeText(time);
 }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        /// <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;
            }
        }
Exemplo n.º 9
0
    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();
        }
    }
Exemplo n.º 10
0
        /// <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;
            }
        }
Exemplo n.º 11
0
 public void OnWaitForPlayerFinish()
 {
     theRoundState = RoundStates.WaitForPlayerFinished;
     OnRoundStart();
 }
Exemplo n.º 12
0
 public void OnRoundFail()
 {
     theRoundState = RoundStates.RoundFailed;
     timeText.text = "INSUFFICIENT FUNDS";
 }
Exemplo n.º 13
0
 public void OnRoundWin()
 {
     theRoundState = RoundStates.RoundWon;
     timeText.text = "ALL SALES FINAL";
 }
Exemplo n.º 14
0
        /// <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;
            }
        }
Exemplo n.º 15
0
        /// <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;
            }
        }
Exemplo n.º 16
0
        /// <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;
        }