1. Trang chủ
  2. » Luận Văn - Báo Cáo

tower defense game software specification

104 1 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

Class DiagramTower:Description: The "Tower" is an abstract class that describes the behaviorand properties of a defensive tower object in a tower defense game.. Each tower instance can h

Trang 1

TOWER DEFENSE GAMESoftware Specification

Project Code: TD

Document Code: TD_ Software Specification_v02

Ha Noi, 10/06/2023

Trang 2

LEADER : Nguyễn Minh Thái REVIEWERS: TD Development Team 10/06/2023

APPROVAL: Bùi Thị Thùy 21/06/2023

TEAM MEMBER :

Trang 4

11.2 Place and control: 66

11.3 Upgrading and Summoning: 66

12.Balancing 66

12.1 Total Strength formula: 66

12.2 Pseudocode for calculating strength of monsters and player over wave 66

12.3 Graph of strength over time 67

Trang 5

13.4 Popup MenuSkill 70

13.5 Popup when click option button in game 70

13.6 Screen when lose game 71

13.7 Mini Map 71

14 Mindmap 72

15 Interaction 73

15.1 Interaction between Warrior and Harpy 73

15.2 Interaction between Warrior and Ogre 73

15.4 Interaction between Warrior and Banshee 76

15.5 Interaction between Archery and Harpy 76

15.6 Interaction between Archery and Ogre 77

15.7 Interaction between Archery and Minotaur 78

15.8 Interaction between Archery and Banshee 79

15.9 Interaction between Monster and Tower 79

Trang 6

Understand the Problem

Implement a game called Tower Defense In the game, the player can buy defenders to resist the monster’s attack Besides that, the user can move the defenders to the target position to attack the monsters Playerswill receive support from the towers And players can upgrade the power of towers and defenders.

Upgrading turrets will cause turrets to take more damage and fire faster From there you can kill monsters easier In addition, the player can upgrade the defender's strength stats There are 3 types of turrets, each with 3 different power levels There are two types of defenders: ranged and melee.

Monsters will get stronger over time They will be spawned in turns When each turn ends, the player will have 5 seconds to prepare for the next turn After turns, monsters will become stronger (attack, speed, defense).

The player's points will be accumulated through the plays Each monsterturn is a turn When the main house is destroyed, the player's score is the number of turns the monster has been destroyed During the game, the player can go to the menu to save the game and keep playing or play a new game.

Design a Solution

We’ll approach our design, implementation, and testing in five iterations Specifically, we'll have iterations for basic gameplay, full gameplay, menus, sounds, and XML configuration data It should be obvious why we're thinking of the full gameplay The difficulty menu, and the pause menu as menus Perhaps less intuitively, we're also thinking of the high score menu as a menu because it will behave just like any other menu, with a clickable button to take some action (in this case, close the menu and return to the main menu Just as we did in Chapter 17, we'll make our main menu and difficulty menu separate scenes in our game Our pause menu will be a "popup menu" that appears above the gameplay scene, so we'll make that a prefab we can create and destroy as necessary This is a different approach from the one we used in the

Trang 7

previous chapter for our high score table, but recall that in our previous approach we included a canvas in the scene, then modified whether or not it was displayed as appropriate Although our game here only has one gameplay scene, you should be able to easily imagine a game with many gameplay scenes (e.g., levels) We don't want to have to add the pause menu canvas to each of those scenes in the editor, so a prefab is the better way to go Finally, our high score menu will also be a prefab We'll display it both from the main menu and at the end of a game, so having a prefab we can use in both places will be a good approach.

Trang 8

Class DiagramTower:

Description: The "Tower" is an abstract class that describes the behaviorand properties of a defensive tower object in a tower defense game It inherits from MonoBehaviour, indicating that it's meant to be attached to a game object in the Unity environment The Tower class outlines the core attack functionality of a defensive tower, including attack modes

Trang 9

and targeting Each tower instance can hold specific properties such as damage, cooldown, and range, and manage its own bullet instantiation.Attributes:

- targetRotation: A Quaternion that represents the rotation needed to aimat the current target.

- bullet: A GameObject which is the bullet that the tower fires.- animator: An Animator that is responsible for handling animation.- cooldownTimerBullet: A Timer that handles the cooldown between bullet shots.

- finishedRotate: A Boolean to check if the tower has finished rotating towards the target.

- colliders: A static list of GameObjects which holds all the colliders (presumably of potential targets) the tower can interact with.- isAttack: A Boolean indicating if the tower is currently attacking.- damage, cooldown, range: Double values representing the tower's attack properties, accessible via respective public properties (Damage, Cooldown, Range).

- AttackSelectedMonster(): Handles the procedure of attacking a specificmonster when selected by the user.

- AttackMonsterWithLowestHitPoint(): A targeting behavior where the tower attacks the monster with the lowest hitpoints.

