Esempio n. 1
0
 public void HandleSpacePress()
 {
     //Handle the keyboard input
     if (!PlayerPrefs.HasKey("alexaUserDynamoKey"))
     {//If the AlexaUserId has not been recieved from Alexa (If the user has not opened the skill)
         Debug.LogError("'alexaUserDynamoKey' not found in PlayerPrefs. We must establish connection from Alexa to set this. Please open the skill to set the 'AlexaUserId' PlayerPref.");
     }
     else
     {
         alexaManager.GetSessionAttributes((result) =>
         {
             //if (result.IsError)
             //    Debug.LogError(result.Exception.Message);
             UpdateLight("Color", "blue", result);
         });
     }
 }
Esempio n. 2
0
    private void OnAlexaMessage(HandleMessageEventData eventData)
    {
        //Listen for new messages from the Alexa skill
        Debug.Log("OnAlexaMessage");

        Dictionary <string, object> message = eventData.Message;

        //Get Session Attributes with in-line defined callback
        switch (message["type"] as string)
        {
        case "AlexaUserId":
            Debug.Log("AlexaUserId: " + message["message"]);
            alexaManager.alexaUserDynamoKey = message["message"] as string;
            break;
        }

        alexaManager.GetSessionAttributes((result) =>
        {
            if (result.IsError)
            {
                Debug.LogError(eventData.Exception.Message);
            }

            switch (message["type"] as string)
            {
            case "AlexaUserId":
                ConfirmSetup(result);
                break;

            case "StartRequest":
                alexaManager.SendToAlexaSkill(StartGame(), null);
                break;

            case "NextGameRequest":
                alexaManager.SendToAlexaSkill(NextGame(), null);
                break;

            case "MathGameAnswer":
                string answer = message["answer"] as string;
                alexaManager.SendToAlexaSkill(onMathAnswer(answer), null);
                break;

            case "ColorGameAnswer":
                string response = onColorAnswer(message["color1"] as string, message["color2"] as string, message["color3"] as string, message["color4"] as string, message["color5"] as string);
                alexaManager.SendToAlexaSkill(response, null);
                break;

            case "HelpRequest":
                alexaManager.SendToAlexaSkill(onHelpRequest(), null);
                break;

            default:
                alexaManager.SendToAlexaSkill("Unrecognized message type!", null);
                break;
            }
        });
    }
Esempio n. 3
0
    private void OnAlexaMessage(HandleMessageEventData eventData)
    {
        //Listen for new messages from the Alexa skill
        Debug.Log("OnAlexaMessage");

        Dictionary <string, object> message = eventData.Message;

        //Get Session Attributes with in-line defined callback
        switch (message["type"] as string)
        {
        case "AlexaUserId":
            Debug.Log("AlexaUserId: " + message["message"]);
            alexaManager.alexaUserDynamoKey = message["message"] as string;
            break;
        }

        alexaManager.GetSessionAttributes((result) =>
        {
            if (result.IsError)
            {
                Debug.LogError(eventData.Exception.Message);
            }
            GameManager gm = FindObjectOfType <GameManager>();
            switch (message["type"] as string)
            {
            case "AlexaUserId":
                ConfirmSetup(result);
                break;

            case "PlaceRequest":
                alexaManager.SendToAlexaSkill(gm.onMoveCommand(message["ship"] as string, message["col"] as string, message["row"] as string, message["orientation"] as string), null);
                break;

            case "ConfirmPlacement":
                alexaManager.SendToAlexaSkill(gm.onConfirmPlacementCommand(), null);
                break;

            case "FireRequest":
                alexaManager.SendToAlexaSkill(gm.onFireCommand(message["col"] as string, message["row"] as string), null);
                break;

            default:
                alexaManager.SendToAlexaSkill("Unrecognized message type!", null);
                break;
            }
        });
    }
Esempio n. 4
0
    private void OnAlexaMessage(HandleMessageEventData eventData)
    {
        //Listen for new messages from the Alexa skill
        Debug.Log("OnAlexaMessage");

        Dictionary <string, object> message = eventData.Message;

        //Get Session Attributes with in-line defined callback
        switch (message["type"] as string)
        {
        case "AlexaUserId":
            Debug.Log("AlexaUserId: " + message["message"]);
            alexaManager.alexaUserDynamoKey = message["message"] as string;
            break;
        }

        alexaManager.GetSessionAttributes((result) =>
        {
            if (result.IsError)
            {
                Debug.LogError(eventData.Exception.Message);
            }

            switch (message["type"] as string)
            {
            case "AlexaUserId":
                ConfirmSetup(result);
                break;

            case "DestroyRequest":
                Destroy(GameObject.Find("Ship"));
                alexaManager.SendToAlexaSkill("BOOM!", null);
                break;

            default:
                alexaManager.SendToAlexaSkill("Unrecognized message type!", null);
                break;
            }
        });
    }
Esempio n. 5
0
        //Callback for when a message is recieved
        public void OnAlexaMessage(HandleMessageEventData eventData)
        {
            //Step 10: Listen for new messages from the Alexa skill
            Debug.Log(displayName + " OnAlexaMessage: " + eventData.Message["type"]);// + " " + eventData.Message["message"]);

            Dictionary <string, object> message = eventData.Message;

            //Get Session Attributes with in-line defined callback
            switch (message["type"] as string)
            {
            case "AlexaUserId":
                Debug.Log(displayName + " AlexaUserId: " + message["message"]);
                alexaManager.alexaUserDynamoKey = message["message"] as string;
                break;
            }

            alexaManager.GetSessionAttributes((result) =>
            {
                if (result.IsError)
                {
                    Debug.LogError(eventData.Exception.Message);
                }

                switch (message["type"] as string)
                {
                case "AlexaUserId":
                    ConfirmSetup(result);
                    break;

                case "ExecuteCommand":
                    Debug.Log(displayName + " Requested Execute Command: " + message["message"]);
                    ExecuteCommand(message["type"] as string, message["message"] as string, Convert.ToSingle(message["time"]), Convert.ToSingle(message["value"]), result);
                    break;

                case "GetAttribute":
                    Debug.Log(displayName + " Requested Attribute: " + message["message"]);
                    GetAttribute(message["type"] as string, message["message"] as string, result);
                    break;

                case "Stage":
                    Debug.Log(displayName + " Requested Staging");
                    InputSimulator Ins = new InputSimulator();
                    Ins.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);
                    break;

                case "SetThrottle":
                    Debug.Log(displayName + " Requested SetThrottle: " + message["message"]);
                    currentThrottle = Convert.ToSingle(message["message"]);
                    Debug.Log(displayName + currentThrottle);
                    vessel.OnFlyByWire += new FlightInputCallback(SetThrottle);
                    break;

                case "BurnCommand":
                    Debug.Log(displayName + " Requested BurnCommand: " + message["message"] + ", " + message["time"]);
                    burnTime            = Convert.ToSingle(message["time"]);
                    currentThrottle     = Convert.ToSingle(message["message"]);
                    vessel.OnFlyByWire += new FlightInputCallback(Burn);
                    break;

                default:
                    break;
                }
            });
        }