Skip to content

Tower Upgrader Component

Guoyang Luo edited this page Oct 3, 2023 · 6 revisions

This component listens for events being sent to the tower signalling that an upgrade has been done, and makes the necessary changes to the tower's statistics to implement the upgrade specified.

Hasakev: I made some changes to adhere to the new changes to fire rate and income - Sprint 3 :)

The type of upgrade performed is dependent on the first argument supplied with the triggered event, an UPGRADE enum.

  • UPGRADE.ATTACK causes the component to upgrade the tower's attack stat in the Combat Stats Component
  • UPGRADE.MAXHP causes the component to upgrade the tower's maximum health in the Combat Stats Component
  • UPGRADE.FIRERATE sets the tower's fire rate to the (1/value given) in the Upgradable Stats Component and the associated Tower Combat Task.
  • UPGRADE.INCOME Sets the tower's income rate to the value given in the Income Upgrade Component and the associated Currency Task.
  • UPGRADE.REPAIR sets the tower's health to its maximum health value in the Combat Stats Component

The second argument supplied to the triggered event determines how much the stat is changed, working on a 1-to-1 increase of the stat for ATTACK and MAXHP, for FIRERATE it sets the firerate to (1/given value * 0.2), for INCOME, it sets the income rate to the given value (in seconds) REPAIR is unaffected by the argument.

Example lines of code to to invoke the Tower Upgrader Component from another class:

tower.getEvents().trigger("upgradeTower", TowerUpgraderComponent.UPGRADE.ATTACK, 10);

The above line would increase the 'tower' entity's attack by 10.

tower.getEvents().trigger("upgradeTower", TowerUpgraderComponent.UPGRADE.FIRERATE, 60);

The above line would set the 'tower' entity's rate of fire to 1/12.

tower.getEvents().trigger("upgradeTower", TowerUpgraderComponent.UPGRADE.INCOME, 60);

The above line would set the 'tower' entity's income rate to 60s.

tower.getEvents().trigger("upgradeTower", TowerUpgraderComponent.UPGRADE.MAXHP, -20);

The above line would decrease the 'tower' entity's maximum health by 20.

UI

When a user clicks an upgradable tower, a menu appears for the user to view stats for the current turret and upgrade options.

for now this is only for: Income, Wall, Droid, Fire and Stun a pop-up appears for the user.

Based on the turret there are currently 3 different displays:

Income:

image

Wall:

image

Weapon (Droid, Fire, Stun, Weapon):

image

The heart icon symbolises the health of the current tower with CURRENT_HEALTH/MAX_HEALTH The gun icon symbolises the damage that current tower can have. The hourglass icon symbolises the attack rate that the current has. The Scrap icon symbolises the rate (in seconds) that the scrap generates gold. The hammer icon symbolises the repair tool such that the current health is restored to max health.

The buttons with green up arrow and the associated symbols above is the upgrade button for each stat of the turret.

When an upgrade is clicked, an indicator appears for the cost and if you have enough to purchase the upgrade, the label and stats of the turret would upgrade.

Before Upgrade:
image

The image depicts the mouse hovering the upgrade scrap button

After Upgrade:
image

30s has decreased to 25s

UML

image

Clone this wiki locally