47 lines
1.0 KiB
C#
47 lines
1.0 KiB
C#
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
public class GameManager : MonoBehaviour
|
|
{
|
|
public Transform Ball;
|
|
public Text CoinText;
|
|
public void AddCoins()
|
|
{
|
|
CoinText.text = (int.Parse(CoinText.text) + 1).ToString();
|
|
}
|
|
public GameObject Finishpanel;
|
|
public void NextLevel()
|
|
{
|
|
int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
|
|
|
|
SceneManager.LoadScene(currentSceneIndex + 1);
|
|
|
|
}
|
|
public void Restart()
|
|
{
|
|
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
|
|
|
|
}
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (Ball.position.y < -20)
|
|
{
|
|
Restart();
|
|
}
|
|
}
|
|
public void Finished()
|
|
{
|
|
Finishpanel.SetActive(true);
|
|
Ball.GetComponent<Rigidbody>().isKinematic = true;
|
|
}
|
|
}
|