Esempio n. 1
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);
                }
            });
        }
Esempio n. 2
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);
                }
            });
        }
Esempio n. 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));
                }
            });
        }
Esempio n. 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);
         }
     });
 }
Esempio n. 5
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));
                }
            });
        }
Esempio n. 6
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);
                }
            });
        }
Esempio n. 7
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));
                }
            });
        }
Esempio n. 8
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);
                }
            });
        }
Esempio n. 9
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);
                }
            });
        }
Esempio n. 10
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);
                }
            });
        }
Esempio n. 11
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);
                }
            });
        }
Esempio n. 12
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);
                }
            });
        }
Esempio n. 13
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);
                }
            });
        }
Esempio n. 14
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);
                }
            });
        }
Esempio n. 15
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);
                }
            });
        }
Esempio n. 16
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);
                }
            });
        }
Esempio n. 17
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);
                }
            });
        }
Esempio n. 18
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);
                }
            });
        }
Esempio n. 19
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);
                }
            });
        }