MeleeTowerModel
Specific model implementation for the Melee Tower.
MeleeTowerModel
Extends TowerModel.
Properties
| Property | Type | Description |
|---|---|---|
currentTier | number | The current tier of the melee tower. |
base | SpriteEntity | The base sprite for the current tier. |
middle | SpriteEntity | The middle (arm) sprite for the current tier. |
head | SpriteEntity | The head (glove/fist) sprite for the current tier. |
middleMask | DrawEntity | A masking rectangle used to hide the back of the punching arm. |
Methods
constructor()
function constructor(): voidInitializes the model by calling the super({ name: 'melee-tower' }). Creates the middleMask and initializes the model at tier 1.
update()
function update(dt: number, user: any): voidUpdates the model every frame. Calls updateModel, updateAnimation, and updateHealthBar.
updateModel()
function updateModel(tier: number): voidUpdates the base, middle, and head sprites if the tier has changed. Supported tiers are 1 through 8. Applies the middleMask to the middle attachment. Attachments are added at layers 1 (base), 2 (middle), and 3 (head).
updateHealthBar()
function updateHealthBar(tick: ENTITY_DATA, networkEntity: NetworkEntity): voidCalls the superclass updateHealthBar, then updates the health and maxHealth of the health bar and rotates it based on tick.yaw.
updateAnimation()
function updateAnimation(tick: ENTITY_DATA): voidAnimates the punching action if tick.firingTick is present. The punch animation lasts for 250ms and adjusts the position of the middle sprite. Also handles the rotation of the head, middle, and middleMask to face tick.towerYaw.