Пример #1
0
        public void List()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            Stellarium.GET(Path, "list", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                JSONObject json = new JSONObject(result);
                ActionGroupList actionGroupList = new ActionGroupList();
                actionGroupList.actionGroups    = new ActionGroup();
                foreach (string actionGroupName in json.keys)
                {
                    int numberOfActions   = json.GetField(actionGroupName).Count;
                    ActionList actionList = new ActionList();
                    actionList.actions    = new Action[numberOfActions];
                    for (int i = 0; i < numberOfActions; i++)
                    {
                        actionList.actions[i] = JsonUtility.FromJson <Action>(json.GetField(actionGroupName)[i].ToString());
                    }
                    actionGroupList.actionGroups.Add(actionGroupName, actionList);
                }
                if (OnGotList != null)
                {
                    OnGotList(actionGroupList);
                }
            });
        }
Пример #2
0
        public void GetObjectsByType(string type, bool english = default(bool))
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("type", type);
            if (english != default(bool))
            {
                parameters.Add("english", english.ToString());
            }
            Stellarium.GET(Path, "listobjectsbytype", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                JSONObject json             = new JSONObject(result);
                string[] objectsByTypeArray = new string[json.Count];
                for (int i = 0; i < json.Count; i++)
                {
                    objectsByTypeArray[i] = json[i].str;
                }
                if (OnGotObjectsByType != null)
                {
                    OnGotObjectsByType(objectsByTypeArray);
                }
            });
        }
Пример #3
0
        public void Nearby(string planet = default(string), float latitude = default(float), float longitude = default(float), float radius = default(float))  //TODO: Find out why I am getting a 400 Bad request
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            if (planet != default(string))
            {
                parameters.Add("planet", planet);
            }
            if (latitude != default(float))
            {
                parameters.Add("latitude", latitude.ToString());
            }
            if (longitude != default(float))
            {
                parameters.Add("longitude", longitude.ToString());
            }
            if (radius != default(float))
            {
                parameters.Add("radius", radius.ToString());
            }
            Stellarium.GET(Path, "countrylist", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                if (OnGotNearby != null)
                {
                    OnGotNearby(JsonUtility.FromJson <string[]>(result));
                }
            });
        }
Пример #4
0
 void GetInfoHTML(Dictionary <string, string> parameters)
 {
     Stellarium.GET(Path, "info", parameters, (result, error) => {
         if (error != null)
         {
             Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
         }
         if (OnGotInfo != null)
         {
             OnGotInfoHTML(result);
         }
     });
 }
Пример #5
0
 void SetLocationFields(Dictionary <string, string> parameters)
 {
     Stellarium.POST(Path, "setlocationfields", parameters, (result, error) => {
         if (error != null)
         {
             Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
         }
         if (OnSetLocationFields != null)
         {
             OnSetLocationFields();
         }
     });
 }
Пример #6
0
        public void Stop()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            Stellarium.POST(Path, "stop", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                if (OnStoppedScript != null)
                {
                    OnStoppedScript();
                }
            });
        }
Пример #7
0
        public void GetSkyCultureDescription()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            Stellarium.GET(Path, "skyculturedescription/", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                if (OnGotSkyCultureDescription != null)
                {
                    OnGotSkyCultureDescription(result);
                }
            });
        }
Пример #8
0
        public void GetStatus()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            Stellarium.GET(Path, "status", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                if (OnGotStatus != null)
                {
                    OnGotStatus(JsonUtility.FromJson <ScriptStatus>(result));
                }
            });
        }
Пример #9
0
        public void SetFOV(float fov)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("fov", fov.ToString());
            Stellarium.POST(Path, "fov", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                if (OnSetFOV != null)
                {
                    OnSetFOV();
                }
            });
        }
Пример #10
0
        public void Run(string id)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("id", id);
            Stellarium.POST(Path, "run", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                if (OnStartedScript != null)
                {
                    OnStartedScript();
                }
            });
        }
Пример #11
0
        public void Lookup(string str)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("str", str);
            Stellarium.GET(Path, "lookup", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                if (OnGotLookup != null)
                {
                    OnGotLookup(JsonUtility.FromJson <Lookup>(result));
                }
            });
        }
Пример #12
0
        public void GetPlanetImage(string planet)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("planet", planet);
            Stellarium.GETTexture(Path, "planetimage", parameters, (texture, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                if (OnGotPlanetImage != null)
                {
                    OnGotPlanetImage(texture);
                }
            });
        }
