IEnumerator LightUp() { if (alter != null) { alter.SendMessage("Activate"); } GameObject totemBeam = new GameObject("TotemBeam"); totemBeam.transform.parent = transform; totemBeam.transform.localPosition = new Vector3(0, 0, 0); SpriteRenderer sr = totemBeam.AddComponent <SpriteRenderer>(); sr.sortingLayerName = "Environment"; sr.sortingOrder = 1; sr.sprite = Resources.Load <Sprite>("Totems/TotemBeam"); sr.color = myColor; for (int i = 0; i < 10; i++) { GameObject beam = new GameObject("Beam"); beam.transform.parent = totemBeam.transform; beam.AddComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Totems/TotemBeamStraight"); beam.GetComponent <SpriteRenderer>().sortingLayerName = "TopEnvironment"; beam.GetComponent <SpriteRenderer>().sortingOrder = 1; beam.GetComponent <SpriteRenderer>().color = myColor; if (i > 4) { beam.GetComponent <SpriteRenderer>().color = new Color(myColor.r, myColor.g, myColor.b, 1 - ((i - 5) * 0.2f)); } beam.transform.localPosition = new Vector3(0, (2 * i) + 2, 0); } GameObject fogEater = new GameObject("TotemFogEater"); fogEater.transform.parent = transform; fogEater.transform.position = transform.position; if (color == TotemColor.White) { fogEater.tag = "FogDestroyer"; } else { fogEater.tag = "FogSweeper"; } fogEater.layer = 2; CircleCollider2D circ = fogEater.AddComponent <CircleCollider2D>(); circ.isTrigger = true; circ.radius = 1; float s = transform.Find("Background").localScale.x; totemBeam.transform.localScale = new Vector3(0, s, s); while (totemBeam.transform.localScale.x < s) { float x = Mathf.MoveTowards(totemBeam.transform.localScale.x, s, 0.025f); totemBeam.transform.localScale = new Vector3(x, s, s); foreach (GameObject aBeam in alterBeams) { aBeam.transform.localScale = new Vector3(x, s, s); } yield return(new WaitForEndOfFrame()); } float rad = 50; if (color == TotemColor.White) { rad = 20; } while (circ.radius < rad) { circ.radius += 0.04f; yield return(new WaitForEndOfFrame()); } if (color == TotemColor.White) { GameObject.Find("Demons").SetActive(false); yield return(StartCoroutine(LevelManager.Whiter.WhiteScreen())); yield return(new WaitForSeconds(1)); WinText.Say("You win!"); yield return(new WaitForSeconds(3)); WinText.Say("Thanks for playing!\n-@skeletonware"); yield return(new WaitForSeconds(10)); WinText.FadeText(); yield return(new WaitForSeconds(3)); LevelManager.gameWon = true; LevelManager.LoadLevel(1); // load main menu } yield break; }