Example #1
0
        private void RemoveInactiveWords()
        {
            //Handle the situation if there is completed word inside the selected GameObject
            if (selectedObject != null && selectedObject.GetFirstNotDestroyed() != null && WordManipulator.IsWholeWordToUpper(selectedObject.GetFirstNotDestroyed()))
            {
                int selectedWordsBodyLength = selectedObject.GetValueAsListOfWords().Count;
                selectedObject.GetFirstNotDestroyed().IsGuessed = true;
                IncreaseScore();
                CreateScoreObject();
                selectedObject.RemoveIfDestroyed();
                selectedObject = null;
            }
            bool wordHasFallen = false;

            //Check every active object in ActiveObjects
            foreach (GameObject gm in activeObjects)
            {
                foreach (Word word in gm.GetValueAsListOfWords())
                {
                    if (word.GetPosition().posX == Console.WindowHeight - 2)
                    {
                        selectedObject = null;
                        wordHasFallen  = true;
                    }
                }
                gm.RemoveIfDestroyed();
                painter.InsertIntoField(gm);
            }
            if (wordHasFallen && !inBossFight)
            {
                activeObjects.Clear();
                LivesLeft--;
            }
            else
            {
                activeObjects.RemoveAll(x => x.ToDestroyFlag);
            }
        }