Skip to content

Instantly share code, notes, and snippets.

@oismaelash
Created February 19, 2018 01:07
Show Gist options
  • Save oismaelash/5ea33be10a1feba5749c1cc45121f5aa to your computer and use it in GitHub Desktop.
Save oismaelash/5ea33be10a1feba5749c1cc45121f5aa to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Main : MonoBehaviour
{
[Header("Sala:")]
public GameObject[] SalaButtons;
[Header("Dificudade:")]
public GameObject[] DificudadeButtons;
[Header("Oponentes:")]
public GameObject[] OponentesButtons;
[Header("Componentes:")]
public GameObject SelectionBar;
public GameObject SelectionArrows;
public int BarPosi;
[Header("Posicoes da Barra:")]
public Transform[] BarSelectionPositions;
private int ClickButton;
public Color TextOffColor;
public Color TextOnColor;
// Use this for initialization
void Start()
{
if (BarPosi == 0)
{
if (ClickButton == 0)
{
SalaButtons[0].GetComponent<Text>().color = TextOnColor;
SalaButtons[0].GetComponent<Animation>().enabled = true;
}
if (ClickButton == 1)
{
SalaButtons[1].GetComponent<Text>().color = TextOnColor;
SalaButtons[1].GetComponent<Animation>().enabled = true;
}
if (ClickButton == 2)
{
SalaButtons[2].GetComponent<Text>().color = TextOnColor;
SalaButtons[2].GetComponent<Animation>().enabled = true;
}
}
else
{
for (int i = 0; i < SalaButtons.Length; i++)
{
SalaButtons[i].GetComponent<Text>().color = TextOffColor;
SalaButtons[i].GetComponent<Animation>().enabled = false;
}
}
if (BarPosi == 1)
{
if (ClickButton == 0)
{
DificudadeButtons[0].GetComponent<Text>().color = TextOnColor;
DificudadeButtons[0].GetComponent<Animation>().enabled = true;
}
if (ClickButton == 1)
{
DificudadeButtons[1].GetComponent<Text>().color = TextOnColor;
DificudadeButtons[1].GetComponent<Animation>().enabled = true;
}
if (ClickButton == 2)
{
DificudadeButtons[2].GetComponent<Text>().color = TextOnColor;
DificudadeButtons[2].GetComponent<Animation>().enabled = true;
}
}
else
{
for (int a = 0; a < DificudadeButtons.Length; a++)
{
DificudadeButtons[a].GetComponent<Text>().color = TextOffColor;
DificudadeButtons[a].GetComponent<Animation>().enabled = false;
}
}
if (BarPosi == 2)
{
if (ClickButton == 0)
{
OponentesButtons[0].GetComponent<Text>().color = TextOnColor;
OponentesButtons[0].GetComponent<Animation>().enabled = true;
}
if (ClickButton == 1)
{
OponentesButtons[1].GetComponent<Text>().color = TextOnColor;
OponentesButtons[1].GetComponent<Animation>().enabled = true;
}
if (ClickButton == 2)
{
OponentesButtons[2].GetComponent<Text>().color = TextOnColor;
OponentesButtons[2].GetComponent<Animation>().enabled = true;
}
}
else
{
for (int b = 0; b < OponentesButtons.Length; b++)
{
OponentesButtons[b].GetComponent<Text>().color = TextOffColor;
OponentesButtons[b].GetComponent<Animation>().enabled = false;
}
}
}
public void NextButton()
{
BarPosi++;
if (BarPosi == BarSelectionPositions.Length)
{
BarPosi = 0;
}
SelectionBar.transform.position = new Vector3(SelectionBar.transform.position.x, BarSelectionPositions[BarPosi].position.y, SelectionBar.transform.position.z);
SelectionArrows.transform.position = new Vector3(SelectionArrows.transform.position.x, BarSelectionPositions[BarPosi].position.y, SelectionArrows.transform.position.z);
}
public void BackButton()
{
BarPosi--;
if (BarPosi < 0)
{
int Resu = BarSelectionPositions.Length - 1;
BarPosi = Resu;
}
SelectionBar.transform.position = new Vector3(SelectionBar.transform.position.x, BarSelectionPositions[BarPosi].position.y, SelectionBar.transform.position.z);
SelectionArrows.transform.position = new Vector3(SelectionArrows.transform.position.x, BarSelectionPositions[BarPosi].position.y, SelectionArrows.transform.position.z);
}
public void SelectionNextButton()
{
ClickButton++;
if (BarPosi == 0)
{
for (int i = 0; i < SalaButtons.Length; i++)
{
SalaButtons[i].SetActive(false);
}
if (ClickButton == SalaButtons.Length)
{
ClickButton = 0;
}
SalaButtons[ClickButton].SetActive(true);
}
if (BarPosi == 1)
{
for (int i = 0; i < DificudadeButtons.Length; i++)
{
DificudadeButtons[i].SetActive(false);
}
if (ClickButton == DificudadeButtons.Length)
{
ClickButton = 0;
}
DificudadeButtons[ClickButton].SetActive(true);
}
if (BarPosi == 2)
{
for (int i = 0; i < OponentesButtons.Length; i++)
{
OponentesButtons[i].SetActive(false);
}
if (ClickButton == OponentesButtons.Length)
{
ClickButton = 0;
}
OponentesButtons[ClickButton].SetActive(true);
}
}
public void SelectionBackButton()
{
ClickButton--;
if (BarPosi == 0)
{
for (int i = 0; i < SalaButtons.Length; i++)
{
if(SalaButtons[ClickButton].GetComponent<Text>().text.Length != ClickButton)
{
SalaButtons[i].SetActive(false);
}
}
int Resu = SalaButtons.Length - 1;
if (ClickButton < 0)
{
ClickButton = Resu;
}
SalaButtons[ClickButton].SetActive(true);
}
if (BarPosi == 1)
{
for (int i = 0; i < DificudadeButtons.Length; i++)
{
DificudadeButtons[i].SetActive(false);
}
int Resu = DificudadeButtons.Length - 1;
if (ClickButton < 0)
{
ClickButton = Resu;
}
DificudadeButtons[ClickButton].SetActive(true);
}
if (BarPosi == 2)
{
for (int i = 0; i < OponentesButtons.Length; i++)
{
OponentesButtons[i].SetActive(false);
}
int Resu = OponentesButtons.Length - 1;
if (ClickButton < 0)
{
ClickButton = Resu;
}
OponentesButtons[ClickButton].SetActive(true);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment