示例#1
0
        public void CollisionWithMissile()
        {
            int healthSubby;
            Missile missile = new Missile() { Damage = 300 };

            level.Subby.CollisionWith(missile);

            healthSubby = level.Subby.Health;

            Assert.AreEqual(700, healthSubby, "Er gaat iets mis met de health en kogel collision");
        }
示例#2
0
        public void setup()
        {
            missile = new Missile()
            {
                Damage = 300,
                Active = true,
                Speed = 3f,
                Exploded = false,
                Position = new Vector2(0, 0)
            };
            chopper = new Chopper()
            {
                Health = 300,
                Speed = 2f,
                Position = new Vector2 (20,20)
            };

            level = new Level();
        }
示例#3
0
文件: Level.cs 项目: va-14/kb24subby
        public Missile CreateMissile(Missile missile, Point position, int Damage)
        {
            if (missile != null)
            {
                missile.Texture = _missileTexture;
                missile.TextureName = "missile";
                missile.Color = Color.White;
                missile.Active = false;
                if (position != null)
                    missile.Position = new Vector2(position.X + ScrollingPosition, position.Y);

                if (Damage > 0)
                    missile.Damage = Damage;

                SpriteList.Add(missile);

                if (MissileList == null)
                    MissileList = new List<Missile>();

                MissileList.Add(missile);
            }
            return missile;
        }
示例#4
0
文件: Level.cs 项目: va-14/kb24subby
 private void HostileSubShoot(GameTime gameTime)
 {
     foreach (ISprite sprite in SpriteList.ToList())
     {
         if (sprite is HostileSub)
         {
             if (((HostileSub)sprite).Shoot(TotalRoundTime) & ((HostileSub)sprite).Active)
             {
                 Point position = PointOnCircle((int)(sprite.Texture.Width / 2 + 30), (int)(((HostileSub)sprite).AngleDeg + 180), new Point((int)sprite.Position.X, (int)sprite.Position.Y));
                 position = new Point(position.X - ScrollingPosition, position.Y);
                 Missile missile = new Missile();
                 missile.Rotation = ((HostileSub)sprite).AngleDeg;
                 missile.Speed = -7.0f;
                 CreateMissile(missile, position, 300);
             }
         }
     }
 }
示例#5
0
文件: Level.cs 项目: va-14/kb24subby
        private void CheckMissileCollision(Missile s1, ISprite s2)
        {
            Rectangle r1 = new Rectangle((int)s1.Position.X - ScrollingPosition, (int)s1.Position.Y, s1.Width, s1.Height);
            Rectangle r2 = new Rectangle((int)s2.Position.X - ScrollingPosition, (int)s2.Position.Y, s2.Width, s2.Height);

            Rectangle collisionCheck = Rectangle.Intersect(r1, r2);
            if (!collisionCheck.IsEmpty)
            {
                s2.CollisionWith(s1);
                s1.CollisionWith(s2);
                if (s2 is Chopper )
                {
                    UpdateScore(((Chopper)s2).Score);
                }
                if (s2 is HostileSub)
                {
                    UpdateScore(((HostileSub)s2).Score);
                }
            }
        }