diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9e17579 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +curly_bracket_next_line = false +spaces_around_operators = true + +[*.cs] +indent_size = 4 + +[*.{markdown,md}] +trim_trailing_whitespace = false diff --git a/Assets/Scripts/GameMasterManager.cs b/Assets/Scripts/GameMasterManager.cs index 9d01397..5675ff3 100644 --- a/Assets/Scripts/GameMasterManager.cs +++ b/Assets/Scripts/GameMasterManager.cs @@ -6,8 +6,8 @@ using UnityEngine; using UnityEngine.UI; -public class GameMasterManager : MonoBehaviour -{ +public class GameMasterManager : MonoBehaviour { + public StateMachine controller; public GameObject mainMenu, gameMenu, optionsMenu; public WordGridManager gridManger; @@ -19,7 +19,6 @@ public class GameMasterManager : MonoBehaviour public Button dailyButton; public GameObject Tutorial; - public void Quit() { Application.Quit(); } @@ -59,8 +58,6 @@ private void Start() { if (!gridManger.HasInt(WordGridManager.MONTH)) gridManger.SetInt(WordGridManager.MONTH, 0); if (!gridManger.HasInt(WordGridManager.YEAR)) gridManger.SetInt(WordGridManager.YEAR, 0); - - controller = new StateMachine(new MainMenuState(), this); GoToMainMenu(); GetWord(); @@ -93,11 +90,8 @@ public void DailyCheck() { dailySeed = v.GetHashCode(); } dailyTimerText.gameObject.SetActive(DailyDisabled); - - } - public void OpenTutorial() { Tutorial.SetActive(true); } @@ -112,13 +106,11 @@ public void CloseTutorial() { public static Dictionary> answerWords = new Dictionary>(); public static bool initYet = false; - public TMP_Dropdown dropDown, numberOfGuessesDropDown; public List wordbanks = new List(); public string GetWord() { - if (!initYet) { InitializeWordBanks(); } @@ -126,53 +118,19 @@ public string GetWord() { return commonWords[selectedLength].PickRandom(); } - public void SetLength(int i) { - if (i == 0) { - selectedLength = 1; - } else if (i == 1) { - selectedLength = 2; - } else if (i == 2) { - selectedLength = 3; - } else if ( i == 3) { - selectedLength = 4; - } else if (i == 4) { - selectedLength = 5; - } else if (i == 5) { - selectedLength = 6; - } else if (i == 6) { - selectedLength = 7; - } else if (i == 7) { - selectedLength = 8; + if (i >= 0 && i <= 7) { + selectedLength = i + 1; } - gridManger.SetInt(WordGridManager.SELECTEDLENGTH, i); } public void SetNumberOfGuesses(int i) { - if (i == 0) { - numberOfGuesses = 1; - } else if (i == 1) { - numberOfGuesses = 2; - } else if (i == 2) { - numberOfGuesses = 3; - } else if (i == 3) { - numberOfGuesses = 4; - } else if (i == 4) { - numberOfGuesses = 5; - } else if (i == 5) { - numberOfGuesses = 6; - } else if (i == 6) { - numberOfGuesses = 7; - } else if (i == 7) { - numberOfGuesses = 8; - } else if (i == 8) { - numberOfGuesses = 9; - } else if (i == 9) { - numberOfGuesses = 10; + if (i >= 0 && i <= 9) { + numberOfGuesses = i + 1; } gridManger.SetInt(WordGridManager.NUMBEROFGUESSES, i); @@ -182,8 +140,8 @@ public void SetNumberOfGuesses(int i) { public void InitializeWordBanks() { commonWords = new Dictionary>(); answerWords = new Dictionary>(); - foreach (WordBank b in wordbanks) { + foreach (WordBank b in wordbanks) { int len = b.wordLength; if (!commonWords.ContainsKey(len)) { commonWords.Add(len, new List()); @@ -195,7 +153,6 @@ public void InitializeWordBanks() { string contents = b.commonWordText.text; string[] w = contents.Split("\n"); foreach (string s in w) { - //print(s); string sss = s.ToUpper(); sss = sss.Substring(0, b.wordLength); commonWords[len].Add(sss); @@ -206,7 +163,6 @@ public void InitializeWordBanks() { contents = b.answerWordText.text; w = contents.Split("\n"); foreach (string s in w) { - // print(s); string sss = s.ToUpper(); sss = sss.Substring(0, b.wordLength); answerWords[len].Add(sss); @@ -217,22 +173,16 @@ public void InitializeWordBanks() { initYet = true; } - - public static string jsonSaveFileName = "LASTPUZZLE.json"; - public string GetLastPuzzleSavePath() { return Application.persistentDataPath +"/"+ jsonSaveFileName; } public LastPuzzle GetDefaultLastPuzzle() { - - LastPuzzle last = new LastPuzzle(); last.grid = new WORDBUTTONSTATE[5, 6]; return last; - } public GridLayoutGroup gridgroup; @@ -241,7 +191,6 @@ public LastPuzzle GetDefaultLastPuzzle() { public List spawnedImages = new List(); public void GetLastPuzzleForDisplay() { - LastPuzzle puzzle = null; if (File.Exists(GetLastPuzzleSavePath())) { @@ -289,12 +238,8 @@ public void GetLastPuzzleForDisplay() { } } } - - } - - public void SetHardMode(bool b) { gridManger.SetBool(WordGridManager.HARDMODE, b); } @@ -313,18 +258,12 @@ public void InitializeStringVars(List s) { public void SetStringVars(List s, int val) { foreach (string ss in s) { - gridManger.SetInt(ss, val); + gridManger.SetInt(ss, val); } } - private void Update() { controller.Update(); - - - - - } public void HideAll() { @@ -365,11 +304,7 @@ public void GoToGameplayMenu(bool isDaily) { } public void DeleteProgress() { - SetStringVars(new List() { WordGridManager.CURRENTSTREAK, WordGridManager.LARGESTSTREAK, WordGridManager.NUMBEROFPUZZLESPLAYED, WordGridManager.NUMBERWINS, WordGridManager.WIN1, WordGridManager.WIN2, WordGridManager.WIN3, WordGridManager.WIN4, WordGridManager.WIN5, WordGridManager.WIN6, WordGridManager.DAY, WordGridManager.MONTH, WordGridManager.YEAR }, 0); - - - } public void SaveLastPuzzle(LastPuzzle l) { @@ -410,17 +345,7 @@ public class OptionsState : State { } - - [System.Serializable] public class LastPuzzle { - - public WORDBUTTONSTATE[,] grid; - - } - - - - diff --git a/Assets/Scripts/TitleSetter.cs b/Assets/Scripts/TitleSetter.cs index 5c62b7e..ee9d8e7 100644 --- a/Assets/Scripts/TitleSetter.cs +++ b/Assets/Scripts/TitleSetter.cs @@ -3,12 +3,11 @@ using UnityEngine; using TMPro; -public class TitleSetter : MonoBehaviour -{ +public class TitleSetter : MonoBehaviour { + public List textMeshProUGUIs = new List(); public string title = "Word Game"; - private void Awake() { foreach (TextMeshProUGUI t in textMeshProUGUIs) { t.SetText(title); diff --git a/Assets/Scripts/WordRow.cs b/Assets/Scripts/WordRow.cs index 022f5e7..a9ce46b 100644 --- a/Assets/Scripts/WordRow.cs +++ b/Assets/Scripts/WordRow.cs @@ -15,6 +15,7 @@ public class WordRow : MonoBehaviour { public float shakeAmount = 50f; public float shakeSpeed = 200f; public float currentTarget = 0; + public void Shake() { shaking = true; stopshaketime = Time.time + shakeTime; @@ -36,7 +37,7 @@ private void Update() { MoveTowardsTarget(); } } - } + } } public void MoveTowardsZeroX() {