public bool AstroidBulletCollisionDetection(Bullet bullet, Astroid astroid) { float bulletMinY = bullet.position.Y; float bulletMaxY = (bullet.position.Y + bullet.texture.Bounds.Height); float bulletMinX = bullet.position.X; float bulletMaxX = (bullet.position.X + bullet.texture.Bounds.Width); float astroidMinX = astroid.position.X; float astroidMaxX = (astroid.position.X + astroid.texture.Bounds.Width); float astroidMinY = astroid.position.Y; float astroidMaxY = (astroid.position.Y + astroid.texture.Bounds.Height); if (astroidMinX < bulletMinX && astroidMaxX > bulletMinX && astroidMinX < bulletMaxX && astroidMaxX > bulletMaxX) { if (astroidMinY < bulletMinY && astroidMaxY > bulletMinY && astroidMinY < bulletMaxY && astroidMaxY > bulletMaxY) { astroid.health--; if (astroid.health < 1) bullet.shotBy.score += 500; return true; } } return false; }
public override void Shoot() { float spread = 1; for(int i=-2;i<3;i++){ Bullet b = new Bullet(Graphics, Collisions, s.Rotation+(float)(Math.PI*i*spread/20), s.Position); Collisions.blist.Add(b); } }
public static void disparaBala() { PosicaoDirecaoBala(); balaTemp = balasNaoAtivas.First(); balaTemp.position = posicaoBala; balaTemp.direcao = direcaoBala; balasAtivas.Add(balaTemp); balasNaoAtivas.Remove(balaTemp); }
public override void Shoot() { Bullet b = new Bullet(Graphics, Collisions, s.Rotation, s.Position); Collisions.blist.Add(b); }
public static void removerBala(Bullet bala) { balasAtivas.Remove(bala); balasNaoAtivas.Add(bala); }