public LoopSprite CreateLoopSprite(float uniqueSpriteHue) { GameObject newLoop = Instantiate(baseLoopSprite, Vector3.zero, Quaternion.identity, overlayGroup.transform); LoopSprite newLoopSprite = newLoop.GetComponent <LoopSprite>(); newLoopSprite.offset = overlayStartOffset; newLoopSprite.ColorSprite(uniqueSpriteHue); displayedLoops.Add(newLoop); return(newLoopSprite); }
public IEnumerator DrawCoroutine() { // Add sprites over the grid for the next few frames, to display the current loops. float uniqueSpriteHue = Random.value; TextDraw(uniqueSpriteHue, true); foreach (KMapLoop loop in Main.Instance.loops) { yield return(new WaitForEndOfFrame()); LoopSprite loopSpritePlacement = CreateLoopSprite(uniqueSpriteHue); List <int[]> wrapAround = loopSpritePlacement.PositionInOverlay(loop); foreach (int[] position in wrapAround) { // Deal with copies of the loop that are shown "wrapping" around the grid. LoopSprite cloneSpritePlacement = CreateLoopSprite(uniqueSpriteHue); cloneSpritePlacement.SetPosition(position[0], position[1], position[2], position[3]); } uniqueSpriteHue += 1f / Main.Instance.loops.Count; // Cycle through hues. uniqueSpriteHue %= 1f; } }