void Start() { soundFlag = true; levelCompleted = 1; lineDemo = gameObject.GetComponent <LineDemo>(); gearsList = GameObject.FindGameObjectsWithTag("Gear"); }
void SetPermission() { foreach (GameObject gear in gearsList) { LineDemo gearLine2 = gear.GetComponent <LineDemo>(); gearLine2.lineDrawPermission = 0; } lineDrawPermission = 1; }
void CheckLevelCompletion() { lineDemo.countOutLines = 1; //to ensure that outgoing lines could not be drawn foreach (GameObject gear in gearsList) { LineDemo lineDemoChild = gear.GetComponent <LineDemo>(); if (lineDemoChild.countInLines != lineDemoChild.maxInLines || lineDemoChild.countOutLines != lineDemoChild.maxOutLines) { levelCompleted = 0; } } if (levelCompleted == 1) { if (soundFlag == true) //ensures sound is played only once and not on every update { ButtonSoundPlayer.instance.PlayLvlCompClip(); soundFlag = false; } int currentUnlockedLvl = PlayerPrefs.GetInt("LvlUnlocked"); int lvlUnlockedCount = PlayerPrefs.GetInt("LvlUnlockedCount"); string currentScene = SceneManager.GetActiveScene().name; // string []lvlUnlockedArr; List <string> lvlUnlockedArr = new List <string>(); for (int i = 0; i < lvlUnlockedCount; i++) { lvlUnlockedArr.Add(PlayerPrefs.GetString("LvlUnlockedArr" + i)); } if (lvlUnlockedArr.Contains(currentScene) == false) { // PlayerPrefs.SetInt("LvlUnlockedCount", ++lvlUnlockedCount); PlayerPrefs.SetInt("LvlUnlocked", ++currentUnlockedLvl); PlayerPrefs.SetString("LvlUnlockedArr" + lvlUnlockedCount, currentScene); PlayerPrefs.SetInt("LvlUnlockedCount", ++lvlUnlockedCount); if (currentUnlockedLvl % 20 == 0) { int currentWorldUnlocked = PlayerPrefs.GetInt("WorldUnlocked"); PlayerPrefs.SetInt("WorldUnlocked", ++currentWorldUnlocked); } } IEnumerator coroutine = LoadNextLevel(); StartCoroutine(coroutine); } }
/// <summary> /// Get a list of active lines and deactivates them. /// </summary> public void Clear() { // var activeLines = lineFactory.GetActive (); ClearLines(); SetPermission(); countOutLines = 0; int currentPos = connectingGears.IndexOf(gameObject); for (int i = connectingGears.Count - 1; i > currentPos; i--) { gearLine = connectingGears[i].GetComponent <LineDemo>(); int multipleInstanceFlag = 0; // If multi input gears connect each other in a loop for (int j = 0; j < currentPos; j++) { if (connectingGears[i] == connectingGears[j]) { multipleInstanceFlag = 1; break; } } Debug.Log(connectingGears[i] + ":multipleInstanceFlag:" + multipleInstanceFlag); if (multipleInstanceFlag == 1) { // Debug.Log(gameObject+":countOutgoingLines: "+countOutgoingLines); gearLine.countInLines--; // gearLine.countOutLines--; gearLine.ClearLinesMulti(); } else { gearLine.countOutLines = 0; gearLine.countInLines = 0; gearLine.ClearLines(); } Debug.Log("Connectgears remove at" + connectingGears[i]); connectingGears.RemoveAt(i); } if (maxInLines > 0) //To ensure that countInLines of Root gear is not set to 1 { countInLines = 1; //To ensure that multi input gears do not initialize to zero in lines. } }
void Start() { lineDemo = gameObject.GetComponent <LineDemo>(); image = gameObject.GetComponent <Image>(); }