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

Method constructor

code/main/Demon.ts:8–70  ·  view source on GitHub ↗
(quest: Quest, pos: Pos)

Source from the content-addressed store, hash-verified

6
7 // Constructor
8 constructor(quest: Quest, pos: Pos){
9 super(quest,
10 pos,
11 new Naming("A demon", "a demon"),
12 new RenderArea(0, 0),
13 new Pos(0, 0),
14 new CollisionBoxCollection(),
15 new QuestEntityMovement()
16 );
17
18 // Set gravity
19 this.getQuestEntityMovement().setGravity(true);
20
21 // Set destructible
22 this.setDestructible(true);
23
24 // Set the demon type, randomly-chosen
25 switch(Random.between(0, 2)){
26 case 0: this.type = DemonType.CUBE; break;
27 case 1: this.type = DemonType.EYES; break;
28 case 2: this.type = DemonType.BUBBLES; break;
29 }
30
31 // Depending on the type, resize the render area, add a collision box, and draw the ascii art, and add the weapon and its delay
32 switch(this.type){
33 case DemonType.CUBE:
34 this.getRenderArea().resize(5, 3);
35 this.getCbc().addCollisionBox(new CollisionBox(this, new Pos(0, 0), new Pos(5, 3)));
36 this.getRenderArea().drawArray(Database.getAscii("places/quests/hell/demonCube"));
37 this.setTransparency(new RenderTransparency(" ", "%"));
38 this.addQuestEntityWeapon(new QuestEntityWeapon(this.getQuest(), this, new Naming("Its huge body", "its huge body"), new CollisionBoxCollection(new CollisionBox(this, new Pos(-1, 2), new Pos(7, 2))), 50));
39 this.getLastQuestEntityWeapon().getCloseCombatDelay().setFixedDelay(10);
40 break;
41 case DemonType.EYES:
42 this.getRenderArea().resize(5, 4);
43 this.getCbc().addCollisionBox(new CollisionBox(this, new Pos(0, 1), new Pos(5, 3)));
44 this.getRenderArea().drawArray(Database.getAscii("places/quests/hell/demonEyes"));
45 this.setTransparency(new RenderTransparency(" ", "%"));
46 this.addQuestEntityWeapon(new QuestEntityWeapon(this.getQuest(), this, new Naming("Demonish eyes", "demonish eyes"), new CollisionBoxCollection(new CollisionBox(this, new Pos(-1, -1), new Pos(7, 6))), 10));
47 this.getLastQuestEntityWeapon().getCloseCombatDelay().setFixedDelay(0);
48 break;
49 case DemonType.BUBBLES:
50 this.getRenderArea().resize(5, 3);
51 this.getCbc().addCollisionBox(new CollisionBox(this, new Pos(0, 0), new Pos(5, 3)));
52 this.getRenderArea().drawArray(Database.getAscii("places/quests/hell/demonBubbles" + Random.between(0, 6).toString()));
53 this.setTransparency(new RenderTransparency(" "));
54 this.addQuestEntityWeapon(new QuestEntityWeapon(this.getQuest(), this, new Naming("Fire bubbles", "fire bubbles"), new CollisionBoxCollection(new CollisionBox(this, new Pos(-1, -1), new Pos(7, 5))), 15));
55 this.getLastQuestEntityWeapon().getCloseCombatDelay().setFixedDelay(1);
56 break;
57 }
58
59 // Set the health points, depending on the type
60 switch(this.type){
61 case DemonType.CUBE: // Cube : 120 hp
62 this.setMaxHp(120);
63 this.setHp(120);
64 break;
65 default: // Default : 30 / 40 / 50 / 60 / 70 / 80 / 90 / 100 hp

Callers

nothing calls this directly

Calls 15

setGravityMethod · 0.80
setDestructibleMethod · 0.80
addCollisionBoxMethod · 0.80
getCbcMethod · 0.80
drawArrayMethod · 0.80
getAsciiMethod · 0.80
setTransparencyMethod · 0.80
addQuestEntityWeaponMethod · 0.80
getQuestMethod · 0.80
setFixedDelayMethod · 0.80
getCloseCombatDelayMethod · 0.80

Tested by

no test coverage detected