IEnumerator RunEnlargeY() { yield return(Rest(40)); foreach (var rest in Loop(64, 0, 1, 0)) { RandomTile().RunAnimation( AnimationKeyPath.RelScaleY, AnimationCurveUtils.FromPairs(0, 1f, NoteValueToDuration(1, 0), 5f, NoteValueToDuration(2, 0), 1), Location.Top, 1f, NoteValueToDuration(0, 1) ); yield return(rest); } }
IEnumerator RunRotation() { yield return(Rest(16)); foreach (var rest in Loop(32, 0, 2, 0)) { var tile = RandomTile(); var rot = tile.animatable.rotation % 360; RandomTile().RunAnimation( AnimationKeyPath.Rotation, AnimationCurveUtils.FromPairs( 0, rot, NoteValueToDuration(0, 1), rot + Random.Range(360, 360)), Location.Axis, 0.6f, NoteValueToDuration(0, 1) ); yield return(rest); } foreach (var rest in Loop(32, 0, 2, 0)) { var tile = RandomTile(); var rot = tile.animatable.rotation % 360; RandomTile().RunAnimation( AnimationKeyPath.Rotation, AnimationCurveUtils.FromPairs( 0, rot, NoteValueToDuration(0, 1), rot + Random.Range(90, 360)), Location.Axis, 0.6f, NoteValueToDuration(0, 1) ); yield return(rest); } }
void _RunAnimation(string keyPath, float startTime, float startValue, float endTime, float endValue) { animatable.AddAnimationCurve(keyPath, AnimationCurveUtils.FromPairs(startTime, startValue, endTime, endValue)); }
IEnumerator Run() { System.Action <Tile, Location> f = (Tile target, Location l) => {}; f = (Tile target, Location loc) => { // can this automatically lock the target? target.RunAnimation( AnimationKeyPath.Opacity, AnimationCurveUtils.FromPairs(0, 1, NoteValueToDuration(0, 1), 0f, NoteValueToDuration(0, 6.9f), 0f, NoteValueToDuration(0, 7.85f), 1) ); // this locks StartCoroutine(C.WithDelay(() => { var nextTarget = target.TileAtLocation(loc, TileMutexFlag.Opacity); if (nextTarget != null) { f(nextTarget, loc); } }, NoteValueToDuration(0, 0.1f))); }; // max length yield return(Rest(2)); foreach (var rest in Loop(6, 0, 1, 0)) { // Find target bool found = false; int runCount = 0; while (!found && runCount < 100) { int x = Random.Range(0, cols); int y = Random.Range(0, rows); var tile = board[x, y]; if (!tile.IsLocked(TileMutexFlag.Opacity)) { var randomAxis = Location.None; /* * if (Random.value < 0.45f) randomAxis |= Location.Left; * if (Random.value < 0.45f) randomAxis |= Location.Right; * if (Random.value < 0.45f) randomAxis |= Location.Top; * if (Random.value < 0.45f) randomAxis |= Location.Bottom; */ f(tile, randomAxis); found = true; } runCount++; } yield return(rest); } foreach (var rest in Loop(64, 0, 1, 0)) { // Find target bool found = false; int runCount = 0; while (!found && runCount < 100) { int x = Random.Range(0, cols); int y = Random.Range(0, rows); var tile = board[x, y]; if (!tile.IsLocked(TileMutexFlag.Opacity)) { var randomAxis = Location.None; if (Random.value < 0.30f) { randomAxis |= Location.Left; } if (Random.value < 0.30f) { randomAxis |= Location.Right; } if (Random.value < 0.30f) { randomAxis |= Location.Top; } if (Random.value < 0.30f) { randomAxis |= Location.Bottom; } if (randomAxis == Location.None && Random.value > 0.5f) { randomAxis |= Location.Bottom; } f(tile, randomAxis); found = true; } runCount++; } yield return(rest); } /* * * RandomTile().RunAnimation( * AnimationKeyPath.Opacity, * AnimationCurveUtils.FromPairs(0, 1, NoteValueToDuration(0, 2), 0.0f, NoteValueToDuration(1, 0), 1), * Location.Left, * 0.95f, * NoteValueToDuration(0, 1) * ); * * RandomTile().RunAnimation( * AnimationKeyPath.RelScaleY, * AnimationCurveUtils.FromPairs(0, 1f, NoteValueToDuration(1, 0), 5f, NoteValueToDuration(2, 0), 1), * Location.Top, * 1f, * NoteValueToDuration(0, 1) * ); */ }