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

Method addMagicBall

code/main/DeveloperEntity.ts:92–117  ·  view source on GitHub ↗
(finalPosition: Pos, damage: number, timeToLive: number, colorType: ColorType)

Source from the content-addressed store, hash-verified

90
91 // Public methods
92 public addMagicBall(finalPosition: Pos, damage: number, timeToLive: number, colorType: ColorType): void{
93 // Set the first position (either the mouth or one of the eyes)
94 var firstPosition: Pos;
95 switch(Random.upTo(2)){
96 case 0: firstPosition = new Pos(15, 15); break;
97 case 1: firstPosition = new Pos(25, 15); break;
98 case 2: firstPosition = new Pos(20, 26); break;
99 }
100
101 // Create the fireball
102 var magicBall: DeveloperMagicBall = new DeveloperMagicBall(this.getQuest(),
103 this.getGlobalPosition().plus(firstPosition),
104 new Naming("A magic ball", "a magic ball"),
105 new Color(colorType),
106 new Pos(2, 1),
107 damage,
108 this.getAndPossiblyCreateSpellCastingDamageReason(new Naming("A magic ball", "a magic ball")),
109 timeToLive
110 );
111
112 // No target
113 magicBall.setTargetTypeTargetPosition(finalPosition, new Pos(1, 1));
114
115 // Add the entity
116 this.getQuest().addEntity(magicBall);
117 }
118
119 public createTexts(): void{
120 // Empty the array

Callers 1

updateMethod · 0.80

Calls 6

getQuestMethod · 0.80
plusMethod · 0.80
getGlobalPositionMethod · 0.80
addEntityMethod · 0.80

Tested by

no test coverage detected