Exemple #1
0
    public void WriteJson()
    {
        eltCollection          = new ElementCollection();
        eltCollection.elements = new List <ElementJson>();

        //Grid
        for (int x = 0; x < lenght; x++)
        {
            for (int y = 0; y < lenght; y++)
            {
                for (int z = 0; z < lenght; z++)
                {
                    if (arr[x, y, z])
                    {
                        ElementJson newElt = new ElementJson();
                        newElt.id       = idArr[x, y, z];
                        newElt.position = arr[x, y, z].transform.position;
                        newElt.rotation = arr[x, y, z].transform.rotation;
                        eltCollection.elements.Add(newElt);
                    }
                }
            }
        }

        //Groups
        eltCollection.groups = new List <GroupJson>();
        foreach (Group gr in groups)
        {
            GroupJson newGrp = new GroupJson();
            Debug.Log(gr.pA);
            Debug.Log(gr.pB);
            newGrp.pA                 = gr.pA;
            newGrp.pB                 = gr.pB;
            newGrp.component          = new ComponentJson();
            newGrp.component.id       = gr.id;
            newGrp.component.position = gr.pos;
            newGrp.component.speed    = gr.speed;
            newGrp.component.channel  = gr.channel;
            eltCollection.groups.Add(newGrp);
        }

        //interactables
        eltCollection.interactables = new List <InteractableJson>();
        foreach (Interactable i in interactables)
        {
            InteractableJson newInter = new InteractableJson();
            newInter.pos     = i.gameObject.transform.position;
            newInter.channel = i.channel;
            eltCollection.interactables.Add(newInter);
        }

        string jsonFile = JsonUtility.ToJson(eltCollection);

        File.WriteAllText(Application.persistentDataPath + "/Levels/" + levelName, jsonFile);
        Debug.Log(jsonFile);
        LevelGenerator.levelName = levelName;
    }
        private void btnCreateGroup_Click(object sender, EventArgs e)
        {
            IUserApi  userBLL = new UserApi();
            GroupJson info    = userBLL.CreateGroup(token, "创建测试分组");

            if (info != null)
            {
                string tips = string.Format("GroupId:{0} GroupName:{1}", info.id, info.name);
                Console.WriteLine(tips);

                string       newName = "创建测试修改";
                CommonResult result  = userBLL.UpdateGroupName(token, info.id, newName);
                Console.WriteLine("修改分组名称:" + (result.Success ? "成功" : "失败:" + result.ErrorMessage));
            }
        }
Exemple #3
0
        /// <summary>
        /// 创建分组
        /// </summary>
        /// <param name="accessToken">调用接口凭证</param>
        /// <param name="name">分组名称</param>
        /// <returns></returns>
        public GroupJson CreateGroup(string accessToken, string name)
        {
            string url  = string.Format("https://api.weixin.qq.com/cgi-bin/groups/create?access_token={0}", accessToken);
            var    data = new
            {
                group = new
                {
                    name = name
                }
            };
            string postData = data.ToJson();

            GroupJson         group  = null;
            CreateGroupResult result = JsonHelper <CreateGroupResult> .ConvertJson(url, postData);

            if (result != null)
            {
                group = result.group;
            }
            return(group);
        }