-
Notifications
You must be signed in to change notification settings - Fork 0
/
RockLevelMovementChecker.cs
executable file
·167 lines (147 loc) · 6.7 KB
/
RockLevelMovementChecker.cs
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
using UnityEngine;
using System.Collections;
public class RockLevelMovementChecker : MonoBehaviour {
bool gridStatic, fifthSlideGone, gameStarted, startLaunchingStars, launchBombs, artilleryLaunched, tutorialLevel, collectingDone;
RockLevelController rockLevelController;
RockLevelCheckForMatches checkForMatches;
RockLevelInstantiator instantiator;
RockLevelJewelMovement jewelMovement;
RockLevelBombHandler bombHandler;
RockLevelStarShooter starShooter;
// LevelThreeBombRemainderController remainderController;
// LevelThreeTutorialShadeController shadeController;
RockLevelTouchHandler touchHandler;
RockLevelFourInARow fourInARow;
RockLevelFiveInARow fiveInARow;
RockLevelCorners corners;
RockLevelNoMatchChecker noMatchChecker;
RockLevelShuffleGameBoard shuffle;
RockLevelDeleteJewels deleteJewels;
SoundController soundController;
public GameObject levelCompleteShade;
GameObject instantiatedShade;
// Use this for initialization
void Start () {
rockLevelController = gameObject.GetComponent<RockLevelController> ();
instantiator = gameObject.GetComponent<RockLevelInstantiator> ();
checkForMatches = rockLevelController.GetComponent<RockLevelCheckForMatches> ();
instantiator = rockLevelController.GetComponent<RockLevelInstantiator> ();
bombHandler = rockLevelController.GetComponent<RockLevelBombHandler> ();
starShooter = gameObject.GetComponent<RockLevelStarShooter> ();
// remainderController = levelThreeController.GetComponent<LevelThreeBombRemainderController> ();
touchHandler = rockLevelController.GetComponent<RockLevelTouchHandler> ();
fourInARow = gameObject.GetComponent<RockLevelFourInARow> ();
fiveInARow = gameObject.GetComponent<RockLevelFiveInARow> ();
corners = gameObject.GetComponent<RockLevelCorners> ();
noMatchChecker = gameObject.GetComponent<RockLevelNoMatchChecker> ();
shuffle = gameObject.GetComponent<RockLevelShuffleGameBoard> ();
soundController = gameObject.GetComponent<SoundController> ();
deleteJewels = gameObject.GetComponent<RockLevelDeleteJewels> ();
if (GameObject.Find ("Mountain Level One ID") != null)
tutorialLevel = true;
}
public void CheckGridForMovement () {
gridStatic = false;
if (GameObject.Find ("Time Bomb Identification") != null) {
if (GameObject.Find ("Time Bomb Identification").GetComponent<TimeBombController> ().GetBombsExploding ()) {
return;
}
}
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
if (instantiator.GetJewelGridGameObject (i, j) == null)
return;
jewelMovement = instantiator.GetJewelGridGameObject (i, j).GetComponent<RockLevelJewelMovement> ();
if (PaidPowerTracker.GetPowerListSize () != 0 /*|| starShooter.GetBombCount () > 0 || fourInARow.GetHomingStarList ().Count > 0 || fiveInARow.GetMotherStarList ().Count > 0 || fiveInARow.GetMotherStarList ().Count > 0 || corners.GetCornerStarList ().Count > 0*/) {
gridStatic = false;
deleteJewels.PunchNewTimeStamp ();
return;
}
}
}
if (!shuffle.GetShuffleFinished ()) {
shuffle.SetShuffleFinished (true);
}
if (noMatchChecker.CheckForNoMatches ()) {
gridStatic = false;
deleteJewels.PunchNewTimeStamp ();
return;
}
if (!soundController.GetGameStarted ()) {
soundController.SetGameStarted (true);
}
CheckEveryJewelForMatch ();
gridStatic = true;
PowerStarTracker.Clear ();
}
void CheckEveryJewelForMatch () {
//Debug.Log ("gridStatic = true");
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
if (gameStarted) {
GameObject tempObject = instantiator.GetJewelGridGameObject (i, j);
if (checkForMatches.CheckForSwapBack (tempObject, i , j)) {
gridStatic = false;
deleteJewels.PunchNewTimeStamp ();
// CheckGridForMovement ();
return;
}
// tempObject.GetComponent<Rigidbody2D> ().isKinematic = false;
tempObject.GetComponent<RockLevelJewelMovement> ().SetMoving (false);
tempObject.GetComponent<RockLevelJewelMovement> ().SetNotToBeDestroyed ();
}
}
}
bombHandler.ZeroBombsStillExist ();
if (!bombHandler.BombIsExploded () && !touchHandler.GetGameStarted ()) {
touchHandler.SetGameStarted (true);
}
// if (tutorialLevel && GameObject.Find ("No Extras Shade").GetComponent<LevelOneShadeController> ().GetOwlieNumber () == 1 && bombHandler.GetBombCount () > 0) {
// GameObject.Find ("No Extras Shade").GetComponent<LevelOneShadeController> ().DarkenShade ();
// }
if (GameObject.Find ("Jewel Collection Level ID") == null && !startLaunchingStars && bombHandler.GetBombListCount () == 0) {
startLaunchingStars = true;
touchHandler.SetGameStarted (false);
starShooter.SetStartLaunchingStars (true);
} else if (GameObject.Find ("Jewel Collection Level ID") != null && collectingDone && !GameObject.Find ("Jewel Collector").GetComponent<EndOfLevelCollectionJewelShooter> ().GetStartSpray ()) {
GameObject.Find ("Jewel Collector").GetComponent<EndOfLevelCollectionJewelShooter> ().StartJewelSpray ();
} /*else if (GameObject.Find ("Jewel Collection Level ID") != null && collectingDone && GameObject.Find ("Jewel Collector").GetComponent<EndOfLevelCollectionJewelShooter> ().GetStartSpray () &&
GameObject.Find ("Jewel Collector").GetComponent<JewelCollectorController> ().GetTotalJewelCollectionGoalNumber () <= 0) {
// GameObject instantiatedShade = (GameObject)Instantiate (levelCompleteShade);
// instantiatedShade.GetComponent<DarkenOnInstantiaton> ().SetLevelComplete(true);
GameObject.Find ("Jewel Collector").GetComponent<MoveNumberHandler> ().StartLaunchingRowDestructionStars ();
}
*/
else if (GameObject.Find ("Jewel Collection Level ID") != null && !collectingDone && GameObject.Find ("Jewel Collector").GetComponent<MoveNumberHandler> ().GetMoveNumber () == 0) {
GameObject instantiatedShade = (GameObject)Instantiate (levelCompleteShade);
instantiatedShade.GetComponent<DarkenOnInstantiaton> ().SetLevelComplete (false);
}
if (GameObject.Find ("Jewel Collector") != null && GameObject.Find ("Jewel Collector").GetComponent<MoveNumberHandler> ().GetFinishedLaunching ()) {
GameObject instantiatedShade = (GameObject)Instantiate (levelCompleteShade);
instantiatedShade.GetComponent<DarkenOnInstantiaton> ().SetLevelComplete (true);
}
if (!launchBombs && bombHandler.TimeBombIsExploded ()) {
launchBombs = true;
touchHandler.SetGameStarted (false);
bombHandler.LaunchArtillery ();
}
if (gameStarted == false) {
gameStarted = true;
}
}
public bool GetGridStatic () {
return gridStatic;
}
public void SetGridStaticToFalse () {
gridStatic = false;
}
public void SetFifthSlideGoneTrue () {
fifthSlideGone = true;
}
public bool GetGameStarted () {
return gameStarted;
}
public void SetCollectingDone () {
collectingDone = true;
}
}