-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameLayer.h
204 lines (153 loc) · 5.76 KB
/
GameLayer.h
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
//
// GameLayer.h
// FingerJoust
//
// Created by Hunter Francis on 7/11/13.
// Copyright 2013 Hunter Francis. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "cocos2d.h"
//#define COLOR_TOUCHAREA ccc3(223,214,195)
//#define COLOR_TOUCHAREA_B4 ccc4(223,214,195,255)
//#define COLOR_GAMEAREA ccc3(25,25,25)
//#define COLOR_GAMEAREA_B4 ccc4(25,25,25,255)
#define COLOR_TOUCHAREA ccc3(195,211,223)
#define COLOR_TOUCHAREA_B4 ccc4(195,211, 223, 255)
//tan
//#define COLOR_GAMEAREA ccc3(193,184,175)
//#define COLOR_GAMEAREA_B4 ccc4(193,184,175,255)
#define COLOR_GAMEAREA ccc3(195,185,170)
#define COLOR_GAMEAREA_B4 ccc4(195,185,170,255)
#define COLOR_GAMEBORDER ccc3(60,60,60)
#define COLOR_GAMEBORDER_B4 ccc4(60,60,60,255)
//font names
extern NSString *const MAIN_FONT;
extern NSString *const SECOND_FONT;
//player colors
#define COLOR_DISABLED ccc4(115, 115,115, 255)
#define COLOR_PLAYER_NON ccc3(155,155,155)
#define COLOR_PLAYER_NON_LIGHT ccc3(211,211,211)
#define COLOR_PLAYER_NON_B4 ccc4(155,155,155, 255)
#define COLOR_PLAYER_NON_LIGHT_B4 ccc4(211,211,211, 255)
#define COLOR_PLAYER_NON_LIGHT_F4 ccc4f(211.0/255.0,211.0/255.0,211.0/255.0, 255.0/255.0)
#define COLOR_PLAYER_ONE ccc3(195,64,64)
#define COLOR_PLAYER_ONE_LIGHT ccc3(195,64,64)
#define COLOR_PLAYER_ONE_TITLE_LIGHT ccc3(195,111,111)
#define COLOR_PLAYER_ONE_B4 ccc4(195,64,64,255)
#define COLOR_PLAYER_ONE_LIGHT_B4 ccc4(195,64,64, 255)
#define COLOR_PLAYER_ONE_LIGHT_F4 ccc4f(195.0/255.0,64.0/255.0,64.0/255.0, 255.0/255.0)
#define COLOR_PLAYER_TWO ccc3(84,175,64)
#define COLOR_PLAYER_TWO_LIGHT ccc3(84,175,64)
#define COLOR_PLAYER_TWO_TITLE_LIGHT ccc3(111,195,111)
#define COLOR_PLAYER_TWO_B4 ccc3(84,175,64 255)
#define COLOR_PLAYER_TWO_LIGHT_B4 ccc4(84,175,64, 255)
#define COLOR_PLAYER_TWO_LIGHT_F4 ccc4f(84.0/255.0,175.0/255.0,64.0/255.0, 255.0/255.0)
#define COLOR_PLAYER_THREE ccc3(84,64,175)
#define COLOR_PLAYER_THREE_LIGHT ccc3(84,64,175)
#define COLOR_PLAYER_THREE_TITLE_LIGHT ccc3(111,111,195)
#define COLOR_PLAYER_THREE_B4 ccc4(84,64,175 255)
#define COLOR_PLAYER_THREE_LIGHT_B4 ccc4(84,64,175, 255)
#define COLOR_PLAYER_THREE_LIGHT_F4 ccc4f(84.0/255.0,64.0/255.0,175.0/255.0, 255.0/255.0)
#define COLOR_PLAYER_FOUR ccc3(195,64,175)
#define COLOR_PLAYER_FOUR_LIGHT ccc3(195,64,175)
#define COLOR_PLAYER_FOUR_TITLE_LIGHT ccc3(195,111,195)
#define COLOR_PLAYER_FOUR_B4 ccc4(195,64,175,255)
#define COLOR_PLAYER_FOUR_LIGHT_B4 ccc4(195,64,175,255)
#define COLOR_PLAYER_FOUR_LIGHT_F4 ccc4f(195.0/255.0,64.0/255.0,175.0/255.0,255.0/255.0)
//#define CONTROL_OFFSET 286
//#define CONTROL_OFFSET 312
#define CONTROL_OFFSET 230
#define EXTRA_CONTROL_OFFSET 280
#define MIDDLEBAR_HEIGHT 60
#define STUN_TIME 3.0
#define ROUND_TIME 20
#define VORTEX_DISTANCE 150
#define VORTEX_LIFE 3.0
#define STUN_CONTRAINT 360
#define COLLISION_STEPS 6
#define TRANSITION_TIME 2.0
#define PLAYER_ONE_COLOR ccORANGE
#define PLAYER_TWO_COLOR ccYELLOW
#define BUTTON_CLICK @"wood_hit_wood_1.mp3"
typedef enum GameState
{
GAMEPLAY = 0,
ROUND_START = 1,
ROUND_END = 2,
GAME_OVER = 3,
GAME_START = 4,
}GameState;
@class Jouster, PowerStone, SneakyJoystick, UILayer, Player, HazardLayer;
@interface GameLayer : CCLayerColor {
UILayer *uiLayer;
HazardLayer *hazardLayer;
float gameSpeed;
NSMutableArray *jousterArray;
CCLabelTTF *blueWinsLabel;
CCLabelTTF *redWinsLabel;
//power stones display
CCLabelTTF * bluePowerStonesLabel;
CCLabelTTF * redPowerStonesLabel;
//powerstone object
PowerStone * powerStone;
//vortex array
NSMutableArray *vortexArray;
NSMutableArray *touchParticleArray;
//death clock
NSString *winner;
float deathClock;
//center sprite
CCSprite *centerSprite;
BOOL centerVisible;
//state stuff
int currentRound;
int lastWinner;
float timeBeforeNewRoundStarts;
BOOL didRedWinRound;
GameState currentState;
CCSprite *victorySprite;
CCLayerColor *whiteOverlay;
Jouster *winningJouster;
CCLabelTTF *moveLabelOne, *moveLabelTwo, *moveLabelThree, *moveLabelFour, *centerLabel;
float tempSlowTimer;
BOOL isSlowedDown;
}
@property int lastWinner;
@property (retain, nonatomic) PowerStone *powerStone;
@property (assign, nonatomic) HazardLayer *hazardLayer;
@property (assign, nonatomic) UILayer *uiLayer;
@property (retain, nonatomic) NSMutableArray *vortexArray, *jousterArray, *touchParticleArray;
-(Jouster*) getJousterWithPlayerNumber:(int) playerNumber;
-(void) spawnVortexAtPoint:(CGPoint) point;
-(Jouster*) createJouster:(int) character WithPlayer:(Player*) player;
-(void) refreshUI;
-(void) resetJousters;
//-(void) spawnPowerStone;
//-(void) spawnVortexAtPoint:(CGPoint)point;
-(void) updateTimer:(ccTime) dt;
-(void) updateVortex:(ccTime)dt;
-(void) incrementWinsForTeam:(int) team;
-(int) getWinsForTeam:(int) team;
-(void) checkClosestJousterToCenter;
-(void) checkBodyOnBodyStun:(Jouster *) jouseterA otherJouster:(Jouster *)jousterB;
//collision stuff
-(void) collisionChecks:(ccTime) dt;
-(void) powerStoneCollisionCheck;
-(BOOL) bodyOnBodyCheck:(Jouster *) jouster;
-(void) jousterOnBodyCheck;
-(BOOL) jousterOnJousterCheck;
//state stuff
-(void) gameIntro;
-(void) transitionToStartRound;
-(void) transitionToGamePlay;
-(void) transitionToEndRound;
-(void) transitionToGameOver;
-(void) activateSlow;
-(void) deactiveSlow;
//special effects
//-(void) clashEffect:(CGPoint) p1 otherPoint:(CGPoint) p2;
-(void) clashEffect:(CGPoint) p1 otherPoint:(CGPoint) p2 withMagnitude:(float) magnitude withStun:(BOOL) stun;
-(void) clashWeakEffect:(CGPoint) p1 otherPoint:(CGPoint) p2 withMagnitude:(float) magnitude withStun:(BOOL) stun;
-(void) deathEffect:(Jouster*) deadJouster;
-(CCParticleSystemQuad*) vortexEffect:(CGPoint) pt;
@end