mirror of
https://github.com/ConjureETS/OuijaMTLGJ2016.git
synced 2026-03-24 10:11:07 +00:00
55 lines
916 B
C#
55 lines
916 B
C#
using UnityEngine;
|
|
|
|
public class Player {
|
|
|
|
public int num;
|
|
public int[] letters;
|
|
public int index = 0;
|
|
public int score = 0;
|
|
|
|
public Player(int num)
|
|
{
|
|
this.num = num;
|
|
}
|
|
|
|
public void SetWord(string str)
|
|
{
|
|
letters = new int[str.Length];
|
|
for (int i = 0; i < str.Length; i++)
|
|
{
|
|
letters[i] = (int)(str[i] - 'A');
|
|
}
|
|
/*Debug.Log("Player " + num + " has:");
|
|
foreach (int i in letters)
|
|
{
|
|
Debug.Log(i);
|
|
}*/
|
|
}
|
|
|
|
public void SetWord(int[] letters)
|
|
{
|
|
this.letters = letters;
|
|
}
|
|
|
|
public bool hasNextLetter(int letterNum)
|
|
{
|
|
if (index < 0 || index >= letters.Length) return false;
|
|
|
|
if (letters[index] == letterNum)
|
|
{
|
|
index++;
|
|
Debug.Log("Player " + num + " uncovered their " + index + "th letter");
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool hasWon()
|
|
{
|
|
return index >= letters.Length;
|
|
}
|
|
}
|