-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlgizAllEnemies.m
107 lines (93 loc) · 3.16 KB
/
AlgizAllEnemies.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
//
// AlgizAllEnemies.m
// TEORWorldMapTest
//
// Created by Zach Babb on 7/7/11.
// Copyright 2011 InstantLazer. All rights reserved.
//
#import "AlgizAllEnemies.h"
#import "GameController.h"
#import "AbstractScene.h"
#import "AbstractBattleEnemy.h"
#import "BattleRanger.h"
#import "ParticleEmitter.h"
#import "BattleStringAnimation.h"
@implementation AlgizAllEnemies
- (void)dealloc {
if (essenceEmitter) {
[essenceEmitter release];
}
[super dealloc];
}
- (id)init
{
self = [super init];
if (self) {
BattleRanger *ranger = [sharedGameController.battleCharacters objectForKey:@"BattleRanger"];
int enemyIndex = 0;
for (AbstractBattleEnemy *enemy in sharedGameController.currentScene.activeEntities) {
if ([enemy isKindOfClass:[AbstractBattleEnemy class]]) {
if (enemy.isAlive && (RANDOM_0_TO_1() * 100) < ([ranger calculateAlgizDurationTo:enemy] * 2)) {
emitterPoints[enemyIndex] = Vector2fMake(enemy.renderPoint.x, enemy.renderPoint.y + 20);
algizDurations[enemyIndex] = [ranger calculateAlgizDurationTo:enemy];
enemyIndex++;
} else {
emitterPoints[enemyIndex] = Vector2fMake(0, 0);
algizDurations[enemyIndex] = 0;
if (enemy.isAlive) {
[BattleStringAnimation makeIneffectiveStringAt:enemy.renderPoint];
}
enemyIndex++;
}
}
}
essenceEmitter = [[ParticleEmitter alloc] initParticleEmitterWithFile:@"EssenceEmitter.pex"];
essenceEmitter.startColor = Color4fMake(0, 0, 0, 1);
essenceEmitter.gravity = Vector2fMake(0, -500);
essenceEmitter.speed = 0;
stage = 0;
duration = 1.5;
active = YES;
}
return self;
}
- (void)updateWithDelta:(float)aDelta {
if (active) {
duration -= aDelta;
if (duration < 0) {
switch (stage) {
case 0:
stage++;
int enemyIndex = 0;
for (AbstractBattleEnemy *enemy in sharedGameController.currentScene.activeEntities) {
if ([enemy isKindOfClass:[AbstractBattleEnemy class]]) {
if (algizDurations[enemyIndex] > 0) {
[enemy youWereDrauraed:(int)algizDurations[enemyIndex]];
}
enemyIndex++;
}
}
duration = 1;
break;
case 1:
stage++;
active = NO;
break;
default:
break;
}
}
for (int i = 0; i < 4; i++) {
if (emitterPoints[i].x != 0) {
essenceEmitter.sourcePosition = emitterPoints[i];
[essenceEmitter updateWithDelta:aDelta];
}
}
}
}
- (void)render {
if (active && stage == 0) {
[essenceEmitter renderParticles];
}
}
@end