Esempio n. 1
0
    public int calculateDice(int totalDiceNum, int dic3, int dic6)
    {
        if ((dic3 + dic6) > totalDiceNum)
        {
            return(0);
        }


        int[] resD3Array    = new int[dice3Amount];
        int   _RollD3resSUM = 0;

        int[] resD6Array    = new int[dice6Amount];
        int   _RollD6resSUM = 0;

        for (int i = 0; i < dice3Amount; i++)
        {
            Dice tem = new Dice3();
            tem.Roll();
            resD3Array[i] = tem.getDiceRes();
            Debug.Log(tem.getDiceRes());
            _RollD3resSUM += tem.getDiceRes();
        }
        Debug.Log(dice3Amount + " 颗三面骰子的和 " + _RollD3resSUM);

        for (int i = 0; i < dice6Amount; i++)
        {
            Dice tem = new Dice6();
            tem.Roll();
            resD6Array[i] = tem.getDiceRes();
            Debug.Log(tem.getDiceRes());
            _RollD6resSUM += tem.getDiceRes();
        }
        Debug.Log(dice6Amount + " 颗六面骰子的和 " + _RollD6resSUM);
        return(_RollD3resSUM + _RollD6resSUM);
    }
Esempio n. 2
0
    public int calculateDice(int dic3, int dic6)
    {
        resD3Array = new int[dic3];
        int _RollD3resSUM = 0;

        resD6Array = new int[dic6];
        int _RollD6resSUM = 0;

        for (int i = 0; i < dic3; i++)
        {
            Dice tem = new Dice3();
            tem.Roll();
            resD3Array[i] = tem.getDiceRes();
            //            Debug.Log(tem.getDiceRes());
            _RollD3resSUM += tem.getDiceRes();
        }
        //		Debug.Log(dic3 + " 颗三面骰子的和 " + _RollD3resSUM);

        for (int i = 0; i < dic6; i++)
        {
            Dice tem = new Dice6();
            tem.Roll();
            resD6Array[i] = tem.getDiceRes();
            //            Debug.Log(tem.getDiceRes());
            _RollD6resSUM += tem.getDiceRes();
        }
        //		Debug.Log(dic6+ " 颗六面骰子的和 " + _RollD6resSUM);
        int _sum = _RollD3resSUM + _RollD6resSUM;

        //  Debug.Log(dic3 + " 颗三面骰子和 " + dic6 + " 颗六面骰子的结果为 " + _sum);
        return(_RollD3resSUM + _RollD6resSUM);
    }
Esempio n. 3
0
        public void throwSeverald3Test()
        {
            Dice dice = new Dice3(new VisualStudioRandomGenerator());

            for (int i = 0; i < 100; i++)
            {
                int dvalue = (int)dice.rollADice();
                Assert.IsTrue(1 <= dvalue && dvalue <= 3, "value not fit for d3:" + dvalue);
            }
        }
Esempio n. 4
0
    void ZeroingOut()
    {
        totalDamage       = 0;
        HowManyDicesKnown = 0;

        Dice1.ChangeAttack(0);
        Dice2.ChangeAttack(0);
        Dice3.ChangeAttack(0);
        Dice4.ChangeAttack(0);

        Dice1.whatadice = false;
        Dice2.whatadice = false;
        Dice3.whatadice = false;
        Dice4.whatadice = false;

        d1WasAdded = false;
        d2WasAdded = false;
        d3WasAdded = false;
        d4WasAdded = false;
    }
Esempio n. 5
0
    //我只想丢dic3个骰子, 不关心是几面的
    public int calculateDice(int dic3)
    {
        if (dic3 > 0)
        {
            int[] resD3Array    = new int[dic3];
            int   _RollD3resSUM = 0;

            for (int i = 0; i < dic3; i++)
            {
                Dice tem = new Dice3();
                tem.Roll();
                resD3Array[i] = tem.getDiceRes();
                //            Debug.Log(tem.getDiceRes());
                _RollD3resSUM += tem.getDiceRes();
            }
            //  Debug.Log(dic3 + " 颗三面骰子的和 " + _RollD3resSUM);
            return(_RollD3resSUM);
        }
        return(0);
    }
Esempio n. 6
0
        /// <summary>
        /// Roll the dices and return their values.
        /// </summary>
        /// <param name="dice1">First dice. If true, the dice value will be processed again.</param>
        /// <param name="dice2">Second dice. If true, the dice value will be processed again.</param>
        /// <param name="dice3">Third dice. If true, the dice value will be processed again.</param>
        public void RollDices()
        {
            if (!this.Dice1.Checked)
            {
                Dice1.Roll();
            }
            if (!this.Dice2.Checked)
            {
                Dice2.Roll();
            }
            if (!this.Dice3.Checked)
            {
                Dice3.Roll();
            }

            // Sorts the score so it's shown from the bigger number to the lowest.
            char[] arrayTmp = (Dice1.ToString() + Dice2.ToString() + Dice3.ToString()).ToArray();
            Array.Sort(arrayTmp);
            Array.Reverse(arrayTmp);
            GamePlayers.CurrentPlayer.DiceRoll = Convert.ToInt32(new string(arrayTmp));

            GamePlayers.CurrentPlayer.PlaysLeft--;
        }
Esempio n. 7
0
 /// <summary>
 /// Resets the dices.
 /// </summary>
 private void ResetDices()
 {
     Dice1.Reset();
     Dice2.Reset();
     Dice3.Reset();
 }
Esempio n. 8
0
        public void throw1d3Test()
        {
            Dice dice = new Dice3(new FakeRandomGenerator());

            Assert.AreEqual(DiceValue.PlusOne, dice.rollADice());
        }