//--------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Link the labels on the GUI form to the dice and players /// </summary> /// <param name="form"></param> private void LoadLabels(Form1 form) { Label[] diceLabels = form.GetDice(); for (int i = 0; i < dice.Length; i++) { dice[i].Load(diceLabels[i]); } for (int i = 0; i < players.Count; i++) { players[i].Load(form.GetScoreTotals()); } }
/// <summary> /// Creates a new game and initiates the GUI desgin and starting buttons. /// </summary> /// <param name="form"></param> public Game(Form1 form) { form.clearScoreLabels(); players.ResetBindings(); players.Add(new Player(Names[0], form.GetScoreTotals())); string message = "Please Select the Number of Players"; currentPlayerindex = 0; playersFinished = 0; numRolls = 0; this.form = form; this.dieLabels = this.form.GetDice(); for (int i = 0; i < dice.Length; i++) { dice[i] = new Die(dieLabels[i]); } currentPlayer = players[currentPlayerindex]; for (int i = 0; i < dice.Length; i++) { dieLabels[i].Text = ""; } string name = Names[currentPlayerindex]; form.DisableAndClearCheckBoxes(); form.DisableAllButtons(); form.ShowPlayerName(name); form.EnableUpDown(); form.EnableRollButtons(); form.ShowMessage(message); form.HideOKButton(); form.enablesave(); form.disableload(); }
/// <summary> /// Adds players to the binding list. /// </summary> public void addToList() { players.Add(new Player(Names[form.numberofplayers()], form.GetScoreTotals())); }