private void Initialize() { AudioListener.volume = 0.3f; if (_instance != this) { Destroy(gameObject); return; } DungeonSeed = new System.Random((int)System.DateTime.UtcNow.Ticks).Next(int.MinValue, int.MaxValue); PlayerHealth = 1; PlayerMagic = 1; PlayerExperience = 0; ReminderSymbolRow = new SymbolRow(); CollectedSymbolRow = new SymbolRow(); CollectedSymbolRow.Clear(); PuzzleHistoryRows = new List <HistoryRow>(); CorrectSymbolRow = new SymbolRow(); GenerateCorrectSymbolRow(); DontDestroyOnLoad(gameObject); }
private string[] GenerateHints(SymbolRow collectedSymbolRow) { var hints = new List <string>(); var correctSymbolsToHandle = CorrectSymbolRow.Symbols.ToList(); var currentSymbolsToHandle = collectedSymbolRow.Symbols.ToList(); var correctLineSelection = CorrectSymbolRow.Symbols.Select((value, i) => new { i, value }); // Check for full on correct positions foreach (var item in correctLineSelection) { if (item.value == collectedSymbolRow.Symbols[item.i]) { hints.Add("X"); correctSymbolsToHandle.Remove(item.value); currentSymbolsToHandle.Remove(item.value); } } // Check for correct symbol but wrong position foreach (var item in correctLineSelection.Where(x => correctSymbolsToHandle.Any(y => y == x.value))) { if (collectedSymbolRow.Symbols.Where(x => currentSymbolsToHandle.Any(y => y == x)).Any(x => x == item.value)) { hints.Add("O"); correctSymbolsToHandle.Remove(item.value); currentSymbolsToHandle.Remove(item.value); } } // Check for correct character foreach (var item in correctLineSelection.Where(x => correctSymbolsToHandle.Any(y => y == x.value))) { if (collectedSymbolRow.Symbols.Where(x => currentSymbolsToHandle.Any(y => y == x)).Any(x => x[0] == item.value[0])) { hints.Add("C"); correctSymbolsToHandle.Remove(item.value); currentSymbolsToHandle.Remove(item.value); } } // Check for correct number foreach (var item in correctLineSelection.Where(x => correctSymbolsToHandle.Any(y => y == x.value))) { if (collectedSymbolRow.Symbols.Where(x => currentSymbolsToHandle.Any(y => y == x)).Any(x => x[1] == item.value[1])) { hints.Add("N"); correctSymbolsToHandle.Remove(item.value); currentSymbolsToHandle.Remove(item.value); } } return(hints.ToArray()); }