|
|
@ -4,14 +4,140 @@ using UnityEngine; |
|
|
|
|
|
|
|
public class Ouija : Level |
|
|
|
{ |
|
|
|
public class Divination |
|
|
|
{ |
|
|
|
public string Question; |
|
|
|
public List<string> Answers = new List<string>(); |
|
|
|
}; |
|
|
|
|
|
|
|
public List<Divination> _divinations = new List<Divination>(); |
|
|
|
int _greenLettersCorrect = 0; |
|
|
|
int _redLettersCorrect = 0; |
|
|
|
string _question; |
|
|
|
string _greenAnswer; |
|
|
|
string _redAnswer; |
|
|
|
int _divinationNumber = -1; |
|
|
|
|
|
|
|
[SerializeField] UnityEngine.UI.Text _greenAnswerText; |
|
|
|
[SerializeField] UnityEngine.UI.Text _redAnswerText; |
|
|
|
[SerializeField] UnityEngine.UI.Text _questionText; |
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start() |
|
|
|
{ |
|
|
|
InitDivinations(); |
|
|
|
for (int i = 0; i < 3; ++i) |
|
|
|
{ |
|
|
|
_players[i].GetComponent<Player>().BecomeInvisible(); |
|
|
|
_players[i].GetComponent<Player>().PassInputOnto = _players[3].GetComponent<Player>(); |
|
|
|
} |
|
|
|
PickNewDivination(); |
|
|
|
RefreshText(); |
|
|
|
} |
|
|
|
|
|
|
|
void PickNewDivination() |
|
|
|
{ |
|
|
|
_redLettersCorrect = 0; |
|
|
|
_greenLettersCorrect = 0; |
|
|
|
_divinationNumber++; |
|
|
|
|
|
|
|
if (_divinationNumber >= _divinations.Count) |
|
|
|
_divinationNumber = 0; |
|
|
|
|
|
|
|
Divination div = _divinations[_divinationNumber]; |
|
|
|
_question = div.Question; |
|
|
|
_redAnswer = div.Answers[Random.Range(0, div.Answers.Count)]; |
|
|
|
div.Answers.Remove(_redAnswer); |
|
|
|
_greenAnswer = div.Answers[Random.Range(0, div.Answers.Count)]; |
|
|
|
|
|
|
|
_redAnswer = _redAnswer.ToUpper(); |
|
|
|
_greenAnswer = _greenAnswer.ToUpper(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void AddLetter(char letter) |
|
|
|
{ |
|
|
|
if (_redAnswer[_redLettersCorrect] == letter) |
|
|
|
{ |
|
|
|
_redLettersCorrect++; |
|
|
|
AddScore(10, 3); |
|
|
|
|
|
|
|
if (_redLettersCorrect == _redAnswer.Length) |
|
|
|
{ |
|
|
|
AddScore(30, 3); |
|
|
|
PickNewDivination(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (_greenAnswer[_greenLettersCorrect] == letter) |
|
|
|
{ |
|
|
|
_greenLettersCorrect++; |
|
|
|
AddScore(10, 1); |
|
|
|
|
|
|
|
if (_greenLettersCorrect == _greenAnswer.Length) |
|
|
|
{ |
|
|
|
AddScore(30, 1); |
|
|
|
PickNewDivination(); |
|
|
|
} |
|
|
|
} |
|
|
|
RefreshText(); |
|
|
|
} |
|
|
|
|
|
|
|
void RefreshText() |
|
|
|
{ |
|
|
|
_questionText.text = _question; |
|
|
|
|
|
|
|
_redAnswerText.text = ""; |
|
|
|
for (int i =0; i< _redAnswer.Length; ++i) |
|
|
|
{ |
|
|
|
if (i < _redLettersCorrect) |
|
|
|
{ |
|
|
|
_redAnswerText.text += _redAnswer[i]; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_redAnswerText.text += "_"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_greenAnswerText.text = ""; |
|
|
|
for (int i = 0; i < _greenAnswer.Length; ++i) |
|
|
|
{ |
|
|
|
if (i < _greenLettersCorrect) |
|
|
|
{ |
|
|
|
_greenAnswerText.text += _greenAnswer[i]; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_greenAnswerText.text += "_"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void InitDivinations() |
|
|
|
{ |
|
|
|
Divination div = new Divination(); |
|
|
|
div.Question = "How will we die?"; |
|
|
|
div.Answers.Add("Trainwreck"); |
|
|
|
div.Answers.Add("Decapitation"); |
|
|
|
div.Answers.Add("Poisoning"); |
|
|
|
div.Answers.Add("Asphyxiation"); |
|
|
|
//div.Answers.Add("Senescence");
|
|
|
|
div.Answers.Add("Overeating"); |
|
|
|
_divinations.Add(div); |
|
|
|
|
|
|
|
div = new Divination(); |
|
|
|
div.Question = "How animal we will be in our next life?"; |
|
|
|
div.Answers.Add("Unicorn"); |
|
|
|
div.Answers.Add("Wombat"); |
|
|
|
div.Answers.Add("Anteater"); |
|
|
|
div.Answers.Add("Goldfinch"); |
|
|
|
div.Answers.Add("Alpaca"); |
|
|
|
div.Answers.Add("Dachshund"); |
|
|
|
div.Answers.Add("Meerkat"); |
|
|
|
div.Answers.Add("Capybara"); |
|
|
|
_divinations.Add(div); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|