public void EndGame() { if (PlayerPrefs.GetInt("GameAdsCount", 0) >= 3) { if (AppLovin.HasPreloadedInterstitial()) { PlayerPrefs.SetInt("GameAdsCount", 0); AppLovin.ShowInterstitial(); } } GameAnalytics.NewProgressionEvent(GAProgressionStatus.Complete, "game", SpaceShipController.instance.score); ShowEndScreen(); SaveScore(); LoadScore(); InGameUI.SetActive(false); EndGameUI.SetActive(true); HighScoreTxt2.text = HighScoreTxt.text; ScoreTxt2.text = ScoreTxt.text; }
private void OnCollisionEnter2D(Collision2D other) { print(other.gameObject.name); if (other.gameObject.tag == "Station") { state = State.landing; StartCoroutine(Land(other)); SoundEffect.PlayOneShot(SoundOnLandingNormal); } if (other.gameObject.tag == "Death") { rb.velocity = Vector2.zero; state = State.idle; m_Anim.SetTrigger("Death"); SoundEffect.PlayOneShot(SoundOnDeath); //Game Over EndGameUI.SetActive(true); StartCoroutine("GameOver"); } }
private void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.tag == "Station") { rb.velocity = Vector2.zero; state = State.idle; if (other.contacts[0].normal.y >= 0.9f) { Vector3 angle = new Vector3(0f, 0f, 0f); spaceman.transform.rotation = Quaternion.Euler(angle); } else if (other.contacts[0].normal.y <= -0.9f) { Vector3 angle = new Vector3(0f, 0f, 180f); spaceman.transform.rotation = Quaternion.Euler(angle); } else if (other.contacts[0].normal.x >= 0.9f) { Vector3 angle = new Vector3(0f, 0f, 270f); spaceman.transform.rotation = Quaternion.Euler(angle); } else if (other.contacts[0].normal.x <= -0.9f) { Vector3 angle = new Vector3(0f, 0f, 90f); spaceman.transform.rotation = Quaternion.Euler(angle); } // adjust to perpendicular position } if (other.gameObject.tag == "Death") { rb.velocity = Vector2.zero; state = State.idle; //Game Over EndGameUI.SetActive(true); } }
public IEnumerator CountDown() { if (isGameOver) { PlayerPrefs.SetInt("GameAdsCount", PlayerPrefs.GetInt("GameAdsCount")); EndGameUI.SetActive(false); CountDownUI.SetActive(true); for (i = 3; i > 0; i--) { CountDownText.text = i.ToString(); CountDownText.gameObject.transform.localScale = Vector3.one; CountDownText.gameObject.transform.DOScale(Vector3.zero, 1f).SetEase(Ease.Linear); yield return(new WaitForSeconds(1f)); } if (i == 0) { ResumeGame(); } } else { yield return(null); } }