- AttackClosestMonster(): A targeting behavior where the tower attacks the monster closest to it.

- OnTriggerExit2D(): Method to handle when a collider exits the tower's range The attack flag is turned off.

Trang 10

- Create(): An abstract method to be implemented by subclasses, used to create and place a tower at a specific position.

Trang 11

This class is responsible for managing the attack behavior of towers in the game It contains properties and methods to deal with the attack's range, damage, the target of the attack, and even the visualization of reaching the target with an animation.

Range: A float indicating how far the attack can reach.sourceGameObject: The game object initiating the attack.targetDirection: The Vector2 direction towards which the attack is aimed.

targetGameObjectPrefab: A GameObject representing the prefab of the target object for the attack.

targetGameObject: A reference to the unit that is the target of the attack.

Damage: The amount of damage the attack can cause.reachingAnimation: A GameObject that serves to display an animation when the attack reaches its target.

Methods:

Trang 12

Start(): A Unity engine method that sets up the count variable when the game starts.

Update(): A Unity engine method that updates every frame, checking if the attack has reached its target, applying damage, and managing relevant animations and behaviors.

DoesEffectBehaviour(): A virtual method that is meant to be overridden in derived classes to define specific

behaviors/effects of the attack upon reaching the target.OnBecameInvisible(): A Unity engine method that destroys the game object when it becomes invisible to the camera, helping to manage resources and performance.

Trang 13

The Unit class represents a generic, controllable unit in the game This class is abstract, indicating that it is not meant to be instantiated directly but should be used as a base for other, more specific unit types Units

Trang 14

can be thought of as the main entities participating in the game's battles or interactions.

Fundamental attributes like Damage, HitPoints, Speed, AttackRange, CoolDown, and AttackType define the unit's basic capabilities.Level and MaxHitPoint represent the unit's current experience level and maximum hit points, respectively.

CooldownTimerBullet is a timer to control the rate at which the unit attacks.

AtkRangeCollider and SelectedRangeCollider are two CircleCollider2D instances to manage the unit's attack range and selected range.

AttackShape is a GameObject that likely represents the visual form of the unit's attacks.

HealthBar is a reference to the unit's health bar.

IsAttack and StateAttack indicate whether the unit is currently attacking and the state of the attack.

BaseDamage, BaseHitPoints, and BaseSpeed denote the fundamental attributes that are utilized to compute the actual attributes with respect tothe unit's level.

Initialize(float damageMultiplier, float hitpointMultiplier, float

speedMultiplier): Initialize the unit with a multiplier for damage, hit points,and speed.

Attack(Unit target): Executes the unit's attack on a target unit.

DisplayAttackShape(Vector2 direction, Unit target): Displays the shape of the unit's attack, with specific logic for different types of attacks (MeleAttack, AOEAttack, RangedAttack).

TakeDamage(float amount): Reduces the unit's hit points by a certain amount and updates the health bar accordingly, triggering the Die method if hit points fall to or below zero.

Die(): Defines what should happen when the unit dies (currently, the unit GameObject is destroyed).

LevelUp(): Increments the unit's level.

Trang 15

StrengtCaculation(): Calculates and returns the unit's strength based on its damage, hit points, and speed.

This class is responsible for managing the behavior of attacking units in a game It contains properties and methods for dealing with the selectionof target, range of attack, turning towards the target and controlling animations It also has behaviors for attacking enemy units or towers, continuing the movement after killing a target, and flipping direction based on the position of the target.

agent: An instance of AgentMoventMentMonster class for controlling the movement of the attacker.

threshold: A float for determining when to flip the direction of the attacker.

FlipDirection: A Vector3 to calculate the direction between attacker and its target.

dotProduct: A float to calculate the dot product of FlipDirection and transform.right.

Trang 16

OnTriggerExit2D(Collider2D other): A method that's called when the Collider2D other has stopped touching the trigger.

Attack(Unit target): A method that starts the attack on a target Unit.Die(): A method that handles the death of the attacker.

Strength2(): A method that calculates and returns the strength of the attacker.

This class is responsible for managing the behavior of defending units in a game It contains properties and methods for dealing with the selectionof target, stopping and continuing movement, interacting with attackers, and handling the death of a defender.

Properties:

Trang 17

currentTarget: An instance of Attacker indicating the current target of the defender.

selection: A GameObject representing the selected unit.

isInsideTrigger: A boolean to check if the defender is inside a trigger.stateAttack: An integer for tracking the attack state of the defender.UpGradedGold: An integer representing the gold gained by upgrading the defender.

StrengthGold(): A method that calculates and returns the strength of the defender.

Die(): A method that handles the death of the defender It calculates the value using StrengthGold method and destroys the game object.Game Click Manager

Trang 18

