Beispiel #1
0
        private async Task <DialogTurnResult> RespondToName(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Respond with name ..
            await TheBot.SendMessage($"Hello, your name is {stepContext.Context.Activity.Text}", stepContext.Context);

            return(await ProceedWithDialog(stepContext));
        }
Beispiel #2
0
        public void FollowLoop()
        {
            while (KeepFollowing)
            {
                Thread.Sleep(100);
                Vector3 lastKnown;
                if (!Target.TryGetSimPosition(out lastKnown))
                {
                    DLRConsole.DebugWriteLine("" + this + " Not regions attached " + Target);
                    Thread.Sleep(2000);
                    continue;
                }

                double dist = TheBot.Distance(Target);

                if (dist < maxDistance || CloseEnough())
                {
                    continue;
                }

                if (!TheCBot.SalientGoto(Target))
                {
                    SwitchSalientProc();
                    continue;
                }
                if (!TheCBot.WaitUntilPosSimple(Target.GlobalPosition, Target.GetSizeDistance(), 3, true))
                {
                    SwitchSalientProc();
                }
                else
                {
                    SucceedSalientProc();
                }
            }
        }
Beispiel #3
0
        private async Task <DialogTurnResult> Ask4Name(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            await TheBot.SendMessage("What is your name?", stepContext.Context);

            // Wait for user input ..
            return(await WaitForUserInput(stepContext));
        }
        /// <summary>
        /// Generate a simple answer from the json template of this dialog.
        /// </summary>
        /// <param name="stepContext">the waterfall step context</param>
        /// <param name="cancellationToken">the cancellation token</param>
        /// <returns></returns>
        protected async Task <DialogTurnResult> SimpleAnswer(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            string        json    = MiscExtensions.LoadEmbeddedResource(_smallTalkPath + "." + $"{_top}.json");
            List <string> answers = json == null ? new List <string>() : JsonConvert.DeserializeObject <List <string> >(json);
            await TheBot.SendMessage(GetSimpleAnswer(answers), stepContext.Context);

            return(await ProceedWithDialog(stepContext));
        }
Beispiel #5
0
        private async Task <DialogTurnResult> PingStep(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Send Pong
            await TheBot.SendMessage($"[PONG]: {stepContext.Context.Activity.Text}", stepContext.Context);

            // Continue
            return(await ProceedWithDialog(stepContext));
        }
Beispiel #6
0
        private void Debug(string x)
        {
            var Client         = GetGridClient();
            var ClientMovement = Client.Self.Movement;

            // return; /* remove for debugging */
            TheBot.Debug(x + " {0,3:##0} {1,3:##0} {2,3:##0} diff {3,5:##0.0} olddiff {4,5:##0.0}  At:{5,5} {6,5}  Up:{7,5} {8,5}  v: {9} w: {10}",
                         myPos.X, myPos.Y, myPos.Z, diff, saveolddiff,
                         ClientMovement.AtPos, ClientMovement.AtNeg, ClientMovement.UpPos, ClientMovement.UpNeg,
                         Client.Self.Velocity.ToString(), Client.Self.AngularVelocity.ToString());
        }
Beispiel #7
0
        public override void Abort()
        {
            var Client         = GetGridClient();
            var ClientMovement = Client.Self.Movement;

            DeRegCallback();
            TheBot.StopMoving();
            EndFlyto();
            ClientMovement.Fly = true;
            if (FollowThread.IsAlive)
            {
                FollowThread.Abort();
            }
        }
        private async Task <DialogTurnResult> ClassifySmallTalk(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var top = TheBot.Result.GetTopScoringIntent().Item1.Substring("st_".Length);

            if (MiscExtensions.LoadEmbeddedResource(SmallTalkPath + "." + $"{top}.json") == null)
            {
                await TheBot.SendMessage($"Ich habe noch nicht gelernt auf {top} zu antworten.", stepContext.Context);
            }
            else
            {
                List <string> answers = FindSpecificAnswers(top);
                await TheBot.SendMessage(GetAnswer(answers), stepContext.Context);
            }
            return(await ProceedWithDialog(stepContext));
        }
Beispiel #9
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");
            }
        }
Beispiel #10
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();
                }
            }
        }
Beispiel #11
0
        private async Task <DialogTurnResult> SorryStep(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            await TheBot.SendMessage("Sorry, I did not understand you ..", stepContext.Context);

            return(await ProceedWithDialog(stepContext));
        }
 public override void Abort()
 {
     TheBot.StopMoving(true);
 }
 public override string ToString()
 {
     return("BotObjectAction:( " + TheBot.GetName() + " " + TargetUse.ToString() + ")");
 }