Files
BoostBaller/Assets/Scripts/GameManager.cs

45 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
public int scorePlayer1 = 0;
public int scorePlayer2 = 0;
public Transform player1;
public Transform player2;
public Transform ball;
public Transform player1Initial, player2Initial, ballInitial;
/* UI */
public Text scoreLabel;
// Start is called before the first frame update
void Start()
{
this.player1Initial = new GameObject().transform;
this.player1Initial.position = this.player1.position;
this.player2Initial = new GameObject().transform;
this.player2Initial.position = this.player2.position;
this.ballInitial = new GameObject().transform;
this.ballInitial.position = this.ball.position;
}
// Update is called once per frame
void Update()
{
this.scoreLabel.text = "Score: " + this.scorePlayer1 + " : " + this.scorePlayer2;
}
public void ResetPositions()
{
this.player1.position = this.player1Initial.position;
this.player2.position = this.player2Initial.position;
this.ball.position = this.ballInitial.position;
}
}