public virtual void checkContactWithPlayer()
        {
            cPlayer player = Scene.Player;

            float d = (float)AppMath.Vec2Distance(player.Bounds.center, this.Bounds.center);

            if (!this.pulling)
            {
                this.pulling = d <= MAX_PULL_DISTANCE;
            }

            if (!pickedUp && cCollision.OverlapAABB(player.Bounds, this.HitCollisionRect))
            {
                player.pickUp(pickup);
                pickedUp = true;
            }
        }
        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*/);
            }
        }
Exemple #3
0
        public void Update(Vector2f target, AABB region_bounds, float step_time = Constants.STEP_TIME)
        {
            this.Target      = target;
            PreviousPosition = ActualPosition;
            if (Smooth)
            {
                Vector2f dir = AppMath.Vec2NormalizeReturn(Target - ActualPosition);
                float    len = (float)AppMath.Vec2Distance(ActualPosition, Target);
                Vector2f vel = dir * (len * Smoothness);
                //AppMath.Vec2Truncate(ref vel, 2.0f);
                //vel += ShakeScreen.Offset;
                ActualPosition += vel;
            }
            else
            {
                ActualPosition = Target + ShakeScreen.Offset;
            }

            checkBounds(region_bounds);
        }