Beispiel #1
0
        public override void Update(GameTime gameTime)
        {
            _wanderDirection.X +=
                MathHelper.Lerp(-.25f, .25f, (float)random.NextDouble());
            _wanderDirection.Y +=
                MathHelper.Lerp(-.25f, .25f, (float)random.NextDouble());

            if (_wanderDirection != Vector3.Zero)
            {
                _wanderDirection.Normalize();
            }

            MyMathHelper.TurnToFace(_aiPlayer.Position, _aiPlayer.FacingDirection, _aiPlayer.Position + _wanderDirection, .15f * _aiPlayer.RotationSpeed);

            Vector3 screenCenter = new Vector3(WZGame.Terrain.Width / 2, 0, -WZGame.Terrain.Height / 2);

            float distanceFromCenter          = Vector3.Distance(screenCenter, _aiPlayer.Position);
            float MaxDistanceFromScreenCenter =
                Math.Min(screenCenter.Y, screenCenter.X);

            float normalizedDistance = distanceFromCenter / MaxDistanceFromScreenCenter;

            float turnToCenterSpeed = .3f * normalizedDistance * normalizedDistance *
                                      _aiPlayer.RotationSpeed;

            MyMathHelper.TurnToFace(_aiPlayer.Position, _aiPlayer.FacingDirection, screenCenter, turnToCenterSpeed);

            //_aiPlayer.CurrentSpeed = .25f * _aiPlayer.MaxSpeed;
        }
Beispiel #2
0
        public void Recenter(GameTime gameTime)
        {
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
            float angle   = 0;

            MyMathHelper.VectorToRadiansY(
                Vector3.Lerp(_facingDirectionVector, Vector3.Up * (_camera.Yaw + MathHelper.Pi), _rotationSpeed * elapsed),
                out angle);


            FacingDirection = angle;
        }
Beispiel #3
0
        public override void Update(GameTime gameTime)
        {
            if (Enabled)
            {
                float orientation = _aiPlayer.FacingDirection;

                Vector3 aiPosition = _aiPlayer.Position;
                // aiPosition.Z *= 1;

                Vector3 p1Position = _player.Position;
                // p1Position.Z *= 1;

                orientation = MyMathHelper.TurnToFace(aiPosition, orientation, p1Position, _player.RotationSpeed);
                _aiPlayer.FacingDirection = orientation;
            }
        }