public bool detectEnemyCollision(List <EnemyTank> enemyTanks, Rectangle nextTankLocation, EnemyTank enemyTank = null) { foreach (EnemyTank element in enemyTanks) { if (element.Equals(enemyTank)) { continue; } else { if (element.Bounds.IntersectsWith(nextTankLocation)) { return(true); } } } return(false); }
public bool detectCollision(List <BrickWall> gameWalls, Rectangle nextTankLocation, List <EnemyTank> enemyTanks, EnemyTank enemyTank = null) { foreach (BrickWall element in gameWalls) { if (element.Bounds.IntersectsWith(nextTankLocation) || detectEnemyCollision(enemyTanks, nextTankLocation, enemyTank)) { return(true); } } return(false); }
public void respawnEnemyTank(List <Point> spawnPoints, List <EnemyTank> enemyTanks, EnemyTank enemyTank) { int temp; Random random = new Random(Guid.NewGuid().GetHashCode()); while (true) { temp = random.Next(0, spawnPoints.Count); Rectangle tempTank = new Rectangle(spawnPoints.ElementAt(temp), new Size(50, 50)); if (detecter.detectEnemyCollision(enemyTanks, tempTank)) { continue; } else { enemyTank.Location = spawnPoints.ElementAt(temp); return; } } }