//collision detection for enemies and players public void Collision() { Point2D playerpt = SwinGame.PointAt(_player.X, _player.Y); _shadowplayer.Center = playerpt; _shadowplayer.Radius = _player.Size; List <Enemy> toRemove = new List <Enemy> (); foreach (Enemy e in _enemies) { Point2D enemypt = SwinGame.PointAt(e.X, e.Y); _shadowenemy.Center = enemypt; _shadowenemy.Radius = e.Size; if (SwinGame.BitmapCollision(_player.Sprite, _player.X, _player.Y, e.Sprite, e.X, e.Y) == true) { //if (SwinGame.CircleCircleCollision (_shadowplayer, _shadowenemy) == true) { if (_player.Size > e.Size) { _player.Size += e.Size; _tempScore += e.Size; toRemove.Add(e); } else if (e.Size > _player.Size) { gameover = 1; } if ((e.X < -20) || (820 < e.X)) { toRemove.Add(e); } } } foreach (Enemy e in toRemove) { _enemies.Remove(e); } _score = _tempScore; }
public bool IsAt(GameObject gb) { return(SwinGame.BitmapCollision(gb.ObjectBitmap(), gb.Location, ObjectBitmap(), Location)); }
/// <summary> /// This checks if any of the laser shots have collided with an enemy. /// </summary> /// <param name="w">Is a single instance of a laser shot</param> /// <param name="e">Is a single instance of an enemy</param> /// <returns>True if the two object collide.</returns> public bool WeaponHitEnemy(WeaponInstance w, IEnemy e) { return(SwinGame.BitmapCollision(w.Type, w.X, w.Y, e.Type, e.X, e.Y)); }
/// <summary> /// This checks to see if any individual enemy and the player have collided. /// </summary> /// <param name="p">Is the player</param> /// <param name="e">Is the enemy, taken from a list of enemies.</param> /// <returns>True if the collision has occured</returns> public bool EnemyHitShip(Player p, IEnemy e) { return(SwinGame.BitmapCollision(e.Type, e.X, e.Y, p.Type, p.XShip, p.YShip)); }
// Check if Fire hits enemy public bool EnemyHitFire(Enemy enemy, Fire fire) { return(SwinGame.BitmapCollision(enemy.Bitmap, enemy.X, enemy.Y, fire.Bitmap, fire.X, fire.Y)); }
// Check if Enemy hits dog public bool EnemyHitDog(Enemy enemy, Dog dog) { return(SwinGame.BitmapCollision(enemy.Bitmap, enemy.X, enemy.Y, dog.Bitmap, dog.X, dog.Y)); }