Commit ebdf89f6 authored by bogomil's avatar bogomil

Color for the Players

parent 4e6a0900
using System.Collections;
using System.Collections.Generic;
using _Game.Scripts.GameManager;
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 GameManagerData 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) {
player1InputField.text = data.player1.name;
player2InputField.text = data.player2.name;
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
player1InputField.text = data.Player1Name;
player2InputField.text = data.Player2Name;
}
public void GoToGameScene()
{
data.Player1Name = player1InputField.text;
data.Player2Name = player2InputField.text;
SceneManager.LoadScene("TestLevel");
}
public void GoToGameScene() {
data.Reset();
data.player1.Reset(player1InputField.text, Color.green);
data.player2.Reset(player2InputField.text, Color.red);
SceneManager.LoadScene("MainLevel");
public void ChangeColorPlayer1(int colors)
{
switch (colors)
{
case 1:
data.Player1Color = Color.green;
break;
case 2 :
data.Player1Color = Color.yellow;
break;
case 3 :
data.Player1Color = Color.red;
break;
case 4 :
data.Player1Color = Color.blue;
break;
default:
data.Player1Color = Color.gray;
break;
}
}
public void ChangeColorPlayer2(int colors2)
{
switch (colors2)
{
case 1:
data.Player2Color = Color.green;
break;
case 2 :
data.Player2Color = Color.yellow;
break;
case 3 :
data.Player2Color = Color.red;
break;
case 4 :
data.Player2Color = Color.blue;
break;
default :
data.Player2Color = 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;
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment