MCPcopy Create free account
hub / github.com/candybox2/candybox2.github.io / update

Method update

code/main/Fireball.ts:81–113  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

79 }
80
81 public update(): void{
82 // If we target an entity
83 if(this.targetType == FireballTargetType.TARGET_ENTITY){
84 // If this entity is still alive
85 if(this.fireballTargetEntity != null && this.fireballTargetEntity.getDead() == false){
86 // We go towards it
87 this.goTowards(this.getGlobalPosition().plus(new Pos(Math.floor(this.size.x/2), Math.floor(this.size.y/2))), this.fireballTargetEntity.getRenderAreaCenter(), 0, this.speed);
88 }
89 // Else, we die
90 else this.setDead(true);
91 }
92 // Else, if we target to stick on an entity
93 else if(this.targetType == FireballTargetType.TARGET_STICK_ON_ENTITY){
94 // If this entity is still alive
95 if(this.fireballTargetEntity != null && this.fireballTargetEntity.getDead() == false){
96 // We teleport on it
97 this.teleport(this.fireballTargetEntity.getGlobalPosition().plus(this.specialTargetPosition));
98 }
99 // Else, we die
100 else this.setDead(true);
101 }
102 // Else, if we target a position
103 else if(this.targetType == FireballTargetType.TARGET_POSITION){
104 // We go towards this position
105 this.goTowards(this.getGlobalPosition().plus(new Pos(Math.floor(this.size.x/2), Math.floor(this.size.y/2))), this.targetPosition, 0, this.speed);
106 }
107
108 // Handle our damage
109 this.handleDamage();
110
111 // Call the mother class update method
112 super.update();
113 }
114
115 // willDie()
116 public willDie(): void{}

Callers

nothing calls this directly

Calls 8

handleDamageMethod · 0.95
getDeadMethod · 0.80
goTowardsMethod · 0.80
plusMethod · 0.80
getGlobalPositionMethod · 0.80
getRenderAreaCenterMethod · 0.80
setDeadMethod · 0.80
teleportMethod · 0.80

Tested by

no test coverage detected