Skip to content

NPC Upgrades

Joanna edited this page Oct 14, 2024 · 3 revisions

Introduction

The NPCFactory class provides methods for creating different types of NPC (Non-Player Character) entities in the game. This documentation covers the creation of a special upgrade NPC (penguin) that interacts with players to offer random upgrades. This NPC appears in the game area, and players can press "U" to access the upgrades menu when the press U hover box is shown.

Purpose

createUpgradeNPC(Vector2 firstPosition, UpgradesDisplay upgradesDisplay)

Creates a special upgrade NPC, represented as a penguin, that offers upgrades to the player. The penguin is animated, follows a defined path, and displays a hover box when ready.

createStandard(Vector2 targetPosition)

Creates a standard NPC entity with basic movement and collision components. This serves as a base for other NPC types.

Class Overview

NPCFactory Class

This class provides factory methods for creating various types of NPCs in the game. It uses different game components, such as physics and AI tasks, to define the behavior and interactions of the created NPCs.

Method: createUpgradeNPC(Vector2 firstPosition, UpgradesDisplay upgradesDisplay)

Description: Creates an upgrade NPC that moves to a specified position, displays a hover box when ready, and opens the upgrades menu when U is pressed.

Parameters:

  • firstPosition: The initial position where the NPC will be placed in the game.
  • upgradesDisplay: The display component that will show the upgrades menu when the NPC is clicked.

Behavior:

  • The NPC starts moving to the specified position.
  • Once it reaches the destination, the hover box becomes visible, indicating it’s ready to interact.
  • When U is pressed, the upgrades menu is displayed.
  • NPC will be disposed of after interaction.

Method: createStandard(Vector2 targetPosition)

Description: Creates a basic NPC entity with physics and movement capabilities.

Parameters:

  • targetPosition: The position the NPC will move towards.

Behavior:

  • The NPC moves along a predefined path and interacts with other game entities based on its components.

Key Components:

  • PhysicsComponent: Adds properties to the NPC.
  • PhysicsMovementComponent: Enables movement using physics-based controls.
  • ColliderComponent: Sets up collision detection with other entities.
  • HitboxComponent: Defines the hitbox area for interactions.

Spawning the Upgrade NPC

Method: spawnPenguin(UpgradesDisplay upgradesDisplay)

Description: Spawns the upgrade NPC (penguin) in the forest game area at a specified position.

Parameters:

  • upgradesDisplay: The display component for showing the upgrades menu.

Behavior:

  • The penguin is created using the createUpgradeNPC method and spawned at the designated position within the forest game area.
  • The penguin's position is set based on the targetPos vector.
  • Once spawned, the penguin will move to its initial position and await player interaction.

UML Diagram

Screenshot 2024-10-03 at 8 30 10 AM

Sequential Diagram

Screenshot 2024-10-03 at 8 30 36 AM

Conclusion

The NPCFactory class provides an efficient way to create and manage special NPCs, like the upgrade-offering penguin. By using predefined components and behaviors, it ensures consistency in NPC interactions and easy integration into different game areas. The spawnPenguin method can be used to place these NPCs in specific locations, adding variety and interactive opportunities for players within the game.

Table of Contents

Home

Team Design Document

Game Features

Inventory System
Scoring System
Food Recipes
Level System
Player Actions
Ordering System
Stations
Items
Map Design
Customers
Pause Menu
Upgrades
End of Day Display
Day Night Cycle
Moral System
Debug Terminal
Game Interactions Tutorial
Backstory Cutscenes

Game

Getting Started

Entities and Components

World Backstory

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Map Design

Test Plans

Sensor Component

Customer Sensor Component

Interaction Component

Inventory Component

Inventory Display

Station Meal Component

Station Progress Display

Keyboard Input Component

Fire Extinguisher Handler Component

Score System

HoverBox Component

MainGameActions Create Docket Triggers

End Day Display Component

Cutscene Area

Docket

Docket Line Display

Docket Meal Display

Main Game Order Button Display

Order Actions

Recipe

Ticket Details Component

BackstoryCutscene Test Plan

BackstoryCutsceneDisplay Test Plan

Test Plan for Tutorial

Keybinds

Keybinds Test Plan

Test Plan for MainGameOrderTicketDisplay

Test Plan for MainGameOrderBtnDisplay

Test Plan for Docket

Test Plan for DocketLineDisplay

Test Plan for OrderActions

Ticket Details

Test plan for RandomComboService

Test plan for LoanUpgrade

Test plan for UpgradesDisplay

Test plan for RageUpgrade

Test plan for SpeedBoostUpgrade

Test plan for DancePartyUpgrade

Test plan for ExtortionUpgrade

Troubleshooting

MacOS Setup Guide

Clone this wiki locally