Example #1
0
        public bool CheckForHitUFO(UFO ufo)
        {
            if (ufo.State == ShipState.Destroyed)
                return false;

            Rectangle ufoBoundingBox = ufo.BoundingBox;

            foreach (Bullet bullet in bulletList) {
                if (bullet.BulletSource != BulletSource.UfoPhotonBlaster) {
                    if (bullet.BoundingBox.Intersects(ufoBoundingBox)) {
                        ufo.Damaged(bullet.Power);
                        bulletList.Remove(bullet);
                        return true;
                    }
                }
            }
            return false;
        }
Example #2
0
        public void InitLevel(int iLevel)
        {
            //int sectorPosX = (int)InvasionGame.SectorPos.X;
            float sectorPosX = InvasionGame.SectorPos.X;

            int valinc = 1;

            int strength = (iLevel-1) / 6 + 1;

            switch (iLevel % 6) {
                case 0:
                    int	i = iLevel / 6;

                    UFO ufo = new UFO(Game, UFOModel.RedUFO, new Vector2(sectorPosX + 20, 20), strength);
                    ufo.Speed = i;
                    ufo.Maneuver = 0;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.RedUFO, new Vector2(sectorPosX + 110, 90), strength);
                    ufo.Speed = i;
                    ufo.Maneuver = 0;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.RedUFO, new Vector2(sectorPosX + 20, 160), strength);
                    ufo.Speed = i;
                    ufo.Maneuver = 0;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.RedUFO, new Vector2(sectorPosX + 540, 20), strength);
                    ufo.Speed = i;
                    ufo.Maneuver = 1;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.RedUFO, new Vector2(sectorPosX + 470, 90), strength);
                    ufo.Speed = i;
                    ufo.Maneuver= 1;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.RedUFO, new Vector2(sectorPosX + 540, 160), strength);
                    ufo.Speed = i;
                    ufo.Maneuver = 1;
                    UFOsList.Add(ufo);
                    ufo = null;

                    break;

                case 1:

                    for (i=0; i<3; i++) {
                        ufo = new UFO(Game, UFOModel.SilverUFO, new Vector2(sectorPosX + 15 + (i*30), (i * 65)+10), strength);
                        ufo.Speed = 1;
                        ufo.Maneuver = 0;
                        ufo.AltitudeTargetDrop = 1;
                        UFOsList.Add(ufo);
                        ufo = null;
                    }

                    ufo = new UFO(Game, UFOModel.SilverUFO, new Vector2(sectorPosX + 45, 195), strength);
                    ufo.Speed = 1;
                    ufo.Maneuver = 0;
                    ufo.AltitudeTargetDrop = 1;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.SilverUFO, new Vector2(sectorPosX + 15, 260), strength);
                    ufo.Speed = 1;
                    ufo.Maneuver = 0;
                    ufo.AltitudeTargetDrop = 1;
                    UFOsList.Add(ufo);
                    ufo = null;

                    for (i=0; i<3; i++) {
                        ufo = new UFO(Game, UFOModel.SilverUFO, new Vector2(sectorPosX + 560 - (i*30), (i * 65)+10), strength);
                        ufo.Speed = -1;
                        ufo.Maneuver = 0;
                        ufo.AltitudeTargetDrop = 1;
                        UFOsList.Add(ufo);
                        ufo = null;
                    }

                    ufo = new UFO(Game, UFOModel.SilverUFO, new Vector2(sectorPosX + 530, 195), strength);
                    ufo.Speed = -1;
                    ufo.Maneuver = 0;
                    ufo.AltitudeTargetDrop = 1;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.SilverUFO, new Vector2(sectorPosX + 560, 260), strength);
                    ufo.Speed = -1;
                    ufo.Maneuver = 0;
                    ufo.AltitudeTargetDrop = 1;
                    UFOsList.Add(ufo);
                    ufo = null;

                    break;

                case 2:
                    for (i=0; i<5; i++) {
                        ufo = new UFO(Game, UFOModel.SilverUFO, new Vector2(sectorPosX + 15 + (i*30), (i * 65)+10), strength);
                        ufo.Speed = 1;
                        ufo.Maneuver = 0;
                        ufo.AltitudeTargetDrop = 1;
                        UFOsList.Add(ufo);
                        ufo = null;
                    }

                    for (i=0; i<5; i++) {
                        ufo = new UFO(Game, UFOModel.SilverUFO, new Vector2(sectorPosX + 560 - (i*30), (i * 65)+10), strength);
                        ufo.Speed = -1;
                        ufo.Maneuver = 0;
                        ufo.AltitudeTargetDrop = 1;
                        UFOsList.Add(ufo);
                        ufo = null;
                    }
                    break;
                case 3:
                    for (int j=0; j<3; j++) {
                        for (i=0; i<8; i++) {
                            ufo = new UFO(Game, UFOModel.SilverUFO, new Vector2(sectorPosX + (i * 77)+15, j*80), strength);
                            ufo.Speed = valinc;
                            ufo.Maneuver = 0;
                            UFOsList.Add(ufo);
                            ufo = null;
                        }
                        valinc = -valinc;
                    }
                    break;

                case 4:
                    ufo  = new UFO(Game, UFOModel.OrangeUFO, new Vector2(sectorPosX + 20, 20), strength);
                    ufo.Speed = 2;
                    ufo.Maneuver = 2;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.OrangeUFO, new Vector2(sectorPosX + 180, 180), strength);
                    ufo.Speed = 2;
                    ufo.Maneuver = 2;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.OrangeUFO, new Vector2(sectorPosX + 530, 110), strength);
                    ufo.Speed = 2;
                    ufo.Maneuver = 3;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.OrangeUFO, new Vector2(sectorPosX + 100, 100), strength);
                    ufo.Speed = 2;
                    ufo.Maneuver = 1;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.OrangeUFO, new Vector2(sectorPosX + 450, 190), strength);
                    ufo.Speed = 2;
                    ufo.Maneuver = 0;
                    UFOsList.Add(ufo);
                    ufo = null;
                    break;

                case 5:
                    ufo = new UFO(Game, UFOModel.OrangeUFO, new Vector2(sectorPosX + 20, 20), strength);
                    ufo.Speed = 3;
                    ufo.Maneuver = 2;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.OrangeUFO, new Vector2(sectorPosX + 90, 90), strength);
                    ufo.Speed = 3;
                    ufo.Maneuver = 2;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.OrangeUFO, new Vector2(sectorPosX + 20, 160), strength);
                    ufo.Speed = 3;
                    ufo.Maneuver = 3;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.OrangeUFO, new Vector2(sectorPosX + 540, 20), strength);
                    ufo.Speed = 3;
                    ufo.Maneuver = 3;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.OrangeUFO, new Vector2(sectorPosX + 470, 90), strength);
                    ufo.Speed = 3;
                    ufo.Maneuver = 3;
                    UFOsList.Add(ufo);
                    ufo = null;

                    ufo = new UFO(Game, UFOModel.OrangeUFO, new Vector2(sectorPosX + 540, 160), strength);
                    ufo.Speed = 3;
                    ufo.Maneuver = 2;
                    UFOsList.Add(ufo);
                    ufo = null;
                    break;
            }

            shootChance = 180 - (40 * (strength-1));

            if (shootChance < 50)
                shootChance = 50;

            InvasionGame.Scoreboard.NumSectorUFOs = UFOsList.Count;
        }
