-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSelectScript.cs
103 lines (91 loc) · 2.74 KB
/
SelectScript.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
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class SelectScript : MonoBehaviour
{
public GameObject Broly;
public GameObject Goku;
private Vector3 CharPos;
private Vector3 offScreen;
private int CharInt = 1;
private SpriteRenderer GokuRender, BrolyRender;
private readonly string selectChar = "selectedCharacter";
private void Awake()
{
CharPos = Broly.transform.position;
offScreen = Goku.transform.position;
GokuRender = Goku.GetComponent<SpriteRenderer>();
BrolyRender = Broly.GetComponent<SpriteRenderer>();
}
public void NextChar()
{
switch (CharInt)
{
case 1:
PlayerPrefs.SetInt(selectChar,1);
GokuRender.enabled = false;
Goku.transform.position = offScreen;
Broly.transform.position = CharPos;
BrolyRender.enabled = true;
CharInt++;
break;
case 2:
PlayerPrefs.SetInt(selectChar, 2);
BrolyRender.enabled = false;
Broly.transform.position = offScreen;
Goku.transform.position = CharPos;
GokuRender.enabled = true;
CharInt++;
ResetInt();
break;
default:
ResetInt();
break;
}
}
public void PrevChar()
{
switch (CharInt)
{
case 1:
PlayerPrefs.SetInt(selectChar, 1);
GokuRender.enabled = false;
Goku.transform.position = offScreen;
Broly.transform.position = CharPos;
BrolyRender.enabled = true;
ResetInt();
break;
case 2:
PlayerPrefs.SetInt(selectChar, 2);
BrolyRender.enabled = false;
Broly.transform.position = offScreen;
Goku.transform.position = CharPos;
GokuRender.enabled = true;
CharInt--;
break;
default:
ResetInt();
break;
}
}
private void ResetInt()
{
if(CharInt >= 2)
{
CharInt = 1;
}
else
{
CharInt = 2;
}
}
public void ConfirmButton()
{
SceneManager.LoadScene("TestScene");
}
public void Player2()
{
SceneManager.LoadScene("Player2Select");
}
}