Пример #13
0
        public void SetMove(float x, float y)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("x", x.ToString());
            parameters.Add("y", y.ToString());
            Stellarium.POST(Path, "move", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                if (OnSetMove != null)
                {
                    OnSetMove();
                }
            });
        }
Пример #14
0
        public void Set(string id, string value)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("id", id);
            parameters.Add("value", value);
            Stellarium.POST(Path, "set", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                if (OnSetProperty != null)
                {
                    OnSetProperty();
                }
            });
        }
Пример #15
0
        public void SetTime(double time, double timerate)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("time", time.ToString());
            parameters.Add("timerate", timerate.ToString());
            Stellarium.POST(Path, "time", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                if (OnSetTime != null)
                {
                    OnSetTime();
                }
            });
        }
Пример #16
0
        public void GetInfoHTML(string name = default(string))
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            if (name != default(string))
            {
                parameters.Add("name", name);
            }
            Stellarium.GET(Path, "info", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                if (OnGotInfoHTML != null)
                {
                    OnGotInfoHTML(result);
                }
            });
        }
Пример #17
0
        public void GetPlanetList()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            Stellarium.GET(Path, "planetlist", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                JSONObject json       = new JSONObject(result);
                Planet[] planetsArray = new Planet[json.Count];
                for (int i = 0; i < json.Count; i++)
                {
                    planetsArray[i] = JsonUtility.FromJson <Planet>(json[i].ToString());
                }
                if (OnGotPlanetList != null)
                {
                    OnGotPlanetList(planetsArray);
                }
            });
        }
Пример #18
0
        public void DirectRun(string code, bool useIncludes = default(bool))
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("code", code);
            if (useIncludes != default(bool))
            {
                parameters.Add("useIncludes", useIncludes.ToString());
            }
            parameters.Add("useIncludes", useIncludes.ToString());
            Stellarium.POST(Path, "direct", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                if (OnRanCode != null)
                {
                    OnRanCode();
                }
            });
        }
Пример #19
0
        public void GetList()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            Stellarium.GET(Path, "list", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                JSONObject json        = new JSONObject(result);
                string[] locationArray = new string[json.Count];
                for (int i = 0; i < json.Count; i++)
                {
                    locationArray[i] = json[i].str;
                }
                if (OnGotList != null)
                {
                    OnGotList(locationArray);
                }
            });
        }
Пример #20
0
        public void Do(string id)   //TODO: Find out what constitutes a valid parameter
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("id", id);
            Stellarium.POST(Path, "do", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                bool b = false;
                if (!bool.TryParse(result, out b))
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, result)); return;
                }
                if (OnDidAction != null)
                {
                    OnDidAction(b);
                }
            });
        }
Пример #21
0
        public void ListProjection()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            Stellarium.GET(Path, "listprojection", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                ProjectionList projectionList = new ProjectionList();
                projectionList.projections    = new Projection();
                foreach (KeyValuePair <string, string> projection in (new JSONObject(result).ToDictionary()))
                {
                    projectionList.projections.Add(projection.Key, projection.Value);
                }
                if (OnGotProjectionList != null)
                {
                    OnGotProjectionList(projectionList);
                }
            });
        }
Пример #22
0
        public void ListLandscape()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            Stellarium.GET(Path, "listlandscape", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                LandscapeList landscapeList = new LandscapeList();
                landscapeList.landscapes    = new Landscape();
                foreach (KeyValuePair <string, string> landscape in (new JSONObject(result).ToDictionary()))
                {
                    landscapeList.landscapes.Add(landscape.Key, landscape.Value);
                }
                if (OnGotLandscapeList != null)
                {
                    OnGotLandscapeList(landscapeList);
                }
            });
        }
Пример #23
0
        public void ListSkyCulture()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            Stellarium.GET(Path, "listskyculture", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                SkyCultureList skyCultureList = new SkyCultureList();
                skyCultureList.skyCultures    = new SkyCulture();
                foreach (KeyValuePair <string, string> skyCulture in (new JSONObject(result).ToDictionary()))
                {
                    skyCultureList.skyCultures.Add(skyCulture.Key, skyCulture.Value);
                }
                if (OnGotSkyCultureList != null)
                {
                    OnGotSkyCultureList(skyCultureList);
                }
            });
        }
