Beispiel #1
0
 public ActionResult Trigger(string trigger)
 {
     try
     {
         if (!String.IsNullOrEmpty(trigger))
         {
             if (IntentManager.GetIntentManager().TriggerExists(trigger))
             {
                 var intents = IntentManager.GetIntentManager().GetUserIntentData(trigger);
                 IntentManager.GetIntentManager().Trigger(trigger);
                 return(Json(Models.Response <dynamic> .Success(intents.Select(intent =>
                 {
                     return new
                     {
                         name = intent.name,
                         trigger = intent.trigger,
                         action = intent.action.ToString() //because we can't serialize entire Actions (methods), nor should we attempt to
                     };
                 })), JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(Models.Response.GetDefaultErrorMessage("Invalid Trigger: Trigger not found"), JsonRequestBehavior.AllowGet));
             }
         }
         else
         {
             return(Json(Models.Response.GetDefaultErrorMessage("Invalid Trigger: Empty String"), JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         return(Json(Models.Response.GetDefaultErrorMessage(ex.Message), JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #2
0
        public IActionResult TextToTestConverter(String Utterance)
        {
            Intent        userIntent    = new Intent();
            CodeConverter codeConverter = new CodeConverter();

            userIntent.Utterance = Utterance;
            string[] lines = Utterance.Split(new[] { "\r\n" }, StringSplitOptions.None);
            if (lines != null && lines.Count() > 0)
            {
                String codeResult = String.Empty;
                foreach (var item in lines)
                {
                    Task <String> intentTask = IntentManager.GetIntent(item);
                    codeResult += codeConverter.ConvertToCode(intentTask.Result);
                }
                userIntent.IntentValue = codeResult;
            }
            else
            {
                Task <String> intentTask = IntentManager.GetIntent(Utterance);
                String        codeResult = codeConverter.ConvertToCode(intentTask.Result);
                userIntent.IntentValue = codeResult;
            }


            return(View(userIntent));
        }
        public SpeechletResponseEnvelope Post()
        {
            var r           = Request.Content.ReadAsStringAsync().Result;
            var requestBody = JsonConvert.DeserializeObject <SpeechletRequestEnvelope>(r);

            Trace.TraceInformation(r);
            Trace.TraceInformation("---------");
            var type = requestBody?.Request?.Type;

            Trace.TraceInformation("intent type" + type);
            if (type == "LaunchRequest")
            {
                return(IntentManager.GetIntent("LaunchRequest").GetAlexaResponse());
                //   return  LaunchRequest.GetAlexaResponse();
            }
            var intentName = requestBody?.Request?.Intent?.Name;

            Trace.TraceInformation("intent Name" + intentName);
            if (string.IsNullOrEmpty(intentName))
            {
                return(null);
            }
            CacheManager.AddSlots(requestBody.Request.Intent.GetSlots);
            IntentBase intent = IntentManager.GetIntent(intentName);

            if (intent == null)
            {
                return(AlexaService.Json.UtillResponces.NoIntent(intentName));
            }
            var alexaResponse = intent.GetAlexaResponse();

            CacheManager.Intent.Push(intent);
            return(alexaResponse);
        }
Beispiel #4
0
 public JsonResult GetIntents()
 {
     return(Json(Models.Response <dynamic> .Success(IntentManager.GetIntentManager().GetIntents().Select(intent =>
     {
         return new
         {
             name = intent.name,
             trigger = intent.trigger,
             action = intent.action.ToString() //because we can't serialize entire Actions (methods), nor should we attempt to
         };
     })), JsonRequestBehavior.AllowGet));
 }
Beispiel #5
0
 void HandleIntents_SimulationMode()
 {
     if (IntentManager.Instance != null)
     {
         IntentManager intentManager = IntentManager.Instance;
         List <Intent> intents       = intentManager.Intents;
         for (int i = 0; i < intents.Count; i++)
         {
             if (intents[i].intentType == IntentType.LoadMode)
             {
                 LoadMode(intents[i].intentInt);
             }
         }
     }
 }
Beispiel #6
0
 void HandleIntents_Terrain()
 {
     if (IntentManager.Instance != null)
     {
         IntentManager intentManager = IntentManager.Instance;
         List <Intent> intents       = intentManager.Intents;
         for (int i = 0; i < intents.Count; i++)
         {
             if (intents[i].intentType == IntentType.LoadTerrain)
             {
                 levelEditor.Load(intents[i].intentString, intents[i].intentBool);
             }
         }
     }
 }
Beispiel #7
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     IntentManager.GetIntentManager(new SessionRepository()).Register(new Intent <string>()
     {
         name    = "page-request",
         trigger = "page-request",
         action  = (string data) =>
         {
             Console.WriteLine("New Page Request");
         }
     });
 }
Beispiel #8
0
 public ActionResult Subscribe(string trigger, string name, string data, string redirectUri = null)
 {
     try
     {
         IntentManager.GetIntentManager().AddIntentData(trigger, name, data);
         if (!String.IsNullOrEmpty(redirectUri))
         {
             return(Redirect(redirectUri));
         }
         if (Request.UrlReferrer != null)
         {
             return(Redirect(Request.UrlReferrer.ToString()));
         }
         return(Json(Models.Response.GetDefaultSuccessMessage(), JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(Models.Response.GetDefaultErrorMessage(ex.Message), JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #9
0
    void HandleIntents()
    {
        if (IntentManager.Instance != null)
        {
            IntentManager intentManager = IntentManager.Instance;
            List <Intent> intents       = intentManager.Intents;
            for (int i = 0; i < intents.Count; i++)
            {
                switch (intents[i].intentType)
                {
                case IntentType.LoadTerrain:
                    levelEditor.Load(intents[i].intentString, intents[i].intentBool);
                    break;

                case IntentType.LoadMode:
                    LoadMode(intents[i].intentInt);
                    break;
                }
            }
        }
    }
        public override void AddSpaceship(Entity e, Vector2 position, float rotation, IntentManager intentManager)
        {
            base.AddSpaceship(e, position, rotation, intentManager);

            e.AddComponent(new TextureComponent(Assets.Get <Texture2D>(GameConfig.Folders.Textures, GameConfig.Spaceship.DefaultTexture), Vector2.One * GameConfig.Spaceship.Size, GameConfig.Spaceship.Origin, 0.7f));
            e.AddComponent(new ParticleSpawnComponent(5, new Vector2(0, GameConfig.Spaceship.Size / 2f), Color.White, MathHelper.PiOver4));

            SpriteAnimation animation = Assets.LoadSpriteSheet(GameConfig.Spaceship.FlameAnimationSheet).GetSpriteAnimation(GameConfig.Spaceship.FlameAnimation);

            animation.Duration = 0.5f;
            animation.Origin   = new Vector2(450, 400);
            animation.Initialize();
            e.AddComponent(new SpriteAnimationComponent(animation, 0.02f, new Vector2(0, GameConfig.Spaceship.Size / 2f)));
        }
Beispiel #11
0
 protected void Application_BeginRequest()
 {
     IntentManager.GetIntentManager().Trigger("page-request");
 }
Beispiel #12
0
 protected void Session_Start()
 {
     IntentManager.GetIntentManager().CreateSessionStorage();
 }
Beispiel #13
0
 public ClientInputManager(BaseConnection connectionInfo, IntentManager intentManager) : base(intentManager)
 {
     this.connectionInfo = connectionInfo;
 }