public bool checkCollisionWithBullet(Unit unit) { // If shot is still in play, check for collisions for (int j = 0; j < monsters.Count; ++j) { if (monsters[j].unit.alive && unit.collideWith(monsters[j].unit)) { monsters[j].health -= myGame.difficultyConstants.MONSTER_HEALTH_PER_BULLET; hpBillBoardSystem.setTexture(j); if (monsters[j].health <= 0) { monsters[j].Die(); monsters[j].unit.alive = false; myGame.mediator.fireEvent(MyEvent.M_DIE); } else { monsters[j].TakeDamage(); ((MonsterUnit)monsters[j].unit).moving = true; } return true; } } return false; }
public bool checkCollisionWithBullet(Unit unit) { // If shot is still in play, check for collisions for (int j = 0; j < monsters.Count; ++j) { if (monsters[j].unit.alive && unit.collideWith(monsters[j].unit)) { myGame.mediator.fireEvent(MyEvent.M_HIT); monsters[j].health -= monsters[j].monsterUnit.monsterConstants.MONSTER_HEALTH_PER_BULLET; hpBillBoardSystem.setTexture(j); if (monsters[j].health <= 0) { monsters[j].Die(); monsters[j].unit.alive = false; myGame.mediator.fireEvent(MyEvent.M_DIE, "Score", monsters[j].getScore()); } else { monsters[j].TakeDamage(); ((MonsterUnit)monsters[j].unit).moving = true; } return(true); } } return(false); }
public bool checkCollisionWithBullet(Unit unit) { // If shot is still in play, check for collisions for (int j = 0; j < firstAidKits.Count; ++j) { if (unit.collideWith(firstAidKits[j].unit)) { addHealth(j); return true; } } return false; }
/// <summary> /// if the unit(player or bullet) collide with the first aid add the health /// </summary> /// <param name="unit">Unit to check collision with</param> public bool checkCollisionWithBullet(Unit unit) { // If shot is still in play, check for collisions for (int j = 0; j < firstAidKits.Count; ++j) { if (unit.collideWith(firstAidKits[j].unit)) { addHealth(j); return(true); } } return(false); }