fixed wordle
Some checks failed
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (push) Waiting to run
Build project / Publish to itch.io (StandaloneLinux64) (push) Blocked by required conditions
Build project / Publish to itch.io (StandaloneWindows64) (push) Blocked by required conditions
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (push) Has been cancelled
Some checks failed
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (push) Waiting to run
Build project / Publish to itch.io (StandaloneLinux64) (push) Blocked by required conditions
Build project / Publish to itch.io (StandaloneWindows64) (push) Blocked by required conditions
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (push) Has been cancelled
This commit is contained in:
parent
3288b328d8
commit
cba7033371
24
Assets/Puzzles/Word Puzzle/Scripts/TabletToggle.cs
Normal file
24
Assets/Puzzles/Word Puzzle/Scripts/TabletToggle.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
using TMPro;
|
||||||
|
|
||||||
|
public class TabletToggle : MonoBehaviour
|
||||||
|
{
|
||||||
|
public GameObject tablet;
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (Input.GetKeyDown(KeyCode.T))
|
||||||
|
{
|
||||||
|
TMP_InputField inputField = null;
|
||||||
|
if (EventSystem.current != null && EventSystem.current.currentSelectedGameObject != null)
|
||||||
|
{
|
||||||
|
inputField = EventSystem.current.currentSelectedGameObject.GetComponent<TMP_InputField>();
|
||||||
|
}
|
||||||
|
if (inputField != null && inputField.isFocused)
|
||||||
|
return;
|
||||||
|
|
||||||
|
tablet.SetActive(!tablet.activeSelf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
Assets/Puzzles/Word Puzzle/Scripts/TabletToggle.cs.meta
Normal file
2
Assets/Puzzles/Word Puzzle/Scripts/TabletToggle.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1f363690cf70e6449a55d819bd9503b6
|
@ -17,11 +17,9 @@ public enum WGameState
|
|||||||
public class WordPuzzle : MonoBehaviour
|
public class WordPuzzle : MonoBehaviour
|
||||||
{
|
{
|
||||||
private TMP_Text[] allLetterTexts;
|
private TMP_Text[] allLetterTexts;
|
||||||
private List<TMP_Text> usedLetterTexts = new List<TMP_Text>();
|
|
||||||
private List<string> words = new List<string>();
|
private List<string> words = new List<string>();
|
||||||
private int currentCount;
|
private int currentCount;
|
||||||
private int currentSubmit = 0;
|
private int currentSubmit = 0;
|
||||||
|
|
||||||
public GameObject congratulations;
|
public GameObject congratulations;
|
||||||
public GameObject retry;
|
public GameObject retry;
|
||||||
public TMP_Text retryText;
|
public TMP_Text retryText;
|
||||||
@ -30,7 +28,6 @@ public class WordPuzzle : MonoBehaviour
|
|||||||
public Color wrongColor = Color.red;
|
public Color wrongColor = Color.red;
|
||||||
public string currentWord = string.Empty;
|
public string currentWord = string.Empty;
|
||||||
public WGameState gameState = WGameState.Uninitialized;
|
public WGameState gameState = WGameState.Uninitialized;
|
||||||
|
|
||||||
[SerializeField] private TextAsset textAsset = null;
|
[SerializeField] private TextAsset textAsset = null;
|
||||||
public AudioClip loseSound;
|
public AudioClip loseSound;
|
||||||
public AudioClip winSound;
|
public AudioClip winSound;
|
||||||
@ -40,15 +37,14 @@ public class WordPuzzle : MonoBehaviour
|
|||||||
allLetterTexts = GetComponentsInChildren<TMP_Text>();
|
allLetterTexts = GetComponentsInChildren<TMP_Text>();
|
||||||
foreach (var text in allLetterTexts)
|
foreach (var text in allLetterTexts)
|
||||||
{
|
{
|
||||||
text.text = string.Empty;
|
text.text = "";
|
||||||
|
text.color = Color.white;
|
||||||
}
|
}
|
||||||
|
words = Regex.Split(textAsset.text, Environment.NewLine)
|
||||||
words = Regex.Split(textAsset.text, Environment.NewLine).ToList();
|
.Where(x => !string.IsNullOrEmpty(x))
|
||||||
if (string.IsNullOrEmpty(currentWord)) {
|
.Select(x => x.Trim().ToLower())
|
||||||
currentWord = words[UnityEngine.Random.Range(0, words.Count)];
|
.ToList();
|
||||||
Debug.Log("Chosen random word: " + currentWord);
|
ResetPuzzle();
|
||||||
}
|
|
||||||
gameState = WGameState.Uninitialized;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
@ -89,57 +85,69 @@ public class WordPuzzle : MonoBehaviour
|
|||||||
|
|
||||||
public void StartGame(string overrideWord)
|
public void StartGame(string overrideWord)
|
||||||
{
|
{
|
||||||
currentWord = overrideWord;
|
currentWord = overrideWord.ToLower();
|
||||||
ResetPuzzle();
|
ResetPuzzle();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveChar()
|
private void RemoveChar()
|
||||||
{
|
{
|
||||||
if (!usedLetterTexts.Any() || currentCount <= 0)
|
if (currentCount <= 0) return;
|
||||||
return;
|
int index = currentSubmit * 5 + (currentCount - 1);
|
||||||
|
if (index < 0 || index >= allLetterTexts.Length) return;
|
||||||
usedLetterTexts.Last().text = string.Empty;
|
allLetterTexts[index].text = "";
|
||||||
usedLetterTexts.RemoveAt(usedLetterTexts.Count - 1);
|
allLetterTexts[index].color = Color.white;
|
||||||
currentCount--;
|
currentCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoKeyPress(char character)
|
private void DoKeyPress(char character)
|
||||||
{
|
{
|
||||||
if (usedLetterTexts.Count >= allLetterTexts.Length || currentCount >= 5)
|
if (currentCount >= 5) return;
|
||||||
return;
|
int index = currentSubmit * 5 + currentCount;
|
||||||
|
if (index < allLetterTexts.Length)
|
||||||
var currentText = allLetterTexts[usedLetterTexts.Count];
|
{
|
||||||
currentText.text = character.ToString();
|
allLetterTexts[index].text = character.ToString();
|
||||||
usedLetterTexts.Add(currentText);
|
|
||||||
currentCount++;
|
currentCount++;
|
||||||
|
if (currentCount == 5)
|
||||||
|
{
|
||||||
|
SubmitButtonClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SubmitButtonClick()
|
private void SubmitButtonClick()
|
||||||
{
|
{
|
||||||
if (currentCount != 5)
|
if (currentCount != 5) return;
|
||||||
|
string submittedWord = "";
|
||||||
|
for (int i = currentSubmit * 5; i < currentSubmit * 5 + 5; i++)
|
||||||
|
{
|
||||||
|
submittedWord += allLetterTexts[i].text;
|
||||||
|
}
|
||||||
|
submittedWord = submittedWord.ToLower();
|
||||||
|
if (!words.Contains(submittedWord))
|
||||||
|
{
|
||||||
|
for (int i = currentSubmit * 5; i < currentSubmit * 5 + 5; i++)
|
||||||
|
{
|
||||||
|
allLetterTexts[i].text = "";
|
||||||
|
allLetterTexts[i].color = Color.white;
|
||||||
|
}
|
||||||
|
currentCount = 0;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var submittedWord = string.Empty;
|
|
||||||
int ii = 0;
|
|
||||||
for (int i = 0 + (currentSubmit * 5); i < usedLetterTexts.Count; i++)
|
|
||||||
{
|
|
||||||
TMP_Text texts = usedLetterTexts[i];
|
|
||||||
var textsChar = char.Parse(texts.text);
|
|
||||||
submittedWord += textsChar;
|
|
||||||
|
|
||||||
texts.color = wrongColor;
|
|
||||||
if (currentWord.Contains(textsChar))
|
|
||||||
{
|
|
||||||
texts.color = inWordColor;
|
|
||||||
if (textsChar == currentWord[ii])
|
|
||||||
texts.color = perfectMatchColor;
|
|
||||||
}
|
}
|
||||||
ii++;
|
for (int i = currentSubmit * 5; i < currentSubmit * 5 + 5; i++)
|
||||||
}
|
|
||||||
|
|
||||||
if (words.Contains(submittedWord))
|
|
||||||
{
|
{
|
||||||
if(submittedWord == currentWord)
|
char letter = char.ToLower(allLetterTexts[i].text[0]);
|
||||||
|
allLetterTexts[i].color = wrongColor;
|
||||||
|
if (currentWord.Contains(letter))
|
||||||
|
{
|
||||||
|
allLetterTexts[i].color = inWordColor;
|
||||||
|
int pos = i - (currentSubmit * 5);
|
||||||
|
if (letter == currentWord[pos])
|
||||||
|
{
|
||||||
|
allLetterTexts[i].color = perfectMatchColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (submittedWord == currentWord)
|
||||||
{
|
{
|
||||||
congratulations.SetActive(true);
|
congratulations.SetActive(true);
|
||||||
SetGameState(WGameState.Win);
|
SetGameState(WGameState.Win);
|
||||||
@ -148,17 +156,7 @@ public class WordPuzzle : MonoBehaviour
|
|||||||
}
|
}
|
||||||
currentSubmit++;
|
currentSubmit++;
|
||||||
currentCount = 0;
|
currentCount = 0;
|
||||||
}
|
if (currentSubmit == 6)
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int i = 0 + (currentSubmit * 5); i < usedLetterTexts.Count; i++)
|
|
||||||
{
|
|
||||||
TMP_Text texts = usedLetterTexts[i];
|
|
||||||
texts.color = Color.white;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(currentSubmit == 6)
|
|
||||||
{
|
{
|
||||||
retry.SetActive(true);
|
retry.SetActive(true);
|
||||||
retryText.text = currentWord;
|
retryText.text = currentWord;
|
||||||
@ -172,18 +170,16 @@ public class WordPuzzle : MonoBehaviour
|
|||||||
allLetterTexts = GetComponentsInChildren<TMP_Text>();
|
allLetterTexts = GetComponentsInChildren<TMP_Text>();
|
||||||
retry.SetActive(false);
|
retry.SetActive(false);
|
||||||
congratulations.SetActive(false);
|
congratulations.SetActive(false);
|
||||||
usedLetterTexts.Clear();
|
foreach (var text in allLetterTexts)
|
||||||
foreach (var texts in allLetterTexts)
|
|
||||||
{
|
{
|
||||||
texts.text = string.Empty;
|
text.text = "";
|
||||||
texts.color = Color.white;
|
text.color = Color.white;
|
||||||
}
|
}
|
||||||
currentSubmit = 0;
|
currentSubmit = 0;
|
||||||
currentCount = 0;
|
currentCount = 0;
|
||||||
if (string.IsNullOrEmpty(currentWord)) {
|
|
||||||
currentWord = words[UnityEngine.Random.Range(0, words.Count)];
|
currentWord = words[UnityEngine.Random.Range(0, words.Count)];
|
||||||
|
currentWord = currentWord.ToLower();
|
||||||
Debug.Log("Chosen random word: " + currentWord);
|
Debug.Log("Chosen random word: " + currentWord);
|
||||||
}
|
|
||||||
SetGameState(WGameState.Playing);
|
SetGameState(WGameState.Playing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19334,6 +19334,8 @@ MonoBehaviour:
|
|||||||
keyCardName: move rack
|
keyCardName: move rack
|
||||||
keyCardPlayer: {fileID: 0}
|
keyCardPlayer: {fileID: 0}
|
||||||
interactionDistance: 5
|
interactionDistance: 5
|
||||||
|
keyCardItem: {fileID: 0}
|
||||||
|
playerInventory: {fileID: 0}
|
||||||
--- !u!65 &1050845135
|
--- !u!65 &1050845135
|
||||||
BoxCollider:
|
BoxCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -24105,6 +24107,51 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 69125d056127da746a8a1ed8371ea8d6, type: 3}
|
m_Script: {fileID: 11500000, guid: 69125d056127da746a8a1ed8371ea8d6, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!1 &1328799368
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1328799370}
|
||||||
|
- component: {fileID: 1328799369}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: TabletToggleManager
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &1328799369
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1328799368}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 1f363690cf70e6449a55d819bd9503b6, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
tablet: {fileID: 0}
|
||||||
|
--- !u!4 &1328799370
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1328799368}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0.88123596, y: 23.22024, z: -4.681444}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &1339936851
|
--- !u!1 &1339936851
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -37444,6 +37491,8 @@ MonoBehaviour:
|
|||||||
keyCardName: move rack
|
keyCardName: move rack
|
||||||
keyCardPlayer: {fileID: 0}
|
keyCardPlayer: {fileID: 0}
|
||||||
interactionDistance: 5
|
interactionDistance: 5
|
||||||
|
keyCardItem: {fileID: 0}
|
||||||
|
playerInventory: {fileID: 0}
|
||||||
--- !u!65 &2090030717
|
--- !u!65 &2090030717
|
||||||
BoxCollider:
|
BoxCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -39966,6 +40015,8 @@ MonoBehaviour:
|
|||||||
keyCardName: Deck C key card
|
keyCardName: Deck C key card
|
||||||
keyCardPlayer: {fileID: 7685886779921947557}
|
keyCardPlayer: {fileID: 7685886779921947557}
|
||||||
interactionDistance: 5
|
interactionDistance: 5
|
||||||
|
keyCardItem: {fileID: 0}
|
||||||
|
playerInventory: {fileID: 0}
|
||||||
--- !u!114 &4244626406387182888
|
--- !u!114 &4244626406387182888
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -40787,7 +40838,7 @@ Transform:
|
|||||||
m_GameObject: {fileID: 7094977339719025836}
|
m_GameObject: {fileID: 7094977339719025836}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: -0, y: -0.6649941, z: -0, w: 0.7468486}
|
m_LocalRotation: {x: -0, y: -0.6649941, z: -0, w: 0.7468486}
|
||||||
m_LocalPosition: {x: -49.75, y: -9.26, z: 23.94}
|
m_LocalPosition: {x: -49.75, y: 7.59, z: 28.33}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children:
|
m_Children:
|
||||||
@ -41749,3 +41800,4 @@ SceneRoots:
|
|||||||
- {fileID: 171829751}
|
- {fileID: 171829751}
|
||||||
- {fileID: 1766395669}
|
- {fileID: 1766395669}
|
||||||
- {fileID: 1232642964}
|
- {fileID: 1232642964}
|
||||||
|
- {fileID: 1328799370}
|
||||||
|
Loading…
Reference in New Issue
Block a user