Example #3
0
 public void Add(UFO ufo)
 {
     UFOsList.Add(ufo);
 }
Example #4
0
 public int GetIndex(UFO ufo)
 {
     return UFOsList.IndexOf(ufo);
 }
Example #5
0
 /// <summary>
 /// Check to see if a ufo has hit into another ufo
 /// </summary>
 /// <param name="ufo">ufo to check against</param>
 /// <returns>true if there is a crash
 /// false if there is no crash</returns>
 bool CheckForUFOtoUFOCrash(UFO ufo)
 {
     foreach (UFO otherUFO in UFOsList) {
         if (otherUFO.State == ShipState.OK && otherUFO.Y == ufo.Y && otherUFO != ufo) {
             if (ufo.X < otherUFO.X) {
                 if ((otherUFO.X - ufo.X <= 70) &&
                     ((ufo.Speed > 0 && ufo.UFOModel == UFOModel.SilverUFO) ||
                      (ufo.Maneuver == 0 && ufo.UFOModel == UFOModel.RedUFO)))
                     return true;
             }
             else {
                 if ((ufo.X - otherUFO.X <= 70) &&
                     ((ufo.Speed < 0 && ufo.UFOModel == UFOModel.SilverUFO) ||
                     (ufo.Maneuver == 1 && ufo.UFOModel == UFOModel.RedUFO)))
                     return true;
             }
         }
     }
     return false;
 }