Hello!
I am following a tutorial named Simon Says, - YouTube
However I am stuck at 34-ish minutes. I have done everything the person said in the video however mine doesn’t do what his does. Could anyone help me out?
(http://wtrns.fr/hdz-yb1f1aujL1c you can download my files here, I used WeTransfer).
EDIT: In the video it shows that I can now press a button, all of them should light up. however in my project it doesn’t light up nor can I press on any of the 4 buttons.
Code 1 named ‘SimonSays’
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
struct SimonLightPlate
{
public enum eType
{
INVALID_TYPE = -1,
BLUE,
GREEN,
RED,
YELLOW,
NUM_TYPES
}
public SimonLightPlate( string plateName )
{
plate = GameObject.Find (plateName);
}
public GameObject plate; //The plate associated with the colors.
}
public class SimonSays : MonoBehaviour
{
SimonLightPlate[] lightPlates = new SimonLightPlate[(int)SimonLightPlate.eType.NUM_TYPES];
enum eState
{
INVALID_STATE = -1,
THINKING,
DISPLAY_SEQUENCE,
WAITING_FOR_USER,
NUM_STATES
}
eState currentState = eState.INVALID_STATE;
List<int> sequence = new List<int>(100); // hold the sequence
int sequenceCount = 0; //The counter for which index of the sequence we're currently showing
List<int> clickedSequence = new List<int>(100);
// Use this for initialization
void Start ()
{
lightPlates[(int)SimonLightPlate.eType.BLUE] = new SimonLightPlate("BluePlane");
lightPlates[(int)SimonLightPlate.eType.GREEN] = new SimonLightPlate("GreenPlane");
lightPlates[(int)SimonLightPlate.eType.YELLOW] = new SimonLightPlate("YellowPlane");
lightPlates[(int)SimonLightPlate.eType.RED] = new SimonLightPlate("RedPlane");
}
void OnLeftClickDown(SimonLightPlate.eType color)
{
lightPlates[(int)color].plate.renderer.enabled = true;
}
// Update is called once per frame
void Update ()
{
}
void ResetGame()
{
}
}
Code 2 named ‘ColorPlateClickHandler’
using UnityEngine;
using System.Collections;
public class ColorPlateClickHandler : MonoBehaviour
{
void OnMouseOver()
{
//Handle left mouse click.
if (Input.GetMouseButtonDown(0))
{
SimonLightPlate.eType colorPlate = SimonLightPlate.eType.INVALID_TYPE;
if (this.name == "BlueClickPlane")
{
colorPlate = SimonLightPlate.eType.BLUE;
}
else if (this.name == "RedClickPlane")
{
colorPlate = SimonLightPlate.eType.RED;
}
else if (this.name == "YellowClickPlane")
{
colorPlate = SimonLightPlate.eType.YELLOW;
}
else if (this.name == "GreenClickPlane")
{
colorPlate = SimonLightPlate.eType.GREEN;
}
this.SendMessageUpwards("OnLeftClickDown", colorPlate, SendMessageOptions.DontRequireReceiver);
}
}
void OnMouseUp()
{
if (Input.GetMouseButtonUp(0))
{
this.SendMessageUpwards("OnLeftClickUp", this.name, SendMessageOptions.DontRequireReceiver);
}
}
}