Esempio n. 1
0
 public void HandleBombsIntersection(Player p, BuildingHandler bh, ContentManager theContentManager)
 {
     if (p.bombs.Count > 0)
     {
         foreach (Bomb b in p.bombs)
         {
             bombRectangle = new Rectangle((int)b.X, (int)b.Y, 20, 20); //TODO: width, height if needed
             foreach (Building building in bh.buildings)
             {
                 buildingRectangle = new Rectangle((int)building.X, (int)building.Y - building.H + 10, building.W, building.H);
                 if (bombRectangle.Intersects(buildingRectangle))
                 {
                     building.Damaged = true;
                     p.score.AddPoints(50);
                     p.eh.CreateExplosion("huge", new Vector2(b.X - 48, b.Y - 16), theContentManager);
                     p.bombs.Remove(b);
                     bombRemoved = true;
                 }
             }
             if (bombRemoved)
             {
                 bombRemoved = false;
                 break;
             }
         }
     }
 }
Esempio n. 2
0
 public void HandleBuildingIntersection(Player p, BuildingHandler bh)
 {
     playerRectangle = new Rectangle((int)p.X + p.W / 2, (int)p.Y + p.H / 4, p.W / 4, p.H / 2);
     foreach (Building b in bh.buildings)
     {
         buildingRectangle = new Rectangle((int)b.X + 5, (int)b.Y - b.H + 10, b.W - 10, b.H);
         if (playerRectangle.Intersects(buildingRectangle))
         {
             b.Damaged = true;
             p.Hitpoints = 0;
             p.Crash = true;
         }
     }
 }
Esempio n. 3
0
        public GamePage()
        {
            InitializeComponent();

            // Get the content manager from the application
            contentManager = (Application.Current as App).Content;

            // Create a timer for this page
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(/*333333*/ 111111);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;

            player = new Player();
            background = new Background();
            clouds = new Clouds();
            enemyHandler = new EnemyHandler(player, background);
            intersectionHandler = new IntersectionHandler();
            buildingHandler = new BuildingHandler();
            powerupHandler = new PowerupHandler();
        }