/// <summary> /// Transition for the level when start new level or repeat current level /// </summary> /// <returns></returns> public IEnumerator LevelTransition(LevelPatterns newLevelData) { canPlayerMove = false; float duration = 0.75f; if (!GameProcess.firstStart) // If the game just start then only fade out { // Fade in screen for (float t = 0; t < duration; t += Time.deltaTime) { Color newColor = levelFader.color; newColor.a = t / duration; levelFader.color = newColor; yield return(null); } Color fullColor = levelFader.color; fullColor.a = 1; levelFader.color = fullColor; } else { GameProcess.firstStart = false; } StartNewLevel(newLevelData); // Fade out screen for (float t = 0; t < duration; t += Time.deltaTime) { Color newColor = levelFader.color; newColor.a = (duration - t) / duration; levelFader.color = newColor; yield return(null); } Color noColor = levelFader.color; noColor.a = 0; levelFader.color = noColor; canPlayerMove = true; }
public void StartNewLevel(LevelPatterns newLevelData) { // Change level texts GameProcess.instance.levelNameText.text = GameProcess.instance.allLevelNames[GameProcess.instance.currentLevelIndex]; GameProcess.instance.levelFlavorText.text = GameProcess.instance.allLevelFlavorTexts[GameProcess.instance.currentLevelIndex].text; // Refresh player move history moveHistory = new List <Vector2>(); currentLevel = newLevelData; SetRandomStartAndExit(); // Create new map CreateNewLevelGridObjects(); // Make first move for the player playerXcoord = startPointXcoord; playerYcoord = startPointYcoord; PlayerMoved(0, 0); }
void generateRandomBarrier(Vector3 pos0) { // function generate barrier based on bounds of objects and bound of ground, // no need to fit manually LevelPatterns.PatternInfo patternInfo = LevelPatterns.getRandomPattern(); Primitive[,] pattern = patternInfo.PatternData; int countElementsPerBlock = patternInfo.NumElementsPerBlock; int heightPattern = pattern.GetLength(0); int widthPattern = pattern.GetLength(1); int countElementsPerLine = widthPattern * countElementsPerBlock; // now pattern will be tuned by the width of ground, for simplify // generate pattern for (int y = 0; y < heightPattern; ++y) { for (int x = 0; x < widthPattern; ++x) { Primitive element = pattern[y, x]; instantiateGameObjectBasedOnElement(element, x, y, countElementsPerLine, countElementsPerBlock, pos0); } } }