Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
GameDevWeek
S
Sommersemester 2019
Unity
Touch me if you can
Commits
06e27e80
Commit
06e27e80
authored
Sep 21, 2019
by
Jonas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Character Customization with Updated Resets
parent
563cd657
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
186 additions
and
11 deletions
+186
-11
Assets/_Game/Scripts/UI/CharacterCustomization.cs
Assets/_Game/Scripts/UI/CharacterCustomization.cs
+186
-11
No files found.
Assets/_Game/Scripts/UI/CharacterCustomization.cs
View file @
06e27e80
...
...
@@ -5,34 +5,209 @@ using _Game.Scripts.GameManagerData;
using
TMPro
;
using
UnityEngine
;
using
UnityEngine.SceneManagement
;
using
UnityEngine.UI
;
public
class
CharacterCustomization
:
MonoBehaviour
{
[
SerializeField
]
private
GameData
data
;
public
class
CharacterCustomization
:
MonoBehaviour
{
public
GameData
data
;
public
TMP_InputField
player1InputField
;
public
TMP_InputField
player2InputField
;
public
Button
greenButtonP1
;
public
Button
yellowButtonP1
;
public
Button
redButtonP1
;
public
Button
blueButtonP1
;
public
Button
greyButtonP1
;
public
Button
greenButtonP2
;
public
Button
yellowButtonP2
;
public
Button
redButtonP2
;
public
Button
blueButtonP2
;
public
Button
greyButtonP2
;
// Start is called before the first frame update
// Start is called before the first frame update
// called first
void
OnEnable
()
{
void
OnEnable
()
{
SceneManager
.
sceneLoaded
+=
OnSceneLoaded
;
}
void
OnDisable
()
{
void
OnDisable
()
{
Debug
.
Log
(
"OnDisable"
);
SceneManager
.
sceneLoaded
-=
OnSceneLoaded
;
}
//
// called second
void
OnSceneLoaded
(
Scene
scene
,
LoadSceneMode
mode
)
{
void
OnSceneLoaded
(
Scene
scene
,
LoadSceneMode
mode
)
{
player1InputField
.
text
=
data
.
player1
.
name
;
player2InputField
.
text
=
data
.
player2
.
name
;
}
public
void
GoToGameScene
()
{
public
void
GoToGameScene
()
{
data
.
Reset
();
data
.
player1
.
Reset
(
player1InputField
.
text
,
Color
.
green
,
GameData
.
Role
.
Head
);
data
.
player2
.
Reset
(
player2InputField
.
text
,
Color
.
red
,
GameData
.
Role
.
Body
);
data
.
player1
.
Reset
(
player1InputField
.
text
,
GameData
.
Role
.
Head
);
data
.
player2
.
Reset
(
player2InputField
.
text
,
GameData
.
Role
.
Body
);
SceneManager
.
LoadScene
(
"MainLevel"
);
}
}
public
void
ChangeColorPlayer1
(
int
colors
)
{
switch
(
colors
)
{
case
1
:
data
.
player1
.
color
=
Color
.
green
;
break
;
case
2
:
data
.
player1
.
color
=
Color
.
yellow
;
break
;
case
3
:
data
.
player1
.
color
=
Color
.
red
;
break
;
case
4
:
data
.
player1
.
color
=
Color
.
blue
;
break
;
default
:
data
.
player1
.
color
=
Color
.
gray
;
break
;
}
}
public
void
ChangeColorPlayer2
(
int
colors2
)
{
switch
(
colors2
)
{
case
1
:
data
.
player2
.
color
=
Color
.
green
;
break
;
case
2
:
data
.
player2
.
color
=
Color
.
yellow
;
break
;
case
3
:
data
.
player2
.
color
=
Color
.
red
;
break
;
case
4
:
data
.
player2
.
color
=
Color
.
blue
;
break
;
default
:
data
.
player2
.
color
=
Color
.
gray
;
break
;
}
}
public
void
ButtonSelected1
(
int
buttonNummber
)
{
switch
(
buttonNummber
)
{
case
0
:
greenButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
BoldAndItalic
;
yellowButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
redButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
blueButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
greyButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
break
;
case
1
:
yellowButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
BoldAndItalic
;
greenButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
redButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
blueButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
greyButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
break
;
case
2
:
redButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
BoldAndItalic
;
greenButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
yellowButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
blueButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
greyButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
break
;
case
3
:
blueButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
BoldAndItalic
;
greenButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
yellowButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
redButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
greyButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
break
;
default
:
greyButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
BoldAndItalic
;
greenButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
yellowButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
redButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
blueButtonP1
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
break
;
}
}
public
void
ButtonSelected2
(
int
buttonNummber2
)
{
switch
(
buttonNummber2
)
{
case
0
:
greenButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
BoldAndItalic
;
yellowButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
redButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
blueButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
greyButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
break
;
case
1
:
yellowButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
BoldAndItalic
;
greenButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
redButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
blueButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
greyButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
break
;
case
2
:
redButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
BoldAndItalic
;
greenButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
yellowButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
blueButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
greyButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
break
;
case
3
:
blueButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
BoldAndItalic
;
greenButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
yellowButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
redButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
greyButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
break
;
default
:
greyButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
BoldAndItalic
;
greenButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
yellowButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
redButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
blueButtonP2
.
GetComponentInChildren
<
Text
>().
fontStyle
=
FontStyle
.
Normal
;
break
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment