Exemple #1
0
        public override void Attack(GameTime gameTime, Player player, Bullets bullets, ContentManager Content)
        {
            Rectangle EnemyPlusHisRange = new Rectangle((int)(this.position.X) - Range, (int)(this.position.Y), (int)(this.size.X) + Range, (int)(this.size.Y));

            if (!Rectangle.Intersect(EnemyPlusHisRange, convertToRectangle(player.position, player.size)).IsEmpty&& this.position.X > player.position.X)
            {
                if (TimeFromPreviousAttack == 0)
                {
                    TimeFromPreviousAttack = gameTime.ElapsedGameTime.Seconds;
                }
                System.TimeSpan delay = new TimeSpan(0, 0, Delay);
                if (((int)(gameTime.TotalGameTime.Seconds) - this.TimeFromPreviousAttack >= (int)(delay.Seconds)))
                {
                    System.Console.WriteLine("I'm assassin! Watch my razor.");
                    stateOfMoving = StateOfMoving.attacking;
                    Texture2D texture = Content.Load <Texture2D>("AnimationSprites/NotSmartEnemy/notsmartenemy_attacking");
                    animatedSprite         = new AnimatedSprite(texture, 1, 7);
                    dmg                   += AttackDamage;
                    TimeFromPreviousAttack = (int)(gameTime.TotalGameTime.Seconds);
                }
            }
        }
Exemple #2
0
        public override void Attack(GameTime gameTime, Player player, Bullets bullets, ContentManager Content)
        {
            Rectangle EnemyPlusHisRange = new Rectangle((int)(this.position.X) - Range, (int)(this.position.Y), (int)(this.size.X) + 2 * Range, (int)(this.size.Y));

            if (this.HP >= 0.5 * BaseHP)
            {
                if (TimeFromPreviousShot == 0)
                {
                    TimeFromPreviousShot = gameTime.ElapsedGameTime.Seconds;
                }
                System.TimeSpan delay = new TimeSpan(0, 0, Delay);
                if ((Math.Abs((int)(gameTime.TotalGameTime.Seconds) - this.TimeFromPreviousShot) >= (int)(delay.Seconds)))
                {
                    System.Console.WriteLine("Omg I shoot around! Watch out, derp!");

                    AddFewBulletsToBullets(bullets, Content);
                    TimeFromPreviousShot = (int)(gameTime.TotalGameTime.Seconds);
                }
                return;
            }

            else if (this.HP < 0.5 * BaseHP)
            {
                if (TimeFromPreviousShot == 0)
                {
                    TimeFromPreviousShot = gameTime.ElapsedGameTime.Seconds;
                }
                System.TimeSpan delay = new TimeSpan(0, 0, Delay / 2);
                if ((Math.Abs((int)(gameTime.TotalGameTime.Seconds) - this.TimeFromPreviousShot) >= (int)(delay.Seconds)))
                {
                    System.Console.WriteLine("Omg I shoot around! Watch out, derp!");

                    AddFewBulletsToBullets(bullets, Content);

                    TimeFromPreviousShot = (int)(gameTime.TotalGameTime.Seconds);
                }
            }
        }
Exemple #3
0
        public void Update(GameTime gameTime, GameWindow gameWindow, Platforms platforms, ref int shift, PlayerBullets playerBullets,
                           ContentManager content, Enemies enemies, Bullets bullets)
        {
            playerAnimation.Update(gameTime);
            GetHurt(enemies, bullets);
            KeyboardState newState = Keyboard.GetState();

            SetPlayerDirection(oldState, newState);
            PlayerJump(oldState, newState, gameWindow, platforms, shift);
            SetVelocity(gameWindow, platforms, ref shift, gameTime);
            Shoot(oldState, newState, playerBullets, content);
            if (canMoveRight(gameWindow, platforms, shift) && newState.IsKeyDown(Keys.Right))
            {
                position.X += velocity.X;
                changeShift(ref shift, gameWindow);
            }
            if (canMoveLeft(gameWindow, platforms, shift) && newState.IsKeyDown(Keys.Left))
            {
                position.X -= velocity.X;
                changeShift(ref shift, gameWindow);
            }
            oldState = newState;
            EndGame();
        }
Exemple #4
0
 public virtual void Attack(GameTime gameTime, Player player, Bullets bullets, ContentManager Content)
 {
 }
Exemple #5
0
 private void GetHurt(Enemies enemies, Bullets bullets)
 {
     this.HP -= enemies.DamageDealt(this, bullets);
 }