int secondsPassed = 0; // Used to monitor the number of seconds that have passed since the gamee started #endregion Fields #region Constructors // When an instance of this GameForm is created public GameForm(LoginForm parentForm, string usernameArg) { InitializeComponent(); // Initialize this Form component loginForm = parentForm; // Store the parent LoginForm username = usernameArg; // Record the Username that the player logged in with using the supplied username SettingsQuestionEntryBox.SetUsername(usernameArg); // Set the username stored by the SettingsQuestionEntryBox DropGrid.SetGridRange(7, 21, 21, 0); // Manually set the range of the DropGrid DropGrid.AllowDrop = true; // Ensure that the DropGrid allows dropping DropGrid.SetGridVisibility(false); // Set the Grid in the drop grid to invisible DropGrid.AddOccupyingPB(SoldierPictureBox); // Add the picture of the soldier to the list of PictureBoxes that cannot be dropped ontop of DropGrid.DragDrop += new DragEventHandler(objectPlaced); // Add a DragDrop listener to the DropGrid to call the objectPlaced method when triggered BeginPanel.BringToFront(); // Ensure that the BeginPanel is at the front of theform ShopFlowLayoutPanel.HorizontalScroll.Visible = false; // Prevent the Shop FlowLayoutPanel from scrolling horizontally FormClosed += new FormClosedEventHandler(formClosed); // Add a FormClosed listener to call the formClosed method when this form is closed PointsLabel.Text = "Points: " + points; // Update the text of the PointsLabel to display the current points of the user UserDatabase userDB = new UserDatabase(); // Create a new instance of a UserDatabase. This is done for reading purposes QuestionButtonState buttonState = userDB.getQuestionButtonState(username); // Read and store the button state that has been saved for this user SetBiologyButtonsState(buttonState.biologyButtonEnabled); // Set the state of the Biology Buttons to the saved values OtherSubjectTextBox.Text = buttonState.otherButtonLabel; // Update the name of the Other subjcet to the saved value SetOtherButtonState(buttonState.otherButtonEnabled); // Set the state of the Other Subject Buttons to the saved values PlantDispenser.stock = 3; // Manually set the stock for each dispenser in the shop. TapDispenser.stock = 4; FoodMachineDispenser.stock = 1; TorchDispenser.stock = 1; }
public Game(Login parentForm, string usernameArg) { InitializeComponent(); loginForm = parentForm; username = usernameArg; questionEntryBox1.SetUsername(usernameArg); dropGrid.SetGridRange(7, 21, 21, 0); dropGrid.AllowDrop = true; dropGrid.SetGridVisibility(false); dropGrid.AddOccupyingPB(pictureBox2); dropGrid.DragDrop += new DragEventHandler(objectPlaced); BeginPanel.BringToFront(); flowLayoutPanel1.HorizontalScroll.Visible = false; FormClosed += new FormClosedEventHandler(formClosed); PointsLabel.Text = "Points: " + points; UserDatabase userDB = new UserDatabase(); QuestionButtonState buttonState = userDB.getQuestionButtonState(username); SetBiologyButtonsState(buttonState.biologyButtonEnabled); OtherSubjectTextBox.Text = buttonState.otherButtonLabel; SetOtherButtonState(buttonState.otherButtonEnabled); PlantDispenser.stock = 3; TapDispenser.stock = 4; FoodMachineDispenser.stock = 1; TorchDispenser.stock = 1; }
// Used to update the button states of Biology and the Custom Subject private void UpdateButtonStates() { UserDatabase userDB = new UserDatabase(); // Create a new instance of a UserDatabase QuestionButtonState buttonState = userDB.getQuestionButtonState(activePupilUsername); // Extract the button state for the active username and store it SetBiologyEnabled(buttonState.biologyButtonEnabled); // Set Biology to enabled or disabled depending on the extracted value SetOtherSubjectEnabled(buttonState.otherButtonEnabled, buttonState.otherButtonLabel); // Set the Custom Subject to enabled or disabled depending on the extracted value }