private IEnumerator ReturnToHandAnimation(IContainer game, GameAction action) { var returnAction = (ReturnToHandAction)action; // TODO: Only Spells? if (returnAction.Source.Data.Type == CardType.Spell) { var sequence = DOTween.Sequence(); foreach (var returnedCard in returnAction.ReturnedCards) { if (returnAction.Source == returnedCard) { // TODO: Different effect for this case? continue; } var particleType = returnAction.Source.GetLessonType(); var particleSequence = _gameView.GetParticleSequence(returnAction.Player, returnedCard, particleType); sequence.Append(particleSequence); } while (sequence.IsPlaying()) { yield return(null); } } var cardViews = _gameView.FindCardViews(returnAction.ReturnedCards); // TODO: Cards could come from multiple zones, but we need to capture the from zones for each card for the animation. var fromZone = returnAction.ReturnedCards.Select(c => c.Zone).Distinct().Single(); yield return(true); foreach (var cardView in cardViews) { var sequence = fromZone.IsInBoard() // TODO: Not every card that has this action requires a card to be revealed (e.g. Gringotts Vault Key) ? _gameView.GetMoveToZoneSequence(cardView, Zones.Hand, fromZone) : _boardView.GetRevealSequence(cardView, Zones.Hand, fromZone); while (sequence.IsPlaying()) { yield return(null); } } }
private IEnumerator ShuffleDeckAnimation(IContainer container, GameAction action) { yield return(true); var shuffleAction = (ShuffleDeckAction)action; var sequence = DOTween.Sequence().AppendInterval(0.5f).AppendInterval(0f); foreach (var target in shuffleAction.Targets) { var cardViews = _gameView.FindCardViews(target.Deck); for (var i = 0; i < cardViews.Count; i++) { var cardView = cardViews[i]; var offsetX = i % 2 == 1 ? 6f : -6f; var offsetZ = -2f; var offsetPos = cardView.transform.position + offsetX * Vector3.right + offsetZ * Vector3.forward; var leftOffsetRot = new Vector3(5.5f, 16f, -6); var rightOffsetRot = new Vector3(5.5f, -16f, 6); var targetRot = offsetX < 0f ? leftOffsetRot : rightOffsetRot; if (target == _gameView.Match.EnemyPlayer) { targetRot.z += 180f; } sequence.Join(cardView.Move(offsetPos, targetRot, 0.6f)); } } while (sequence.IsPlaying()) { yield return(null); } sequence = DOTween.Sequence(); foreach (var target in shuffleAction.Targets) { var zoneView = _gameView.FindZoneView(target, Zones.Deck); var targetRot = zoneView.GetRotation(); var startDelay = 0f; for (var i = 0; i < target.Deck.Count; i++) { var card = target.Deck[i]; var cardView = _gameView.FindCardView(card); var finalPos = zoneView.GetPosition(i); sequence.Join(cardView.Move(finalPos, targetRot, 0.3f, startDelay)); startDelay += i % 2 == 1 ? 0.05f : 0f; } } while (sequence.IsPlaying()) { yield return(null); } }