35 lines
783 B
C#
35 lines
783 B
C#
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
public class ScoreManager : MonoBehaviour
|
|
{
|
|
public int scoreToReach;
|
|
private int Player_1score = 0;
|
|
private int Player_2score = 0;
|
|
|
|
public Text Player_1scoreText;
|
|
public Text Player_2scoreText;
|
|
|
|
public void Player_1Goal()
|
|
{
|
|
Player_1score++;
|
|
Player_1scoreText.text = Player_1score.ToString();
|
|
CheckScore();
|
|
}
|
|
public void Player_2Goal()
|
|
{
|
|
Player_2score++;
|
|
Player_2scoreText.text = Player_2score.ToString();
|
|
CheckScore();
|
|
|
|
}
|
|
private void CheckScore()
|
|
{
|
|
if (Player_1score == scoreToReach || Player_2score == scoreToReach)
|
|
{
|
|
SceneManager.LoadScene(2);
|
|
}
|
|
}
|
|
}
|