Example #1
0
        public override void Update(float step_time)
        {
            double dist = AppMath.Vec2Distance(Scene.Player.Bounds.center, this.Bounds.center);

            if (dist <= SPOT_DISTANCE)
            {
                Vector2f toTarget = AppMath.Vec2NormalizeReturn((Scene.Player.Bounds.center + Scene.Player.Velocity) - this.Bounds.center);


                float      ang = AppMath.GetAngleBetwenVecs(toTarget, gunFacingDirection);
                Quaternion q   = Quaternion.CreateFromAxisAngle(new Vector3f(toTarget.X, toTarget.Y, 0.0f), ang);
                Quaternion q2  = Quaternion.CreateFromAxisAngle(new Vector3f(gunFacingDirection.X, gunFacingDirection.Y, 0.0f), ang);
                q = Quaternion.Slerp(q, q2, ang);

                gunFacingDirection = new Vector2f(q.X, q.Y); //  toTarget;
                gun.Fire(Scene.Player.Bounds.center /*+ Scene.Player.Velocity * step_time*/);
            }
        }