public void MoveCard(Vector2 direction) { if (currentCard == null) { Debug.LogWarning("s_currentCard is null"); return; } cardsCleared++; var tempcard = SetNewCard(); // Send the current card of the screen in the direction the player swiped #if DEBUG Debug.Log("Sending card in direction: " + direction); #endif currentCard.GetComponent <Renderer>().sortingOrder = 2; currentCard.GetComponent <Rigidbody2D>().AddForce(direction * forceMod, ForceMode2D.Impulse); var cb = currentCard.GetComponent <CardBehaviour>(); cb.StartSelfRecycleTimer(0.5f); if (gameRules.CheckRules(DirectionUtils.Vector2ToDirection(direction), cb.Card)) { // Correct swipe AudioClipPlayer.PlaySwipe(); sessionData.Score++; // Continue streak or start a new one if (sessionData.IsOnStreak) { sessionData.CurrentStreak++; } else { sessionData.IsOnStreak = true; sessionData.CurrentStreak = 1; } } else { // Wrong swipe AudioClipPlayer.PlaySwipe(); AudioClipPlayer.PlaySwipeError(); cameraShake.Shake(); sessionData.Lives--; // Streak broken sessionData.IsOnStreak = false; if (sessionData.CurrentStreak > sessionData.HighestStreakInSession) { sessionData.HighestStreakInSession = sessionData.CurrentStreak; } } // Is player is dead? if (sessionData.Lives <= 0) { if (tempcard != null) { tempcard.GetComponent <Rigidbody2D>().AddForce(-Vector2.up * forceMod, ForceMode2D.Impulse); tempcard.GetComponent <CardBehaviour>().StartSelfRecycleTimer(0.4f); } EndRound(); gameStateChanger.ChangeGameState(GameState.GameEnd, 0.4f); return; } currentCard = tempcard; // Has the player cleared enough cards to end the round? if (cardsCleared >= cardsToClear) { EndRound(); gameStateChanger.ChangeGameState(GameState.RoundEnd, 0.5f); } }