示例#1
0
        private static void Advance(INPC e, GameTime time)
        {
Again:
            Vector3 v1 = e.Path.Current;

            e.Path.NextNode();
            Vector3 v2 = e.Path.Current;
            Vector3 v  = (v2 - v1);

            if (v.Length() == 0)
            {
                goto Again;//Duplicate, should not exist
            }
            v.Normalize();
            if (v.X != 0 || v.Z != 0)
            {
                float angle = (float)Math.Atan(v.X / v.Z);
                if (v.X == 0 && v.Z < 0)
                {
                    angle += MathHelper.Pi;
                }
                Vector3 newrot = new Vector3(0, angle, 0);
                if (!newrot.Equals(e.Rotation))
                {
                    e.StopWalking(time);
                }
                e.Rotation = newrot;
            }
        }
示例#2
0
 public void Register(INPC enemy)
 {
     enemies.AddFirst(enemy);
     enemy.Position = enemy.Path.Current;
     enemy.StopWalking(Manager.Game.GameTime);
 }
示例#3
0
 public void Register(INPC enemy)
 {
     enemies.AddFirst(enemy);
     enemy.Position = enemy.Path.Current;
     enemy.StopWalking(Manager.Game.GameTime);
 }
示例#4
0
 private static void Advance(INPC e, GameTime time)
 {
     Again:
     Vector3 v1 = e.Path.Current;
     e.Path.NextNode();
     Vector3 v2 = e.Path.Current;
     Vector3 v = (v2 - v1);
     if (v.Length() == 0)
         goto Again;//Duplicate, should not exist
     v.Normalize();
     if (v.X != 0 || v.Z != 0)
     {
         float angle = (float)Math.Atan(v.X / v.Z);
         if (v.X == 0 && v.Z < 0) angle += MathHelper.Pi;
         Vector3 newrot = new Vector3(0, angle, 0);
         if (!newrot.Equals(e.Rotation))
             e.StopWalking(time);
         e.Rotation = newrot;
     }
 }