Пример #1
0
 public void Option4()
 {
     bettingPanel.SetActive(false);
     betAmount = BetAmount.Large;
     DisplayPayouts();
     AudioManager.instance.PlaySFX("Large Bet");
 }
Пример #2
0
 public void Option3()
 {
     bettingPanel.SetActive(false);
     betAmount = BetAmount.Medium;
     DisplayPayouts();
     AudioManager.instance.PlaySFX("Medium Bet");
 }
Пример #3
0
 public void Option2()
 {
     bettingPanel.SetActive(false);
     betAmount = BetAmount.Small;
     DisplayPayouts();
     AudioManager.instance.PlaySFX("Small Bet");
 }
Пример #4
0
    private void InitializeAI(BetAmount betAmount)
    {
        AIUnit ai = ai_units.Find(p => (p.m_BetAmount == betAmount));

        mInfo = new List <QuestionAnswerInfo>();

        int correctNum = Random.Range(ai.m_QuestionToAnswer.MinQuestionsToBeAnswered, ai.m_QuestionToAnswer.MaxQuestionsToBeAnswered + 1);

        int TimeToAnswer = 0;

        for (int i = 0; i < MULTIPLAYER_QUESTION_NUMBER; i++)
        {
            QuestionAnswerInfo tInfo = new QuestionAnswerInfo();

            int answerInWithin = Random.Range(ai.MinTimeToAnswer, ai.MaxTimeToAnswer);

            tInfo.AnsweredInTime = answerInWithin;

            TimeToAnswer = (i == 0) ? maxAllowedTime - answerInWithin : TimeToAnswer - answerInWithin;

            tInfo.TimeToAnswerQuestion = TimeToAnswer;//UnityEngine.Random.Range(ai.MinTimeToAnswer, ai.MaxTimeToAnswer);

            mInfo.Add(tInfo);
        }

        FisherYatesShuffle obj = new FisherYatesShuffle(5);

        obj.ShuffleList();
        List <int> correctIndex = obj.ShuffledList;

        for (int i = 0; i < correctNum; i++)
        {
            mInfo[correctIndex[i]].isCorrectAnswer = true;
        }
    }
Пример #5
0
 public object Clone()
 {
     return(new Bet
     {
         BetAmount = (ScoreAmount)BetAmount?.Clone(),
         PlayType = PlayType
     });
 }
Пример #6
0
 public bool Equals(Bet other)
 {
     if (other == null)
     {
         return(false);
     }
     return(BetAmount.Equals(other.BetAmount) && PlayType == other.PlayType);
 }
Пример #7
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = 13;
         hashCode = (hashCode * 397) ^ BetAmount.GetHashCode();
         hashCode = (hashCode * 397) ^ PlayType.GetHashCode();
         return(hashCode);
     }
 }
Пример #8
0
        /// <summary>
        /// Resets all data except user name. This is for when player resets the game from settings.
        /// </summary>
        public void ResetProgress()
        {
            ResetAfterGameFinish();

            TotalLives      = 10;
            TotalBananas    = 10;
            BetAmount       = BetAmount.Five;
            Achievements    = new List <Achievement>();
            Score           = 0;
            TotalLevels     = 25;
            RemainingLevels = 25;
        }
Пример #9
0
 private void OnEnable()
 {
     if (HolderUI.Mode == MultiplayerMode.ChallengeWaitingForPlayer || HolderUI.Mode == MultiplayerMode.FindingPlayer)
     {
         CurrentBetAmount = GameDataManager.Instance.BetAmount;
         EnableDisablePrevNextButton(PrevNextButton.both, EnableDisableAction.Disable);
     }
     else if (HolderUI.Mode == MultiplayerMode.Challenge || HolderUI.Mode == MultiplayerMode.FindPlayer)
     {
         CurrentBetAmount = BetAmount.Five;
         EnableDisablePrevNextButton(PrevNextButton.both, EnableDisableAction.Enable);
     }
 }
Пример #10
0
        private async void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var am     = new BetAmount();
                var q      = client.Eth.GetContractQueryHandler <BetAmount>();
                var result = await q.QueryAsync <Int32>(am, contractAddress);

                MessageBox.Show(result.ToString());
            }
            catch (Exception ex)
            {
            }
        }
Пример #11
0
    public void StartAI(BetAmount betAmount)
    {
        ScorePerQuestion     = GameManager.Instance.ScorePerQuestionMultiplayer;
        ScoreForLastQuestion = GameManager.Instance.ScoreForLastQuestionMultiplayer;

        QuestionMultiplier     = GameManager.Instance.MultiplayerQuestionMultiplier;
        LastQuestionMultiplier = GameManager.Instance.MultiplayerLastQuestionMultiplier;

        maxAllowedTime = GameManager.Instance.MultiplayerTotalTime;
        MULTIPLAYER_QUESTION_NUMBER = GameManager.Instance.MultiplayerQuestionsPerRound;

        InitializeAI(betAmount);
        Debug.Log("<color=green>AI STARTED LISTENING</color>");
        mAIstate = AIState.Active;
    }
