当前位置: 首页>>代码示例>>C#>>正文


C# Storage.toJSON方法代码示例

本文整理汇总了C#中Storage.toJSON方法的典型用法代码示例。如果您正苦于以下问题:C# Storage.toJSON方法的具体用法?C# Storage.toJSON怎么用?C# Storage.toJSON使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Storage的用法示例。


在下文中一共展示了Storage.toJSON方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnButtonDrawTenCards

	public void OnButtonDrawTenCards(){
		string[] storageJsonArray = new string[10];
		JSONNode j;
		Storage s = new Storage();
		bool[] isCounselors = new bool[10];
		int random;
		bool isRedraw = true;
		bool isMustRedraw = false;
		JSONClass json;
		int[] results = new int[10];
		do {
			isMustRedraw = false;
			for (int i=0; i<10; i++) {
				random = UnityEngine.Random.Range (1, numberOfCounselors + numberOfGenerals);
				isCounselors[i] = (random <= numberOfCounselors);
				//Debug.Log (random);
				results[i] = (isCounselors[i]) ? random : random - numberOfCounselors + 1000;
				s = new Storage (){productId= results[i], type =2, quantity =1}; //TODO: Personnel number instead of 0.
				if (isCounselors[i]){ 
					isRedraw = (counselorList[random-1].Rank != rankStopRedraw) ; // Make it false if any card Rank 6
					if (counselorList[random-1].Rank == rankNeedRedraw) isMustRedraw = true;
					storageJsonArray[i] = "{\"type\":"+results[i]+",\"level\":1}";
				}else{ // result == generals
					isRedraw = ( generalList[random-numberOfCounselors].Rank != rankStopRedraw); // Make it false if any card Rank 6
					if (generalList[random-numberOfCounselors].Rank == rankNeedRedraw) isMustRedraw = true;
					j = (JSONNode)s.toJSON ();
					storageJsonArray[i] = j.ToString();
				}
			}
		} while(isRedraw|| isMustRedraw);
		//string data = "["+ String.Join(" , ", storageJsonArray)+"]";
		json = new JSONClass ();
		for (int i = 0; i<10; i++) {
			json["data"]  = storageJsonArray [i];
			json["action"]="NEW";
			json["table"]= (isCounselors[i])? "counselors" : "storage" ;
			wsc.Send (json.ToString ());
		}

		json ["data"] = "";

	}
开发者ID:marcochiu2-c,项目名称:MainMenu_uFrame1.6,代码行数:42,代码来源:DrawCards.cs

示例2: OnButtonDrawSingleCard

	public void OnButtonDrawSingleCard(){
		int random = UnityEngine.Random.Range (1, numberOfCounselors + numberOfGenerals);
		bool isCounselors = (random <= numberOfCounselors);
		int result = (isCounselors) ? random : random - numberOfCounselors + 1000;

		//Debug.Log ("Random Number: "+random);

		//Debug.Log ("Result Number: "+ result);

		Storage s = new Storage(){productId= result, type =2, quantity =1}; //TODO: Personnel number instead of 0.

		json = new JSONClass ();
		if (isCounselors) {
			json["data"].Add ("userId",new JSONData(game.login.id));
			json["data"].Add ("type" , new JSONData(result));
			json["data"].Add ("level", new JSONData(1));
		} else {
			json.Add ("data", (JSONNode)s.toJSON ());
			json["data"].Add ("userId",new JSONData (game.login.id));
		}
		if (isCounselors) {
			json ["action"] = "NEW";
			json ["table"] = (isCounselors) ? "counselors" : "storage";
			Debug.Log (json.ToString ());
			wsc.Send (json.ToString ());
		}
	}
开发者ID:marcochiu2-c,项目名称:MainMenu_uFrame1.6,代码行数:27,代码来源:DrawCards.cs


注:本文中的Storage.toJSON方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。