/// <summary> /// Moves the cam to/from game. Initially above, will slide down to the center point and properly frame the polygons. /// </summary> /// <returns> /// The coroutine stuff /// </returns> /// <param name='to'> /// True for going to the game, false for away. /// </param> private IEnumerator moveCamToGame(bool to) { if (to == true) { yield return(new WaitForSeconds(1f)); loadingPanel.SendMessage("fadeOutPanel"); } //disablePolygons(); //Debug.Log ("Moving cam called: " + to.ToString()); Bounds b = getBounds(getMiddlePoint()); Vector3 camStartPos = b.center + new Vector3(0, b.size.y * 3, 100); Vector3 camEndPos = b.center + new Vector3(0, 0, 100); if (to == false) //if false, increment end point { Vector3 temp = camStartPos; camStartPos = camEndPos; camEndPos = temp; camEndPos.y *= -1; //yield return new WaitForSeconds(getScreenSlideLength()); } orthoCamMax = 1.15f * Mathf.Max(b.extents.x / gameCam.aspect, b.extents.y); //if (b.extents.y > b.extents.x) orthoCamMax = 1.15f * b.extents.y; //fix for the triangle easy //Debug.Log ("size: " + gameCam.orthographicSize + " to " + orthoCamMax); gameCam.orthographicSize = orthoCamMax != 0 ? orthoCamMax : 1; for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / 0.5f) { gameCam.transform.position = MathS.ULerp(camStartPos, camEndPos, MathS.bounceInOutLogic(t)); //gameCam.transform.position = Vector3.Lerp(camStartPos, camEndPos, t); yield return(null); } gameCam.transform.position = camEndPos; if (to == true) { Debug.Log("Going to game"); //startGame(this); playScreenMenu.SetActive(true); gameOptions.SendMessage("Off"); //playScreenMenu.SendMessage("fadeInPanel"); } if (to == false) { Debug.Log("Going to menu"); gameCam.transform.position = new Vector3(-100, 250, -100); foreach (TessellationPolygon p in polygons) { Destroy(p.gameObject.transform.parent.gameObject); } polygons.Clear(); } }