static StringBuilder GetEndPositionJson(Level.GamePositions pEndPosition, ref StringBuilder pResources) { StringBuilder aEndPositionGobj = new StringBuilder("{"); aEndPositionGobj.Append("\"name\" : \"End Position\",\n"); aEndPositionGobj.Append("\"enabled\" : false,\n"); aEndPositionGobj.Append("\"Components\" : [\n"); GTransform aTransform = new GTransform(); aTransform.Position = new position(pEndPosition.mWorldPosition.x * 64.00001f, pEndPosition.mWorldPosition.y * 64.00001f); aEndPositionGobj.Append(aTransform.ToString()); aEndPositionGobj.Append(",\n"); string aSpGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(pEndPosition.mDisplaySprite)); GSprite aSprite = new GSprite(pEndPosition.mDisplaySprite.rect, aSpGUID, pEndPosition.mDisplaySprite.texture.height, (int)Level.LayerTypes.Players); SaveAssetData(GetAssetFromGUID(aSpGUID, AssetMetaData.AssetType.TextureAsset), ref pResources); aEndPositionGobj.Append(aSprite.ToString() + ",\n"); GPolygonCollider aPolygonCollider = new GPolygonCollider(true); aEndPositionGobj.Append(aPolygonCollider.ToString() + ",\n"); Teleporter aTeleporter = new Teleporter(); aEndPositionGobj.Append(aTeleporter.ToString()); aEndPositionGobj.Append("]\n"); aEndPositionGobj.Append("}"); return(aEndPositionGobj); }
static StringBuilder GetStartPositionJson(Level.GamePositions pStartPosition, ref StringBuilder pResources, AssetMetaData pPlayer) { StringBuilder aStartPositionGobj = new StringBuilder("{\n"); aStartPositionGobj.Append("\"name\" : \"Start Position\",\n"); aStartPositionGobj.Append("\"Components\" : [\n"); GTransform aTransform = new GTransform(); aTransform.Position = new position(pStartPosition.mWorldPosition.x * 64.00001f, pStartPosition.mWorldPosition.y * 64.00001f); aStartPositionGobj.Append(aTransform.ToString()); aStartPositionGobj.Append(",\n"); PlayerSpawner aSpawner = new PlayerSpawner(); aSpawner.mPlayerPrefabGUID = pPlayer.mGUID; SavePlayer(pPlayer, ref pResources); aStartPositionGobj.Append(aSpawner.ToString()); aStartPositionGobj.Append("]\n"); aStartPositionGobj.Append("}\n"); return(aStartPositionGobj); }
static StringBuilder GetGameScriptableJson(Vector2Int pPosition, GameScriptable pScriptable, ref StringBuilder pResources) { StringBuilder aGameScriptable = new StringBuilder("{\n"); aGameScriptable.Append("\"name\" : \"" + pScriptable.mName + "\",\n"); aGameScriptable.Append("\"Components\" : [\n"); GTransform aTransform = new GTransform(); aTransform.Position = new position(pPosition.x * 64.00001f, pPosition.y * 64.00001f); aGameScriptable.Append(aTransform.ToString() + ",\n"); switch (pScriptable.mType) { case GameScriptable.ObjectType.SpawnFactory: aGameScriptable.Append(GetSpawnFactoryJson((SpawnFactory)pScriptable, ref pResources)); break; case GameScriptable.ObjectType.StaticObject: aGameScriptable.Append(GetStaticObjectJson((StaticObject)pScriptable, ref pResources)); break; } aGameScriptable.Append("]\n"); aGameScriptable.Append("}"); return(aGameScriptable); }