コード例 #1
0
ファイル: Round.cs プロジェクト: DotNetInAction/Blackjack
        /// <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;
        }
コード例 #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();
    }
コード例 #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;
    }
コード例 #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;
        }
    }
コード例 #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";
 }
コード例 #6
0
 public void OnRoundStart()
 {
     theRoundState = RoundStates.RoundStarted;
     price         = startPrice;
     time          = baseTimeLimit;
     SetMoneyText(price);
     SetTimeText(time);
 }
コード例 #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);
        }
コード例 #8
0
ファイル: Round.cs プロジェクト: DotNetInAction/Blackjack
        /// <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;
            }
        }
コード例 #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();
        }
    }
コード例 #10
0
ファイル: Round.cs プロジェクト: DotNetInAction/Blackjack
        /// <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;
            }
        }
コード例 #11
0
 public void OnWaitForPlayerFinish()
 {
     theRoundState = RoundStates.WaitForPlayerFinished;
     OnRoundStart();
 }
コード例 #12
0
 public void OnRoundFail()
 {
     theRoundState = RoundStates.RoundFailed;
     timeText.text = "INSUFFICIENT FUNDS";
 }
コード例 #13
0
 public void OnRoundWin()
 {
     theRoundState = RoundStates.RoundWon;
     timeText.text = "ALL SALES FINAL";
 }
コード例 #14
0
ファイル: Round.cs プロジェクト: yakimovim/Blackjack
        /// <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;
            }
        }
コード例 #15
0
ファイル: Round.cs プロジェクト: yakimovim/Blackjack
        /// <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;
            }
        }
コード例 #16
0
ファイル: Round.cs プロジェクト: yakimovim/Blackjack
        /// <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;
        }