This class, 'SkillManager', handles the operations related to the skill management of the player character in the game It contains properties and methods to choose and activate different skills, such as Hypnosis, Healing, and Meteo.

chooseSkill: An integer to keep track of the selected skill.skillCanvas: A GameObject representing the UI canvas for skills.btnHypnosis, btnHeal: Buttons for activating the Hypnosis and Heal skillsrespectively.

Hypnosis, Health, Meteo: GameObjects representing the skills or effects associated with Hypnosis, Healing, and Meteo.

Trang 19

mainCamera: An instance of the game's main camera.

isMoving: A boolean flag indicating if a Meteo object is currently moving.Methods:

Start(): A Unity engine method that is called before the first frame update It initializes the chooseSkill, skillCanvas, and mainCamera.Update(): A Unity engine method that is called once per frame It checks for mouse input to activate the chosen skill.

CreateMovingObject(Vector3 vector3): A method that instantiates the Meteo GameObject at a specified position.

SkillHypnosis(), SkillHeal(), SkillMeteo(): These methods set the chooseSkill to the respective skills and hide the skillCanvas.Exit(): This method sets chooseSkill to 1 and hides the skillCanvas.

Wave Manager

Description:

Trang 20

This class, `UnitSpawner`, manages the spawning of enemy units in the game, following certain conditions and waves.

- Constants such as `WIDTH_MAP`, `HEIGHT_MAP`, and `DELTA_TIME_PER_WAVE` which define gameplay parameters.- `attackersQueue`: A queue to hold and manage the attackers in the game.

- Prefabs of game entities like `prefabBanshee`, `prefabHarpy`, `prefabMinotaur`, `prefabOrge`, `prefabGhost`, and `prefabBoss`.- Public getters and setters for `StrengthPerWave`, `CountWave`, `AccumStrength`, and `TypeUnit`.

- Parameters to define the maximum and minimum values for the x and ycoordinates of spawning positions.

- A `System.Random` instance `rand` for generating random numbers.- Other private variables such as `isEndWave`, `level`, and `timer`.Methods:

- `TriggerCondition()`: A function to check the condition for spawning the boss Currently, it always returns false.

- `Start()`: A Unity engine method that initializes the wave count, wave strength, and spawns a new wave of attackers.

- `Update()`: A Unity engine method that checks the completion of a wave and initiates a new wave if completed.

- `IsFinishWave()`: Checks whether a wave is finished by checking if there are any remaining attackers.

- `SpawnNewWave()`: Generates a new wave of attackers based on the total strength for the wave.

- `IncreaseStrength()`: Calls the `LevelUp()` method on all attacker typesto increase their strength.

- `GenerateUnit(GameObject prefab)`: Creates a new unit of the type provided by the GameObject argument at a random position within defined bounds.

- `StartNewWave(float delay)`: A coroutine that waits for a given delay then starts a new wave If the previous wave has finished, it increments the wave count and strength per wave.

Trang 21

Usage:

This class would typically be attached to a manager GameObject in the scene Its purpose is to manage the spawning of enemy waves in the game, controlling their strength and frequency, and checking conditions for wave completion and boss spawning.

Game state manager

The MenuMainManagement class serves as the control center for the main menu of your game The class is equipped with the functions that correspond to the buttons present in the main menu.

This class also has functionality for saving and loading the state of the game by converting game object data into a JSON string and storing it using Unity's PlayerPrefs These functions can be invoked when the player decides to continue the game after exiting or wants to start a new game.

The functions in this class can be explained as follows:

Start(): This function is invoked when the scene starts It adds an invokerto the EventManager for the ResetGold event.

ToResetGold(int value): This function invokes the ResetGold event with a value of 0.

Trang 22

NewGameButtonOnClickEvent(): This function loads the scene "map" when the New Game button is clicked.

ContinueButtonOnClickEvent(): This function loads the saved game and then loads the "map" scene when the Continue button is clicked.QuitButtonOnClickEvent(): This function quits the application when the Quit button is clicked.

SettingButton(): This function enables the canvas of the child GameObject tagged with "optionInGame" when the Settings button is clicked.

getGameChildObject(GameObject target): This helper function returns the GameObject named "BackGround" which is a child of the input GameObject.

ExitSettingButton(): This function disables the canvas of the child GameObject tagged with "optionInGame" when the Exit button in the settings is clicked.

SurrenderButton(): This function resets the game information and loads the "GameOver" scene when the Surrender button is clicked.

ExitSettingButton2(): This function loads the "Menu" scene when the second Exit button in the settings is clicked.

RestGame(): This function saves the state of the game by storing information about all game objects in PlayerPrefs The information is serialized into a JSON string before saving.

Overall, this class controls the flow of your game from the main menu, allowing the player to start a new game, continue a saved game, access settings, and quit the game.

Map

Ngày đăng: 09/05/2024, 10:58

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w