RosimInc 7c4cef3a49 Added the word solving system.
Bug: After a player finishes the game, application will crash. Make sure winning scenario is handled.
Gameplay scene is gameplay_02.unity.
2016-01-30 19:30:39 -05:00

53 lines
843 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 (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;
}
}