-
Notifications
You must be signed in to change notification settings - Fork 0
/
S_LevelThreeState.as
105 lines (88 loc) · 2.89 KB
/
S_LevelThreeState.as
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
package
{
import flash.display.MovieClip;
import flash.geom.Matrix;
import flash.geom.*;
import flash.utils.*;
public class S_LevelThreeState extends GameState
{
override public function S_LevelThreeState(documentClass)
{
refToDocClass = documentClass;
//Initialise the player
player = new Player(40, 40, this);
//Initialise Hitler
hitler = new Hitler(40, 40, this);
hud = new HUD(this);
enemies.push(new Enemy(this, hitler));
enemies.push(new Enemy(this, hitler));
enemies.push(new Enemy(this, hitler));
muteSoundButton = new GUIButton(refToDocClass, "MUTE_SOUNDS", new ButtonSound());
muteSoundButton.x = 727.8;
muteSoundButton.startX = 727.8;
muteSoundButton.y = 14.6;
muteMusicButton = new GUIButton(refToDocClass, "MUTE_MUSIC", new ButtonMusic());
muteMusicButton.x = 662.8;
muteMusicButton.startX = 662.8;
muteMusicButton.y = 14.6;
}
override public function endLevel()
{
//Before we transition away from this state, flush the scores to the Config class so they can be retrieved
Config.getScore(enemiesKilled, levelTime, hitler.health, 3);
//Tell the document class to transition to the next state
refToDocClass.changeStateTo(refToDocClass.s_EndLevel, 3);
}
public function restartLevel()
{
Config.getScore(0,0,0, 3);
refToDocClass.changeStateTo(refToDocClass.s_LevelThree);
}
//Move through each of the sections on the XML file and push a new instance of what is found into the respective array
override public function buildFromXML()
{
var item:XML;
for each(item in refToDocClass.xmlManager.xmlFile.level_3.midground.object)
{
create(item, midgroundArray);
}
//stopping point
for each(item in refToDocClass.xmlManager.xmlFile.level_3.stop_point.object)
{
create(item, stoppingPointArray);
}
//CollisionBoundingBox
for each(item in refToDocClass.xmlManager.xmlFile.level_3.collision.object)
{
barrierArray.push(new Barrier(item.@x, item.@y, item.@width, item.@height))
}
//JumpTrigger
for each(item in refToDocClass.xmlManager.xmlFile.level_3.jump_trigger.object)
{
jumpTriggerArray.push(new JumpTrigger(item.@x, item.@y, item.@width, item.@height))
}
//foreground
for each(item in refToDocClass.xmlManager.xmlFile.level_3.foreground.object)
{
create(item, foregroundArray);
}
//static foreground
for each(item in refToDocClass.xmlManager.xmlFile.level_3.static_foreground.object)
{
create(item, staticForegroundArray);
}
//static background
for each(item in refToDocClass.xmlManager.xmlFile.level_3.static_background.object)
{
create(item, staticBackgroundArray);
}
//background
for each(item in refToDocClass.xmlManager.xmlFile.level_3.background.object)
{
create(item, backgroundArray);
}
addToStage();
addChild(muteSoundButton);
}
}
}