Пример #1
0
    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();
            }
        }
    }
Пример #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;
        }
    }