示例#1
0
        public void GetAttribute(string type, string message, GetSessionAttributesEventData eventData)
        {
            Dictionary <string, string> messageToAlexa = new Dictionary <string, string>();

            Vessel vessel = this.vessel;

            switch (message)
            {
            case "mass":
                messageToAlexa.Add("object", vessel.RevealMass().ToString());
                break;

            case "altitude":
                messageToAlexa.Add("object", vessel.RevealAltitude().ToString());
                break;

            case "body":
                messageToAlexa.Add("object", vessel.mainBody.ToString());
                break;

            case "velocity":
                messageToAlexa.Add("object", vessel.RevealSpeed().ToString());
                break;

            default:
                messageToAlexa.Add("object", "nothing");
                break;
            }
            alexaManager.SendToAlexaSkill(messageToAlexa, OnMessageSent);
        }
示例#2
0
 public void ConfirmSetup(GetSessionAttributesEventData eventData)
 {
     //Step 7: Notify the skill that setup has completed by updating the skills persistant attributes (in DynamoDB)
     attributes = eventData.Values;
     attributes["SETUP_STATE"] = new AttributeValue {
         S = "COMPLETED"
     };                                                                  //Set SETUP_STATE attribute to a string, COMPLETED
     alexaManager.SetSessionAttributes(attributes, SetAttributesCallback);
 }
    public void UpdateLight(string type, string value, GetSessionAttributesEventData eventData)
    {
        //Update the light based on the incoming message, then save the state of the light through the skill's session attributes
        attributes = eventData.Values;
        if (type == "Color")
        {
            attributes["color"] = new AttributeValue {
                S = value
            };                                                      //Set color attribute to a string value
        }
        else if (type == "State")
        {
            attributes["state"] = new AttributeValue {
                S = value
            };                                                      //Set state attribute to a string value
        }

        switch (value)
        {
        case "white":
            lightCube.GetComponent <Renderer>().material.color = Color.white;
            break;

        case "red":
            lightCube.GetComponent <Renderer>().material.color = Color.red;
            break;

        case "green":
            lightCube.GetComponent <Renderer>().material.color = Color.green;
            break;

        case "yellow":
            lightCube.GetComponent <Renderer>().material.color = Color.yellow;
            break;

        case "blue":
            lightCube.GetComponent <Renderer>().material.color = Color.blue;
            break;

        case "on":
            lightCube.GetComponent <Renderer>().enabled = true;
            break;

        case "off":
            lightCube.GetComponent <Renderer>().enabled = false;
            break;
        }
        alexaManager.SetSessionAttributes(attributes, SetAttributesCallback);  //Save Attributes for Alexa to use
    }
示例#4
0
        public void ExecuteCommand(string type, string message, float time, float value, GetSessionAttributesEventData eventData)
        {
            Vessel          vessel     = this.vessel;
            FlightCtrlState flightCtrl = new FlightCtrlState();

            switch (message)
            {
            case "roll":
                rollTime            = time;
                rollVal             = value;
                vessel.OnFlyByWire += new FlightInputCallback(Roll);
                break;

            case "pitch":
                pitchTime           = time;
                pitchVal            = value;
                vessel.OnFlyByWire += new FlightInputCallback(Pitch);
                break;

            case "yaw":
                yawTime             = time;
                yawVal              = value;
                vessel.OnFlyByWire += new FlightInputCallback(Yaw);
                break;
            }
        }