public class Movement {
public string movementName { get; set; }
public List<int> keyTable { get; set; }
}
public class GameManager : MonoBehaviour {
List<Movement> movements = new List<Movement>()
{
new Movement()
{
movementName = "Shuffle_Up",
keyTable = new List<int>()
{
2,
4,
1,
6,
3,
8,
5,
7
}
},
/*new Movement()
{
movementName = "Shuffle_Down",
keyTable = new List<int>()
{
3,
1,
5,
2,
7,
4,
8,
6,
}
},*/
new Movement()
{
movementName = "Diagonal_Top",
keyTable = new List<int>()
{
8,
7,
3,
4,
5,
6,
2,
1,
}
}
};
public GameObject keySet;
public int shuffleCount;
public float shuffleTime;
public float shuffleSpeed;
List<int> keySlots = new List<int>()
{
0,
1,
2,
3,
4,
5,
6,
7
};
List<GameObject> keys = new List<GameObject>();
Color32 normalColour = new Color32(255, 255, 255, 255);
Color32 indicateColour = new Color32(0, 255, 0, 255);
void Start() {
for (int i = 0; i < keySet.transform.childCount; i++)
{
keys.Add(keySet.transform.GetChild(i).gameObject);
}
StartCoroutine(GameStart());
}
IEnumerator GameStart() {
yield return new WaitForSecondsRealtime(1f);
GameObject key = keys[Random.Range(0, keys.Count - 1)];
StartCoroutine(Lerp("colour", key, .5f, normalColour, indicateColour));
yield return new WaitForSecondsRealtime(1f);
StartCoroutine(Lerp("colour", key, .5f, indicateColour, normalColour));
yield return new WaitForSecondsRealtime(1f);
for (int i = 0; i < shuffleCount; i++)
{
Movement selectedMovement;
//Movement selectedMovement = movements[Random.Range(0, movements.Count)];
if (i % 2 == 0)
{
selectedMovement = movements[1];
}
else
{
selectedMovement = movements[0];
}
print(selectedMovement.movementName);
for (int c = 0; c < keys.Count; c++)
{
int nextPos = selectedMovement.keyTable[c] - 1;
//StartCoroutine(Lerp("movement", keys[keySlots[c]], shuffleSpeed, keys[keySlots[c]].transform.position, keys[keySlots[nextPos]].transform.position));
}
for (int c = 0; c < keySlots.Count; c++)
{
int newKey = selectedMovement.keyTable.IndexOf(keySlots[c] + 1);
keySlots[c] = newKey;
print(i + " " + (newKey + 1));
}
yield return new WaitForSecondsRealtime(shuffleTime);
}
}