-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAustrinAllEnemies.m
123 lines (110 loc) · 3.67 KB
/
AustrinAllEnemies.m
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
//
// AustrinAllEnemies.m
// TEORWorldMapTest
//
// Created by Zach Babb on 6/23/11.
// Copyright 2011 InstantLazer. All rights reserved.
//
#import "AustrinAllEnemies.h"
#import "GameController.h"
#import "AbstractScene.h"
#import "AbstractBattleEnemy.h"
#import "BattleRoderick.h"
#import "ParticleEmitter.h"
#import "WorldFlashColor.h"
#import "FadeInOrOut.h"
@implementation AustrinAllEnemies
- (void)dealloc {
if (rainEmitter) {
[rainEmitter release];
}
[super dealloc];
}
- (id)init
{
self = [super init];
if (self) {
BattleRoderick *roderick = [sharedGameController.battleCharacters objectForKey:@"BattleRoderick"];
int damageIndex = 0;
for (AbstractBattleEnemy *enemy in sharedGameController.currentScene.activeEntities) {
if ([enemy isKindOfClass:[AbstractBattleEnemy class]]) {
damage[damageIndex] = [roderick calculateAustrinDamageTo:enemy];
damageIndex++;
enemy.skyAffinity -= (1 + ((roderick.level + roderick.levelModifier + roderick.skyAffinity - enemy.skyAffinity) / 10));
enemy.skyAffinity = MAX(1, enemy.skyAffinity);
}
}
rainEmitter = [[ParticleEmitter alloc] initParticleEmitterWithFile:@"RainEmitter.pex"];
dimWorld = [[FadeInOrOut alloc] initFadeOutToAlpha:0.3 withDuration:1];
stage = 0;
duration = 1;
active = YES;
}
return self;
}
- (void)updateWithDelta:(float)aDelta {
if (active) {
duration -= aDelta;
if (duration < 0) {
switch (stage) {
case 0:
stage++;
duration = 0.5;
break;
case 1:
stage++;
duration = 0.8;
WorldFlashColor *wfc = [[WorldFlashColor alloc] initColorFlashWithColor:Color4fMake(0.9, 0.9, 0, 0.3)];
[sharedGameController.currentScene addObjectToActiveObjects:wfc];
[wfc release];
break;
case 2:
stage++;
duration = 0.3;
WorldFlashColor *wfc2 = [[WorldFlashColor alloc] initColorFlashWithColor:Color4fMake(0.9, 0.9, 0, 0.3)];
[sharedGameController.currentScene addObjectToActiveObjects:wfc2];
[wfc2 release];
break;
case 3:
stage++;
duration = 1;
int damageIndex = 0;
for (AbstractBattleEnemy *enemy in sharedGameController.currentScene.activeEntities) {
if ([enemy isKindOfClass:[AbstractBattleEnemy class]]) {
[enemy youTookDamage:damage[damageIndex]];
damageIndex++;
}
}
break;
case 4:
stage++;
active = NO;
break;
default:
break;
}
}
switch (stage) {
case 0:
[dimWorld updateWithDelta:aDelta];
break;
case 1:
[rainEmitter updateWithDelta:aDelta];
break;
case 2:
[rainEmitter updateWithDelta:aDelta];
break;
case 3:
[rainEmitter updateWithDelta:aDelta];
default:
break;
}
}
}
- (void)render {
if (active && stage < 4) {
[dimWorld render];
[rainEmitter renderParticles];
}
}
@end