本文整理汇总了C#中JSONObject.GetField方法的典型用法代码示例。如果您正苦于以下问题:C# JSONObject.GetField方法的具体用法?C# JSONObject.GetField怎么用?C# JSONObject.GetField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONObject
的用法示例。
在下文中一共展示了JSONObject.GetField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessMyGameStateResponse
private static void ProcessMyGameStateResponse(JSONObject jsonData)
{
if (jsonData.GetField ("gameStates")) {
JSONObject gameStateData = jsonData.GetField ("gameStates");
for (int i = 0; i < gameStateData.list.Count; i++) {
JSONObject gameState = gameStateData.list [i];
string access = null;
if (gameState.HasField ("access")) {
access = gameState.GetField ("access").str;
}
string data = null;
if (gameState.HasField ("data")) {
data = gameState.GetField ("data").str;
}
if (access != null && data != null) {
if (access.Equals ("private")) {
PrivateGameStateData = data;
SpilUnityImplementationBase.fireGameStateUpdated ("private");
} else if (access.Equals ("public")) {
PublicGameStateData = data;
SpilUnityImplementationBase.fireGameStateUpdated ("public");
}
}
}
}
}
示例2: CreateFromJson
public static GameModeDescription CreateFromJson(JSONObject jsonObject)
{
if (jsonObject == null)
{
Debug.LogWarning("There is no gameMode");
return new GameModeDescription()
{
Mode = "TargetScore",
TargetScore = 3000,
Turns = 40
};
/*return new GameModeDescription()
{
Mode = "TargetChuzzle",
Turns = 30,
Amount = 20
};*/
/*return new GameModeDescription()
{
Mode = "TargetPlace",
Turns = 30
};*/
}
var desc = new GameModeDescription
{
Mode = jsonObject.GetField("Mode").str,
Turns = (int) jsonObject.GetField("Turns").n,
TargetScore = jsonObject.HasField("TargetScore") ? (int) jsonObject.GetField("TargetScore").n : 0,
Amount = jsonObject.HasField("Amount") ? (int) jsonObject.GetField("Amount").n : 0
};
return desc;
}
示例3: InstantiateObject
public WorldObject InstantiateObject(JSONObject view)
{
var prefabName = view.GetField("prefab").ToString();
var instanceId = Convert.ToInt32(view.GetField("id").ToString());
var newObject = TryGetPrefab(prefabName);
if (newObject == null)
{
var prefab = Resources.Load("prefabs/" + prefabName);
if (prefab == null)
{
return null;
}
var obj = (GameObject)Instantiate(prefab, new Vector3(), Quaternion.identity);
newObject = obj.GetComponent<WorldObject>();
}
newObject.InitializeFromView(view);
AddObject(newObject, prefabName);
newObject.transform.parent = transform;
if (!_entities.ContainsKey(instanceId))
{
_entities.Add(instanceId, newObject);
}
return newObject;
}
示例4: HealUp
public HealUp(JSONObject js) : base()
{
_id = (int)js.GetField(js.keys[0]).n;
_heal = (int)js.GetField(js.keys[1]).n;
NbTurn = (int)js.GetField("nbTurn").n;
ApplyReverseEffect = true;
}
示例5: Deserialize
public static void Deserialize(this Template template)
{
template.Clear();
var tplJs = new JSONObject(template.JSON);
// Discard templates without the Operators and Connections fields
if (tplJs.HasField("Operators") && tplJs.HasField("Connections")) {
var opsJs = tplJs.GetField("Operators");
var connsJs = tplJs.GetField("Connections");
foreach (var opJs in opsJs.list) {
var type = System.Type.GetType(opJs["Type"].str);
var op = (Operator) System.Activator.CreateInstance(type);
op.Deserialize(opJs);
template.AddOperator(op, false);
}
foreach (var connJs in connsJs.list) {
// Discard connections with invalid Operator GUIDs
if (!template.Operators.ContainsKey(connJs["From"].str) || !template.Operators.ContainsKey(connJs["To"].str)) {
Debug.LogWarning("Discarding connection in template due to an invalid Operator GUID");
continue;
}
Operator fromOp = template.Operators[connJs["From"].str];
IOOutlet output = fromOp.GetOutput(connJs["Output"].str);
Operator toOp = template.Operators[connJs["To"].str];
IOOutlet input = toOp.GetInput(connJs["Input"].str);
template.Connect(fromOp, output, toOp, input, false);
}
}
}
示例6: initialize
public static void initialize() {
JSON = new JSONObject(GameManager.SongList.text);
version = JSON.GetField("version").str;
songList = JSON.GetField("songs").list;
nextSong();
}
示例7: MovementDown
public MovementDown(JSONObject js) : base()
{
_id = (int)js.GetField(js.keys[0]).n;
_movement = (int)js.GetField(js.keys[1]).n;
NbTurn = (int)js.GetField("nbTurn").n;
ApplyReverseEffect = true;
}
示例8: UnSerialize
public static JSONAble UnSerialize(JSONObject jsonObject)
{
JSONAble r = null;
if (jsonObject.HasField("_class") && jsonObject.HasField("_data"))
{
string c = jsonObject.GetField("_class").str;
Type t = Type.GetType(c);
if (t.IsSubclassOf(typeof(JSONAble)))
{
if (t.IsSubclassOf(typeof(ScriptableObject)))
{
r = ScriptableObject.CreateInstance(t) as JSONAble;
r.fromJSONObject(jsonObject.GetField("_data"));
}
}
}
else if (jsonObject.IsArray)
{
r = ScriptableObject.CreateInstance<IsoUnityCollectionType>();
r.fromJSONObject(jsonObject);
}
else if (jsonObject.IsString || jsonObject.IsNumber || jsonObject.IsBool)
{
r = ScriptableObject.CreateInstance<IsoUnityBasicType>();
r.fromJSONObject(jsonObject);
}
return r;
}
示例9: shootRope
public void shootRope(JSONObject rope)
{
GameObject.Find ("JumpButton").GetComponent<JumpButtonController> ().currentControl = "rope";
hinge.enabled = true;
line.enabled = true;
playerHinge.enabled = true;
RaycastHit2D hit = Physics2D.Raycast(ropeInitialTransform.position,new Vector2(rope.GetField("shootVectorX").f,rope.GetField("shootVectorY").f));
if(hit.collider.tag == "Ground"){
line.SetVertexCount(2);
line.SetPosition(0,new Vector3(hit.point.x,hit.point.y,-10));
line.SetPosition(1,bodyTransform.position);
hinge.connectedBody = hit.collider.GetComponent<Rigidbody2D>();
//접착지점에 게임 오브젝트 생성.
hitPosition.transform.position = hit.point;
hitPosition.transform.SetParent(hit.collider.transform);
hinge.connectedAnchor = hitPosition.transform.localPosition;
hinge.anchor = new Vector2(new Vector2(bodyTransform.position.x-hit.point.x,bodyTransform.position.y-hit.point.y).magnitude,0);
//hinge.anchor = new Vector2(hit.point.x - bodyTransform.position.x,hit.point.y-bodyTransform.position.y);
playerHinge.enabled =true;
playerHinge.connectedBody = this.GetComponent<Rigidbody2D>();
}
}
示例10: DamageElement
public DamageElement(JSONObject js) : base()
{
_id = (int)js.GetField(js.keys[0]).n;
_min = (int)js.GetField(js.keys[1]).n;
_max = (int)js.GetField(js.keys[2]).n;
_element = Element.GetElement((int)js.GetField(js.keys[3]).n);
}
示例11: callback
// Network call completed
private void callback(JSONObject result) {
if (final == null) {
// Create Result container
final = new SuperCookResult();
final.total_can_make_right_now = int.Parse(result.GetField("total_can_make_right_now").ToString());
final.results = new List<SuperCookRecipe>();
}
// Convert results
JSONArray arr = JSON.Parse(result.GetField("results").ToString()).AsArray;
foreach (JSONNode jn in arr) {
SuperCookRecipe scRecipe = new SuperCookRecipe();
scRecipe.title = jn["title"];
scRecipe.url = jn["url"];
scRecipe.uses = jn["uses"];
scRecipe.id = jn["id"].AsInt;
final.results.Add(scRecipe);
}
if (final.results.Count >= final.total_can_make_right_now)
finished(final);
else
{
skip += 40;
getRecipes(ingredients, finished);
}
}
示例12: DestroyGround
public void DestroyGround(JSONObject coll)
{
V2int c = World2Pixel(coll.GetField("centerX").f, coll.GetField("centerY").f);
int r = Mathf.RoundToInt(coll.GetField("sizeX").f*widthPixel/widthWorld);
Debug.Log (c);
Debug.Log (r);
int x, y, px, nx, py, ny, d;
for (x = 0; x <= r; x++)
{
d = (int)Mathf.RoundToInt(Mathf.Sqrt(r * r - x * x));
for (y = 0; y <= d; y++)
{
px = c.x + x;
nx = c.x - x;
py = c.y + y;
ny = c.y - y;
sr.sprite.texture.SetPixel(px, py, transp);
sr.sprite.texture.SetPixel(nx, py, transp);
sr.sprite.texture.SetPixel(px, ny, transp);
sr.sprite.texture.SetPixel(nx, ny, transp);
}
}
sr.sprite.texture.Apply();
Destroy(GetComponent<PolygonCollider2D>());
gameObject.AddComponent<PolygonCollider2D>();
}
示例13: ParseUnitObject
public static bool ParseUnitObject( JSONObject _UnitNode ,
ref string _UnitName ,
ref string _PrefabName ,
ref Vector3 _InitPosition ,
ref Quaternion _InitQuaternion )
{
if( true == _UnitNode.HasField( "name" ) &&
true == _UnitNode.HasField( "prefabName" )
)
{
_UnitName = _UnitNode.GetField( "name" ).str ;
Debug.Log( "JSonParseUtility01:ParseUnitObject() _UnitName=" + _UnitName) ;
_PrefabName = _UnitNode.GetField( "prefabName" ).str ;
if( true == _UnitNode.HasField( "position3D" ) )
{
JSONObject positione3DNode = _UnitNode.GetField( "position3D" ) ;
ParsePosition( positione3DNode ,
ref _InitPosition ) ;
}
if( true == _UnitNode.HasField( "orientationEuler" ) )
{
JSONObject orientationNode = _UnitNode.GetField( "orientationEuler" ) ;
ParseQuaternion( orientationNode ,
ref _InitQuaternion ) ;
}
return true ;
}
return false ;
}
示例14: InitializeFromView
public virtual void InitializeFromView(JSONObject view)
{
Name = view.GetField("name").ToString();
InstanceId = Convert.ToInt32(view.GetField("id").ToString());
transform.position = HelperMethods.PositionFromJSONArray(view.GetField("position"));
Prefab = view.GetField("prefab").ToString();
}
示例15: ObstacleCreation
public ObstacleCreation(JSONObject js)
{
_id = (int)js.GetField("id").n;
Life = (int)js.GetField("life").n;
Name = js.GetField("name").str;
_prefab = (GameObject)Resources.Load("Prefabs/" + Name, typeof(GameObject));
}