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

Method draw

code/main/QuestEntityHealthBar.ts:45–66  ·  view source on GitHub ↗
(renderArea: RenderArea)

Source from the content-addressed store, hash-verified

43
44 // Public methods
45 public draw(renderArea: RenderArea): void{
46 // Draw if we should be drawn
47 if(this.shouldBeDrawn){
48 switch(this.positionType){
49 case QuestEntityHealthBarPositionType.FIXED_ON_PAGE:
50 renderArea.drawArea(this.bar, ((this.questEntity.getQuest().getRenderArea().getWidth()-100) - this.questEntity.getQuest().getGap())/2 + this.questEntity.getQuest().getRealQuestPosition().x + this.position.x + this.questEntity.getQuest().getGlobalDrawingOffset().x, this.questEntity.getQuest().getRealQuestPosition().y + this.position.y + this.questEntity.getQuest().getGlobalDrawingOffset().y, new RenderTransparency(" "));
51 break;
52 case QuestEntityHealthBarPositionType.FIXED:
53 renderArea.drawArea(this.bar, this.questEntity.getQuest().getRealQuestPosition().x + this.position.x + this.questEntity.getQuest().getGlobalDrawingOffset().x, this.questEntity.getQuest().getRealQuestPosition().y + this.position.y + this.questEntity.getQuest().getGlobalDrawingOffset().y, new RenderTransparency(" "));
54 break;
55 case QuestEntityHealthBarPositionType.RELATIVE:
56 if(this.questEntity.getQuest().getRealQuestPosition().x + this.questEntity.getGlobalPosition().x + this.position.x > 0 && // If the bar fit at the left
57 this.questEntity.getQuest().getRealQuestPosition().x + this.questEntity.getGlobalPosition().x + this.position.x + this.bar.getWidth() <= renderArea.getWidth() && // And at the right too
58 this.questEntity.getGlobalPosition().y + this.position.y > 0 && // And at the top
59 this.questEntity.getGlobalPosition().y + this.position.y <= this.questEntity.getQuest().getRealQuestSize().y // And at the bottom
60 ){
61 renderArea.drawArea(this.bar, this.questEntity.getQuest().getRealQuestPosition().x + this.questEntity.getGlobalPosition().x + this.position.x + this.questEntity.getQuest().getGlobalDrawingOffset().x, this.questEntity.getQuest().getRealQuestPosition().y + this.questEntity.getGlobalPosition().y + this.position.y + this.questEntity.getQuest().getGlobalDrawingOffset().y, new RenderTransparency(" "));
62 }
63 break;
64 }
65 }
66 }
67
68 public update(): void{
69 // If we should draw the bar even if full or it isn't full, then we set that we should draw it

Callers

nothing calls this directly

Calls 9

drawAreaMethod · 0.80
getQuestMethod · 0.80
getRealQuestPositionMethod · 0.80
getGlobalPositionMethod · 0.80
getRealQuestSizeMethod · 0.80
getWidthMethod · 0.45
getRenderAreaMethod · 0.45
getGapMethod · 0.45

Tested by

no test coverage detected