/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="sot">SeachOptionType</param>
 /// <param name="val">string value</param>
 /// <param name="st">SeachType of the option</param>
 public SearchOption(SeachOptionType sot, string val, SeachType st)
 {
     optiontype = sot;
     value = val;
     searchtype = st;
 }
Beispiel #2
0
    public IEnumerator IGetSocieties(SeachType type, string SeachKeyword, bool isForCheck)
    {
        ScreenAndPopupCall.Instance.LoadingScreen();
        var encoding = new System.Text.UTF8Encoding();

        Dictionary <string, string> postHeader = new Dictionary <string, string> ();
        var jsonElement = new Simple_JSON.JSONClass();

        jsonElement ["data_type"]   = "search";
        jsonElement ["search_type"] = type.ToString();
        jsonElement ["keyword"]     = SeachKeyword;
        jsonElement ["player_id"]   = PlayerPrefs.GetInt("PlayerId").ToString();

        postHeader.Add("Content-Type", "application/json");
        postHeader.Add("Content-Length", jsonElement.Count.ToString());

        WWW www = new WWW(SocietyLink, encoding.GetBytes(jsonElement.ToString()), postHeader);

        print("jsonDtat is ==>> " + jsonElement.ToString());
        yield return(www);

        if (www.error == null)
        {
            JSONNode _jsnode = Simple_JSON.JSON.Parse(www.text);
            print("_jsnode ==>> " + _jsnode.ToString());
            if (_jsnode ["status"].ToString().Contains("400") || _jsnode ["status"].ToString().Contains("200"))
            {
                JSONNode data      = _jsnode ["data"];
                var      Societies = new List <Society> ();
                for (int i = 0; i < data.Count; i++)
                {
                    string name        = data [i] ["society_name"];
                    string description = data [i] ["society_description"];
                    int    emblem      = 0;
                    int.TryParse(data [i] ["emblem_index"], out emblem);
                    int room = 0;
                    int.TryParse(data [i] ["room_index"], out room);
                    int _id = 0;
                    int.TryParse(data [i] ["society_id"], out _id);

                    JSONNode tags       = data [i] ["tags"];
                    var      listofTags = new List <string> ();

                    for (int x = 0; x < tags.Count; x++)
                    {
                        listofTags.Add(tags [x] ["tag_title"]);
                    }

                    Society sc = new Society(name, _id, description, emblem - 1, room - 1, listofTags);
                    Societies.Add(sc);
                }
                switch (type)
                {
                case SeachType.mine:
                    if (Societies.Count > 0)
                    {
                        _mySociety = Societies [0];
                    }
                    else
                    {
                        _mySociety = null;
                    }

                    if (!isForCheck)
                    {
                        CreateSocietyList(Societies, MySocietyContainer);
                        ScreenManager.Instance.SocietyListScreen.transform.FindChild("MySociety").GetComponent <Button> ().interactable = false;
                        if (!GameManager.Instance.gameObject.GetComponent <Tutorial> ()._SocietyCreated)
                        {
                            ScreenManager.Instance.SocietyListScreen.transform.FindChild("MostRecent").GetComponent <Button> ().interactable = false;
                        }
                        else
                        {
                            ScreenManager.Instance.SocietyListScreen.transform.FindChild("MostRecent").GetComponent <Button> ().interactable = true;
                        }
                        IndicationManager.Instance.IncrementIndicationFor("Society", 4);
                    }
                    break;

                case SeachType.recent:
                    CreateSocietyList(Societies, RecentSocietyContainer);
                    ScreenManager.Instance.SocietyListScreen.transform.FindChild("MySociety").GetComponent <Button> ().interactable  = true;
                    ScreenManager.Instance.SocietyListScreen.transform.FindChild("MostRecent").GetComponent <Button> ().interactable = false;
                    break;

                case SeachType.name:
                    CreateSocietyList(Societies, AllSocietyContainer);
                    ScreenManager.Instance.SocietyListScreen.transform.FindChild("MySociety").GetComponent <Button> ().interactable  = true;
                    ScreenManager.Instance.SocietyListScreen.transform.FindChild("MostRecent").GetComponent <Button> ().interactable = true;
                    break;

                case SeachType.tag:
                    CreateSocietyList(Societies, AllSocietyContainer);
                    ScreenManager.Instance.SocietyListScreen.transform.FindChild("MySociety").GetComponent <Button> ().interactable  = true;
                    ScreenManager.Instance.SocietyListScreen.transform.FindChild("MostRecent").GetComponent <Button> ().interactable = true;
                    break;

                default:
                    Debug.LogError("Search type not specified");
                    break;
                }
                yield return(_mySociety);
            }
        }
        ScreenAndPopupCall.Instance.LoadingScreenClose();
    }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="sot">SeachOptionType</param>
 /// <param name="val">string value</param>
 public SearchOption(SeachOptionType sot, string val)
 {
     optiontype = sot;
     value = val;
     searchtype = SeachType.Equal;
 }