修复台湾问题;加服务器时间;
This commit is contained in:
parent
584cba79ae
commit
9a4e646a8f
@ -123,12 +123,13 @@ namespace Assets.Scripts.Apis
|
||||
return result;
|
||||
}
|
||||
|
||||
public DateTime GetNow()
|
||||
public async Task<DateTime> GetNow()
|
||||
{
|
||||
var result = Get("NoAuth/GetNow");
|
||||
var result = await GetAsync("NoAuth/GetNow");
|
||||
|
||||
return DateTime.Parse(result);
|
||||
return DateTime.Parse(System.Text.Encoding.UTF8.GetString(result));
|
||||
}
|
||||
|
||||
public async Task<JsonResult<object>> Register(string Phone, string Pwd, string Captcha)
|
||||
{
|
||||
var param = new
|
||||
|
||||
@ -8,7 +8,7 @@ using System.Net;
|
||||
|
||||
public static class App
|
||||
{
|
||||
public static string Host = "http://192.168.0.101:5083/";
|
||||
public static string Host = "http://192.168.0.97:5082/";
|
||||
|
||||
public static string AppVersion = "1.0.0";
|
||||
|
||||
|
||||
35
Assets/Scripts/PFConstants.cs
Normal file
35
Assets/Scripts/PFConstants.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
public static class PFConstants
|
||||
{
|
||||
/// <summary>
|
||||
/// 课程训练保存在本地的路径
|
||||
/// </summary>
|
||||
public static string MapWorkoutRecordFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
if(!Directory.Exists(Application.persistentDataPath + "/MapWorkoutRecords/")){
|
||||
Directory.CreateDirectory(Application.persistentDataPath + "/MapWorkoutRecords/");
|
||||
}
|
||||
|
||||
return Application.persistentDataPath + "/MapWorkoutRecords/";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 设备连接缓存在本地的路径
|
||||
/// </summary>
|
||||
public static string DeviceCacheFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
return Application.persistentDataPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/PFConstants.cs.meta
Normal file
11
Assets/Scripts/PFConstants.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe6b725ad54bc6747801a7f7f9b40a59
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -16,7 +16,7 @@ public class MainController : MonoBehaviour
|
||||
{
|
||||
Version = this.transform.Find("GameObject").Find("Version").GetComponent<Text>();
|
||||
Version.text = "V"+App.AppVersion;
|
||||
DeviceCache.Init(Application.dataPath);
|
||||
DeviceCache.Init(PFConstants.DeviceCacheFolder);
|
||||
|
||||
AntConnector.Instance((device2) => {
|
||||
//自动连接
|
||||
|
||||
@ -8,8 +8,9 @@ public class LoadingPf : PFUIPanel
|
||||
List<Sprite> sprites;
|
||||
Image image;
|
||||
|
||||
protected override void Start()
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
sprites = new List<Sprite>();
|
||||
for (int i = 1; i < 80; i++)
|
||||
{
|
||||
@ -17,29 +18,56 @@ public class LoadingPf : PFUIPanel
|
||||
}
|
||||
image = transform.GetComponent<Image>();
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
|
||||
}
|
||||
int index = 0;
|
||||
float time = 0;
|
||||
//float time = 0;
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
|
||||
index = 0;
|
||||
time = 0;
|
||||
//time = 0;
|
||||
|
||||
StartCoroutine(Animation());
|
||||
}
|
||||
|
||||
IEnumerator Animation()
|
||||
{
|
||||
for (; ; )
|
||||
{
|
||||
if (index % 79 == 0)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
image.sprite = sprites[index];
|
||||
index++;
|
||||
yield return new WaitForSeconds(0.03f);
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
time += Time.deltaTime;
|
||||
if (time < 0.03)
|
||||
{
|
||||
return;
|
||||
}
|
||||
time = 0;
|
||||
if (index % 79 == 0)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
image.sprite = sprites[index];
|
||||
index++;
|
||||
//time += Time.deltaTime;
|
||||
//if (time < 0.03)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//time = 0;
|
||||
//if (index % 79 == 0)
|
||||
//{
|
||||
// index = 0;
|
||||
//}
|
||||
//image.sprite = sprites[index];
|
||||
//index++;
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
StopCoroutine(Animation());
|
||||
base.Close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ public class BigMapController : PFUIPanel
|
||||
}
|
||||
private void MapManager_OnUpdated()
|
||||
{
|
||||
Debug.Log("update "+ mapManager.Zoom);
|
||||
//Debug.Log("update "+ mapManager.Zoom);
|
||||
|
||||
if(mapManager.Zoom <= 4.8)
|
||||
{
|
||||
|
||||
@ -113,9 +113,11 @@ public class EarthController : PFUIPanel
|
||||
Country.text = "China";
|
||||
Province.text = "TaiWan";
|
||||
ShowSummary(country.latlonCenter);
|
||||
|
||||
map.HighlightCountryRegion(173, 1, false, true, Color.white);
|
||||
}
|
||||
else {
|
||||
Country.text = country.name;
|
||||
Country.text = country.name;
|
||||
}
|
||||
};
|
||||
|
||||
@ -129,7 +131,7 @@ public class EarthController : PFUIPanel
|
||||
}
|
||||
};
|
||||
|
||||
map.OnProvinceEnter += async (int provinceIndex, int regionIndex) =>
|
||||
map.OnProvinceEnter += (int provinceIndex, int regionIndex) =>
|
||||
{
|
||||
var province = map.provinces[provinceIndex];
|
||||
|
||||
@ -151,11 +153,11 @@ public class EarthController : PFUIPanel
|
||||
EnterBigMap(latLon);
|
||||
};
|
||||
|
||||
skybox = Camera.main.GetComponent<Skybox>();
|
||||
Debug.Log(skybox != null);
|
||||
//skybox = Camera.main.GetComponent<Skybox>();
|
||||
}
|
||||
private float rot = 0;
|
||||
Skybox skybox;
|
||||
|
||||
//private float rot = 0;
|
||||
//Skybox skybox;
|
||||
/// <summary>
|
||||
/// 显示概要信息
|
||||
/// </summary>
|
||||
@ -209,8 +211,6 @@ public class EarthController : PFUIPanel
|
||||
/// <param name="latLon"></param>
|
||||
private void EnterBigMap(Vector2 latLon)
|
||||
{
|
||||
Debug.Log("enter big map");
|
||||
|
||||
map.FlyToLocation(latLon.x, latLon.y, 1f, 0.1f).Then(() => {
|
||||
//Close();
|
||||
|
||||
@ -278,7 +278,7 @@ public class EarthController : PFUIPanel
|
||||
public override void Close()
|
||||
{
|
||||
//base.Close();
|
||||
|
||||
map.Destroy();
|
||||
DestroyImmediate(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ using Newtonsoft.Json;
|
||||
using UnityEngine.UI;
|
||||
using Assets.Scripts.UI.Control;
|
||||
using Assets.Scripts;
|
||||
using System;
|
||||
|
||||
public class UIManager : MonoBehaviour
|
||||
{
|
||||
@ -154,6 +155,11 @@ public class UIManager : MonoBehaviour
|
||||
{ false,Resources.Load<Sprite>("Images/p-4灰")},
|
||||
{ true,Resources.Load<Sprite>("Images/p-4")},
|
||||
};
|
||||
|
||||
if(_now == null)
|
||||
{
|
||||
InitNow();
|
||||
}
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
@ -476,12 +482,27 @@ public class UIManager : MonoBehaviour
|
||||
public static void AddEvent(GameObject gameObject, EventTriggerType eventTriggerType, UnityAction<BaseEventData> call)
|
||||
{
|
||||
EventTrigger et = gameObject.GetComponent<EventTrigger>();
|
||||
EventTrigger.Entry pointerEvent = null;
|
||||
if (et == null)
|
||||
{
|
||||
et = gameObject.AddComponent<EventTrigger>();
|
||||
}
|
||||
EventTrigger.Entry pointerEvent = new EventTrigger.Entry();
|
||||
pointerEvent.eventID = eventTriggerType;
|
||||
foreach (EventTrigger.Entry entry2 in et.triggers)
|
||||
{
|
||||
if(entry2.eventID == eventTriggerType)
|
||||
{
|
||||
pointerEvent = entry2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pointerEvent == null)
|
||||
{
|
||||
pointerEvent = new EventTrigger.Entry();
|
||||
pointerEvent.eventID = eventTriggerType;
|
||||
et.triggers.Add(pointerEvent);
|
||||
}
|
||||
//pointerEvent.callback.RemoveAllListeners();
|
||||
|
||||
pointerEvent.callback.AddListener((e)=> {
|
||||
if (gameObject == null || gameObject.activeInHierarchy == false) return;
|
||||
var btn = gameObject.GetComponent<Button>();
|
||||
@ -492,7 +513,7 @@ public class UIManager : MonoBehaviour
|
||||
|
||||
call(e);
|
||||
});
|
||||
et.triggers.Add(pointerEvent);
|
||||
|
||||
|
||||
if (eventTriggerType == EventTriggerType.PointerClick)
|
||||
{
|
||||
@ -630,6 +651,21 @@ public class UIManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private static CustomDateTime _now;
|
||||
public static CustomDateTime Now
|
||||
{
|
||||
get
|
||||
{
|
||||
return _now;
|
||||
}
|
||||
}
|
||||
|
||||
private async void InitNow()
|
||||
{
|
||||
var now = await ConfigHelper.userApi.GetNow();
|
||||
_now = new CustomDateTime(now);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
UIManager.Instance = null;
|
||||
|
||||
31
Assets/Scripts/Utils/CustomDateTime.cs
Normal file
31
Assets/Scripts/Utils/CustomDateTime.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
/// <summary>
|
||||
/// 跟服务器端同步的时间对象
|
||||
/// </summary>
|
||||
public class CustomDateTime
|
||||
{
|
||||
long StartingTime = Stopwatch.GetTimestamp();
|
||||
private DateTime _dateTime;
|
||||
public CustomDateTime(DateTime dateTime)
|
||||
{
|
||||
_dateTime = dateTime;
|
||||
}
|
||||
|
||||
public DateTime GetDateTime()
|
||||
{
|
||||
//Console.WriteLine(Stopwatch.IsHighResolution);
|
||||
long endingTime = Stopwatch.GetTimestamp();
|
||||
long ElapsedTime = endingTime - StartingTime;
|
||||
|
||||
double ElapsedSeconds = ElapsedTime * (1.0 / Stopwatch.Frequency);
|
||||
|
||||
return _dateTime.AddSeconds(ElapsedSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Scripts/Utils/CustomDateTime.cs.meta
Normal file
11
Assets/Scripts/Utils/CustomDateTime.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08e8f3be54a1de04e9049674ce33fe23
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -12,7 +12,7 @@ PlayerSettings:
|
||||
targetDevice: 2
|
||||
useOnDemandResources: 0
|
||||
accelerometerFrequency: 60
|
||||
companyName: DefaultCompany
|
||||
companyName: ZhiXingPai
|
||||
productName: PowerFun
|
||||
defaultCursor: {fileID: 0}
|
||||
cursorHotspot: {x: 0, y: 0}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user