Ejemplo n.º 1
0
        /// <summary>
        ///   让打架赛车面朝制定目标
        /// </summary>
        /// <param name = "打架赛车的PUnit">The pos.</param>
        /// <returns></returns>
        public void MFace(PUnit mObj)
        {
            float face;

            if (LazyMath.NegativeAngle(AngleHorizontal - mObj.Facing) < Math.PI)
            {
                face = LazyMath.NegativeAngle(AngleHorizontal - mObj.Facing);

                bool moving = mObj.IsMoving;
                if (face > 1)
                {
                    MoveHelper.ReleaseKeys();
                    moving = false;
                }
                FaceHorizontalWithTimer(face, "Left", moving);
            }
            else
            {
                face = LazyMath.NegativeAngle(mObj.Facing - AngleHorizontal);

                bool moving = mObj.IsMoving;
                if (face > 1)
                {
                    MoveHelper.ReleaseKeys();
                    moving = false;
                }
                FaceHorizontalWithTimer(face, "Right", moving);
            }
        }
Ejemplo n.º 2
0
        public static void FaceAngle(float angle)
        {
            float face;

            if (LazyMath.NegativeAngle(angle - ObjectManager.MyPlayer.Facing) < Math.PI)
            {
                face = LazyMath.NegativeAngle(angle - ObjectManager.MyPlayer.Facing);
                bool moving = ObjectManager.MyPlayer.IsMoving;
                if (face > 1)
                {
                    MoveHelper.ReleaseKeys();
                    moving = false;
                }
                FaceHorizontalWithTimer(face, "Left", moving);
            }
            else
            {
                face = LazyMath.NegativeAngle(ObjectManager.MyPlayer.Facing - angle);
                bool moving = ObjectManager.MyPlayer.IsMoving;
                if (face > 1)
                {
                    MoveHelper.ReleaseKeys();
                    moving = false;
                }
                FaceHorizontalWithTimer(face, "Right", moving);
            }
        }
Ejemplo n.º 3
0
        public static Int32 GetClosestPositionInList(List <Location> waypoints, Location pos)
        {
            int    result  = 0;
            Double nearest = -1;
            int    i       = 0;

            foreach (double distance in waypoints.Select(p => LazyMath.Distance3D(pos.X, pos.Y, pos.Z, p.X, p.Y, p.Z)))
            {
                if (nearest == -1 || distance < nearest)
                {
                    result  = i;
                    nearest = distance;
                }
                i++;
            }
            return(result);
        }
Ejemplo n.º 4
0
 public bool IsFacing(float errorMarge)
 {
     return(LazyMath.IsFacingH(AngleHorizontal, errorMarge));
 }
Ejemplo n.º 5
0
 public Single Angle(Location from)
 {
     return(LazyMath.CalculateFace(from, this));
 }