Skip to content

Commit 5c21c54

Browse files
author
Jose Medrano
committed
Code styling and beautifully code in AngryNinjas example
1 parent bf6705e commit 5c21c54

File tree

8 files changed

+65
-1048
lines changed

8 files changed

+65
-1048
lines changed

AngryNinjas/src/Common/Custom/Constants.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,27 @@ namespace AngryNinjas
44
{
55
public static class Constants
66
{
7-
87
public const int PTM_RATIO = 32;
8+
99
//depth levels
10-
1110
public const int DepthClouds = -300;
1211
public const int DepthParticles = -299;
1312
public const int DepthHills = -298;
1413
public const int DepthFloor = -290;
1514
public const int DepthScore = -285;
16-
1715
public const int DepthWhiteDots = -205;
18-
1916
public const int DepthStrapBack = -202;
2017
public const int DepthPlatform = -201;
2118
public const int DepthNinjas = -200;
2219
public const int DepthStack = -199;
23-
24-
2520
public const int DepthSlingShotFront = -179;
2621
public const int DepthStrapFront = -178;
27-
2822
public const int DepthVisualFx = 50;
2923
public const int DepthPointScore = 100;
3024

3125
//tags
32-
3326
public const int TagForWhiteDotsEvenNumberedTurn = 1000;
3427
public const int TagForWhiteDotsOddNumberedTurn = 2000;
35-
3628
}
3729

3830
//creation methods
@@ -42,25 +34,20 @@ public enum CreationMethod
4234

4335
Triangle = 1, //vector points are in the bottom left, bottom right, and top center of the image, (for example image triangleTall.png, triangleLarge.png, triangleMedium.png, triangleSmall.png )
4436
TriangleRightAngle = 2, //vector points are in the top right corner, top left corner, and bottom left corner of the source image, (for example triangleRightAngle.png )
45-
4637
Trapezoid = 3, //vector points are in the bottom left corner, bottom right corner, and 1/4 and 3/4's across the top of the image, (for example trapezoid.png )
47-
4838
DiameterOfImageForCircle = 4, //use for illustrations that are perfect circles and cropped right up to the edge of the circle on all sides. Will work with any size
4939

5040
Hexagon = 5, //any size image with a hexagon can work, scale up or down the hexagonShape.png as a template to get the location of each edge.
5141
Octagon = 6, //any size image with a octagon can work, scale up or down the octagonShape.png as a template to get the location of each edge.
5242
Pentagon = 7, //any size image with a pentagon can work, scale up or down the pentagon.png as a template to get the location of each edge.
5343

5444
Parallelogram = 8, // vector points are in the bottom left corner, and 3/4's across the bottom of the image, top right corner, and 1/4 across the top (for example parallelogram.png )
55-
5645
ShapeOfSourceImageButSlightlySmaller = 9, //defines vector shapes about 80% the size of the source (still a square or rectangle just slightly smaller) . Good for Enemies.
57-
5846
CustomCoordinates1 = 101, //use your own custom coordinates from a program like Vertex Helper Pro
5947
CustomCoordinates2 = 102, //use your own custom coordinates from a program like Vertex Helper Pro
6048
CustomCoordinates3 = 103 //use your own custom coordinates from a program like Vertex Helper Pro
6149

6250
//remember when defining custom coordinates, the vec points much be defined in counter clockwise order, 8 points at most, and make a convex shape (i.e. every point must be able to touch every other point)
63-
6451
}
6552

6653
// Break Effects
Lines changed: 5 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
32
using CocosDenshion;
43
using CocosSharp;
54

@@ -10,13 +9,11 @@ public class GameSounds : CCNode
109
bool soundFXTurnedOff;
1110
bool voiceFXTurnedOff;
1211
bool ambientFXTurnedOff; //ambient or background music
13-
1412
string delayedSoundName;
15-
13+
1614
AmbientFXSounds musicChoice;
1715

1816
const string soundsFolder = "Sounds";
19-
2017
static GameSounds sharedGameSounds;
2118

2219
private GameSounds()
@@ -35,16 +32,13 @@ public static GameSounds SharedGameSounds
3532
get
3633
{
3734
if (sharedGameSounds == null)
38-
{
3935
sharedGameSounds = new GameSounds();
40-
}
4136
return sharedGameSounds;
4237
}
4338
}
4439

