LabWindow Initialization - UQcsse3200/2023-studio-2 GitHub Wiki

LabWindow Class

The LabWindow class represents a window that can be added to a stage to pop up in the extractor Laboratory of your game.

Constructors

LabWindow(Texture background)

  • Creates a new instance of LabWindow with the specified background texture.
  • The window is centered on the stage with 80% width and 65% height of the stage.
  • It sets up buttons and actions for various in-game potions and an exit button.
  • Overrides normal user input to handle interactions within the Laboratory.

Methods

LabWindow MakeNewLaboratory()

  • Creates and returns a new instance of LabWindow with a laboratory-themed background.
  • This method is used to initialize a laboratory window.

#Example

public static LabWindow MakeNewLaboratory() {
        Texture background = new Texture("images/companion/lab.png");
        background.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge);
        return new LabWindow(background);
    }

failLaboratory()

  • Call this method to exit the Laboratory window. #Example
private void failLaboratory() {
        remove();
    }

remove()

  • Overrides the remove method to stop overriding user input when exiting the Laboratory.

Buttons and Actions

  • The LabWindow class sets up several buttons and actions for different potions and an exit button within the Laboratory:
    • "Death" potion button triggers the spawning of a death potion power-up.
    • "Speed" potion button triggers the spawning of a speed boost power-up.
    • "Health" potion button triggers the spawning of a health boost power-up.
    • "Invincibility" potion button triggers the spawning of a temporary immunity power-up.
    • "2x Damage" potion button triggers the spawning of a double damage power-up.
    • "Extra Life" potion button triggers the spawning of an extra life power-up.
    • "Snap" potion button triggers the spawning of a snap power-up.
    • "Double Cross" potion button triggers the spawning of a double cross power-up.
    • "EXIT" button allows the player to exit the Laboratory.

Input Override

  • The LabWindow class uses an InputOverrideComponent to override all normal user input while inside the Laboratory to handle interactions with the Laboratory's buttons and actions.

Dependencies

  • This class depends on various assets and services from the game, including textures for potions, the PowerupType enum, and the ServiceLocator for input and entity services.

Example Usage

To create a new Laboratory window:

LabWindow laboratoryWindow = LabWindow.MakeNewLaboratory();
stage.addActor(laboratoryWindow);