void Update() { // Check if birds was trown, if it died and swap them when needed // ManageBirds(); //if(Input.GetKey(KeyCode.Space)) //{ //} //Evaluate Subsets if (!LevelSimulator.generateLevel) { if (!PreLevelCheck) { LevelShaking(); if (IsLevelStable()) { if (CurrentLevel.levelShaking) { NextLevel(); } PreLevelCheck = true; // CurrentLevel = _levelLoader.EncodeLevel (); SymmetricalLevel = _levelLoader.EncodeSymmetricalLevel(); } } else { if (!HorizontalEvaluationStart) { CurrentLevel.horizontal = true; SymmetricalLevel.horizontal = true; SubsetSimulationHorizontal(); } else { CurrentLevel.horizontal = false; SymmetricalLevel.horizontal = false; SubsetSimulationVertical(); } //check useful levels CheckUseful(_blocksTransform); } } else //Generate Levels { CheckOverlap(); if (initiate) { trajectory = new List <ObjTrack> (); ShootInitiator(); AdaptCameraWidthToLevel(); } else if (!IsLevelStable()) { RecordTrajectory(); } // else (!initiate && IsLevelStable ()) { else { // DeleteStaticSubsetFromList (); SaveCurrentLevel(); int levelID = UnityEngine.Random.Range(0, LevelList.Instance.GetAllLevel().Length); if (trajectory.Count == 0) { LevelList.Instance.CurrentIndex = UnityEngine.Random.Range(0, levelID); ABSceneManager.Instance.LoadScene(SceneManager.GetActiveScene().name); subsetList = new List <SubsetInfo> (); print("Finding different initial subset..."); return; } Vector2 subsetPos = trajectory [UnityEngine.Random.Range(trajectory.Count / 2, trajectory.Count)].pos; ABLevel lvl = LevelList.Instance.GetLevel(levelID); AddSubsetIntoList(levelID, lvl, subsetPos); initiate = true; initx(); // mapChanges.Add (trans.GetInstanceID (), new MapChanges { // lastPosition = trans.position, // distanceObjectMoved = 0f, // timeObjectMoved = 0f // }); } } }
void Update() { // Check if birds was trown, if it died and swap them when needed //if(Input.GetKey(KeyCode.Space)) //{ //} //Evaluate Subsets if (LevelSimulator.generateLevel) // is generate level { if (!isShootTriggerPoint) // shoot trigger point { print("isShootTriggerPoint: "); if (!isShootHorizontalTriggerPoint) { ShootHorizontalTriggerPoint(); } else if (!isShootVerticalTriggerPoint) { ShootVerticalTriggerPoint(); } RecordEveryNFrames(10); } else { //print("else isShootTriggerPoint: "); if (!isGenerateSubset) { // isn't generate subset print("Will Generate"); initx(); randomLevel = UnityEngine.Random.Range(0, LevelList.Instance.GetAllLevel().Length); //Debug.Log("randomLevel " + randomLevel); for (int i = 0; i < positionSubsets.Count; i++) { // generate old subset GenerateSubset(positionSubsets[i], levelSubsets[i]); } tempPosition = UnityEngine.Random.Range(positions.Count / 2, positions.Count); print("GENERATE X: " + positions[tempPosition].x); GenerateSubset(positions[tempPosition], randomLevel); // generate new subset // CurrentLevel.countTNT++; AdaptCameraWidthToLevel(); isGenerateSubset = true; isShootTriggerPoint = true; } if (isGenerateSubset) { // Generate subset loopLimit++; //print("Loop: "+loopLimit); if (subsetCount > 1) { if (loopLimit == 250) { print("subsetCount " + subsetCount); print("Next Level"); SavegenerateLevel(); isShootTriggerPoint = false; loopLimit = 0; } } else { // count subset isn't 5 //if (loopLimit == 100) { // print("TEST: " + SubsetSimulationNumber); // currentLevel.isTestTriggerPoint = true; // if (SubsetSimulationNumber == 0) // Simulate again // { // TestHorizontalTriggerPoint(); // } // if (SubsetSimulationNumber == 1) // { // TestVerticalTriggerPoint(); // } // print("FINISH TEST"); //} //if (currentLevel.isTNTExplode) if (loopLimit == 100) { // TNT explode print("TNT Explode "); positionSubsets.Add(positions[tempPosition]); levelSubsets.Add(randomLevel); subsetCount++; positions.Clear(); // CurrentLevel.isTNTExplode = false; isShootHorizontalTriggerPoint = false; isShootVerticalTriggerPoint = false; isShootTriggerPoint = false; // CurrentLevel.isTestTriggerPoint = false; CurrentLevel.usefulLevel = false; isGenerateSubset = false; loopLimit = 0; } //else if (loopLimit == 500 && !currentLevel.isTNTExplode) //{ // TNT not explode // print(loopLimit + " Not Explode"); // ABTNT.ResetCountExplode(); // currentLevel.countTNT--; // if (countNotExplode > 5) // { // countNotExplode = 0; // isShootTriggerPoint = false; // NextLevel(); // } // if (isGenerateFirstGround) // { // for (int i = 0; i < positions.Count; i++) // { // if (positions[i].y == -3.8f) // { // print("-3.888888ffffff"); // if (i == 0) // { // print("ONE"); // isGenerateFirstGround = false; // maxGroundSubset--; // } // else if (i == 1) // { // print("TWO"); // isGeneratesecondGround = false; // maxGroundSubset--; // } // } // } // isGenerateSubset = false; // loopLimit = 0; // countNotExplode++; // positions.Clear(); // isShootTriggerPoint = false; // currentLevel.isTestTriggerPoint = false; // CurrentLevel.usefulLevel = false; // } //} } //if (isSaveLevel) //{ // Next level // isShootTriggerPoint = false; // isSaveLevel = false; // print("Next Level"); // SavegenerateLevel(); //} } } } //Evaluate Subsets else { ManageBirds(); if (!PreLevelCheck) { LevelShaking(); if (IsLevelStable()) { if (CurrentLevel.levelShaking) { NextLevel(); } PreLevelCheck = true; CurrentLevel = levelLoader.EncodeLevel(); SymmetricalLevel = levelLoader.EncodeSymmetricalLevel(); } } else { if (!horizontalEvaluationStart) { SubsetSimulationHorizontal(); } else { SubsetSimulationVertical(); } //check useful levels CheckUseful(_blocksTransform); } } }