Example #1
0
        public override void Collision(GameplayObject target)
        {
            Bullet b = target as Bullet;

            Ship s = target as Ship;

            if (b != null && (b.Source != this))
            {
                this.Damage();
                b.Die();

                Player p = b.Source as Player;

                if (p != null)
                {
                    p.EnemyKilled();
                }
            }

            else if (s != null)
            {
                this.Damage();
                s.Damage();
            }
        }
Example #2
0
        public bool Intersects(GameplayObject b)
        {
            int Top = Math.Max(Rectangle.Top, b.Rectangle.Top);

            int Bottom = Math.Min(Rectangle.Bottom, b.Rectangle.Bottom);

            int Left = Math.Max(Rectangle.Left, b.Rectangle.Left);

            int Right = Math.Min(Rectangle.Right, b.Rectangle.Right);

            Color colB;

            Color colA;

            for (int y = Top; y < Bottom; y++)
            {
                for (int x = Left; x < Right; x++)
                {
                    colA = TextureData[(y - Rectangle.Top) * Rectangle.Width + (x - Rectangle.Left)];

                    colB = b.TextureData[(y - b.Rectangle.Top) * b.Rectangle.Width + (x - b.Rectangle.Left)];

                    PlayScreen.alphaa = colA.ToString();
                    PlayScreen.alphab = colB.ToString();

                    PlayScreen.calcs = y + x + Texture.Width * Texture.Height;
                    if (colA.A != 0 && colB.A != 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #3
0
 public override void Collision(GameplayObject target)
 {
     Die();
     SFX.PlayEffect("Media/SFX/snap-shut");
     if (target is Bullet)
     {
         target.Die();
     }
 }
Example #4
0
 public static void AddGameObject(GameplayObject newObject)
 {
     addedObjects.Add(newObject);
 }
Example #5
0
 /// <summary>
 /// Collision logic with another GameplayObject
 /// </summary>
 /// <param name="target"></param>
 public virtual void Collision(GameplayObject target)
 {
 }