Пример #12
0
    private int GetCurrentCurrentBet(BetAmount betAmount)
    {
        int bet = -1;

        for (int i = 0; i < BetList.Count; i++)
        {
            if (BetList[i].BetAmountChosen == betAmount)
            {
                bet = i;
                break;
            }
        }

        return(bet);
    }
Пример #13
0
        public void Insert(string optionValue)
        {
            using (var conn = SQLConn.GetConnection())
            {
                conn.Open();
                var trans = conn.BeginTransaction();
                try
                {
                    if (BetCheck(trans))
                    {
                        //update gambler statistics
                        var gambler = new Gambler(UserID, trans);
                        gambler.TotalBet += BetAmount.GetValueOrDefault(0f);

                        if (BetAmount.HasValue)
                        {
                            gambler.Cash -= BetAmount.GetValueOrDefault(0f);
                        }
                        gambler.Update(trans);

                        var banker = new Banker(CasinoItem.GetCasinoItem(CasinoItemGuid).BankerID);
                        banker.Cash += BetAmount.GetValueOrDefault(0f);
                        banker.Update(trans);

                        var key = DataAccess.Bet.InsertBet(UserID, UserName, CasinoItemGuid, BetAmount, BetRate, trans);
                        MatchChoiceOption.SaveMatchChoiceOption(key, optionValue, trans);

                        trans.Commit();
                    }
                    else
                    {
                        throw new Exception("Failed to create bet (SingleChoice).");
                    }
                }
                catch
                {
                    trans.Rollback();
                }

                //conn.Close();
            }
        }
Пример #14
0
    public int GetBetAmount(BetAmount bet)
    {
        switch (bet)
        {
        case BetAmount.One:
            return(1);

        case BetAmount.Five:
            return(5);

        case BetAmount.Fifty:
            return(50);

        case BetAmount.Hundred:
            return(100);

        case BetAmount.FiveHundred:
            return(500);

        default:     // BetAmount.OneThousand
            return(1000);
        }
    }
Пример #15
0
    private void IncreaseDecreaseBet(IncreaseDecreaseAction Action)
    {
        switch (CurrentBetAmount)
        {
        case BetAmount.One:
            switch (Action)
            {
            case IncreaseDecreaseAction.Decrese:
                break;

            case IncreaseDecreaseAction.Increse:
                CurrentBetAmount = BetAmount.Five;
                break;
            }
            break;

        case BetAmount.Five:
            switch (Action)
            {
            case IncreaseDecreaseAction.Decrese:
                CurrentBetAmount = BetAmount.One;
                break;

            case IncreaseDecreaseAction.Increse:
                CurrentBetAmount = BetAmount.Fifty;
                break;
            }
            break;

        case BetAmount.Fifty:
            switch (Action)
            {
            case IncreaseDecreaseAction.Decrese:
                CurrentBetAmount = BetAmount.Five;
                break;

            case IncreaseDecreaseAction.Increse:
                CurrentBetAmount = BetAmount.Hundred;
                break;
            }
            break;

        case BetAmount.Hundred:
            switch (Action)
            {
            case IncreaseDecreaseAction.Decrese:
                CurrentBetAmount = BetAmount.Fifty;
                break;

            case IncreaseDecreaseAction.Increse:
                CurrentBetAmount = BetAmount.FiveHundred;
                break;
            }
            break;

        case BetAmount.FiveHundred:
            switch (Action)
            {
            case IncreaseDecreaseAction.Decrese:
                CurrentBetAmount = BetAmount.Hundred;
                break;

            case IncreaseDecreaseAction.Increse:
                CurrentBetAmount = BetAmount.OneThousand;
                break;
            }
            break;

        case BetAmount.OneThousand:
            switch (Action)
            {
            case IncreaseDecreaseAction.Decrese:
                CurrentBetAmount = BetAmount.FiveHundred;
                break;

            case IncreaseDecreaseAction.Increse:
                break;
            }
            break;
        }
    }
Пример #16
0
 public int CompareTo(Bet other)
 {
     return(BetAmount.CompareTo(other.BetAmount));
 }
