Skip to content

Plant info display component

abhat0 edited this page Oct 17, 2023 · 8 revisions

Description

The PlantInfoDisplayComponent.java is a vital component within our game's user interface, primarily responsible for displaying essential information about the current status of plants and active missions. This component works in tandem with the PlantMouseHoverComponent, ensuring that players receive the information they need based on their interactions with the game world.

This page provides a comprehensive guide to the PlantInfoDisplayComponent, explaining how it seamlessly switches between displaying plant information when players hover their mouse over a plant and showcasing active missions when they are not interacting with a plant. It enhances player immersion and interaction with the game world, providing crucial insights into both plant and mission-related details.

Class Overview

The PlantInfoDisplayComponent is an extension of the UIComponent. Its primary responsibility is to display relevant information in two distinct scenarios:

  • Plant Information Display: When players hover their mouse over a plant, this component showcases pertinent details about the plant's current state. It enriches the player experience by providing plant-related context.
  • Active Mission Display: In moments when players are not interacting with a plant, the PlantInfoDisplayComponent transitions seamlessly to displaying active mission information. This feature ensures that players are always aware of their ongoing quests, promoting engagement with the game's objectives.

Functionality Breakdown

This condensed table provides a more detailed breakdown of the PlantInfoDisplayComponent functionality, including its usage, methods, and interactions with the game world. This table offers a comprehensive overview of the component's capabilities.

Functionality Description Usage Methods
Display Information Displays plant information when the player hovers over a plant, and active missions when not interacting with plants. Dynamic showPlantInfo, clearInfo
Initialization The component initializes during the game's startup, setting up event listeners for specific in-game events. Startup create
Window Management The component creates and manages a display window for information, making it visible or hidden as needed. Dynamic createWindow, toggleOpen

Plant Info Breakdown

This is an example of what the Plant Info Display looks like when the player is hovering their mouse over a plant. plantInfoDisplayExample

Description of what each of the items in the plant info display means:

Item in UI Description
Growth Stage: CURRENT GROWTH STAGE This indicates the current growth stage of the plant where CURRENT GROWTH STAGE can be, SEEDLING, SPROUT, JUVENILE, ADULT, DECAYING, DEAD
Water Level: CURRENT WATER LEVEL/IDEAL WATER LEVEL Indicating the current water level of the crop tile compared to the ideal water level of the plant. The goal is to balance the water level in the tile to be as close to the ideal water level as possible to grow the plant faster.
Water Status: STATUS String representation for the water level in the tile, this is a bit easier to understand that the water level outlines above. There are three strings representing the current water status. Under watered, Over watered, and Ideal water level.
Health: CURRENT HEALTH/CURRENT MAX HEALTH Shows the current health of the plant as well as the maximum health this plant can achieve at the current growth stage.
Growth Level: CURRENT GROWTH LEVEL/GROWTH THRESHOLD Shows the player how far away from achieving the next growth level a plant is. The GROWTH THRESHOLD is the level the CURRENT GROWTH LEVEL must reach before the plant advances to the next growth stage.

Variables

  • private Window window: window used to display the information.
  • private Label label: the label for the plant information.
  • private boolean madeFirstContact: True if the player has made first contact with the questgiver.
  • private MissionManager missionManager: The mission manager to get the active missions from.
  • private boolean isOpen: True if the UI is open or closed.

Methods

  • public void create(): Set up the event listeners and initialise the window and labels. Also get the mission manager.
  • private void makeFirstContact(): Sets madeFirstContact to true.
  • private void toggleOpen(boolean isOpen): Sets the window visible or not based on the isOpen bool.
  • private void createWindow(String windowName): Create the window used to display the plant information.
  • public void showPlantInfo(String plantName, String plantInfo): Display the string of plant information to the window.
  • public void clearInfo(): Clears the window of plant information and displays mission information.
  • private void makeFirstContactWindow(): Show a message that is displayed in the window until the player makes first contact with the questgiver.

UML

The PlantInfoDisplayComponent is dependent on the PlantMouseHoverComponent and the PlantInfoService to determine what information to display, and when to display it.

image

Test Plan

  • create the setUp method to be run before each test
  • initialize the PlantInfoDisplayComponent object
  • create tests for the setter and getter methods
Clone this wiki locally