private void SetCharacterAsHint(char character, int index) { for (int i = 0; i < characterButtons.Length; i++) { KeyDoorCharacterButton characterButton = characterButtons[i]; if (characterButton.character == character && characterButton.characterButton.interactable) { characterButton.SetToHint(); break; } } KeyDoorCharacterFill keyDoorCharacterFill = keyDoorCharacterFillList[index]; keyDoorCharacterFill.SetUpKeyDoorCharacterFill(character, true); }
public void OnRefreshButtonClick() { for (int i = 0; i < filledIndex.Count; i++) { int index = filledIndex[i]; KeyDoorCharacterButton characterButton = characterButtons[index]; characterButton.ResetOnRefresh(); } for (int i = 0; i < keyDoorCharacterFillList.Count; i++) { KeyDoorCharacterFill keyDoorCharacterFill = keyDoorCharacterFillList[i]; if (!keyDoorCharacterFill.fix) { keyDoorCharacterFill.Reset(); } } }
private void SetUpCharacterButtons(HLHWord word) { filledIndex.Clear(); char[] characters = word.spell.ToCharArray(); List <int> allIndex = new List <int> { 0, 1, 2, 3, 4, 5, 6, 7 }; // 生成一个列表,后面用于打乱字母顺序 List <int> charIndexList = new List <int>(); // 生成一个数组,用于存放字母顺序打乱后的字母序号信息 int[] charIndexArray = new int[word.wordLength]; // 8个可用位置中选出单词长度数量的位置 for (int i = 0; i < word.wordLength; i++) { int randomSeed = Random.Range(0, allIndex.Count); int index = allIndex[randomSeed]; filledIndex.Add(index); allIndex.RemoveAt(randomSeed); charIndexList.Add(i); } // 组成单词的字母打成乱序 for (int i = 0; i < word.wordLength; i++) { int randomSeed = Random.Range(0, charIndexList.Count); int index = charIndexList[randomSeed]; charIndexList.RemoveAt(randomSeed); charIndexArray[i] = index; //Debug.Log(index); } int fillCount = 0; for (int i = 0; i < characterButtons.Length; i++) { KeyDoorCharacterButton characterButton = characterButtons[i]; if (filledIndex.Contains(i)) { int characterIndex = charIndexArray[fillCount]; char character = characters[characterIndex]; characterButton.SetUpKeyDoorCharacterButton(character, OnCharacterClick, true); fillCount++; } else { characterButton.SetUpKeyDoorCharacterButton('#', OnCharacterClick, false); } } }