Exemple #1
0
        public float GetCurrentDistance()
        {
            if (PhysicsObj == null)
            {
                return(float.MaxValue);
            }

            if (!MovementParams.Flags.HasFlag(MovementParamFlags.UseSpheres))
            {
                return(PhysicsObj.Position.Distance(CurrentTargetPosition));
            }

            return((float)Position.CylinderDistance(PhysicsObj.GetRadius(), PhysicsObj.GetHeight(), PhysicsObj.Position,
                                                    SoughtObjectRadius, SoughtObjectHeight, CurrentTargetPosition));
        }
Exemple #2
0
        public float GetCurrentDistance()
        {
            if (PhysicsObj == null)
            {
                return(float.MaxValue);
            }

            if ((MovementParams.Bitfield & 0x400) == 0)
            {
                return(PhysicsObj.Position.Distance(CurrentTargetPosition));
            }

            return((float)Position.CylinderDistance(PhysicsObj.GetRadius(), PhysicsObj.GetHeight(), PhysicsObj.Position,
                                                    SoughtObjectRadius, SoughtObjectHeight, CurrentTargetPosition));
        }
Exemple #3
0
        public void SetCameraBehind()
        {
            var rads = CurrentAngle.ToRads();

            var dir = new Vector3(0, (float)Math.Cos(rads), (float)Math.Sin(rads)) * CurrentDist;

            // transform by player rotation
            Camera.Dir = Vector3.Transform(dir, PhysicsObj.Position.Frame.Orientation.ToXna());
            Camera.Dir.Normalize();

            var lookAt = PhysicsObj.Position.GetWorldPos();

            lookAt.Z += PhysicsObj.GetHeight() / CurrentHeightFactor;

            // set camera position
            Camera.Position = lookAt - Camera.Dir;

            Camera.CreateLookAt();
        }
Exemple #4
0
        /// <summary>
        /// Gets the distance to target, with radius excluded
        /// </summary>
        public float GetDistanceToTarget()
        {
            if (AttackTarget == null)
            {
                return(float.MaxValue);
            }

            //var matchIndoors = Location.Indoors == AttackTarget.Location.Indoors;
            //var targetPos = matchIndoors ? AttackTarget.Location.ToGlobal() : AttackTarget.Location.Pos;
            //var sourcePos = matchIndoors ? Location.ToGlobal() : Location.Pos;

            //var dist = (targetPos - sourcePos).Length();
            //var radialDist = dist - (AttackTarget.PhysicsObj.GetRadius() + PhysicsObj.GetRadius());

            // always use spheres?
            var cylDist = (float)Physics.Common.Position.CylinderDistance(PhysicsObj.GetRadius(), PhysicsObj.GetHeight(), PhysicsObj.Position,
                                                                          AttackTarget.PhysicsObj.GetRadius(), AttackTarget.PhysicsObj.GetHeight(), AttackTarget.PhysicsObj.Position);

            if (DebugMove)
            {
                Console.WriteLine($"{Name}.DistanceToTarget: {cylDist}");
            }

            //return radialDist;
            return(cylDist);
        }
Exemple #5
0
        /// <summary>
        /// Gets the distance to target, with radius excluded
        /// </summary>
        public float GetDistanceToTarget()
        {
            if (AttackTarget == null)
            {
                return(float.MaxValue);
            }

            var dist       = (AttackTarget.Location.ToGlobal() - Location.ToGlobal()).Length();
            var radialDist = dist - (AttackTarget.PhysicsObj.GetRadius() + PhysicsObj.GetRadius());

            // always use spheres?
            var cylDist = (float)Physics.Common.Position.CylinderDistance(PhysicsObj.GetRadius(), PhysicsObj.GetHeight(), PhysicsObj.Position,
                                                                          AttackTarget.PhysicsObj.GetRadius(), AttackTarget.PhysicsObj.GetHeight(), AttackTarget.PhysicsObj.Position);

            /*if (DebugMove)
             * {
             *  Console.WriteLine($"Raw distance: {dist} ({radialDist}) - Cylinder dist: {cylDist}");
             *  Console.WriteLine($"Player radius: {AttackTarget.PhysicsObj.GetRadius()} ({AttackTarget.PhysicsObj.GetPhysicsRadius()})");
             *  Console.WriteLine($"Monster radius: {PhysicsObj.GetRadius()} ({PhysicsObj.GetPhysicsRadius()})");
             * }*/

            //return radialDist;
            return(cylDist);
        }