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(); } } }
public IEnumerator SetPositionForSociety() { var societyHomeRoom = ScreenManager.Instance.HomeRoomSociety.GetComponent <SocietyHomeRoom>(); var postionString = SerializeVector3Array(transform.localPosition); CoroutineWithData cd = new CoroutineWithData(societyHomeRoom, societyHomeRoom.SavePositionInSocietyRoom(decorInfo.Id, postionString, direction)); yield return(cd.coroutine); if (cd.result.ToString() == "True" || cd.result.ToString() == "true") { DragSnap dragSnap = GetComponent <DragSnap> (); if (!dragSnap.CanBePlacedHere) { dragSnap.CanBePlacedHere = true; if (dragSnap.nearestFinal) { this.transform.localPosition = dragSnap.nearestFinal.transform.position; } } objPosition = transform.localPosition; if (!Placed) { var Pd = new SocietyDecor(); Pd.Id = decorInfo.Id; Pd.Position = transform.localPosition; Pd.Rotation = direction; societyHomeRoom.PlacedDecorInRoom.Add(Pd); } Placed = true; ScreenAndPopupCall.Instance.placementEnabled = false; transform.FindChild("Check").gameObject.SetActive(false); this.transform.GetChild(1).gameObject.SetActive(false); this.gameObject.GetComponent <DragSnap> ().enabled = false; var placementForSociety = ScreenManager.Instance.HomeRoomSociety.GetComponent <SocietyHomeRoom>().PlacementButton; placementForSociety.gameObject.SetActive(false); var AllDecorInSociety = transform.parent.GetComponentsInChildren <Decor3DView>(); for (int i = 0; i < AllDecorInSociety.Length; i++) { this.GetComponent <DragSnap> ().FindNearTilesInSociety(AllDecorInSociety [i].transform.FindChild("New Sprite"), false); } } else { CrossSociety(); } }