Skip to content

MeleeTowerModel

Specific model implementation for the Melee Tower.

MeleeTowerModel

Extends TowerModel.

Properties

PropertyTypeDescription
currentTiernumberThe current tier of the melee tower.
baseSpriteEntityThe base sprite for the current tier.
middleSpriteEntityThe middle (arm) sprite for the current tier.
headSpriteEntityThe head (glove/fist) sprite for the current tier.
middleMaskDrawEntityA masking rectangle used to hide the back of the punching arm.

Methods

constructor()

ts
function constructor(): void

Initializes the model by calling the super({ name: 'melee-tower' }). Creates the middleMask and initializes the model at tier 1.

update()

ts
function update(dt: number, user: any): void

Updates the model every frame. Calls updateModel, updateAnimation, and updateHealthBar.

updateModel()

ts
function updateModel(tier: number): void

Updates 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()

ts
function updateHealthBar(tick: ENTITY_DATA, networkEntity: NetworkEntity): void

Calls the superclass updateHealthBar, then updates the health and maxHealth of the health bar and rotates it based on tick.yaw.

updateAnimation()

ts
function updateAnimation(tick: ENTITY_DATA): void

Animates 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.