Пример #1
0
    void Loop()
    {
        while (true)
        {
            try
            {
                Coordinate Waypoint;
                float      angle, dist;

                UInt32 timeNow = MM_GetTime();
                UInt32 diff    = (timeNow - lastUpdateTime);
                lastUpdateTime = timeNow;
                if (Waypoints.Count != 0)
                {
                    Waypoint = Waypoints.First();

                    if (Waypoint != null)
                    {
                        angle = TerrainMgr.CalculateAngle(objectMgr.getPlayerObject().Position, Waypoint);
                        dist  = TerrainMgr.CalculateDistance(objectMgr.getPlayerObject().Position, Waypoint);
                        if (angle == objectMgr.getPlayerObject().Position.O)
                        {
                            if (dist > 1)
                            {
                                Flag.SetMoveFlag(MovementFlags.MOVEMENTFLAG_FORWARD);
                                UpdatePosition(diff);
                                lastUpdateTime = timeNow;
                            }
                            else
                            {
                                Waypoints.Remove(Waypoint);
                            }
                        }
                        else
                        {
                            Flag.SetMoveFlag(MovementFlags.MOVEMENTFLAG_NONE);
                            objectMgr.getPlayerObject().Position.O = angle;
                        }
                    }
                }
                else
                {
                    Flag.Clear();
                    Flag.SetMoveFlag(MovementFlags.MOVEMENTFLAG_NONE);
                }
            }
            catch (Exception ex)
            {
                //Exchange.OnNewLog("Exception Occured");
                //Exchange.OnNewLog("Message: " + ex.Message);
                ///Exchange.OnNewLog("Stacktrace: " + ex.StackTrace);
            }
        }
    }
Пример #2
0
 void Loop()
 {
     while (true)
     {
         try
         {
             if (Targets.Count > 0)
             {
                 Assets.Scripts.World.Object target = Targets.First();
                 float dist = TerrainMgr.CalculateDistance(objectMgr.getPlayerObject().Position, target.Position);
                 if (dist > 1)
                 {
                     movementMgr.Waypoints.Add(target.Position);
                 }
                 else if (dist < 1 && !isFighting)
                 {
                     //client.Attack(target);
                     isFighting = true;
                 }
                 else if (isFighting && target.Health < 0)
                 {
                     isFighting = false;
                     Targets.Remove(target);
                 }
                 else if (isFighting && target.Health > 0)
                 {
                     Debug.LogWarning(target.Health.ToString());
                 }
             }
         }
         catch (Exception ex)
         {
             Debug.LogWarning("Exception Occured");
             Debug.LogWarning("Message: " + ex.Message);
             Debug.LogWarning("Stacktrace: " + ex.StackTrace);
         }
     }
 }
Пример #3
0
 void Loop()
 {
     while (true)
     {
         try
         {
             if (Targets.Count > 0)
             {
                 Object target = Targets.First();
                 float  dist   = TerrainMgr.CalculateDistance(objectMgr.getPlayerObject().Position, target.Position);
                 if (dist > 1)
                 {
                     movementMgr.Waypoints.Add(target.Position);
                 }
                 else if (dist < 1 && !isFighting)
                 {
                     client.Attack(target);
                     isFighting = true;
                 }
                 else if (isFighting && target.Health < 0)
                 {
                     isFighting = false;
                     Targets.Remove(target);
                 }
                 else if (isFighting && target.Health > 0)
                 {
                     Console.WriteLine(target.Health);
                 }
             }
         }
         catch (Exception ex)
         {
             Log.WriteLine(LogType.Error, "Exception Occured");
             Log.WriteLine(LogType.Error, "Message: {0}", ex.Message);
             Log.WriteLine(LogType.Error, "Stacktrace: {0}", ex.StackTrace);
         }
     }
 }
Пример #4
0
 public float CalculateDistance(Coordinate c1)
 {
     return(TerrainMgr.CalculateDistance(objectMgr.getPlayerObject().Position, c1));
 }