public bool Create(int i, int j) { int color = rand.Next(0, 10); ChoiceBonus choice = new ChoiceBonus(TextureLoad.Palm, new Rectangle(i * Size, j * Size, Size, Size), Size, Size, new Vector2(i * Size, j * Size)); if (color == (int)bonusType.CHOICE && (j == 0 || !isAlone(choice))) { allChoiceBonuses.Add(choice); return true; } return false; }
public static bool isAlone(ChoiceBonus choice) { for (int i = 0; i < Game1.smile.allSmiles.Count(); i++) { if (isCollision(choice.Position, Game1.smile.allSmiles[i].Position)) return false; } for (int i = 0; i < Game1.choiceBonus.allChoiceBonuses.Count(); i++) { if ((choice != Game1.choiceBonus.allChoiceBonuses[i]) && isCollision(choice.Position, Game1.choiceBonus.allChoiceBonuses[i].Position)) return false; } for (int i = 0; i < Game1.lifeBonus.allLifeBonuses.Count(); i++) { if (isCollision(choice.Position, Game1.lifeBonus.allLifeBonuses[i].Position)) return false; } for (int i = 0; i < Game1.sightBonus.allSightBonuses.Count(); i++) { if (isCollision(choice.Position, Game1.sightBonus.allSightBonuses[i].Position)) return false; } return true; }
public static void newGame() { setConstants(); amountOfShot = 0; smile = new Smile(); lifeBonus = new LifeBonus(); choiceBonus = new ChoiceBonus(); sightBonus = new SightBonus(); for (int i = 0; i < maxNumInRow; i++) for (int j = 0; j < maxNumInCol; j++) { if (smile.Create(i, j)) ; else if (heartIsAvailable && lifeBonus.Create(i, j)); else if (sightIsAvailable && choiceBonus.Create(i, j)); else if (palmIsAvailable && sightBonus.Create(i, j)); } bullet = new Bullet(); bullet.Create(); nextBullet = new Bullet(); nextBullet.Create(); nextBullet.Position = new Vector2(140, ScreenSize.Y - sizeOfSmile - 20); }