Beispiel #1
0
            private static void HitTestToPlayerPlane(EnemyPlane enemyPlane)
            {
                var playerPlanes = EntitiesRunner.Current.GetEntitiesOfType <PlayerPlane>();

                if (playerPlanes == null)
                {
                    return;
                }
                var bullets = enemyPlane.machineGunAndLauncher.AttachedEmitters[0].particles;

                if (bullets != null)
                {
                    for (int i = 0; i < bullets.Length; i++)
                    {
                        if (!bullets[i].IsActive)
                        {
                            continue;
                        }
                        if (bullets[i].Position.X < ScreenSpace.Current.Viewport.Left)
                        {
                            bullets[i].IsActive = false;
                        }
                        foreach (var player in playerPlanes)
                        {
                            if (player.DrawArea.Contains(bullets[i].Position.GetVector2D()))
                            {
                                player.ReceiveAttack();
                                bullets[i].IsActive = false;
                            }
                        }
                    }
                }
                var rockets = enemyPlane.machineGunAndLauncher.AttachedEmitters[1].particles;

                if (rockets != null)
                {
                    for (int i = 0; i < rockets.Length; i++)
                    {
                        if (!rockets[i].IsActive)
                        {
                            continue;
                        }
                        if (rockets[i].Position.X < ScreenSpace.Current.Viewport.Left)
                        {
                            rockets[i].IsActive = false;
                        }
                        foreach (var player in playerPlanes)
                        {
                            if (player.DrawArea.Contains(rockets[i].Position.GetVector2D()))
                            {
                                player.ReceiveAttack(5, true);
                                rockets[i].IsActive = false;
                            }
                        }
                    }
                }
            }
Beispiel #2
0
 private static void HitTestToPlayerPlane(EnemyPlane enemyPlane)
 {
     var playerPlanes = EntitiesRunner.Current.GetEntitiesOfType<PlayerPlane>();
     if (playerPlanes == null)
         return;
     var bullets = enemyPlane.machineGunAndLauncher.AttachedEmitters[0].particles;
     if (bullets != null)
         for (int i = 0; i < bullets.Length; i++)
         {
             if (!bullets[i].IsActive)
                 continue;
             if (bullets[i].Position.X < ScreenSpace.Current.Viewport.Left)
                 bullets[i].IsActive = false;
             foreach (var player in playerPlanes)
                 if (player.DrawArea.Contains(bullets[i].Position.GetVector2D()))
                 {
                     player.ReceiveAttack();
                     bullets[i].IsActive = false;
                 }
         }
     var rockets = enemyPlane.machineGunAndLauncher.AttachedEmitters[1].particles;
     if (rockets != null)
         for (int i = 0; i < rockets.Length; i++)
         {
             if (!rockets[i].IsActive)
                 continue;
             if (rockets[i].Position.X < ScreenSpace.Current.Viewport.Left)
                 rockets[i].IsActive = false;
             foreach (var player in playerPlanes)
                 if (player.DrawArea.Contains(rockets[i].Position.GetVector2D()))
                 {
                     player.ReceiveAttack(5, true);
                     rockets[i].IsActive = false;
                 }
         }
 }