Ejemplo n.º 1
0
        private void CheckCollision(int objectCount)
        {
            for (int n = 0; n < objectCount; n++)
            {
                for (int m = n + 1; m < objectCount; m++)
                {
                    GameObjectVertical obj1 = gameObjects[n];
                    GameObjectVertical obj2 = gameObjects[m];

                    if (MathFunctions.IsOneOfType <AreaDamage>(obj1, obj2))
                    {
                        PerformAreaDamage(obj1, obj2);
                    }
                    else if (MathFunctions.IsOneOfType <AreaShieldCollision>(obj1.AreaCollision, obj2.AreaCollision) &&
                             MathFunctions.IsOneOfType <PlayerBullet>(obj1, obj2))
                    {
                        PerformShieldAreaCollision(obj1, obj2);
                    }

                    if (obj1.CollisionBounding.Intersects(obj2.CollisionBounding))
                    {
                        CollisionHandlingVerticalShooter.GameObjectsCollision(obj1, obj2);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void PerformAreaDamage(GameObjectVertical obj1, GameObjectVertical obj2)
        {
            if (obj1 is AreaDamage && obj2 is AreaDamage)
            {
                return;
            }

            if (obj1 is AreaDamage)
            {
                if (((AreaDamage)(obj1)).IsOverlapping((AnimatedGameObject)obj2))
                {
                    CollisionHandlingVerticalShooter.GameObjectsCollision(obj1, obj2);
                }
            }
            else
            {
                if (((AreaDamage)(obj2)).IsOverlapping((AnimatedGameObject)obj1))
                {
                    CollisionHandlingVerticalShooter.GameObjectsCollision(obj2, obj1);
                }
            }
        }
Ejemplo n.º 3
0
        private Boolean PerformShieldAreaCollision(GameObjectVertical obj1, GameObjectVertical obj2)
        {
            if (obj1.HasAreaCollision() && obj2.HasAreaCollision())
            {
                return(false);
            }

            if (obj1.HasAreaCollision())
            {
                if (((EnemyShip)obj1).ShieldCanTakeHit(obj2.Damage))
                {
                    if (((AreaShieldCollision)(obj1.AreaCollision)).IsOverlapping((PlayerBullet)obj2))
                    {
                        CollisionHandlingVerticalShooter.GameObjectsCollision(obj1.AreaCollision, obj2);
                    }
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                if (((EnemyShip)obj2).ShieldCanTakeHit(obj1.Damage))
                {
                    if (((AreaShieldCollision)(obj2.AreaCollision)).IsOverlapping((PlayerBullet)obj1))
                    {
                        CollisionHandlingVerticalShooter.GameObjectsCollision(obj2.AreaCollision, obj1);
                    }
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }