Resolve WES-75 "Hangman integration"
This commit is contained in:
committed by
Dries Van Schuylenbergh
parent
f9298a055a
commit
f835adaa23
@@ -110,11 +110,6 @@ public class HangmanGameController : MonoBehaviour
|
||||
/// </summary>
|
||||
private int mode;
|
||||
|
||||
/// <summary>
|
||||
/// We give the controller access to the webcam so that it can toggle between the two displays effectivelly.
|
||||
/// </summary>
|
||||
public HangManWebcam webcam;
|
||||
|
||||
// The following attributes are necessary to finish and gameover
|
||||
|
||||
/// <summary>
|
||||
@@ -200,14 +195,27 @@ public class HangmanGameController : MonoBehaviour
|
||||
/// </summary>
|
||||
public GameObject scoreboardEntry;
|
||||
|
||||
/// <summary>
|
||||
/// Accuracy feeback object
|
||||
/// </summary>
|
||||
public Feedback feedback;
|
||||
|
||||
/// <summary>
|
||||
/// The button to go into the game
|
||||
/// </summary>
|
||||
public GameObject gottogamebutton;
|
||||
|
||||
/// <summary>
|
||||
/// Current sign out of the predictor
|
||||
/// </summary>
|
||||
private String currentsign = "";
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
// Make sure the mode starts at zero
|
||||
mode = 0;
|
||||
|
||||
// Make sure that the webcam is turned off
|
||||
webcam.StopCam();
|
||||
|
||||
// Make sure that only the player-selection panel is the one shown
|
||||
gamePanel.SetActive(false);
|
||||
@@ -226,6 +234,16 @@ public class HangmanGameController : MonoBehaviour
|
||||
user.minigames.Add(progress);
|
||||
}
|
||||
userList.Save();
|
||||
|
||||
// Set calllbacks
|
||||
feedback.getSignCallback = () =>
|
||||
{
|
||||
return "A";
|
||||
};
|
||||
feedback.predictSignCallback = (sign) =>
|
||||
{
|
||||
currentsign = sign;
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -271,10 +289,6 @@ public class HangmanGameController : MonoBehaviour
|
||||
currentWord = "";
|
||||
inputTextField.text = currentWord.ToString();
|
||||
|
||||
// Switch to the P1-display and Turn the webcam on
|
||||
webcam.Switch_texture();
|
||||
webcam.PlayCam();
|
||||
|
||||
// Activate the right panel
|
||||
gamePanel.SetActive(false);
|
||||
inputPanel.SetActive(true);
|
||||
@@ -288,9 +302,6 @@ public class HangmanGameController : MonoBehaviour
|
||||
// This word is used for testing before dynamic word-fetching is added
|
||||
PickRandomWord();
|
||||
|
||||
// Turn the webcam on
|
||||
webcam.PlayCam();
|
||||
|
||||
StartGame();
|
||||
}
|
||||
/// <summary>
|
||||
@@ -320,10 +331,7 @@ public class HangmanGameController : MonoBehaviour
|
||||
public void TwoPlayer()
|
||||
{
|
||||
if (currentWord.Length >= 2)
|
||||
{
|
||||
// Switch display to the P2-display
|
||||
webcam.Switch_texture();
|
||||
|
||||
{
|
||||
StartGame();
|
||||
}
|
||||
}
|
||||
@@ -334,7 +342,14 @@ public class HangmanGameController : MonoBehaviour
|
||||
public void Update()
|
||||
{
|
||||
if(mode == 1)
|
||||
{
|
||||
{
|
||||
if (currentsign != "")
|
||||
{
|
||||
char letter = currentsign.ToLower()[0];
|
||||
currentsign = "";
|
||||
currentWord = currentWord + letter.ToString();
|
||||
inputTextField.text = currentWord.ToString();
|
||||
}
|
||||
// We are in the word-input mode
|
||||
// We want to show the user what they are typing
|
||||
// Check to make sure the inputfield is not empty
|
||||
@@ -357,7 +372,7 @@ public class HangmanGameController : MonoBehaviour
|
||||
inputTextField.text = currentWord.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
gottogamebutton.SetActive(currentWord.Length >2);
|
||||
}
|
||||
|
||||
if (mode == 2)
|
||||
@@ -369,9 +384,10 @@ public class HangmanGameController : MonoBehaviour
|
||||
// For the first input char given by the user, check if the letter is in the word that needs to be spelled.
|
||||
|
||||
// Check to make sure the inputfield is not empty
|
||||
if (Input.inputString != "")
|
||||
if (currentsign != "")
|
||||
{
|
||||
char firstLetter = Input.inputString.ToLower()[0];
|
||||
char firstLetter = currentsign.ToLower()[0];
|
||||
currentsign = "";
|
||||
// Check if the letter is a valid guess and that it has not been guessed before
|
||||
if (!guesses.Contains(firstLetter) && guessables.Contains(firstLetter))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user