Esempio n. 1
0
        public override void CheckMovement(GameTime gameTime)
        {
            RecastPositions();


            if (player is IMovementNPC)
            {
                var temp = player as IMovementNPC;
                if (NPCCollision.IsAroundNPC(HeroPlayer.Positie, positie))
                {
                    base.CheckMovement(gameTime);
                }
                else
                {
                    if (!isSetTimer)
                    {
                        timer      = gameTime.TotalGameTime.TotalSeconds;
                        isSetTimer = true;
                    }

                    player.Direction = righting;

                    if (player.Direction)
                    {
                        velocity.X = -1;
                        isGround   = false;
                    }
                    else
                    {
                        velocity.X = 1;
                        isGround   = false;
                    }

                    if ((gameTime.TotalGameTime.TotalSeconds - timer > timeOnJump) && !hasJumped)
                    {
                        effects.PlayJump();
                        isSetTimer = false;
                        velocity.Y = -jumpHeight;
                        hasJumped  = true;
                        isGround   = false;
                    }

                    this.CheckCollide(4, 5);

                    CheckGravity();

                    player.Update(gameTime);
                }
            }
        }
Esempio n. 2
0
        public override void CheckMovement(GameTime gameTime)
        {
            RecastPositions();

            if (player is IMovementNPC)
            {
                var temp = player as IMovementNPC;
                if (NPCCollision.IsAroundNPC(HeroPlayer.Positie, positie))
                {
                    base.CheckMovement(gameTime);
                }
                else
                {
                    if (HeroPlayer.Positie.X + 32 < positie.X)
                    {
                        player.Direction = true;
                        velocity.X       = -1;
                    }
                    else if (HeroPlayer.Positie.X + 32 > positie.X)
                    {
                        player.Direction = false;
                        velocity.X       = 1;
                    }
                    else
                    {
                        velocity.X = 0;
                    }

                    if (HeroPlayer.Positie.Y + 20 < positie.Y && !hasJumped)
                    {
                        //Jump
                        effects.PlayJump();
                        velocity.Y = -jumpHeight;
                        hasJumped  = true;
                        isGround   = false;
                    }

                    CheckCollide(4, 5);
                    CheckGravity();

                    player.Update(gameTime);
                }
            }
        }
Esempio n. 3
0
        public override void CheckMovement(GameTime gameTime)
        {
            RecastPositions();

            if (player is IMovementNPC)
            {
                var temp = player as IMovementNPC;
                if (NPCCollision.IsAroundNPC(HeroPlayer.Positie, positie))
                {
                    base.CheckMovement(gameTime);
                }
                else
                {
                    CheckCollide(4, 5);
                    CheckGravity();

                    player.Update(gameTime);
                }
            }
        }
        public override void CheckMovement(GameTime gameTime)
        {
            RecastPositions();

            if (NPCCollision.IsAroundNPC(HeroPlayer.Positie, positie))
            {
                base.CheckMovement(gameTime);
                hasFollow = true;
            }
            else
            {
                if (hasFollow)
                {
                    hasFollow = false;
                }

                #region met Tijd Guard
                if (!isSetTimer1)
                {
                    timer1      = gameTime.TotalGameTime.TotalSeconds;
                    isSetTimer1 = true;
                }

                player.Direction = righting;

                if (player.Direction)
                {
                    velocity.X = -1;
                }
                else
                {
                    velocity.X = 1;
                }
                if ((gameTime.TotalGameTime.TotalSeconds - timer1 > walkTime))
                {
                    velocity.X = 0;

                    if (!isSetTimer2)
                    {
                        timer2      = gameTime.TotalGameTime.TotalSeconds;
                        isSetTimer2 = true;
                    }

                    if ((gameTime.TotalGameTime.TotalSeconds - timer2 > stopTime))
                    {
                        isSetTimer2 = false;
                        isSetTimer1 = false;
                        righting    = !righting;
                    }
                }
                #endregion

                this.CheckCollide(5, 5);

                CheckGravity();

                player.Positie  = positie;
                player.Velocity = velocity;
                //player.Positie += player.Versnelling;

                player.Update(gameTime);
            }
        }
Esempio n. 5
0
        public override void CheckMovement(GameTime gameTime)
        {
            RecastPositions();
            if (NPCCollision.IsAroundNPC(HeroPlayer.Positie, positie))
            {
                base.CheckMovement(gameTime);
                hasFollow = true;
            }
            else
            {
                if (hasFollow)
                {
                    minX      = positie.X - 32f;
                    maxX      = positie.X + 32f;
                    hasFollow = false;
                }


                #region Met Plaats Guard

                if (positie.X <= minX || positie.X >= maxX)
                {
                    velocity.X = 0;

                    if (!isSetTimer)
                    {
                        timer      = gameTime.TotalGameTime.TotalSeconds;
                        isSetTimer = true;
                    }

                    if ((gameTime.TotalGameTime.TotalSeconds - timer > stopTime))
                    {
                        isSetTimer = false;
                        isSetTimer = false;
                        righting   = !righting;
                        if (righting)
                        {
                            velocity.X = -1;
                        }
                        else
                        {
                            velocity.X = 1;
                        }
                    }
                }
                else
                {
                    player.Direction = righting;

                    if (player.Direction)
                    {
                        velocity.X = -1;
                    }
                    else
                    {
                        velocity.X = 1;
                    }
                }

                #endregion
                this.CheckCollide(5, 5);

                CheckGravity();

                player.Positie  = positie;
                player.Velocity = velocity;
                //player.Positie += player.Versnelling;

                player.Update(gameTime);
            }
        }