-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScore_SideWalls.cs
60 lines (51 loc) · 1.73 KB
/
Score_SideWalls.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
48
49
50
51
52
53
54
55
56
57
58
59
60
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Score_SideWalls : MonoBehaviour {
public BallControl ballcontrol;
static int playerScore01 = 0;
static int playerScore02 = 0;
public string wallName;
public GUISkin ScoreSkin;
public Transform buttonReset;
void Start()
{
ballcontrol = FindObjectOfType(typeof(BallControl)) as BallControl;
buttonReset = GameObject.Find("Ball").transform;
}
// Use this function on trigger - wall hit with ball
void OnTriggerEnter2D ( Collider2D hitInfo ) {
AudioSource audio = GetComponent<AudioSource>();
if (hitInfo.name == "Ball")
audio.Play();
{
if (wallName == "rightWall")
{
playerScore01 += 1;
}
else
{
playerScore02 += 1;
}
Debug.Log("Player01 Score is " + playerScore01);
Debug.Log("Player02 Score is " + playerScore02);
hitInfo.gameObject.SendMessage("Reset_balls");
//ballcontrol.Reset_balls();
}
}
void OnGUI()
{
GUI.skin = ScoreSkin;
GUI.Label(new Rect(Screen.width / 2 - 150-18, 25, 100, 100), "" + playerScore01);
GUI.Label(new Rect(Screen.width / 2 + 150-18, 25, 100, 100), "" + playerScore02);
if (GUI.Button ( new Rect (Screen.width / 2 -121/1.8f, 25, 121, 53), "RESET"))
{
//Comment for old call - new option is reset whole scene
playerScore01 = 0;
playerScore02 = 0;
//buttonReset.SendMessage("Reset_balls");
SceneManager.LoadScene("GamePlay");
}
}
}