/// <summary> /// Moves the UFO sideways. /// </summary> public void UfoMoveSideways() { if (!this.IsSideMovingUfoDisplayed()) { // 10% chance that a sidemoving UFO will appear if (this.r.Next(1, 100) > 90) { // 50% chance of moving left or right. if (this.r.Next(1, 100) > 50) { Ufo sideMovingUFO = new Ufo(20, 25, 100); this.ufoMovingRight = true; this.Model.Ufos.Add(sideMovingUFO); } else { Ufo sideMovingUFO = new Ufo((int)(Settings.WindowWidth - 20), 25, 100); this.ufoMovingRight = false; this.Model.Ufos.Add(sideMovingUFO); } } } else { // There is already a moving UFO. Loops through all the UFO's and moves the one with 100 points sideways. for (int i = 0; i < this.Model.Ufos.Count(); i++) { Ufo actualUFO = this.Model.Ufos[i]; if (actualUFO.Points == 100 && this.ufoMovingRight == true) { actualUFO.MoveSideWays(Settings.UfoSideStepSize); } else if (actualUFO.Points == 100 && this.ufoMovingRight == false) { actualUFO.MoveSideWays(-Settings.UfoSideStepSize); } if (actualUFO.X < 0 || actualUFO.X > Settings.WindowWidth) { this.Model.Ufos.Remove(actualUFO); } } } }