public void AddFruit(String Name, Point Location) { Fruit NewFruit; if (Name.Equals("Watermelon")) { NewFruit = new Watermelon(Name, Location, DirectionOfFruit, 35); } else if (Name.Equals("Pineapple")) { NewFruit = new Pineapple(Name, Location, DirectionOfFruit, 35); } else if (Name.Equals("Apple")) { NewFruit = new Apple(Name, Location, DirectionOfFruit, 35); } else if (Name.Equals("Orange")) { NewFruit = new Orange(Name, Location, DirectionOfFruit, 35); } else if (Name.Equals("Strawberry")) { NewFruit = new Strawberry(Name, Location, DirectionOfFruit, 35); } else { NewFruit = new Bomb(Name, Location, DirectionOfFruit, 35); } AllFruits.Add(NewFruit); }
private void deleteFruits() { for (int i = 0; i < AllFruits.Count; i++) { if (AllFruits[i].State == 0) { if (AllFruits[i].Name.Equals("Bomb") && AllFruits[i].IsHit) { GameOver = true; } if (AllFruits[i].IsHit) { TotalPoints += AllFruits[i].Points; } if (!AllFruits[i].Name.Equals("Bomb") && !AllFruits[i].IsHit) { Misses++; } AllFruits.RemoveAt(i); if (Misses == 3) { GameOver = true; } } } }
public void RemoveAll() { AllFruits.Clear(); }