コード例 #1
0
ファイル: Enemy.cs プロジェクト: hloiseau/DungeonPlanet
        public void Update(GameTime gameTime)
        {
            _animation.Update(gameTime);
            if (WeaponA == null)
            {
                _animation.Position = new Vector2(EnemyLib.Position.X + 20, EnemyLib.Position.Y + 25);
            }
            else
            {
                _animation.Position = new Vector2(EnemyLib.Position.X + 15, EnemyLib.Position.Y + 25);
            }

            if (_ctx != null)
            {
                EnemyLib.Update(EnemyLib.Position.X - _ctx.GraphicsDevice.Viewport.Width / 2, EnemyLib.Position.Y - _ctx.GraphicsDevice.Viewport.Height / 2);
            }
            CheckKeyboardAndUpdateMovement(gameTime);
            EnemyLib.AffectWithGravity();
            EnemyLib.SimulateFriction();
            EnemyLib.MoveAsFarAsPossible((float)gameTime.ElapsedGameTime.TotalMilliseconds / 40);
            EnemyLib.StopMovingIfBlocked();
            position      = new Vector2(EnemyLib.Position.X, EnemyLib.Position.Y);
            EnemyLib.Life = MathHelper.Clamp(EnemyLib.Life, 0, 100);
            if (WeaponA != null)
            {
                WeaponA.Update(gameTime);
            }
            if (EnemyLib != null && Fire != null)
            {
                Fire.position = new Vector2(EnemyLib.Position.X - 5, EnemyLib.Position.Y - 20);
            }
        }
コード例 #2
0
ファイル: Enemy.cs プロジェクト: hloiseau/DungeonPlanet
 public override void Draw()
 {
     if (WeaponA != null)
     {
         WeaponA.Draw();
     }
     if (_ctx.IsOnScreen(new Rectangle(EnemyLib.Bounds.X, EnemyLib.Bounds.Y, EnemyLib.Bounds.Width, EnemyLib.Bounds.Height)))
     {
         if (EnemyLib.State == 1)
         {
             Fire.Draw();
         }
         _animation.Draw(SpriteBatch);
     }
 }
コード例 #3
0
 private Ship AddWeapons(Ship ship, string[] weapons)
 {
     foreach (string weapon in weapons)
     {
         if (weapon == "A")
         {
             ship = new WeaponA(ship);
         }
         if (weapon == "B")
         {
             ship = new WeaponB(ship);
         }
         if (weapon == "C")
         {
             ship = new WeaponC(ship);
         }
     }
     return(ship);
 }