4540
public void PreloadSounds()
4641
{
47-
4842
CCSimpleAudioEngine.SharedEngine.PreloadEffect(FormatSoundFilePath("grunt1"));
4943
CCSimpleAudioEngine.SharedEngine.PreloadEffect(FormatSoundFilePath("grunt2"));
5044
CCSimpleAudioEngine.SharedEngine.PreloadEffect(FormatSoundFilePath("grunt3"));
@@ -69,13 +63,9 @@ string FormatSoundFilePath(string sound)
6963
{
7064
string sndfile = System.IO.Path.Combine(soundsFolder, sound);
7165
if (sndfile.IndexOf(".mp3") > -1)
72-
{
7366
sndfile = sndfile.Substring(0, sndfile.IndexOf(".mp3"));
74-
}
7567
else if (sndfile.IndexOf(".wav") > -1)
76-
{
7768
sndfile = sndfile.Substring(0, sndfile.IndexOf(".wav"));
78-
}
7969
return (sndfile);
8070
}
8171

@@ -93,97 +83,50 @@ public bool AreVoiceFXMuted
9383

9484
public void PlaySoundFX(string fileToPlay)
9585
{
96-
9786
if (!soundFXTurnedOff)
98-
{
99-
10087
CCSimpleAudioEngine.SharedEngine.PlayEffect(FormatSoundFilePath(fileToPlay));
101-
102-
}
103-
10488
}
10589

10690
public void PlayVoiceSoundFX(string fileToPlay)
10791
{
108-
10992
if (!voiceFXTurnedOff)
110-
{
111-
11293
CCSimpleAudioEngine.SharedEngine.PlayEffect(FormatSoundFilePath(fileToPlay));
113-
114-
115-
}
116-
11794
}
11895

11996
public void PlaySoundFXWithDelay(string fileToPlay, float theDelay)
12097
{
121-
12298
if (!soundFXTurnedOff)
12399
{
124-
125100
delayedSoundName = fileToPlay;
126101
ScheduleOnce(PlayThisAfterDelay, theDelay);
127-
128-
129102
}
130-
131103
}
132104

133-
134105
public void PlayVoiceSoundFXWithDelay(string fileToPlay, float theDelay)
135106
{
136-
137-
138-
139107
if (!voiceFXTurnedOff)
140108
{
141-
142109
delayedSoundName = fileToPlay;
143-
144110
ScheduleOnce(PlayThisAfterDelay, theDelay);
145-
146111
}
147-
148112
}
149113

150114
public void PlayThisAfterDelay(float delay)
151115
{
152-
153116
CCSimpleAudioEngine.SharedEngine.PlayEffect(FormatSoundFilePath(delayedSoundName));
154-
155-
156117
}
157118

158-
159-
160-
161-
162119
public void IntroTag()
163120
{
164-
165121
if (!soundFXTurnedOff)
166-
{
167-
168122
CCSimpleAudioEngine.SharedEngine.PlayEffect(FormatSoundFilePath("gong"));
169-
170-
}
171-
172-
173123
}
174124

175-
176125
public void PlayStackImpactSound()
177126
{
178-
179-
180127
if (!soundFXTurnedOff)
181128
{
182-
183-
184129
int randomNum = CCRandom.Next(0, 4); //0 to 4
185-
186-
187130
switch (randomNum)
188131
{
189132
case 0:
@@ -201,28 +144,16 @@ public void PlayStackImpactSound()
201144
case 4:
202145
CCSimpleAudioEngine.SharedEngine.PlayEffect(FormatSoundFilePath("impact5"));
203146
break;
204-
205-
206-
207147
}
208-
209148
}
210-
211-
212149
}
213150

214-
215151
public void PlayBreakSound()
216152
{
217-
218-
219153
if (!soundFXTurnedOff)
220154
{
221-
222-
223155
int randomNum = CCRandom.Next(0, 2); //0 to 2
224-
225-
156+
226157
switch (randomNum)
227158
{
228159
case 0:
@@ -234,37 +165,19 @@ public void PlayBreakSound()
234165
case 2:
235166
CCSimpleAudioEngine.SharedEngine.PlayEffect(FormatSoundFilePath("break3"));
236167
break;
237-
238-
239168
}
240-
241169
}
242-
243-
244170
}
245171

246-
247-
248-
249172
public void ReleaseSlingSounds()
250173
{
251-
252-
253174
if (!soundFXTurnedOff)
254-
{
255-
256175
CCSimpleAudioEngine.SharedEngine.PlayEffect(FormatSoundFilePath("whoosh"));
257176

258-
}
259-
260-
261177
if (!voiceFXTurnedOff)
262178
{
263-
264-
265179
int randomNum = CCRandom.Next(0, 7); //0 to 7
266-
267-
180+
268181
switch (randomNum)
269182
{
270183
case 0:
@@ -291,63 +204,36 @@ public void ReleaseSlingSounds()
291204
case 7:
292205
CCSimpleAudioEngine.SharedEngine.PlayEffect(FormatSoundFilePath("grunt8"));
293206
break;
294-
295-
296207
}
297-
298208
}
299-
300-
301209
}
302210

303-
304211
public void PlayBackgroundMusic(AmbientFXSounds track)
305-
{ //or AMBIENT SOUND FX
306-
212+
{
213+
//or AMBIENT SOUND FX
307214
musicChoice = track;
308-
309215
CCSimpleAudioEngine.SharedEngine.StopBackgroundMusic();
310216

311217
if (!ambientFXTurnedOff)
312218
{
313-
314219
if (musicChoice == AmbientFXSounds.Frogs)
315-
{
316220
CCSimpleAudioEngine.SharedEngine.PlayBackgroundMusic(FormatSoundFilePath("birds"), true);
317-
}
318221
else if (musicChoice == AmbientFXSounds.Insects)
319-
{
320222
CCSimpleAudioEngine.SharedEngine.PlayBackgroundMusic(FormatSoundFilePath("frogs"), true);
321-
}
322-
323223
}
324-
325-
326224
}
327225

328-
329226
public void StopBackgroundMusic()
330227
{
331-
332-
333228
CCSimpleAudioEngine.SharedEngine.StopBackgroundMusic();
334-
335229
ambientFXTurnedOff = true;
336-
337-
338-
339230
}
340231

341232
public void RestartBackgroundMusic()
342233
{
343-
344234
ambientFXTurnedOff = false;
345235
PlayBackgroundMusic(musicChoice);
346236
}
347-
348-
349-
350-
351237
}
352238
}
353239

0 commit comments

Comments
 (0)