Пример #17
0
        private async void GetGameBoard()
        {
            try
            {
                if (GameReady == false)
                {
                    var status = new GameStatus();
                    var q      = client.Eth.GetContractQueryHandler <GameStatus>();
                    var ready  = await q.QueryAsync <bool>(status, contractAddress);

                    if (ready == true)
                    {
                        GameReady = true;
                    }
                    else if (BetTurn == false)
                    {
                        var am     = new BetAmount();
                        var bet    = client.Eth.GetContractQueryHandler <BetAmount>();
                        var result = await bet.QueryAsync <Int32>(am, contractAddress);

                        if (result != ProposedBet)
                        {
                            BetTurn = true;
                        }
                        tx_bet.Value = result;
                    }
                }
                if (GameReady == true)
                {
                    pn_bet.Enabled = false;
                    var handler1  = client.Eth.GetContractQueryHandler <GetWinnerFunction>();
                    var win       = new GetWinnerFunction();
                    var winResult = await handler1.QueryAsync <string>(win, contractAddress);

                    if (String.IsNullOrEmpty(winResult.ToString()) == false)
                    {
                        timer1.Stop();
                    }
                    pnl_Board.Enabled = true;
                    var handler2 = client.Eth.GetContractQueryHandler <GetBoradSquareFunction>();
                    var state    = new GetBoradSquareFunction();
                    state.Row    = 0;
                    state.Column = 0;
                    var cellStatus = await handler2.QueryAsync <string>(state, contractAddress);

                    if (cellStatus == "X")
                    {
                        bt_00.BackColor = Xcolor;
                    }
                    else if (cellStatus == "O")
                    {
                        bt_00.BackColor = Ocolor;
                    }
                    else if (cellStatus == "N")
                    {
                        bt_00.BackColor = Color.Transparent;
                    }

                    state.Row    = 0;
                    state.Column = 1;
                    cellStatus   = await handler2.QueryAsync <string>(state, contractAddress);

                    if (cellStatus == "X")
                    {
                        bt_01.BackColor = Xcolor;
                    }
                    else if (cellStatus == "O")
                    {
                        bt_01.BackColor = Ocolor;
                    }
                    else if (cellStatus == "N")
                    {
                        bt_01.BackColor = Color.Transparent;
                    }

                    state.Row    = 0;
                    state.Column = 2;
                    cellStatus   = await handler2.QueryAsync <string>(state, contractAddress);

                    if (cellStatus == "X")
                    {
                        bt_02.BackColor = Xcolor;
                    }
                    else if (cellStatus == "O")
                    {
                        bt_02.BackColor = Ocolor;
                    }
                    else if (cellStatus == "N")
                    {
                        bt_02.BackColor = Color.Transparent;
                    }

                    state.Row    = 1;
                    state.Column = 0;
                    cellStatus   = await handler2.QueryAsync <string>(state, contractAddress);

                    if (cellStatus == "X")
                    {
                        bt_10.BackColor = Xcolor;
                    }
                    else if (cellStatus == "O")
                    {
                        bt_10.BackColor = Ocolor;
                    }
                    else if (cellStatus == "N")
                    {
                        bt_10.BackColor = Color.Transparent;
                    }

                    state.Row    = 1;
                    state.Column = 1;
                    cellStatus   = await handler2.QueryAsync <string>(state, contractAddress);

                    if (cellStatus == "X")
                    {
                        bt_11.BackColor = Xcolor;
                    }
                    else if (cellStatus == "O")
                    {
                        bt_11.BackColor = Ocolor;
                    }
                    else if (cellStatus == "N")
                    {
                        bt_11.BackColor = Color.Transparent;
                    }

                    state.Row    = 1;
                    state.Column = 2;
                    cellStatus   = await handler2.QueryAsync <string>(state, contractAddress);

                    if (cellStatus == "X")
                    {
                        bt_12.BackColor = Xcolor;
                    }
                    else if (cellStatus == "O")
                    {
                        bt_12.BackColor = Ocolor;
                    }
                    else if (cellStatus == "N")
                    {
                        bt_12.BackColor = Color.Transparent;
                    }


                    state.Row    = 2;
                    state.Column = 0;
                    cellStatus   = await handler2.QueryAsync <string>(state, contractAddress);

                    if (cellStatus == "X")
                    {
                        bt_20.BackColor = Xcolor;
                    }
                    else if (cellStatus == "O")
                    {
                        bt_20.BackColor = Ocolor;
                    }
                    else if (cellStatus == "N")
                    {
                        bt_20.BackColor = Color.Transparent;
                    }

                    state.Row    = 2;
                    state.Column = 1;
                    cellStatus   = await handler2.QueryAsync <string>(state, contractAddress);

                    if (cellStatus == "X")
                    {
                        bt_21.BackColor = Xcolor;
                    }
                    else if (cellStatus == "O")
                    {
                        bt_21.BackColor = Ocolor;
                    }
                    else if (cellStatus == "N")
                    {
                        bt_21.BackColor = Color.Transparent;
                    }

                    state.Row    = 2;
                    state.Column = 2;
                    cellStatus   = await handler2.QueryAsync <string>(state, contractAddress);

                    if (cellStatus == "X")
                    {
                        bt_22.BackColor = Xcolor;
                    }
                    else if (cellStatus == "O")
                    {
                        bt_22.BackColor = Ocolor;
                    }
                    else if (cellStatus == "N")
                    {
                        bt_22.BackColor = Color.Transparent;
                    }

                    if (String.IsNullOrEmpty(winResult.ToString()) == false)
                    {
                        pnl_Board.Enabled = false;
                        pn_player.Enabled = true;
                        GameReady         = false;
                        MessageBox.Show(winResult);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }