-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameManager.cs
47 lines (38 loc) · 1.12 KB
/
GameManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class GameManager : MonoBehaviour
{
[Header("Ball")]
public GameObject ball;
[Header("Player 1")]
public GameObject player1Paddle;
public GameObject player1Goal;
[Header("Player 2")]
public GameObject player2Paddle;
public GameObject player2Goal;
[Header("Score UI")]
public GameObject Player1Text;
public GameObject Player2Text;
private int player1Score;
private int player2Score;
public void Player1Scored()
{
player1Score++;
Player1Text.GetComponent<TextMeshProUGUI>().text = player1Score.ToString();
ResetPositions();
}
public void Player2Scored()
{
player2Score++;
Player2Text.GetComponent<TextMeshProUGUI>().text = player1Score.ToString();
ResetPositions();
}
private void ResetPositions()
{
ball.GetComponent<Ball>().Reset();
player1Paddle.GetComponent<Paddle>().Reset();
player2Paddle.GetComponent<Paddle>().Reset();
}
}