-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAtticScene.pde
138 lines (103 loc) · 4.43 KB
/
AtticScene.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
class AtticScene extends SceneWithTransition implements IHasHiddenLayer, IWaiter {
ImageButton backButton = new ImageButton( "arrowDown.png", round(825 * widthRatio), round(997 * heightRatio), "arrowDown outline.png" );
ImageButton notesPlaceButton = new ImageButton( null, round(579 * widthRatio), round(572 * heightRatio), "Attic notes overlay.png");
UISprite atticNote = new UISprite(579, 572, "Sam_bedroom under bed note sprite.png");
TextBoxWithFader placeText = new TextBoxWithFader("It's too dark, I remember to have a flashlight\r\nin the garage", false);
boolean flashLightInScene = true;
boolean batteriesInScene = true;
PImage hiddenImage;
PImage hiddenImageWithoutNote;
boolean playerHasFlashWithBatteries;
boolean noteInScene = true;
HiddenCollider[] hiddenColliders = new HiddenCollider[] {
new HiddenCollider(this, "5", 1428, 257, 242, 257),
new HiddenCollider(this, "images", 282, 38, 1065, 565),
};
AtticScene() {
super("Attic.png");
hiddenImage = loadImage("Attic hidden.png");
hiddenImage.resize(round(hiddenImage.width * widthRatio), round(hiddenImage.height * heightRatio));
hiddenImageWithoutNote = loadImage("Attic hidden 2 - without note.png");
hiddenImageWithoutNote.resize(round(hiddenImageWithoutNote.width * widthRatio), round(hiddenImageWithoutNote.height * heightRatio));
atticNote.enabled = false;
}
void enterState(State oldState) {
super.enterState(oldState);
boolean playerHasFlashLight = invManager.hasItem("flashlight_item");
boolean playerHasBatteries = invManager.hasItem("batteries_item");
playerHasFlashWithBatteries = invManager.hasItem("flashlight_batteries_item");
if (playerHasFlashWithBatteries == true) {
placeText.textBox.setText("Now I can the flashlight.");
} else if (playerHasFlashLight == false) {
} else if (playerHasFlashLight == true && playerHasBatteries == false) {
placeText.textBox.setText("I have a flashlight but where are the batteries?\r\nMaybe in the garage too.");
} else if (playerHasFlashLight == false && playerHasBatteries == true) {
placeText.textBox.setText("I have some batteries but where is the flashlight?\r\nMaybe in the garage too.");
} else if (playerHasFlashLight && playerHasBatteries) {
placeText.textBox.setText("I forgot to insert the batteries or do I missing something else?");
}
placeText.show();
waiter.waitForSeconds(5, this, 0, null);
}
void checkMessages() {
}
public void doStepWhileInState(float delta)
{
super.doStepWhileInState(delta);
rectMode(CORNER);
noStroke();
float blackAlpha = 0.975 * 255; //to set alpha of image and filler rects
if (usableItemManager.usablesMap.containsKey("flashlight_batteries_item") && usableItemManager.usablesMap.get("flashlight_batteries_item").enabled) {
if (noteInScene == true) {
atticNote.display(delta);
notesPlaceButton.display();
}
} else {
fill(1, 1, 1, blackAlpha);
rect(0, 0, width, height);
}
backButton.display();
placeText.display();
super.TransitionDisplay(delta);
}
void handleMousePressed() {
if ( backButton.isPointInside( mouseX, mouseY ) ) {
changeState(HALLWAY2_ATTIC_SCENE);
}
if (noteInScene == true && notesPlaceButton.isPointInside( mouseX, mouseY ) ) {
noteInScene = false;
//Reassing hidden image to image without the note ans reload
hiddenImage = hiddenImageWithoutNote;
invManager.checkAndEnableHiddenImageForFlashLight(this);
atticNote.enabled = true;
invManager.PickUpItem("notes_item", new Object[] { "notes_item page 4" }, atticNote);
}
}
void execute(int executeId, Object obj) {
if (executeId == 0) {
println("Anis", Ani.size() );
placeText.hide();
}
}
void changeState(State state) {
stateHandler.changeStateTo( state );
soundManager.FOOT_STEPS.play();
if (placeText.alpha > 0)
placeText.hide();
}
PImage getHiddenImage() {
return hiddenImage;
}
HiddenCollider[] getHiddenColliders() {
return hiddenColliders;
}
void hiddenColliderHit(HiddenCollider hc) {
hc.enabled = false; //allways disable the collider stop the collision detection
if (hc.name.equals("5")) {
textManager.showText("Five what? What does this mean?!?", 3);
} else if (hc.name.equals("images")) {
soundManager.ATTIC_MUSIC.play();
textManager.showText("What are those marks?", 3);
}
}
}