-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenuScreenScript
132 lines (116 loc) · 3.17 KB
/
MenuScreenScript
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class playButtonScript : MonoBehaviour
{
public Transform ptl;
public Transform pbr;
public Transform otl;
public Transform obr;
public Transform qtl;
public Transform qbr;
public Animator pAnimator;
public Animator oAnimator;
public Animator qAnimator;
Vector3 mPos;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
calculateMousePos();
playButton();
quitButton();
optionsButton();
}
void calculateMousePos()
{
//Får mousePos
mPos = Input.mousePosition;
mPos = Camera.main.ScreenToWorldPoint(mPos);
//Fortæller de forskellige animators at mousePressed
if (Input.GetMouseButton(0))
{
pAnimator.SetBool("mousePressed", true);
qAnimator.SetBool("mousePressed", true);
oAnimator.SetBool("mousePressed", true);
}
else
{
pAnimator.SetBool("mousePressed", false);
qAnimator.SetBool("mousePressed", false);
oAnimator.SetBool("mousePressed", false);
}
}
void playButton()
{
if(mPos.x > ptl.position.x && mPos.x < pbr.position.x)
{
if (mPos.y < ptl.position.y && mPos.y > pbr.position.y)
{
//Hvis musen er over knappen, fortælles dette til animatoren
pAnimator.SetBool("mouseOver", true);
if (Input.GetMouseButtonUp(0))
{
//Starter spillet når man trykker
SceneManager.LoadScene(1);
}
}
else
{
pAnimator.SetBool("mouseOver", false);
}
}
else
{
pAnimator.SetBool("mouseOver", false);
}
}
void quitButton()
{
if (mPos.x > qtl.position.x && mPos.x < qbr.position.x)
{
if (mPos.y < qtl.position.y && mPos.y > qbr.position.y)
{
qAnimator.SetBool("mouseOver", true);
if (Input.GetMouseButtonUp(0))
{
//Slukker programmet når man trykker
Application.Quit();
}
}
else
{
qAnimator.SetBool("mouseOver", false);
}
}
else
{
qAnimator.SetBool("mouseOver", false);
}
}
void optionsButton()
{
if (mPos.x > otl.position.x && mPos.x < obr.position.x)
{
if (mPos.y < otl.position.y && mPos.y > obr.position.y)
{
oAnimator.SetBool("mouseOver", true);
if (Input.GetMouseButtonUp(0))
{
}
}
else
{
oAnimator.SetBool("mouseOver", false);
}
}
else
{
oAnimator.SetBool("mouseOver", false);
}
}
}