修复台湾问题;加服务器时间;

This commit is contained in:
suntao 2021-05-08 11:09:03 +08:00
parent 584cba79ae
commit 9a4e646a8f
12 changed files with 187 additions and 34 deletions

View File

@ -123,12 +123,13 @@ namespace Assets.Scripts.Apis
return result; 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) public async Task<JsonResult<object>> Register(string Phone, string Pwd, string Captcha)
{ {
var param = new var param = new

View File

@ -8,7 +8,7 @@ using System.Net;
public static class App 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"; public static string AppVersion = "1.0.0";

View 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;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fe6b725ad54bc6747801a7f7f9b40a59
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -16,7 +16,7 @@ public class MainController : MonoBehaviour
{ {
Version = this.transform.Find("GameObject").Find("Version").GetComponent<Text>(); Version = this.transform.Find("GameObject").Find("Version").GetComponent<Text>();
Version.text = "V"+App.AppVersion; Version.text = "V"+App.AppVersion;
DeviceCache.Init(Application.dataPath); DeviceCache.Init(PFConstants.DeviceCacheFolder);
AntConnector.Instance((device2) => { AntConnector.Instance((device2) => {
//自动连接 //自动连接

View File

@ -8,8 +8,9 @@ public class LoadingPf : PFUIPanel
List<Sprite> sprites; List<Sprite> sprites;
Image image; Image image;
protected override void Start() protected override void Awake()
{ {
base.Awake();
sprites = new List<Sprite>(); sprites = new List<Sprite>();
for (int i = 1; i < 80; i++) for (int i = 1; i < 80; i++)
{ {
@ -17,29 +18,56 @@ public class LoadingPf : PFUIPanel
} }
image = transform.GetComponent<Image>(); image = transform.GetComponent<Image>();
} }
protected override void Start()
{
}
int index = 0; int index = 0;
float time = 0; //float time = 0;
public override void Show() public override void Show()
{ {
base.Show(); base.Show();
index = 0; 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() void Update()
{ {
time += Time.deltaTime; //time += Time.deltaTime;
if (time < 0.03) //if (time < 0.03)
{ //{
return; // return;
} //}
time = 0; //time = 0;
if (index % 79 == 0) //if (index % 79 == 0)
{ //{
index = 0; // index = 0;
} //}
image.sprite = sprites[index]; //image.sprite = sprites[index];
index++; //index++;
}
public override void Close()
{
StopCoroutine(Animation());
base.Close();
} }
} }

View File

@ -184,7 +184,7 @@ public class BigMapController : PFUIPanel
} }
private void MapManager_OnUpdated() private void MapManager_OnUpdated()
{ {
Debug.Log("update "+ mapManager.Zoom); //Debug.Log("update "+ mapManager.Zoom);
if(mapManager.Zoom <= 4.8) if(mapManager.Zoom <= 4.8)
{ {

View File

@ -113,9 +113,11 @@ public class EarthController : PFUIPanel
Country.text = "China"; Country.text = "China";
Province.text = "TaiWan"; Province.text = "TaiWan";
ShowSummary(country.latlonCenter); ShowSummary(country.latlonCenter);
map.HighlightCountryRegion(173, 1, false, true, Color.white);
} }
else { 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]; var province = map.provinces[provinceIndex];
@ -151,11 +153,11 @@ public class EarthController : PFUIPanel
EnterBigMap(latLon); EnterBigMap(latLon);
}; };
skybox = Camera.main.GetComponent<Skybox>(); //skybox = Camera.main.GetComponent<Skybox>();
Debug.Log(skybox != null);
} }
private float rot = 0;
Skybox skybox; //private float rot = 0;
//Skybox skybox;
/// <summary> /// <summary>
/// 显示概要信息 /// 显示概要信息
/// </summary> /// </summary>
@ -209,8 +211,6 @@ public class EarthController : PFUIPanel
/// <param name="latLon"></param> /// <param name="latLon"></param>
private void EnterBigMap(Vector2 latLon) private void EnterBigMap(Vector2 latLon)
{ {
Debug.Log("enter big map");
map.FlyToLocation(latLon.x, latLon.y, 1f, 0.1f).Then(() => { map.FlyToLocation(latLon.x, latLon.y, 1f, 0.1f).Then(() => {
//Close(); //Close();
@ -278,7 +278,7 @@ public class EarthController : PFUIPanel
public override void Close() public override void Close()
{ {
//base.Close(); //base.Close();
map.Destroy();
DestroyImmediate(this.gameObject); DestroyImmediate(this.gameObject);
} }
} }

View File

@ -9,6 +9,7 @@ using Newtonsoft.Json;
using UnityEngine.UI; using UnityEngine.UI;
using Assets.Scripts.UI.Control; using Assets.Scripts.UI.Control;
using Assets.Scripts; using Assets.Scripts;
using System;
public class UIManager : MonoBehaviour public class UIManager : MonoBehaviour
{ {
@ -154,6 +155,11 @@ public class UIManager : MonoBehaviour
{ false,Resources.Load<Sprite>("Images/p-4灰")}, { false,Resources.Load<Sprite>("Images/p-4灰")},
{ true,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 // 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) public static void AddEvent(GameObject gameObject, EventTriggerType eventTriggerType, UnityAction<BaseEventData> call)
{ {
EventTrigger et = gameObject.GetComponent<EventTrigger>(); EventTrigger et = gameObject.GetComponent<EventTrigger>();
EventTrigger.Entry pointerEvent = null;
if (et == null) if (et == null)
{ {
et = gameObject.AddComponent<EventTrigger>(); et = gameObject.AddComponent<EventTrigger>();
} }
EventTrigger.Entry pointerEvent = new EventTrigger.Entry(); foreach (EventTrigger.Entry entry2 in et.triggers)
pointerEvent.eventID = eventTriggerType; {
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)=> { pointerEvent.callback.AddListener((e)=> {
if (gameObject == null || gameObject.activeInHierarchy == false) return; if (gameObject == null || gameObject.activeInHierarchy == false) return;
var btn = gameObject.GetComponent<Button>(); var btn = gameObject.GetComponent<Button>();
@ -492,7 +513,7 @@ public class UIManager : MonoBehaviour
call(e); call(e);
}); });
et.triggers.Add(pointerEvent);
if (eventTriggerType == EventTriggerType.PointerClick) 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() private void OnDestroy()
{ {
UIManager.Instance = null; UIManager.Instance = null;

View 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);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 08e8f3be54a1de04e9049674ce33fe23
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -12,7 +12,7 @@ PlayerSettings:
targetDevice: 2 targetDevice: 2
useOnDemandResources: 0 useOnDemandResources: 0
accelerometerFrequency: 60 accelerometerFrequency: 60
companyName: DefaultCompany companyName: ZhiXingPai
productName: PowerFun productName: PowerFun
defaultCursor: {fileID: 0} defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0} cursorHotspot: {x: 0, y: 0}