Example #1
0
        private void Objects_OnObjectUpdated(object s, TerseObjectUpdateEventArgs e)
        {
            var Client         = GetGridClient();
            var ClientMovement = Client.Self.Movement;

            if (startTime == DateTime.MinValue)
            {
                DeRegCallback();
                return;
            }
            if (e.Update.LocalID == Client.Self.LocalID)
            {
                XYMovement();
                ZMovement();
                if (ClientMovement.AtPos || ClientMovement.AtNeg)
                {
                    TheBot.TurnToward(Target.GlobalPosition);
                    //Debug("Flyxy ");
                }
                else if (ClientMovement.UpPos || ClientMovement.UpNeg)
                {
                    TheBot.TurnToward(Target.GlobalPosition);
                    //ClientMovement.SendUpdate(false);
                    //Debug("Fly z ");
                }
                else if (Vector3d.Distance(Target.GlobalPosition, TheBot.GlobalPosition) <= 2.0)
                {
                    EndFlyto();
                    KeepFollowing = false;
                    Debug("At Target");
                }
            }
            if (!KeepFollowing)
            {
                EndFlyto();
                Debug("End Flyto");
            }
        }
Example #2
0
        public bool FlyToOnce()
        {
            // startTime = 10000;
            try
            {
                var      Client   = GetGridClient();
                double   dist     = ((SimMover)TheBot).Distance(Target);
                Vector3d premoved = TheBot.GlobalPosition;
                if (dist > maxDistance)
                {
                    //ClientMovement.Fly = true;
                    //KeepFollowing = true;
                    //ClientMovement.AtPos = true;
                    //startTime = 10000;
                    if (DoZ)
                    {
                        Client.Self.Movement.AtPos = false;
                        //if (startTime + 30000 > Environment.TickCount)
                        {
                            DoZ = false;
                            XYMovement();
                            target0.X = (float)target.X;
                            target0.Y = (float)target.Y;
                            //Client.Objects.OnObjectUpdated -= callback;
                            RegCallback();
                            SetMovement();
                        }
                    }
                    else
                    {
                        if (startTime.AddMinutes(1) > DateTime.Now)
                        {
                            DoZ = true;
                        }
                    }
                    Thread.Sleep(2000);
                    double premovedDist = Vector3d.Distance(premoved, TheBot.GlobalPosition);
                    if (premovedDist < 1)
                    {
                        blockedTimes++;
                        if (blockedTimes < 5)
                        {
                            return(true);
                        }
                        blockedTimes  = 0;
                        KeepFollowing = false;
                        TheBot.Debug("Blocked only moved " + premovedDist);
                        return(false);
                    }
                    //DoZ = !DoZ;
                    //if (DoZ) ZMovement();
                    //ClientMovement.TurnToward(target);
                    //System.Threading.Thread.Sleep(100);

                    //if (!DoZ) XYMovement();
                    //  ClientMovement.AtPos = false;
                    //   ClientMovement.AtNeg = false;
                    //  ZMovement();
                    //   ClientMovement.SendUpdate(false);
                    return(true);
                }
                else
                {
                    DoZ = true;
                    EndFlyto();
                    TheBot.TurnToward(Target.GlobalPosition);
                    //Thread.Sleep(1000); // total 3 seconds
                    return(false);
                }
            }
            finally
            {
                if (false)
                {
                    DeRegCallback();
                }
            }
        }