Esempio n. 1
0
        private void NewGame()
        {
            //set the health of the first enemy
            EnemyHealth = 10;


            //set rnd to an random seed
            rnd = new Random();

            //set the number of dice the player starts with
            NumberOfStartingDice = 3;

            //create an array with empty dice
            DiceToRoll    = new Die[10];
            DieInHoldArea = new DieInHold[5];


            //disable all hold slots
            DiceHoldGroup.Children.Cast <Button>().ToList().ForEach(button =>
            {
                button.IsEnabled = false;
                button.Content   = "";
            });


            //Create disabled emtpy dice in hold
            for (int i = 0; i < DieInHoldArea.Count(); i++)
            {
                DieInHoldArea[i] = new DieInHold(0, false, false);
            }


            //disable all buttons exept a number of dice equal to the starting dice, give to still enabled basic dice data
            for (int i = 0; i < DiceToRoll.Length; i++)
            {
                Button button = (Button)DiceToRollGroup.FindName("DiceToRoll" + "_" + (i).ToString());
                if (i < NumberOfStartingDice)
                {
                    button.IsEnabled = true;
                    DiceToRoll[i]    = new Die(0, new List <string> {
                        "N.0", "A.1", "A.1", "A.1", "A.2", "A.3"
                    }, 6);
                }
                else
                {
                    button.IsEnabled = false;
                    DiceToRoll[i]    = new Die(0, new List <string>(), 0);
                }
            }

            bool HasRoled = RollAllDice();
        }
Esempio n. 2
0
        /// <summary>
        /// Take The button That was pressed and disable it and enable the corrospoonding button in the roll zone
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DiceFromHold(object sender, RoutedEventArgs e)
        {
            Button Sender     = (Button)sender;
            int    DiceNumber = int.Parse(Sender.Name.Split('_')[1]);

            Debug.Print(DieInHoldArea[DiceNumber].JustMoved.ToString());
            if (DieInHoldArea[DiceNumber].JustMoved)
            {
                Sender.IsEnabled = false;
                Sender.Content   = "";
                Button button = (Button)DiceToRollGroup.FindName("DiceToRoll" + "_" + (DieInHoldArea[DiceNumber].RollPos).ToString());
                button.IsEnabled = true;
                DieInHoldArea[DiceNumber].Enabled = false;
            }
            UpdateDiceMove();
        }
Esempio n. 3
0
        /// <summary>
        /// Deal the damage of the dice
        /// then disable all dice in hold area and enable the available dice in the to roll zone
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NextTurnClick(object sender, RoutedEventArgs e)
        {
            EnemyHealth -= UpdateDiceMove();

            EnemyHPLabel.Content = "Enemy HP: " + EnemyHealth.ToString();

            DiceHoldGroup.Children.Cast <Button>().ToList().ForEach(button =>
            {
                if (button.IsEnabled)
                {
                    int DieToDisable            = int.Parse(button.Name.Split('_')[1]);
                    DieInHoldArea[DieToDisable] = new DieInHold(0, false, false);
                    button.IsEnabled            = false;
                    button.Content = "";
                }
            });

            for (int i = 0; i < DiceToRoll.Length; i++)
            {
                Button button = (Button)DiceToRollGroup.FindName("DiceToRoll" + "_" + (i).ToString());
                if (i < NumberOfStartingDice)
                {
                    button.IsEnabled = true;
                    DiceToRoll[i]    = new Die(0, new List <string> {
                        "N.0", "A.1", "A.1", "A.1", "A.2", "A.3"
                    }, 6);
                }
                else
                {
                    button.IsEnabled = false;
                    DiceToRoll[i]    = new Die(0, new List <string>(), 0);
                }
            }

            TimesRolledTurn = 0;

            UpdateDiceRoll(RollAllDice());
        }