using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Advertisements;
public class BallScript : MonoBehaviour
{
public void ShowAd()
{
if (Advertisement.IsReady())
{
Advertisement.Show();
}
}
public Vector2 startForce;
static int times = 0;
public Text goverText;
public Vector3[] positions;
public Rigidbody2D rb;
void Start()
{
int randomNumber = Random.Range(0, positions.Length);
transform.position = positions[randomNumber];
times = PlayerPrefs.GetInt("Played:", times);
rb.AddForce(startForce, ForceMode2D.Impulse);
}
void Update()
{
PlayerPrefs.SetInt("Played:", times);
goverText.text = "Played:" + times.ToString();
}
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.name == "wall_bottom")
{
times++;
if (times==19)
{
ShowAd();
}
SceneManager.LoadScene("wfvv");
}
}
}
↧