-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAustrinSingleCharacter.m
More file actions
96 lines (79 loc) · 2.49 KB
/
AustrinSingleCharacter.m
File metadata and controls
96 lines (79 loc) · 2.49 KB
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
//
// AustrinSingleCharacter.m
// TEORWorldMapTest
//
// Created by Zach Babb on 6/23/11.
// Copyright 2011 InstantLazer. All rights reserved.
//
#import "AustrinSingleCharacter.h"
#import "GameController.h"
#import "AbstractBattleCharacter.h"
#import "BattleRoderick.h"
#import "ParticleEmitter.h"
@implementation AustrinSingleCharacter
- (void)dealloc {
if (raiseStatsEmitter) {
[raiseStatsEmitter release];
}
[super dealloc];
}
- (id)initToCharacter:(AbstractBattleCharacter *)aCharacter {
if (self = [super init]) {
BattleRoderick *roderick = [sharedGameController.battleCharacters objectForKey:@"BattleRoderick"];
originator = roderick;
target1 = aCharacter;
[self calculateEffectFrom:originator to:target1];
raiseStatsEmitter = [[ParticleEmitter alloc] initParticleEmitterWithFile:@"PowerIncreasedEmitterTextureNotEmbedded.pex"];
raiseStatsEmitter.sourcePosition = Vector2fMake(target1.renderPoint.x, target1.renderPoint.y - 40);
raiseStatsEmitter.active = YES;
raiseStatsEmitter.duration = 0.6;
raiseStatsEmitter.startColor = Color4fMake(1, 0, 0, 1);
austrinDuration = [roderick calculateAustrinCharacterDurationTo:aCharacter];
stage = 0;
active = YES;
duration = 0.7;
}
return self;
}
- (void)updateWithDelta:(float)aDelta {
duration -= aDelta;
if (duration < 0) {
switch (stage) {
case 0:
stage = 1;
duration = austrinDuration;
break;
case 1:
stage++;
[target1 decreasePowerModifierBy:powerMod];
[target1 decreaseAffinityModifierBy:affinityMod];
active = NO;
break;
default:
break;
}
}
if (active && stage == 0) {
if (raiseStatsEmitter.startColor.red == 1) {
raiseStatsEmitter.startColor = Color4fMake(0, 0.4, 0.6, 1);
} else {
raiseStatsEmitter.startColor = Color4fMake(1, 0, 0, 1);
}
[raiseStatsEmitter updateWithDelta:aDelta];
}
}
- (void)render {
if (active && stage == 0) {
[raiseStatsEmitter renderParticles];
}
}
- (void)calculateEffectFrom:(AbstractBattleEntity *)aOriginator to:(AbstractBattleEntity *)aTarget {
float power = (originator.power + originator.skyAffinity) * (originator.essence / originator.maxEssence);
[target1 increasePowerModifierBy:(int)(power / 2)];
[target1 increaseAffinityModifierBy:(int)(power / 2)];
[target1 flashColor:Color4fMake(1, 0, 0, 1)];
powerMod = (int)(power / 2);
affinityMod = (int)(power / 2);
//NSLog(@"power is: %f", power);
}
@end