Exemple #1
0
        public override void Update(GameTime gameTime, GameWindow gameWindow, Platforms platforms, ref int shift, Player Player, ContentManager Content)
        {
            UpdateAnimation(gameTime, Content);

            if (Where == WhereIGo.movingLeft)
            {
                if (this.canMoveLeft(gameWindow, platforms, shift))
                {
                    this.position.X -= velocity.X;
                }
                else
                {
                    Where = WhereIGo.movingRight;
                }
            }
            if (Where == WhereIGo.movingRight)
            {
                if (this.canMoveRight(gameWindow, platforms, shift))
                {
                    this.position.X += velocity.X;
                }
                else
                {
                    Where = WhereIGo.movingLeft;
                }
            }
            if (this.stateOfMoving == StateOfMoving.attacking)
            {
                return;
            }
            if (this.canMoveDown(gameWindow, platforms, shift))
            {
                this.position.Y   += velocity.Y;
                this.stateOfMoving = StateOfMoving.falling;
            }
            else
            {
                this.stateOfMoving = StateOfMoving.notfalling;
            }
        }
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) + 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 #3
0
        public void UpdateAnimation(GameTime gameTime, ContentManager content)
        {
            switch (stateOfMoving)
            {
            case StateOfMoving.falling:
                Timer1 += gameTime.ElapsedGameTime;
                if (Timer1 > DelayForRisingAndFalling)
                {
                    Timer1 -= DelayForRisingAndFalling;
                    animatedSprite.Update();
                }
                break;

            case StateOfMoving.notfalling:
                Timer1 += gameTime.ElapsedGameTime;
                if (Timer1 > DelayForRisingAndFalling)
                {
                    Timer1 -= DelayForRisingAndFalling;
                    animatedSprite.Update();
                }
                break;

            case StateOfMoving.attacking:
                Timer1 += gameTime.ElapsedGameTime;
                if (Timer1 > DelayForShooting)
                {
                    Timer1 -= DelayForShooting;
                    int pomocnicze_klatki = animatedSprite.currentFrame;
                    animatedSprite.Update();
                    if (pomocnicze_klatki + 1 >= animatedSprite.totalFrames)
                    {
                        this.stateOfMoving = StateOfMoving.notfalling;
                        this.LoadContent(content);
                    }
                }
                break;
            }
        }