Ejemplo n.º 1
0
 //Bombs hit Gunners
 private bool BombGunnerHitTest(Bomb thisBomb)
 {
     Rect recBomb = new Rect(Canvas.GetLeft(thisBomb), Canvas.GetTop(thisBomb), thisBomb.ActualWidth, thisBomb.ActualHeight);
     Rect recGunner = new Rect(Canvas.GetLeft(imgGunner), Canvas.GetTop(imgGunner), imgGunner.ActualWidth, imgGunner.ActualHeight);
     return recBomb.IntersectsWith(recGunner);
 }
Ejemplo n.º 2
0
 //Bombs Hit shield elements
 private bool BombShieldElementHitTest(Bomb thisBomb, shieldElement thisShieldElement)
 {
     Rect recBomb = new Rect(Canvas.GetLeft(thisBomb), Canvas.GetTop(thisBomb), thisBomb.ActualWidth, thisBomb.ActualHeight);
     Rect recShieldElement = new Rect(Canvas.GetLeft(thisShieldElement), Canvas.GetTop(thisShieldElement), 10, 20);
     return recBomb.IntersectsWith(recShieldElement);
 }
Ejemplo n.º 3
0
        //the idea behind this is that every game tick each invader has a 1 in 1000 chance of dropping a bomb
        //the chances of dropping get higher for each new level.
        private void invadersDropBombs()
        {
            //so run through all the invaders
            foreach (Invader thisInvader in Aliens)
            {   
                //pick a random integer between 0 and intBombRate and if it is a 1 drop the bomb
                if (randomObj.Next(intBombRate) == 1)
                {
                    //instanciate a new bomb and add it to the canvas and add a reference to it to the list Bombs.
                    Bomb newBomb = new Bomb();

                    cnvSpace.Children.Add(newBomb);
                    Bombs.Add(newBomb);
                    //set the position of the bomb to be that of the alien that dropped it
                    Canvas.SetLeft(newBomb, Canvas.GetLeft(thisInvader)+15);
                    Canvas.SetTop(newBomb, Canvas.GetTop(thisInvader)+30);
                }
            }
            
        }