diff --git a/.gitignore b/.gitignore
index 72c27e4f..1dba1bed 100644
--- a/.gitignore
+++ b/.gitignore
@@ -69,3 +69,5 @@ crashlytics-build.properties
# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
+Assets/Packages
+Assets/Packages.meta
diff --git a/Assets/NuGet.config b/Assets/NuGet.config
new file mode 100644
index 00000000..ca703692
--- /dev/null
+++ b/Assets/NuGet.config
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Assets/NuGet.config.meta b/Assets/NuGet.config.meta
new file mode 100644
index 00000000..ba99f687
--- /dev/null
+++ b/Assets/NuGet.config.meta
@@ -0,0 +1,32 @@
+fileFormatVersion: 2
+guid: 36beb3506906c8048ad370241fcd0b87
+PluginImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ iconMap: {}
+ executionOrder: {}
+ defineConstraints: []
+ isPreloaded: 0
+ isOverridable: 0
+ isExplicitlyReferenced: 0
+ validateReferences: 1
+ platformData:
+ - first:
+ Any:
+ second:
+ enabled: 0
+ settings: {}
+ - first:
+ Editor: Editor
+ second:
+ enabled: 0
+ settings:
+ DefaultValueInitialized: true
+ - first:
+ Windows Store Apps: WindowsStoreApps
+ second:
+ enabled: 0
+ settings: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/NuGet.meta b/Assets/NuGet.meta
new file mode 100644
index 00000000..260915e8
--- /dev/null
+++ b/Assets/NuGet.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 217cb7caed5f7fb49b339428b1d80974
+folderAsset: yes
+timeCreated: 1510280316
+licenseType: Free
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/NuGet/Editor.meta b/Assets/NuGet/Editor.meta
new file mode 100644
index 00000000..3b6fd6bc
--- /dev/null
+++ b/Assets/NuGet/Editor.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: b3fad56c531ac5a4db190a745f589a8e
+folderAsset: yes
+timeCreated: 1510280304
+licenseType: Free
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/NuGet/Editor/NugetForUnity.dll b/Assets/NuGet/Editor/NugetForUnity.dll
new file mode 100644
index 00000000..846ffbce
Binary files /dev/null and b/Assets/NuGet/Editor/NugetForUnity.dll differ
diff --git a/Assets/NuGet/Editor/NugetForUnity.dll.meta b/Assets/NuGet/Editor/NugetForUnity.dll.meta
new file mode 100644
index 00000000..833aac7d
--- /dev/null
+++ b/Assets/NuGet/Editor/NugetForUnity.dll.meta
@@ -0,0 +1,33 @@
+fileFormatVersion: 2
+guid: 8dc1be91775c4bb469f6b74cef450eaa
+PluginImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ iconMap: {}
+ executionOrder: {}
+ defineConstraints: []
+ isPreloaded: 0
+ isOverridable: 0
+ isExplicitlyReferenced: 0
+ validateReferences: 1
+ platformData:
+ - first:
+ Any:
+ second:
+ enabled: 0
+ settings: {}
+ - first:
+ Editor: Editor
+ second:
+ enabled: 1
+ settings:
+ DefaultValueInitialized: true
+ - first:
+ Windows Store Apps: WindowsStoreApps
+ second:
+ enabled: 0
+ settings:
+ CPU: AnyCPU
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/NuGet/LICENSE b/Assets/NuGet/LICENSE
new file mode 100644
index 00000000..e5e72104
--- /dev/null
+++ b/Assets/NuGet/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 Patrick McCarthy
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Assets/NuGet/LICENSE.meta b/Assets/NuGet/LICENSE.meta
new file mode 100644
index 00000000..9de0ac8d
--- /dev/null
+++ b/Assets/NuGet/LICENSE.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 1d9014b99ad06af428514a5902d29ff3
+timeCreated: 1573248500
+licenseType: Pro
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/NuGet/README.pdf b/Assets/NuGet/README.pdf
new file mode 100644
index 00000000..e67f9fa5
Binary files /dev/null and b/Assets/NuGet/README.pdf differ
diff --git a/Assets/NuGet/README.pdf.meta b/Assets/NuGet/README.pdf.meta
new file mode 100644
index 00000000..e95001a0
--- /dev/null
+++ b/Assets/NuGet/README.pdf.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 83c5d2001771f15429a88d67e81366d6
+timeCreated: 1517876157
+licenseType: Free
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/NuGet/Resources.meta b/Assets/NuGet/Resources.meta
new file mode 100644
index 00000000..49a5e3b4
--- /dev/null
+++ b/Assets/NuGet/Resources.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 1738075a39a390447b7a620ca6962142
+folderAsset: yes
+timeCreated: 1510280362
+licenseType: Free
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/NuGet/Resources/defaultIcon.png b/Assets/NuGet/Resources/defaultIcon.png
new file mode 100644
index 00000000..a16cc198
Binary files /dev/null and b/Assets/NuGet/Resources/defaultIcon.png differ
diff --git a/Assets/NuGet/Resources/defaultIcon.png.meta b/Assets/NuGet/Resources/defaultIcon.png.meta
new file mode 100644
index 00000000..d23111ab
--- /dev/null
+++ b/Assets/NuGet/Resources/defaultIcon.png.meta
@@ -0,0 +1,88 @@
+fileFormatVersion: 2
+guid: eec19781926cd2248b7c9abfde8db555
+TextureImporter:
+ fileIDToRecycleName: {}
+ externalObjects: {}
+ serializedVersion: 9
+ mipmaps:
+ mipMapMode: 0
+ enableMipMap: 1
+ sRGBTexture: 1
+ linearTexture: 0
+ fadeOut: 0
+ borderMipMap: 0
+ mipMapsPreserveCoverage: 0
+ alphaTestReferenceValue: 0.5
+ mipMapFadeDistanceStart: 1
+ mipMapFadeDistanceEnd: 3
+ bumpmap:
+ convertToNormalMap: 0
+ externalNormalMap: 0
+ heightScale: 0.25
+ normalMapFilter: 0
+ isReadable: 0
+ streamingMipmaps: 0
+ streamingMipmapsPriority: 0
+ grayScaleToAlpha: 0
+ generateCubemap: 6
+ cubemapConvolution: 0
+ seamlessCubemap: 0
+ textureFormat: -1
+ maxTextureSize: 2048
+ textureSettings:
+ serializedVersion: 2
+ filterMode: -1
+ aniso: -1
+ mipBias: -100
+ wrapU: 1
+ wrapV: 1
+ wrapW: 1
+ nPOTScale: 0
+ lightmap: 0
+ compressionQuality: 50
+ spriteMode: 1
+ spriteExtrude: 1
+ spriteMeshType: 1
+ alignment: 0
+ spritePivot: {x: 0.5, y: 0.5}
+ spritePixelsToUnits: 100
+ spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+ spriteGenerateFallbackPhysicsShape: 1
+ alphaUsage: 1
+ alphaIsTransparency: 1
+ spriteTessellationDetail: -1
+ textureType: 8
+ textureShape: 1
+ singleChannelComponent: 0
+ maxTextureSizeSet: 0
+ compressionQualitySet: 0
+ textureFormatSet: 0
+ platformSettings:
+ - serializedVersion: 2
+ buildTarget: DefaultTexturePlatform
+ maxTextureSize: 2048
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ spriteSheet:
+ serializedVersion: 2
+ sprites: []
+ outline: []
+ physicsShape: []
+ bones: []
+ spriteID: 215e43cda847e6d44af8b40376eeed8a
+ vertices: []
+ indices:
+ edges: []
+ weights: []
+ spritePackingTag:
+ pSDRemoveMatte: 0
+ pSDShowRemoveMatteOption: 0
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity
deleted file mode 100644
index 34425e2d..00000000
--- a/Assets/Scenes/SampleScene.unity
+++ /dev/null
@@ -1,298 +0,0 @@
-%YAML 1.1
-%TAG !u! tag:unity3d.com,2011:
---- !u!29 &1
-OcclusionCullingSettings:
- m_ObjectHideFlags: 0
- serializedVersion: 2
- m_OcclusionBakeSettings:
- smallestOccluder: 5
- smallestHole: 0.25
- backfaceThreshold: 100
- m_SceneGUID: 00000000000000000000000000000000
- m_OcclusionCullingData: {fileID: 0}
---- !u!104 &2
-RenderSettings:
- m_ObjectHideFlags: 0
- serializedVersion: 9
- m_Fog: 0
- m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
- m_FogMode: 3
- m_FogDensity: 0.01
- m_LinearFogStart: 0
- m_LinearFogEnd: 300
- m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
- m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
- m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
- m_AmbientIntensity: 1
- m_AmbientMode: 0
- m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
- m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
- m_HaloStrength: 0.5
- m_FlareStrength: 1
- m_FlareFadeSpeed: 3
- m_HaloTexture: {fileID: 0}
- m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
- m_DefaultReflectionMode: 0
- m_DefaultReflectionResolution: 128
- m_ReflectionBounces: 1
- m_ReflectionIntensity: 1
- m_CustomReflection: {fileID: 0}
- m_Sun: {fileID: 705507994}
- m_IndirectSpecularColor: {r: 0.44657826, g: 0.49641263, b: 0.57481676, a: 1}
- m_UseRadianceAmbientProbe: 0
---- !u!157 &3
-LightmapSettings:
- m_ObjectHideFlags: 0
- serializedVersion: 11
- m_GIWorkflowMode: 1
- m_GISettings:
- serializedVersion: 2
- m_BounceScale: 1
- m_IndirectOutputScale: 1
- m_AlbedoBoost: 1
- m_EnvironmentLightingMode: 0
- m_EnableBakedLightmaps: 1
- m_EnableRealtimeLightmaps: 0
- m_LightmapEditorSettings:
- serializedVersion: 12
- m_Resolution: 2
- m_BakeResolution: 40
- m_AtlasSize: 1024
- m_AO: 0
- m_AOMaxDistance: 1
- m_CompAOExponent: 1
- m_CompAOExponentDirect: 0
- m_ExtractAmbientOcclusion: 0
- m_Padding: 2
- m_LightmapParameters: {fileID: 0}
- m_LightmapsBakeMode: 1
- m_TextureCompression: 1
- m_FinalGather: 0
- m_FinalGatherFiltering: 1
- m_FinalGatherRayCount: 256
- m_ReflectionCompression: 2
- m_MixedBakeMode: 2
- m_BakeBackend: 1
- m_PVRSampling: 1
- m_PVRDirectSampleCount: 32
- m_PVRSampleCount: 500
- m_PVRBounces: 2
- m_PVREnvironmentSampleCount: 500
- m_PVREnvironmentReferencePointCount: 2048
- m_PVRFilteringMode: 2
- m_PVRDenoiserTypeDirect: 0
- m_PVRDenoiserTypeIndirect: 0
- m_PVRDenoiserTypeAO: 0
- m_PVRFilterTypeDirect: 0
- m_PVRFilterTypeIndirect: 0
- m_PVRFilterTypeAO: 0
- m_PVREnvironmentMIS: 0
- m_PVRCulling: 1
- m_PVRFilteringGaussRadiusDirect: 1
- m_PVRFilteringGaussRadiusIndirect: 5
- m_PVRFilteringGaussRadiusAO: 2
- m_PVRFilteringAtrousPositionSigmaDirect: 0.5
- m_PVRFilteringAtrousPositionSigmaIndirect: 2
- m_PVRFilteringAtrousPositionSigmaAO: 1
- m_ExportTrainingData: 0
- m_TrainingDataDestination: TrainingData
- m_LightProbeSampleCountMultiplier: 4
- m_LightingDataAsset: {fileID: 0}
- m_UseShadowmask: 1
---- !u!196 &4
-NavMeshSettings:
- serializedVersion: 2
- m_ObjectHideFlags: 0
- m_BuildSettings:
- serializedVersion: 2
- agentTypeID: 0
- agentRadius: 0.5
- agentHeight: 2
- agentSlope: 45
- agentClimb: 0.4
- ledgeDropHeight: 0
- maxJumpAcrossDistance: 0
- minRegionArea: 2
- manualCellSize: 0
- cellSize: 0.16666667
- manualTileSize: 0
- tileSize: 256
- accuratePlacement: 0
- debug:
- m_Flags: 0
- m_NavMeshData: {fileID: 0}
---- !u!1 &705507993
-GameObject:
- m_ObjectHideFlags: 0
- m_CorrespondingSourceObject: {fileID: 0}
- m_PrefabInstance: {fileID: 0}
- m_PrefabAsset: {fileID: 0}
- serializedVersion: 6
- m_Component:
- - component: {fileID: 705507995}
- - component: {fileID: 705507994}
- m_Layer: 0
- m_Name: Directional Light
- m_TagString: Untagged
- m_Icon: {fileID: 0}
- m_NavMeshLayer: 0
- m_StaticEditorFlags: 0
- m_IsActive: 1
---- !u!108 &705507994
-Light:
- m_ObjectHideFlags: 0
- m_CorrespondingSourceObject: {fileID: 0}
- m_PrefabInstance: {fileID: 0}
- m_PrefabAsset: {fileID: 0}
- m_GameObject: {fileID: 705507993}
- m_Enabled: 1
- serializedVersion: 10
- m_Type: 1
- m_Shape: 0
- m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
- m_Intensity: 1
- m_Range: 10
- m_SpotAngle: 30
- m_InnerSpotAngle: 21.80208
- m_CookieSize: 10
- m_Shadows:
- m_Type: 2
- m_Resolution: -1
- m_CustomResolution: -1
- m_Strength: 1
- m_Bias: 0.05
- m_NormalBias: 0.4
- m_NearPlane: 0.2
- m_CullingMatrixOverride:
- e00: 1
- e01: 0
- e02: 0
- e03: 0
- e10: 0
- e11: 1
- e12: 0
- e13: 0
- e20: 0
- e21: 0
- e22: 1
- e23: 0
- e30: 0
- e31: 0
- e32: 0
- e33: 1
- m_UseCullingMatrixOverride: 0
- m_Cookie: {fileID: 0}
- m_DrawHalo: 0
- m_Flare: {fileID: 0}
- m_RenderMode: 0
- m_CullingMask:
- serializedVersion: 2
- m_Bits: 4294967295
- m_RenderingLayerMask: 1
- m_Lightmapping: 1
- m_LightShadowCasterMode: 0
- m_AreaSize: {x: 1, y: 1}
- m_BounceIntensity: 1
- m_ColorTemperature: 6570
- m_UseColorTemperature: 0
- m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
- m_UseBoundingSphereOverride: 0
- m_ShadowRadius: 0
- m_ShadowAngle: 0
---- !u!4 &705507995
-Transform:
- m_ObjectHideFlags: 0
- m_CorrespondingSourceObject: {fileID: 0}
- m_PrefabInstance: {fileID: 0}
- m_PrefabAsset: {fileID: 0}
- m_GameObject: {fileID: 705507993}
- m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
- m_LocalPosition: {x: 0, y: 3, z: 0}
- m_LocalScale: {x: 1, y: 1, z: 1}
- m_Children: []
- m_Father: {fileID: 0}
- m_RootOrder: 1
- m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
---- !u!1 &963194225
-GameObject:
- m_ObjectHideFlags: 0
- m_CorrespondingSourceObject: {fileID: 0}
- m_PrefabInstance: {fileID: 0}
- m_PrefabAsset: {fileID: 0}
- serializedVersion: 6
- m_Component:
- - component: {fileID: 963194228}
- - component: {fileID: 963194227}
- - component: {fileID: 963194226}
- m_Layer: 0
- m_Name: Main Camera
- m_TagString: MainCamera
- m_Icon: {fileID: 0}
- m_NavMeshLayer: 0
- m_StaticEditorFlags: 0
- m_IsActive: 1
---- !u!81 &963194226
-AudioListener:
- m_ObjectHideFlags: 0
- m_CorrespondingSourceObject: {fileID: 0}
- m_PrefabInstance: {fileID: 0}
- m_PrefabAsset: {fileID: 0}
- m_GameObject: {fileID: 963194225}
- m_Enabled: 1
---- !u!20 &963194227
-Camera:
- m_ObjectHideFlags: 0
- m_CorrespondingSourceObject: {fileID: 0}
- m_PrefabInstance: {fileID: 0}
- m_PrefabAsset: {fileID: 0}
- m_GameObject: {fileID: 963194225}
- m_Enabled: 1
- serializedVersion: 2
- m_ClearFlags: 1
- m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
- m_projectionMatrixMode: 1
- m_GateFitMode: 2
- m_FOVAxisMode: 0
- m_SensorSize: {x: 36, y: 24}
- m_LensShift: {x: 0, y: 0}
- m_FocalLength: 50
- m_NormalizedViewPortRect:
- serializedVersion: 2
- x: 0
- y: 0
- width: 1
- height: 1
- near clip plane: 0.3
- far clip plane: 1000
- field of view: 60
- orthographic: 0
- orthographic size: 5
- m_Depth: -1
- m_CullingMask:
- serializedVersion: 2
- m_Bits: 4294967295
- m_RenderingPath: -1
- m_TargetTexture: {fileID: 0}
- m_TargetDisplay: 0
- m_TargetEye: 3
- m_HDR: 1
- m_AllowMSAA: 1
- m_AllowDynamicResolution: 0
- m_ForceIntoRT: 0
- m_OcclusionCulling: 1
- m_StereoConvergence: 10
- m_StereoSeparation: 0.022
---- !u!4 &963194228
-Transform:
- m_ObjectHideFlags: 0
- m_CorrespondingSourceObject: {fileID: 0}
- m_PrefabInstance: {fileID: 0}
- m_PrefabAsset: {fileID: 0}
- m_GameObject: {fileID: 963194225}
- m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
- m_LocalPosition: {x: 0, y: 1, z: -10}
- m_LocalScale: {x: 1, y: 1, z: 1}
- m_Children: []
- m_Father: {fileID: 0}
- m_RootOrder: 0
- m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
diff --git a/Assets/Scenes/SampleScene.unity.meta b/Assets/Scripts/Apis.meta
similarity index 67%
rename from Assets/Scenes/SampleScene.unity.meta
rename to Assets/Scripts/Apis.meta
index 952bd1e9..67a32b42 100644
--- a/Assets/Scenes/SampleScene.unity.meta
+++ b/Assets/Scripts/Apis.meta
@@ -1,5 +1,6 @@
fileFormatVersion: 2
-guid: 9fc0d4010bbf28b4594072e72b8655ab
+guid: c3657715ecf71dd4ca94ba58d3468e81
+folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
diff --git a/Assets/Scripts/Apis/ApiBase.cs b/Assets/Scripts/Apis/ApiBase.cs
new file mode 100644
index 00000000..b7556c96
--- /dev/null
+++ b/Assets/Scripts/Apis/ApiBase.cs
@@ -0,0 +1,516 @@
+using Assets.Scripts;
+using Newtonsoft.Json;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Threading.Tasks;
+using UnityEngine;
+
+namespace Assets.Scripts.Apis
+{
+ public abstract class ApiBase
+ {
+ private static CookieContainer _cookieCollection = new CookieContainer();
+ public static CookieCollection cookies
+ {
+ get
+ {
+ return _cookieCollection.GetCookies(new Uri(ConfigHelper.Host));
+ }
+ //set
+ //{
+ // _cookieCollection = value;
+ //}
+ }
+ //protected static EasyHttp.Http.HttpClient http;
+ private static System.Net.Http.HttpClient httpClient;
+ private static HttpClientHandler httpClientHandler;
+ static ApiBase()
+ {
+ //http = new EasyHttp.Http.HttpClient();
+ //http.Request.PersistCookies = true;
+
+ httpClientHandler = new HttpClientHandler();
+ httpClientHandler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
+
+ httpClientHandler.CookieContainer = _cookieCollection;
+ httpClientHandler.UseCookies = true;
+
+ httpClient = new System.Net.Http.HttpClient(httpClientHandler);
+ httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Unity", ConfigHelper.AppVersion));
+ }
+
+ protected async Task GetAsFileSync(string url, string fileName)
+ {
+ //var result = await Task.Factory.StartNew(() =>
+ //{
+ // var res = http.GetAsFile(ConfigHelper.Host + url, fileName);
+ // return res;
+ //});
+ //return result;
+
+
+ //using (var httpResponseMessage = await httpClient.SendAsync(CreateRequest(url, System.Net.Http.HttpMethod.Get), HttpCompletionOption.ResponseContentRead))
+ //{
+ byte[] data1 = await GetAsync(url);
+
+ if (data1 != null)
+ {
+ using (var stream = new FileStream(fileName, FileMode.Create))
+ {
+ stream.Write(data1, 0, data1.Length);
+ }
+ return true;
+ }
+ return false;
+ // return httpResponseMessage.IsSuccessStatusCode;
+ //}
+ }
+
+
+
+ protected async Task GetAsync(string url)
+ {
+ AddLanguage();
+ var httpResponseMessage = await httpClient.GetAsync(ConfigHelper.Host + url, HttpCompletionOption.ResponseContentRead).ConfigureAwait(false);
+ if (!httpResponseMessage.IsSuccessStatusCode)
+ {
+ return null;
+ }
+ byte[] data1 = await httpResponseMessage.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
+ return data1;
+ }
+
+ protected async Task GetUrlAsync(string url)
+ {
+ var httpResponseMessage = await httpClient.GetAsync(url, HttpCompletionOption.ResponseContentRead).ConfigureAwait(false);
+ if (!httpResponseMessage.IsSuccessStatusCode)
+ {
+ return null;
+ }
+ byte[] data1 = await httpResponseMessage.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
+ return data1;
+ }
+ //private HttpResponse Get(string url, object query = null)
+ //{
+ // return http.Get(ConfigHelper.Host + url, query);
+ //}
+
+ protected async Task GetAsync(string url)
+ {
+ //var result = await Task.Factory.StartNew(() =>
+ //{
+ // return Get(url, query);
+ //});
+
+ //return result;
+ AddLanguage();
+ var response = await httpClient.GetAsync(ConfigHelper.Host + url, HttpCompletionOption.ResponseContentRead).ConfigureAwait(false);
+ return await ParseJsonAsync(response);
+ }
+
+ private async Task ParseJsonAsync(HttpResponseMessage response)
+ {
+ var result = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(result);
+ return JsonConvert.DeserializeObject(result);
+ }
+
+ //protected T Post(string url, object data)
+ //{
+ // //var stream = new StreamContent()
+ // var stringContent = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
+ // AddLanguage();
+ // var response = httpClient.PostAsync(ConfigHelper.Host + url, stringContent).GetAwaiter()
+ // .GetResult();
+ // if (response.IsSuccessStatusCode == false)
+ // {
+ // //return default(T);
+
+ // throw new Exception($"服务器端返回:{ response.StatusCode }\r\n{ response.RequestMessage }");
+ // }
+ // var info = ParseJsonAsync(response).GetAwaiter().GetResult();
+ // return info;
+ //}
+
+ //protected HttpResponse Post(string url, object data, IList files)
+ //{
+ // var formData = data.ToDictionary();
+ // IList files1 = new List();
+ // foreach (var item in files)
+ // {
+ // var fileData = new FileData();
+ // fileData.FieldName = item.Name;
+ // fileData.Filename = item.FullName;
+
+ // files1.Add(fileData);
+ // }
+ // return http.Post(ConfigHelper.Host + url, formData, files1);
+ //}
+
+ //protected async Task PostAsync(string url, object data, IList files)
+ //{
+ // var result = await Task.Factory.StartNew(() =>
+ // {
+ // return Post(url, data, files);
+ // });
+ // return result;
+ //}
+
+ protected string Upload(string url, object data, IList files)
+ {
+ var files1 = new Dictionary();
+ foreach (var file in files)
+ {
+ //writer.Write( // file header
+ // $"\r\n--{boundary}\r\nContent-Disposition: " +
+ // $"form-data; name=\"{ Path.GetFileName(file) }\"; filename=\"{Path.GetFileName(file)}\"\r\n" +
+ // "Content-Type: application/octet-stream\r\n\r\n");
+
+ //writer.Flush();
+ var fileStream = File.OpenRead(file);
+ //fileStream.CopyTo(requestStream);
+
+ files1.Add(Path.GetFileName(file), fileStream);
+ }
+
+ return Upload(url, data, files1);
+ }
+
+ ///
+ /// formdata
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected string Upload(string url, object data, Dictionary files)
+ {
+ //var requestContent = new MultipartFormDataContent();
+ //foreach (var item in files)
+ //{
+ // // here you can specify boundary if you need---^
+ // //var file = new System.IO.FileInfo(item);
+ // var bytes = System.IO.File.ReadAllBytes(item);
+ // var imageContent = new ByteArrayContent(bytes);
+ // imageContent.Headers.ContentType =
+ // MediaTypeHeaderValue.Parse(GetMimeType(System.IO.Path.GetExtension(item)));
+
+ // requestContent.Add(imageContent, Path.GetFileName(item), Path.GetFileName(item));
+ //}
+
+ //var dict = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(data));
+ //foreach (var item in dict)
+ //{
+ // if (item.Value == null) continue;
+ // requestContent.Add(new StringContent(item.Value.ToString()), item.Key);
+ //}
+
+ //using (var res = await httpClient.PostAsync(ConfigHelper.Host + url, requestContent).ConfigureAwait(false))
+ //{
+ // var rrr = await res.Content.ReadAsStringAsync().ConfigureAwait(false);
+
+ // return rrr;
+ //}
+ var request = (HttpWebRequest)WebRequest.Create(ConfigHelper.Host + url);
+ request.UserAgent = httpClient.DefaultRequestHeaders.UserAgent.ToString();
+ request.Headers.Add("Language", "Zh-cn");
+ request.CookieContainer = new CookieContainer();
+ foreach (Cookie item in cookies)
+ {
+ request.CookieContainer.Add(item);
+ }
+
+ var postData = new StringBuilder();
+ var values = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(data));
+ foreach (var item in values)
+ {
+ postData.Append(WebUtility.UrlEncode($"{ item.Key }={ item.Value }&"));
+ }
+
+ var boundary = $"{Guid.NewGuid():N}";
+ request.ContentType = $"multipart/form-data; {nameof(boundary)}={boundary}";
+ request.Method = "POST";
+ request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
+
+
+ //byte[] bytes;
+ //using (var stream = new MemoryStream())
+ //using (var writer = new StreamWriter(stream))
+ //{
+ // foreach (var ddd in values)
+ // {
+ // writer.Write( // put all POST data into request
+ // $"\r\n--{boundary}\r\nContent-Disposition: " +
+ // $"form-data; name=\"{ ddd.Key }\"\r\n\r\n{ ddd.Value }");
+ // }
+ // foreach (var file in files)
+ // {
+ // writer.Write( // file header
+ // $"\r\n--{boundary}\r\nContent-Disposition: " +
+ // $"form-data; name=\"{ Path.GetFileName(file) }\"; filename=\"{Path.GetFileName(file)}\"\r\n" +
+ // "Content-Type: application/octet-stream\r\n\r\n");
+
+ // writer.Flush();
+ // using (var fileStream = File.OpenRead(file))
+ // fileStream.CopyTo(stream);
+ // }
+ // writer.Write($"\r\n--{boundary}--\r\n");
+
+ // bytes = stream.ToArray();
+ //}
+ //using (Stream postStream = request.GetRequestStream())
+ //{
+ // using (var zipStream = new GZipStream(postStream, CompressionMode.Compress))
+ // {
+ // zipStream.Write(bytes, 0, bytes.Length);
+ // }
+ //}
+
+ using (var requestStream = request.GetRequestStream())
+ using (var writer = new StreamWriter(requestStream))
+ {
+ foreach (var ddd in values)
+ {
+ writer.Write( // put all POST data into request
+ $"\r\n--{boundary}\r\nContent-Disposition: " +
+ $"form-data; name=\"{ ddd.Key }\"\r\n\r\n{ ddd.Value }");
+ }
+ foreach (var file in files)
+ {
+ //writer.Write( // file header
+ // $"\r\n--{boundary}\r\nContent-Disposition: " +
+ // $"form-data; name=\"{ Path.GetFileName(file) }\"; filename=\"{Path.GetFileName(file)}\"\r\n" +
+ // "Content-Type: application/octet-stream\r\n\r\n");
+
+ //writer.Flush();
+ //using (var fileStream = File.OpenRead(file))
+ // fileStream.CopyTo(requestStream);
+
+
+ writer.Write( // file header
+ $"\r\n--{boundary}\r\nContent-Disposition: " +
+ $"form-data; name=\"{ file.Key }\"; filename=\"{ file.Key }\"\r\n" +
+ "Content-Type: application/octet-stream\r\n\r\n");
+
+ writer.Flush();
+ //using (var fileStream = File.OpenRead(file))
+ file.Value.CopyTo(requestStream);
+ }
+ writer.Write($"\r\n--{boundary}--\r\n");
+ }
+
+ using (var response = (HttpWebResponse)request.GetResponse())
+ using (var responseStream = response.GetResponseStream())
+ {
+ if (responseStream == null)
+ return string.Empty;
+ using (var reader = new StreamReader(responseStream))
+ return reader.ReadToEnd();
+ }
+ }
+
+ private string GetMimeType(string extension)
+ {
+ if (extension.Contains(".txt"))
+ {
+ return "text/plain";
+ }
+ if (extension.Contains(".png"))
+ {
+ return "image/png";
+ }
+ return "application/octet-stream";
+ }
+
+ //protected async Task PostUrlAsync(string url, string data)
+ //{
+ // StringContent stringContent;
+ // if (data != null)
+ // {
+ // stringContent = new StringContent(data, Encoding.UTF8, "application/json");
+ // }
+ // else
+ // {
+ // stringContent = new StringContent("", Encoding.UTF8);
+ // }
+ // var response = await httpClient.PostAsync(url, stringContent).ConfigureAwait(false);
+ // var result = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
+ // return result;
+ //}
+
+ protected async Task PostAsync(string url, object data)
+ {
+ StringContent stringContent;
+ if (data != null)
+ {
+ stringContent = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
+ }
+ else
+ {
+ stringContent = new StringContent("", Encoding.UTF8);
+ }
+ AddLanguage();
+ var response = await httpClient.PostAsync(ConfigHelper.Host + url, stringContent).ConfigureAwait(false);
+ var result = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
+ return result;
+ }
+
+ protected async Task PostAsync(string url, object data)
+ {
+ //var result = await Task.Factory.StartNew(() =>
+ //{
+ // return Post(url, data);
+ //});
+ //new EasyHttp.Http.HttpResponse().Cookies
+ //return result;
+
+
+ StringContent stringContent;
+ if (data != null)
+ {
+ var str = JsonConvert.SerializeObject(data);
+ stringContent = new StringContent(str, Encoding.UTF8, "application/json");
+ }
+ else
+ {
+ stringContent = new StringContent("", Encoding.UTF8);
+ }
+ AddLanguage();
+ var response = await httpClient.PostAsync(ConfigHelper.Host + url, stringContent).ConfigureAwait(false);
+ //var cookies = response.Headers.GetValues("Set-Cookie");
+ //if (cookies.Any())
+ //{
+ // foreach (var cookie in cookies)
+ // {
+ // ApiBase.cookies.Add(cookie)
+ // }
+
+ //}
+ var info = await ParseJsonAsync(response);
+ return info;
+ }
+
+ //private static HttpRequestMessage CreateRequest(string url, System.Net.Http.HttpMethod method)
+ //{
+ // HttpRequestMessage httpRequestMessage1 = new HttpRequestMessage();
+ // httpRequestMessage1.Method = method;
+ // Uri uri = new Uri(ConfigHelper.Host + url);
+ // httpRequestMessage1.RequestUri = uri;
+ // HttpRequestMessage httpRequestMessage2 = httpRequestMessage1;
+ // //if (requiresAuthentication)
+ // // httpRequestMessage2.Headers.Authorization = this._authorization;
+ // return httpRequestMessage2;
+ //}
+
+ private void AddLanguage()
+ {
+ httpClient.DefaultRequestHeaders.Remove("Language");
+ //httpClient.DefaultRequestHeaders.Add("Language", PubCommData.Lauguage);
+ }
+
+ ///
+ /// 因为cef调用c#代码,异步请求在win7上会有问题,所以写了同步的方法
+ ///
+ ///
+ ///
+ public string Get(string url)
+ {
+ var url1 = url;
+ if (url1.IndexOf("http") == -1)
+ {
+ url1 = ConfigHelper.Host + url1;
+ }
+ //AddLanguage();
+ var request = (HttpWebRequest)WebRequest.Create(url1);
+ request.Method = "GET";
+ //foreach (var item in httpClient.DefaultRequestHeaders)
+ //{
+ // request.Headers.Add(item.Key, item.Value.First());
+ //}
+ request.UserAgent = httpClient.DefaultRequestHeaders.UserAgent.ToString();
+ request.Accept = "application/json";
+ request.Headers.Add("Language", "Zh-cn");
+ request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
+ request.CookieContainer = new CookieContainer();
+ foreach (Cookie item in cookies)
+ {
+ request.CookieContainer.Add(item);
+ }
+
+ var res = request.GetResponse();
+ using (var stream = new StreamReader(res.GetResponseStream()))
+ {
+ return stream.ReadToEnd();
+ }
+ }
+
+ public T Get(string url)
+ {
+ var res = Get(url);
+
+ return Newtonsoft.Json.JsonConvert.DeserializeObject(res);
+ }
+
+ ///
+ /// 因为cef调用c#代码,异步请求在win7上会有问题,所以写了同步的方法
+ ///
+ ///
+ ///
+ ///
+ public string Post(string url, object data)
+ {
+ var request = (HttpWebRequest)WebRequest.Create(ConfigHelper.Host + url);
+ request.Method = "POST";
+ request.UserAgent = httpClient.DefaultRequestHeaders.UserAgent.ToString();
+ request.Accept = "application/json";
+ request.Headers.Add("Language", "Zh-cn");
+ request.CookieContainer = new CookieContainer();
+ foreach (Cookie item in cookies)
+ {
+ request.CookieContainer.Add(item);
+ }
+
+ request.ContentType = "application/json";
+ if (data != null)
+ {
+ using (var streamWriter = new StreamWriter(request.GetRequestStream()))
+ {
+ streamWriter.Write(Newtonsoft.Json.JsonConvert.SerializeObject(data));
+ }
+ }
+ else
+ {
+ request.ContentLength = 0;
+ }
+ var res = request.GetResponse();
+ using (var stream = new StreamReader(res.GetResponseStream()))
+ {
+ return stream.ReadToEnd();
+ }
+ }
+
+ public T Post(string url, object data)
+ {
+ return JsonConvert.DeserializeObject(Post(url, data));
+ }
+
+ protected byte[] GetBytes(string url)
+ {
+ HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
+ HttpWebResponse response = request.GetResponse() as HttpWebResponse;
+ using (Stream netStream = response.GetResponseStream())
+ {
+ var data = ((MemoryStream)netStream).ToArray();
+ return data;
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Apis/ApiBase.cs.meta b/Assets/Scripts/Apis/ApiBase.cs.meta
new file mode 100644
index 00000000..9c252871
--- /dev/null
+++ b/Assets/Scripts/Apis/ApiBase.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 852043d14fe11e044bd628892492efce
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Apis/JsonResult.cs b/Assets/Scripts/Apis/JsonResult.cs
new file mode 100644
index 00000000..78190f86
--- /dev/null
+++ b/Assets/Scripts/Apis/JsonResult.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Assets.Scripts.Apis
+{
+ public class JsonResult
+ {
+ public bool result { get; set; }
+ //public dynamic data { get; set; }
+ public string errMsg { get; set; }
+ }
+
+ public class JsonResult : JsonResult
+ {
+ //public bool result { get; set; }
+ public T data { get; set; }
+ //public string errMsg { get; set; }
+ }
+}
diff --git a/Assets/Scripts/Apis/JsonResult.cs.meta b/Assets/Scripts/Apis/JsonResult.cs.meta
new file mode 100644
index 00000000..8c2822d2
--- /dev/null
+++ b/Assets/Scripts/Apis/JsonResult.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 2d782ebdf1197264fbb7df630c9ec289
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Apis/MapApi.cs b/Assets/Scripts/Apis/MapApi.cs
new file mode 100644
index 00000000..715586f3
--- /dev/null
+++ b/Assets/Scripts/Apis/MapApi.cs
@@ -0,0 +1,74 @@
+using Assets.Scripts.Apis.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Assets.Scripts.Apis
+{
+ public class MapApi :ApiBase
+ {
+ public string GetMapToken(string name)
+ {
+ return Get($"Map/GetMapToken?name={name}");
+ }
+
+ ///
+ /// 获取路线数据
+ ///
+ ///
+ ///
+ public MapDataModel GetData(int id)
+ {
+ return Newtonsoft.Json.JsonConvert.DeserializeObject(Get("Map/GetData?routeId="+id));
+ }
+
+ ///
+ /// 从服务端获取记录信息
+ ///
+ ///
+ public List GetRecordFileFromServer(List id)
+ {
+ return Post>>("Map/GetCyclingRecordsById", id).data;
+ }
+
+ ///
+ /// 通过Id获取路书
+ ///
+ ///
+ ///
+ public JsonResult GetById(int id)
+ {
+ return Get>($"Map/GetMapRouteById?id={id}");
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// 名称,地址,编号
+ /// 距离,格式0-10
+ ///
+ /// hot, distance
+ /// asc
+ ///
+ public JsonResult> GetList(int pageIndex, int pageSize, string name, string distance="", string hands="", bool is3D=false, string sort="", string sortDire = "")
+ {
+ var url = $"Map/GetRoute?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&distance={ distance }&hands={ hands }&is3D={ is3D }&sort={ sort }&sortDire={ sortDire }";
+
+ return Get>>(url);
+ }
+
+ ///
+ /// 从服务端获取Key
+ ///
+ ///
+ public Dictionary GetServiceKeyFromServer()
+ {
+ return Get>>($"Map/GetServiceKey").data;
+ }
+
+ }
+}
diff --git a/Assets/Scripts/Apis/MapApi.cs.meta b/Assets/Scripts/Apis/MapApi.cs.meta
new file mode 100644
index 00000000..dc773c14
--- /dev/null
+++ b/Assets/Scripts/Apis/MapApi.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: efd73e0e9fe10314e8fbfa123aa6d210
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Apis/MapInterruptRecordApi.cs b/Assets/Scripts/Apis/MapInterruptRecordApi.cs
new file mode 100644
index 00000000..ba696aa4
--- /dev/null
+++ b/Assets/Scripts/Apis/MapInterruptRecordApi.cs
@@ -0,0 +1,25 @@
+using Assets.Scripts.Apis.Models;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Assets.Scripts.Apis
+{
+ public class MapInterruptRecordApi:ApiBase
+ {
+
+ ///
+ /// 上传骑行记录到服务端
+ ///
+ ///
+ public JsonResult Add(MapInterruptRecord interruptRecord, List fileNames)
+ {
+ var result = Upload("MapRecord/AddMapInterruptRecord", interruptRecord, fileNames);
+ var jsonResult = JsonConvert.DeserializeObject>(result);
+ return jsonResult;
+ }
+ }
+}
diff --git a/Assets/Scripts/Apis/MapInterruptRecordApi.cs.meta b/Assets/Scripts/Apis/MapInterruptRecordApi.cs.meta
new file mode 100644
index 00000000..a456e598
--- /dev/null
+++ b/Assets/Scripts/Apis/MapInterruptRecordApi.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a19da168ad334a54abc24f4eb95751e1
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Apis/Models.meta b/Assets/Scripts/Apis/Models.meta
new file mode 100644
index 00000000..6415163f
--- /dev/null
+++ b/Assets/Scripts/Apis/Models.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 92062add3e1975c46bbf4d70543955a7
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Apis/Models/AddMapRecordResultModel.cs b/Assets/Scripts/Apis/Models/AddMapRecordResultModel.cs
new file mode 100644
index 00000000..5e33741b
--- /dev/null
+++ b/Assets/Scripts/Apis/Models/AddMapRecordResultModel.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Assets.Scripts.Apis.Models
+{
+ public class AddMapRecordResultModel
+ {
+ public int RankingId { get; set; }
+ }
+}
diff --git a/Assets/Scripts/Apis/Models/AddMapRecordResultModel.cs.meta b/Assets/Scripts/Apis/Models/AddMapRecordResultModel.cs.meta
new file mode 100644
index 00000000..c74370f2
--- /dev/null
+++ b/Assets/Scripts/Apis/Models/AddMapRecordResultModel.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: e10150ebcdd04eb4588cc8cd22385286
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Apis/Models/MapDataModel.cs b/Assets/Scripts/Apis/Models/MapDataModel.cs
new file mode 100644
index 00000000..73920554
--- /dev/null
+++ b/Assets/Scripts/Apis/Models/MapDataModel.cs
@@ -0,0 +1,147 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Assets.Scripts.Apis.Models
+{
+ public class MapDataModel
+ {
+ public string Type { get; set; }
+
+ public double TotalDistance { get; set; }
+
+ //private double? _TotalClimb;
+ /////
+ ///// 累计爬升
+ /////
+ //public double TotalClimb
+ //{
+ // get
+ // {
+ // if(_TotalClimb == null)
+ // {
+ // var total = 0D;
+ // for (int i = 0; i < List.Count; i++)
+ // {
+ // if(i < List.Count - 1)
+ // {
+ // var item = List[i];
+ // var next = List[i + 1];
+ // var value = next.Elevation - item.Elevation;
+ // if(value > 0)
+ // {
+ // total += value;
+ // }
+ // }
+ // }
+ // _TotalClimb = total;
+ // }
+
+ // return _TotalClimb.GetValueOrDefault(0);
+ // }
+ //}
+
+ //public double AverageGrade
+ //{
+ // get
+ // {
+ // }
+ //}
+
+ private List- _List;
+ public List
- List
+ {
+ get
+ {
+ return _List;
+ }
+ set
+ {
+ _List = value;
+ if (_List == null) return;
+ this.CalcDistance();
+ this.CalcGrade();
+ }
+ }
+
+ private void CalcDistance()
+ {
+ //TODO:需要加上turfHelper
+ //for (int i = 0; i < _List.Count - 1; i++)
+ //{
+ // var value = TurfHelper.GetDistances(new double[] { _List[i].Point[1], _List[i].Point[0] }, new double[] { _List[i + 1].Point[1], _List[i + 1].Point[0] });
+ // _List[i].Distance = value;
+ //}
+ }
+ ///
+ /// 计算坡度数据
+ ///
+ private void CalcGrade()
+ {
+ for (int i = 0; i < this._List.Count - 1; i++)
+ {
+ var a = _List[i + 1].Elevation - _List[i].Elevation;
+ if (a == 0)
+ {
+ //grade.Add(0);
+ _List[i].Grade = 0;
+ continue;
+ }
+ //勾股定理
+ var c = _List[i].Distance;//如果车停了下来,c为0
+ //如果当前点到下一个点的距离是0,并且不是第一条记录,则坡度用上一个点的坡度
+ if (c == 0 && i > 0)
+ {
+ _List[i].Grade = _List[i - 1].Grade;
+ continue;
+ }
+
+ var b = Math.Sqrt(c * c - a * a);
+ if (double.IsNaN(b))
+ {
+ _List[i].Grade = 0;
+ }
+ else if (b == 0)//如果b等于,这就是垂直的墙壁
+ {
+ _List[i].Grade = _List[i - 1].Grade;
+ }
+ else
+ {
+ _List[i].Grade = Math.Round(a / b * 100, 4);
+ }
+
+ }
+ }
+
+ public MapDataModel()
+ {
+ //List = new List
- ();
+ }
+
+ public class Item
+ {
+ ///
+ /// 坐标(lat,lon)
+ ///
+ public double[] Point { get; set; }
+ ///
+ /// 距离(单位米)
+ ///
+ public double Distance { get; set; }
+ ///
+ /// 海拔
+ ///
+ public double Elevation { get; set; }
+
+ public double Grade { get; set; }
+ }
+
+ public override string ToString()
+ {
+ //return base.ToString();
+ return Newtonsoft.Json.JsonConvert.SerializeObject(this);
+ }
+ }
+}
diff --git a/Assets/Scripts/Apis/Models/MapDataModel.cs.meta b/Assets/Scripts/Apis/Models/MapDataModel.cs.meta
new file mode 100644
index 00000000..2a3f2581
--- /dev/null
+++ b/Assets/Scripts/Apis/Models/MapDataModel.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6894ce41336dd9f488f53bbe4ded61f4
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Apis/Models/MapInterruptRecord.cs b/Assets/Scripts/Apis/Models/MapInterruptRecord.cs
new file mode 100644
index 00000000..7db97236
--- /dev/null
+++ b/Assets/Scripts/Apis/Models/MapInterruptRecord.cs
@@ -0,0 +1,109 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Assets.Scripts.Apis.Models
+{
+ public class MapInterruptRecord
+ {
+ public string Id { get; set; }
+
+ public int RouteId { get; set; }
+
+ public string RouteUrl { get; set; }
+
+ public double EndDistance { get; set; }
+
+ public string RouteImage { get; set; }
+
+ public string RecordFileName { get; set; }
+
+ public string RouteName { get; set; }
+
+ public DateTime CreateTime { get; set; }
+
+ public bool IsCompleted { get; set; }
+
+ public string ElevationUrl { get; set; }
+
+ public double TotalDistance { get; set; }
+
+ public int UserId { get; set; }
+
+ public int? Ftp { get; set; }
+
+ public double? IF { get; set; }
+
+ public double? Kj { get; set; }
+
+ public double? Tss { get; set; }
+
+ public double? NormalizedPower { get; set; }
+
+ public double? AveragePower { get; set; }
+
+ public double? MaxPower { get; set; }
+
+ public int Ticks { get; set; }
+
+ public string TrainingTime { get; set; }
+ ///
+ /// 功率体重比
+ ///
+ public double? WeightKg { get; set; }
+ ///
+ /// 车重
+ ///
+ public double BicycleWeight { get; set; }
+
+ public double Weight { get; set; }
+
+ public double? AverageCadence { get; set; }
+
+ public double? MaxCadence { get; set; }
+
+ public double? AverageHeartRate { get; set; }
+
+ public double? MaxHeartRate { get; set; }
+ ///
+ /// 用户实际骑的距离和总线路长度的比
+ ///
+ public double? Progress { get; set; }
+
+ public string SpeedRange { get; set; }
+
+ public string ContinueMark { get; set; }
+
+ public int? ContinueIndex { get; set; }
+
+ public bool IsDelete { get; set; }
+
+ public int MapCompetitionId { get; set; }
+
+ public string ManufacturerName { get; set; }
+
+ public string DeviceNumber { get; set; }
+
+ public bool IsRanking { get; set; }
+
+ public double CurrentRouteStartDistance { get; set; }
+
+ public int? ManufacturerId { get; set; }
+
+ public int? AntModelId { get; set; }
+
+ public DateTime StartTime { get; set; }
+ ///
+ /// 骑行模式
+ ///
+ public string Mode { get; set; }
+ ///
+ /// 骑行模式的参数
+ ///
+ public string Param { get; set; }
+
+ public int GlobalCyclingId { get; set; }
+ }
+}
diff --git a/Assets/Scripts/Apis/Models/MapInterruptRecord.cs.meta b/Assets/Scripts/Apis/Models/MapInterruptRecord.cs.meta
new file mode 100644
index 00000000..2e7462bd
--- /dev/null
+++ b/Assets/Scripts/Apis/Models/MapInterruptRecord.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 35f4d405c5be4b74a913ae454acaae42
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Apis/Models/MapRecordRanking.cs b/Assets/Scripts/Apis/Models/MapRecordRanking.cs
new file mode 100644
index 00000000..a9109b02
--- /dev/null
+++ b/Assets/Scripts/Apis/Models/MapRecordRanking.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Assets.Scripts.Apis.Models
+{
+ public class MapRecordRanking
+ {
+ public int UserId { get; set; }
+
+ public string RecordFileName { get; set; }
+
+ public int RouteId { get; set; }
+
+ public int Ticks { get; set; }
+
+ public Guid Id { get; set; }
+
+ public string[] record { get; set; }
+
+ public string WxHeadImg { get; set; }
+
+ public string NickName { get; set; }
+ }
+}
diff --git a/Assets/Scripts/Apis/Models/MapRecordRanking.cs.meta b/Assets/Scripts/Apis/Models/MapRecordRanking.cs.meta
new file mode 100644
index 00000000..039914e8
--- /dev/null
+++ b/Assets/Scripts/Apis/Models/MapRecordRanking.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 43f7b75b9a3b54845bfcfe10bc670621
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Apis/Models/MapRoute.cs b/Assets/Scripts/Apis/Models/MapRoute.cs
new file mode 100644
index 00000000..7593350c
--- /dev/null
+++ b/Assets/Scripts/Apis/Models/MapRoute.cs
@@ -0,0 +1,104 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Assets.Scripts.Apis.Models
+{
+ public class MapRoute
+ {
+ public int Id { get; set; }
+ ///
+ /// 路线名称
+ ///
+ public string Name { get; set; }
+ ///
+ /// 路线描述
+ ///
+ public string Dec { get; set; }
+ ///
+ /// 文件路径
+ ///
+ public string DirPath { get; set; }
+ ///
+ /// 路线区域
+ ///
+ public int Area { get; set; }
+ ///
+ /// 区域名称
+ ///
+ public string AreaName { get; set; }
+ ///
+ /// 创建时间
+ ///
+ public DateTime? CreateTime { get; set; }
+ ///
+ /// 用户ID
+ ///
+ public int UserId { get; set; }
+ ///
+ /// 是否删除:0未删除,1删除
+ ///
+ public bool? IsUsable { get; set; }
+ ///
+ /// 是否官方路书
+ ///
+ public bool? IsOfficial { get; set; }
+ ///
+ /// 路书的hash值,判断是否重复,得到byte[] hashcode必须传入
+ ///
+ public string Hash { get; set; }
+ ///
+ /// 路线长度
+ ///
+ public double Distance { get; set; }
+ ///
+ /// 最大高程落差
+ ///
+ public double EleDifference { get; set; }
+ ///
+ /// 落差长度
+ ///
+ public int GapLength { get; set; }
+ ///
+ /// 累计爬升
+ ///
+ public double? TotalClimb { get; set; }
+ ///
+ /// 修改时间
+ ///
+ public DateTime UpdateTime { get; set; }
+ ///
+ /// 状态(0未发布,1已发布)
+ ///
+ public int State { get; set; }
+ ///
+ /// 封面文件地址
+ ///
+ public string CoverImage { get; set; }
+ ///
+ /// 海拔数据
+ ///
+ public string ElevationPath { get; set; }
+ ///
+ /// 做为附近的人计算参数,不做数据存储
+ ///
+ public double? Near { get; set; }
+ ///
+ /// 创建人姓名
+ ///
+ public string NickName { get; set; }
+
+
+ public double[] Point { get; set; }
+
+ public string Address { get; set; }
+
+ public double AverageGrade { get; set; }
+
+ public bool IsFavorite { get; set; }
+
+ public bool Enable3D { get; set; }
+ }
+}
diff --git a/Assets/Scripts/Apis/Models/MapRoute.cs.meta b/Assets/Scripts/Apis/Models/MapRoute.cs.meta
new file mode 100644
index 00000000..1a8327c2
--- /dev/null
+++ b/Assets/Scripts/Apis/Models/MapRoute.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: be111aadd2f1b034a9eece75ae35b955
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Apis/Models/SummaryResultModel.cs b/Assets/Scripts/Apis/Models/SummaryResultModel.cs
new file mode 100644
index 00000000..51b9e61d
--- /dev/null
+++ b/Assets/Scripts/Apis/Models/SummaryResultModel.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Assets.Scripts.Apis.Models
+{
+ public class SummaryResultModel
+ {
+ public string NickName { get; set; }
+ public int Id { get; set; }
+ public string Phone { get; set; }
+ public string WxHeadImg { get; set; }
+ public int Ftp { get; set; }
+
+ public int Sex { get; set; }
+
+ public string CountryCode { get; set; }
+ public string CountryImg { get; set; }
+
+ public double TotalKj { get; set; }
+ public double MaxPower { get; set; }
+ public double MaxHeartRate { get; set; }
+ public double Weight { get; set; }
+ public double BicycleWeight { get; set; }
+ public int WheelDiameter { get; set; }
+ ///
+ /// 骑行次数
+ ///
+ public double Count { get; set; }
+ public double TotalDistance { get; set; }
+ public double TotalTicks { get; set; }
+ public string TotalClimb { get; set; }
+ public string Kcal { get; set; }
+ public double TwentyMinutesMaxAP { get; set; }
+ ///
+ /// 单次最高海拔提升
+ ///
+ public string SingleElevationIncrease { get; set; }
+ public double OneMinuteMaxAP { get; set; }
+ public double SingleMaxCyclingTime { get; set; }
+ public string MaxKcal { get; set; }
+ public double FiveMinutesMaxAp { get; set; }
+ public string SingleTripDistance { get; set; }
+ public double CompleteRoute { get; set; }
+
+ public string Tips { get; set; }
+ }
+}
diff --git a/Assets/Scripts/Apis/Models/SummaryResultModel.cs.meta b/Assets/Scripts/Apis/Models/SummaryResultModel.cs.meta
new file mode 100644
index 00000000..eaac1511
--- /dev/null
+++ b/Assets/Scripts/Apis/Models/SummaryResultModel.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5365c1dd3a8ce72429bf173971fa6597
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Apis/Models/UserResultModel.cs b/Assets/Scripts/Apis/Models/UserResultModel.cs
new file mode 100644
index 00000000..34e0076b
--- /dev/null
+++ b/Assets/Scripts/Apis/Models/UserResultModel.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Assets.Scripts.Apis.Models
+{
+ public class UserResultModel
+ {
+ public int Id { get; set; }
+ public string Nickname { get; set; }
+ ///
+ /// 用户的性别,值为1时是男性,值为2时是女性,值为0时是未知
+ ///
+ public int Sex { get; set; }
+ public int Unit { get; set; }
+ public double Weight { get; set; }
+ public int FTP { get; set; }
+ public int WheelDiameter { get; set; }
+ public string Phone { get; set; }
+ public string Email { get; set; }
+ public string Pass { get; set; }
+ public string OtherPlatforms { get; set; }
+ public string Country { get; set; }
+ public string Province { get; set; }
+ public string City { get; set; }
+ public string Area { get; set; }
+ public string WxHeadImg { get; set; }
+ public DateTime LastLoginTime { get; set; }
+ ///
+ /// 自动暂停
+ ///
+ public bool AutoPause { get; set; }
+ ///
+ /// 最大心率
+ ///
+ public int MaxHeartRate { get; set; }
+
+ public bool CanEditRoom { get; set; }
+ ///
+ /// 自行车重
+ ///
+ public double BicycleWeight { get; set; }
+
+ public string Contact { get; set; }
+
+ public string ContactPhone { get; set; }
+
+ public string ContactAddress { get; set; }
+ ///
+ /// 阻力灵敏度
+ ///
+ public int Sensitivity { get; set; }
+ ///
+ /// 已连接到Strava
+ ///
+ public bool ConnectedToStrava { get; set; }
+ }
+}
diff --git a/Assets/Scripts/Apis/Models/UserResultModel.cs.meta b/Assets/Scripts/Apis/Models/UserResultModel.cs.meta
new file mode 100644
index 00000000..64b672be
--- /dev/null
+++ b/Assets/Scripts/Apis/Models/UserResultModel.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: b02776a537d93a042bb09a7c0f7b4815
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Apis/UserApi.cs b/Assets/Scripts/Apis/UserApi.cs
new file mode 100644
index 00000000..c8116a08
--- /dev/null
+++ b/Assets/Scripts/Apis/UserApi.cs
@@ -0,0 +1,97 @@
+using Assets.Scripts.Apis.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Assets.Scripts.Apis
+{
+ public class UserApi : ApiBase
+ {
+ public async Task> Login(string phone, string pwd, string countryCode)
+ {
+ var param = new
+ {
+ Phone = phone,
+ Pwd = pwd,
+ countryCode
+ };
+
+ JsonResult ret = null;
+ try
+ {
+ ret = await PostAsync>("NoAuth/v1/Login", param);
+ }
+ catch (Exception ex)
+ {
+ return new JsonResult { result = false, errMsg = ex.Message };
+ }
+ //ApiBase.cookies = response.Cookies;
+ //var ret = response.DynamicBody;
+ if (ret.result)
+ {
+ //var str = Newtonsoft.Json.JsonConvert.SerializeObject(ret.data);
+ var user = new UserResultModel();
+ user.Id = ret.data.Id;
+ user.Nickname = ret.data.Nickname;
+ user.Phone = ((string)ret.data.Phone).Trim();
+ user.Country = ret.data.Country;
+ user.Province = ret.data.Province;
+ user.City = ret.data.City;
+ user.Area = ret.data.Area;
+ user.Pass = ret.data.Pass;
+ user.Sex = ret.data.Sex;
+ user.Unit = ret.data.Unit;
+ user.Weight = ret.data.Weight;
+ user.FTP = ret.data.FTP;
+ user.WheelDiameter = ret.data.WheelDiameter;
+ user.Email = user.Email ?? "";
+ user.Pass = user.Pass ?? "";
+ user.OtherPlatforms = user.OtherPlatforms ?? "";
+ user.WxHeadImg = ret.data.WxHeadImg ?? "";
+ //user.LoginTime = ret.data.LoginTime;
+ user.LastLoginTime = ret.data.LastLoginTime;
+ user.AutoPause = ret.data.AutoPause;
+ user.MaxHeartRate = ret.data.MaxHeartRate;
+ user.CanEditRoom = ret.data.CanEditRoom;
+ user.BicycleWeight = ret.data.BicycleWeight;
+ user.Contact = ret.data.Contact;
+ user.ContactPhone = ret.data.ContactPhone;
+ user.ContactAddress = ret.data.ContactAddress;
+ user.Sensitivity = ret.data.Sensitivity;
+ if (ret.data.ConnectedToStrava != null)
+ {
+ user.ConnectedToStrava = ret.data.ConnectedToStrava;
+ }
+ //todo: check local database, insert new user
+
+ //PubCommData.CurrentUser = user;
+
+ return new JsonResult() { result = true, data = user };
+ }
+ else
+ {
+ return new JsonResult() { result = false, data = null, errMsg = ret.errMsg };
+ }
+ }
+
+ ///
+ /// 获取个人中心的统计信息
+ ///
+ ///
+ public JsonResult GetSummary()
+ {
+ var result = Get>("User/GetSummary");
+
+ return result;
+ }
+
+ public DateTime GetNow()
+ {
+ var result = Get("NoAuth/GetNow");
+
+ return DateTime.Parse(result);
+ }
+ }
+}
diff --git a/Assets/Scripts/Apis/UserApi.cs.meta b/Assets/Scripts/Apis/UserApi.cs.meta
new file mode 100644
index 00000000..7045c2a1
--- /dev/null
+++ b/Assets/Scripts/Apis/UserApi.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5125f13b6b78d534bada8457fa9c2413
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/ConfigHelper.cs b/Assets/Scripts/ConfigHelper.cs
new file mode 100644
index 00000000..197d1839
--- /dev/null
+++ b/Assets/Scripts/ConfigHelper.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Assets.Scripts
+{
+ public class ConfigHelper
+ {
+ public static string Host = "http://192.168.0.97:5082/";
+
+ public static string AppVersion = "1.0.0";
+ }
+}
diff --git a/Assets/Scripts/ConfigHelper.cs.meta b/Assets/Scripts/ConfigHelper.cs.meta
new file mode 100644
index 00000000..ba3d1018
--- /dev/null
+++ b/Assets/Scripts/ConfigHelper.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 021b5a61b832e5543b09fc9b06da54a6
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/packages.config b/Assets/packages.config
new file mode 100644
index 00000000..5b7ca85f
--- /dev/null
+++ b/Assets/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/Assets/packages.config.meta b/Assets/packages.config.meta
new file mode 100644
index 00000000..90a79966
--- /dev/null
+++ b/Assets/packages.config.meta
@@ -0,0 +1,32 @@
+fileFormatVersion: 2
+guid: 0564d4e30aa722a499a256f4aa9eab96
+PluginImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ iconMap: {}
+ executionOrder: {}
+ defineConstraints: []
+ isPreloaded: 0
+ isOverridable: 0
+ isExplicitlyReferenced: 0
+ validateReferences: 1
+ platformData:
+ - first:
+ Any:
+ second:
+ enabled: 0
+ settings: {}
+ - first:
+ Editor: Editor
+ second:
+ enabled: 0
+ settings:
+ DefaultValueInitialized: true
+ - first:
+ Windows Store Apps: WindowsStoreApps
+ second:
+ enabled: 0
+ settings: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant: