Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simon Says with Script
  • Loading branch information
apw14002 committed Oct 18, 2016
1 parent 93ad6ce commit dd89bc0
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified Simon/Assets/.DS_Store
Binary file not shown.
Binary file modified Simon/Assets/Scenes/simon.unity
Binary file not shown.
Binary file modified SimonSays_Wolf.zip
Binary file not shown.
Binary file modified SimonSays_Wolf/.DS_Store
Binary file not shown.
200 changes: 200 additions & 0 deletions SimonSays_Wolf/Scripts/Simon.cs
@@ -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 () {


}
}
12 changes: 12 additions & 0 deletions SimonSays_Wolf/Scripts/Simon.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dd89bc0

Please sign in to comment.