//name: private void CheckForRepeats(List<fallingLetter> currentCharList, fallingLetter tempStruct) //purpose: checks the currentCharList to ensure there are no repeat letters in it //parameters: List<fallingLetter> currentCharList - current fallingLetter list // fallingLetter tempStruct - the newly created fallingLetter struct to compare to the list private void CheckForRepeats(List <fallingLetter> currentCharList, fallingLetter tempStruct) { int valueCount = 0; //count for how many of each letter are present in the list //loop compares the tempStruct to the current list, to ensure there are only unique letters. Repeats if a letter is duplicated in the list while (valueCount != 1) { //resets value count valueCount = 0; //iterates through the list comparing the temp value to the list values for (int j = 0; j < currentCharList.Count; j++) { //if there is a match then increment valueCount (if there is only 1 of each letter then value count is 1 and that's what we want) if (tempStruct.letter == currentCharList[j].letter) { valueCount++; //if valueCount is > 1 that means there are duplicates, so generate a new random letter if (valueCount > 1) { //subs a new random character into the tempStruct tempStruct = MakeNewFallingLetter(); currentCharList[j] = tempStruct; } } } } }
//name: private fallingLetter RemoveLetter(fallingLetter letterDestroyed) //purpose: neutralizes the values in a fallingLetter structure to be replaced with FillList private fallingLetter RemoveLetter(fallingLetter letterDestroyed) { letterDestroyed.letter = '0'; letterDestroyed.fallSpeed = 0; letterDestroyed.yLocation = 1; letterDestroyed.xLocation = 1; return(letterDestroyed); }