Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
using UnityEngine.UI; | ||
|
||
public class Simon : MonoBehaviour { | ||
|
||
public int button = 0; | ||
public GameObject redButton; | ||
public GameObject greenButton; | ||
public GameObject yellowButton; | ||
public GameObject blueButton; | ||
public GameObject start; | ||
public GameObject gameOverText; | ||
|
||
public bool isPlayer = false; | ||
|
||
|
||
|
||
public int level = 1; | ||
public int playerIndex = 0; | ||
public bool isPlaying = true; | ||
public int[] computerSequence; | ||
//int ComputerSequence [100]; | ||
//int PlayerSequence [100]; | ||
|
||
|
||
|
||
public int ButtonComp = 0; | ||
|
||
// Use this for initialization | ||
void Start () { | ||
computerSequence = new int[400]; | ||
for (int level = 0; level < 400; level++){ | ||
ButtonComp = Random.Range (0, 4); | ||
computerSequence[level] = ButtonComp; | ||
|
||
} | ||
|
||
} | ||
|
||
//RED | ||
|
||
public void red () { | ||
redButton.GetComponent<AudioSource> ().Play(); | ||
redButton.GetComponent<Image> ().color = new Color (1f, 0.45f, 0.45f); | ||
Invoke ("RedbuttonNormal", 1); | ||
|
||
if (isPlayer == true) { | ||
if (computerSequence [playerIndex] == 0) { | ||
playerIndex++; | ||
checkIfPlayerRight (); | ||
} else { | ||
GameOver (); | ||
} | ||
} | ||
} | ||
|
||
public void RedbuttonNormal () { | ||
redButton.GetComponent<Image> ().color = Color.red; | ||
} | ||
|
||
//GREEN | ||
|
||
public void green () { | ||
greenButton.GetComponent<AudioSource> ().Play(); | ||
greenButton.GetComponent<Image> ().color = new Color (0.369f, 0.875f, 0.431f); | ||
Invoke ("GreenbuttonNormal", 1); | ||
|
||
if (isPlayer == true) { | ||
if (computerSequence [playerIndex] == 1) { | ||
playerIndex++; | ||
checkIfPlayerRight (); | ||
} else { | ||
GameOver (); | ||
} | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
public void GreenbuttonNormal () { | ||
greenButton.GetComponent<Image> ().color = new Color (0.055f, 0.816f, 0.149f); | ||
} | ||
|
||
|
||
// YELLOW | ||
|
||
public void yellow () { | ||
yellowButton.GetComponent<AudioSource> ().Play(); | ||
yellowButton.GetComponent<Image> ().color = new Color (0.988f, 0.996f, 0.376f); | ||
Invoke ("YellowbuttonNormal", 1); | ||
|
||
if (isPlayer == true) { | ||
if (computerSequence [playerIndex] == 2) { | ||
playerIndex++; | ||
checkIfPlayerRight (); | ||
} else { | ||
GameOver (); | ||
} | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
public void YellowbuttonNormal () { | ||
yellowButton.GetComponent<Image> ().color = new Color (0.949f, 0.961f, 0f); | ||
} | ||
|
||
// Blue | ||
|
||
public void blue () { | ||
blueButton.GetComponent<AudioSource> ().Play(); | ||
blueButton.GetComponent<Image> ().color = new Color (0.42f, 0.325f, 0.945f); | ||
Invoke ("BluebuttonNormal", 1); | ||
|
||
if (isPlayer == true) { | ||
if (computerSequence [playerIndex] == 3) { | ||
playerIndex++; | ||
checkIfPlayerRight (); | ||
} else { | ||
GameOver (); | ||
} | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
public void BluebuttonNormal () { | ||
blueButton.GetComponent<Image> ().color = new Color (0.184f, 0.043f, 0.961f); | ||
} | ||
|
||
public void checkIfPlayerRight () { | ||
if (playerIndex == level) { | ||
level++; | ||
startGame (); | ||
playerIndex = 0; | ||
} | ||
} | ||
|
||
public void GameOver () { | ||
gameOverText.SetActive(true); | ||
} | ||
|
||
public void reStart () { | ||
gameOverText.SetActive(false); | ||
isPlayer = false; | ||
|
||
|
||
|
||
level = 1; | ||
playerIndex = 0; | ||
isPlaying = true; | ||
|
||
|
||
} | ||
|
||
|
||
public void startGame () { | ||
gameOverText.SetActive(false); | ||
isPlayer = false; | ||
for (int i = 0; i < level; i++) { | ||
if (computerSequence [i] == 0) { | ||
Invoke ("red", i+2); | ||
} | ||
|
||
if (computerSequence [i] == 1) { | ||
Invoke ("green", i+2); | ||
} | ||
|
||
if (computerSequence [i] == 2) { | ||
Invoke ("yellow", i+2); | ||
} | ||
|
||
if (computerSequence [i] == 3) { | ||
Invoke ("blue", i+2); | ||
} | ||
} | ||
Invoke ("isPlayerTest", level+2); | ||
|
||
} | ||
|
||
|
||
public void isPlayerTest () { | ||
isPlayer = true; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
// Update is called once per frame | ||
void Update () { | ||
|
||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.