Пример #24
0
        public void GetObjectTypes()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            Stellarium.GET(Path, "listobjecttypes", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                JSONObject json = new JSONObject(result);
                ObjectTypeArray objectTypeArray = new ObjectTypeArray();
                objectTypeArray.objectTypes     = new ObjectType[json.Count];
                for (int i = 0; i < json.Count; i++)
                {
                    objectTypeArray.objectTypes[i] = JsonUtility.FromJson <ObjectType>(json[i].ToString());
                }
                if (OnGotObjectTypes != null)
                {
                    OnGotObjectTypes(objectTypeArray);
                }
            });
        }
Пример #25
0
        public void FindObjects(string str)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("str", str);
            Stellarium.GET(Path, "find", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                JSONObject json       = new JSONObject(result);
                string[] objectsArray = new string[json.Count];
                for (int i = 0; i < json.Count; i++)
                {
                    objectsArray[i] = json[i].str;
                }
                if (OnFoundObjects != null)
                {
                    OnFoundObjects(objectsArray);
                }
            });
        }
Пример #26
0
        public void Search(string term)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("term", term);
            Stellarium.GET(Path, "search", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                JSONObject json      = new JSONObject(result);
                string[] resultArray = new string[json.Count];
                for (int i = 0; i < json.Count; i++)
                {
                    resultArray[i] = json[i].str;
                }
                if (OnGotSearch != null)
                {
                    OnGotSearch(resultArray);
                }
            });
        }
Пример #27
0
        public void GetPlugins()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            Stellarium.GET(Path, "plugins", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                JSONObject json       = new JSONObject(result);
                PluginList pluginList = new PluginList();
                pluginList.plugins    = new Plugins();
                foreach (string pluginName in json.keys)
                {
                    pluginList.plugins.Add(pluginName, JsonUtility.FromJson <Plugin>(json.GetField(pluginName).ToString()));
                }
                if (OnGotPlugins != null)
                {
                    OnGotPlugins(pluginList);
                }
            });
        }
Пример #28
0
        public void List()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            Stellarium.GET(Path, "list", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                JSONObject json           = new JSONObject(result);
                PropertyList propertyList = new PropertyList();
                propertyList.properties   = new Property();
                foreach (string propertyName in json.keys)
                {
                    propertyList.properties.Add(propertyName, JsonUtility.FromJson <PropertyInfo>(json.GetField(propertyName).ToString()));
                }
                if (OnGotList != null)
                {
                    OnGotList(propertyList);
                }
            });
        }
Пример #29
0
        public void GetStatus(int actionId = default(int), int propId = default(int))
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            if (actionId != default(int))
            {
                parameters.Add("actionId", actionId.ToString());
            }
            if (propId != default(int))
            {
                parameters.Add("propId", propId.ToString());
            }
            Stellarium.GET(Path, "status", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                JSONObject json = new JSONObject(result);
                if (statusJSON)
                {
                    statusJSON.Merge(json);
                }
                else
                {
                    statusJSON = json;
                }
                Status status = JsonUtility.FromJson <Status>(result);
                if (statusJSON.HasField("actionChanges"))
                {
                    Dictionary <string, string> jsonActionChanges = statusJSON.GetField("actionChanges").GetField("changes").ToDictionary();
                    status.actionChanges.changes = new Changes();
                    foreach (KeyValuePair <string, string> change in jsonActionChanges)
                    {
                        bool changed;
                        if (bool.TryParse(change.Value, out changed))
                        {
                            status.actionChanges.changes.Add(change.Key, changed);
                        }
                    }
                }
                else
                {
                    status.actionChanges.changes = new Changes();
                }
                if (statusJSON.HasField("propertyChanges"))
                {
                    Dictionary <string, string> jsonPropertyChanges = statusJSON.GetField("propertyChanges").GetField("changes").ToDictionary();
                    status.propertyChanges.changes = new Changes();
                    foreach (KeyValuePair <string, string> change in jsonPropertyChanges)
                    {
                        bool changed;
                        if (bool.TryParse(change.Value, out changed))
                        {
                            status.propertyChanges.changes.Add(change.Key, changed);
                        }
                    }
                }
                else
                {
                    status.propertyChanges.changes = new Changes();
                }
                if (OnGotStatus != null)
                {
                    OnGotStatus(status);
                }
            });
        }