void GenerateLevel() { if (firstRun) { if (NextLevelStarted != null) { NextLevelStarted(); } } floorNumber.text = PlayerData.currentLevel.ToString(); iTween.ScaleTo(floorNumber.gameObject, iTween.Hash( "scale", Vector3.one, "easetype", iTween.EaseType.easeInOutQuint, "time", 1.0f)); //floor.gameObject.transform.localScale = new Vector3(11, 16, 1); iTween.ScaleTo(floor.gameObject, iTween.Hash( "scale", new Vector3(10, 15, 1), "easetype", iTween.EaseType.easeInOutQuint, "time", 0.3f)); int bgNumber = PlayerData.currentLevel % backgroundCount; Texture2D texNow = Resources.Load <Texture2D>("Backgrounds/Background" + bgNumber); backgroundMat.mainTexture = texNow; Vector2 randOffset = new Vector2(Random.value, Random.value); backgroundMat.SetTextureOffset("_FlowMap", randOffset); backgroundMat.SetTextureOffset("_MainTex", randOffset); cubeMat.mainTexture = texNow; floorMat.SetTexture("_MainTex", floorMat.GetTexture("_SecondaryTex")); floorMat.SetFloat("_Blend", 0.0f); floorMat.SetTexture("_SecondaryTex", texNow); //new texture iTween.ValueTo(floor.gameObject, iTween.Hash( //lerpingMat "from", 0.0f, "to", 1.0f, "easetype", iTween.EaseType.linear, "time", 0.6f, "onupdate", "LerpBeetwenMat", "onupdatetarget", this.gameObject)); // subLight.color = texNow.GetPixel(3, 3); for (int i = 0; i < gameObject.transform.childCount; i++) // delete previous { transform.GetChild(i).gameObject.SetActive(false); } PlayerBehavoir.numberOfMoves = 0; for (int x = 0; x < map.width; x++) { for (int y = 1; y < map.height; y++) { GenerateTile(x, y); } } //generete current //Count the pixels on the bottom; for game logic movesFor3Stars = 0; for (int x = 0, y = 0; x < map.width; x++) { CheckForPixel(x, y); } GameLogicInit(); GameObject playerSpawn = GameObject.FindGameObjectWithTag("Player"); // Initial Update playerSpawn.GetComponent <PlayerBehavoir>().gameUI.UpdateBallLeftText(); // On gui movesLeft = movesFor3Stars + 2; ingameUI.UpdateMoveLeftText(movesLeft); }