IEnumerator IGetAllDecorInSocietyRoom(int societyId)
    {
        PlacedDecorInRoom.Clear();

        var link     = "http://pinekix.ignivastaging.com/decors/getDecorSocietyData";
        var encoding = new System.Text.UTF8Encoding();

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

        jsonElement ["player_id"]  = PlayerPrefs.GetInt("PlayerId").ToString();
        jsonElement ["society_id"] = societyId.ToString();

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

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

        yield return(www);

        if (www.error == null)
        {
            JSONNode _jsnode = Simple_JSON.JSON.Parse(www.text);
            print("_jsnode ==>> " + _jsnode.ToString());
            //TODO
            if (_jsnode["status"].ToString().Contains("200") || _jsnode["description"].ToString().Contains("Data is following."))
            {
//                "data": [
//                        {
//                            "id": "12",
//                            "player_id": "101",
//                            "society_id": "56",
//                            "item_id": "39",
//                            "position": "",
//                            "rotation": ""
//                        }
//                ]
                var data = _jsnode["data"];
                for (int i = 0; i < data.Count; i++)
                {
                    var item = data[i];
                    var sd   = new SocietyDecor();
                    int id   = 0;
                    int.TryParse(item["item_id"], out id);

                    string posString = item["position"].Value;
                    int    rotation  = 0;
                    int.TryParse(item["rotation"], out rotation);

                    sd.Id       = id;
                    sd.Position = Decor3DView.DeserializeVector3Array(posString);
                    sd.Rotation = rotation;
//                    sd.Prefab = FindDecorWithId(id);

                    PlacedDecorInRoom.Add(sd);
                }
                CreatePlacedDecor();
            }
        }
    }
Exemple #2
0
    public void Correct()
    {
        if (ScreenManager.Instance.OpenedCustomizationScreen == "DecorEvent")
        {
            EventManagment.Instance.DecorEventList.Clear();
            StartCoroutine(SetPositionForEvent());
            EventManagment.Instance._registerButton.interactable = true;
            for (int i = 0; i < DecorController.Instance.TempDecorForEvent.Count; i++)
            {
                if (decorInfo.Name == DecorController.Instance.TempDecorForEvent [i].Name)
                {
                    DecorController.Instance.TempDecorForEvent.Remove(DecorController.Instance.TempDecorForEvent [i]);
                    if (DecorController.Instance.TempDecorForEvent.Count == 0)
                    {
                        DecorController.AddItemEnable = false;
                    }
                }
            }
        }
        else if (isForSociety)
        {
            StartCoroutine(SetPositionForSociety());
        }
        else
        {
            ScreenManager.Instance.CellPhone.transform.FindChild("CellButton").gameObject.SetActive(true);
            ScreenManager.Instance.MenuScreen.transform.FindChild("OpenCloseSlider").gameObject.SetActive(true);
            ChangeFlatmateTouch(true);
            DragSnap dragSnap = GetComponent <DragSnap> ();
            if (!dragSnap.CanBePlacedHere)
            {
                dragSnap.CanBePlacedHere = true;
                if (dragSnap.nearestFinal)
                {
                    this.transform.position = dragSnap.nearestFinal.transform.position;
                }
                else
                {
                    var objPosition = Decor3DView.DeserializeVector3Array(PlayerPrefs.GetString("ObjPosition" + decorInfo.Name));
                    this.transform.position = objPosition;
                }
            }

            if (!Placed)
            {
                DecorController.Instance.PlacedDecors.Add(this);
                DecorController.Instance.PlacedDecorsName.Add(decorInfo.Name);
                Placed = true;
            }
            StartCoroutine(SetPosition());
            ScreenAndPopupCall.Instance.placementEnabled = false;
        }
    }
    public void AddDecorToList(int Id, Decor3DView info, string Name, string SubCat, int level, int gems, int price, int vipsub)
    {
//		DecorInfo info = target.GetComponent<DecorInfo> ();
        int subcat = 0;

        /*
         *
         * Sofa = 0,
         * Chairs = 1,
         * Tables = 2,
         * Beds = 3,
         * Techs = 4,
         * Plants = 5,
         * Appliance = 6,
         * Plumbing = 7,
         * Cabinets = 8,
         * Misc = 9
         */
        switch (SubCat.Trim('"'))
        {
        case "Sofas":
            subcat = 0;
            break;

        case "Chairs":
            subcat = 1;
            break;

        case "Tables":
            subcat = 2;
            break;

        case "Beds":
            subcat = 3;
            break;

        case "Plants":
            subcat = 4;
            break;

        case "Electronics":
            subcat = 5;
            break;

        case "Living room":     // Almirah
            subcat = 6;
            break;

        case "Bedroom":    //"Cabinets":
            subcat = 7;
            break;

        case "Kitchen":    //"Fridges":
            subcat = 8;
            break;

        case "Patio":    //"Radio":
            subcat = 9;
            break;


//                Sofa = 0,
//                Chairs = 1,
//                Tables = 2,
//                Beds = 3,
//                Plants = 4,
//                Electronics = 5,
//                Almirah = 6,
//                Cabinets = 7,
//                Fridges = 8,
//                Radio= 9
        }

        DecorData data = new DecorData(Name, Id, subcat, info.decorInfo.DisplayIcon, false, false, level, gems, price, vipsub == 1? true:false);

        AllDecores.Add(data);

        DownloadedDecors.Add(info.gameObject);
    }