Merge remote-tracking branch 'origin/dev' into dev_lishuo

This commit is contained in:
lishuo committed 2021-04-27 20:28:24 +08:00
commit b71a15e2ba
47 files changed
+10164 -2757

No files matched your search

+7
View File
@@ -126,5 +126,12 @@ namespace Assets.Scripts.Apis
return Get<JsonResult<MapRouteRankingList>>(url);
}
public async Task<JsonResult<object>> GetEarthData(double lat, double lon)
{
var result = await GetAsync<JsonResult<object>>($"Map/GetEarthData?lat={ lat }&lon={ lon }");
return result;
}
}
}
+1 -1
View File
@@ -146,7 +146,7 @@ namespace Assets.Scripts.Devices.Ant
private void Log(string str)
{
//System.IO.File.AppendAllText(@"D:\work\PowerFun\PowerFun-Unity\Build\log.txt", str+"\r\n");
Debug.LogError(str);
//Debug.LogError(str);
}
private void antDevice_serialError(ANT_Device sender, ANT_Device.serialErrorCode error, bool isCritical)
+1
View File
@@ -431,6 +431,7 @@ public class LoginController : MonoBehaviour
{ "Days",signForm.days},
};
avatar = Resources.Load<Texture>("Images/New Account");
transform.Find("Version").GetComponent<Text>().text = $"V{App.AppVersion}";
}
async void GetRotateImage()
+1
View File
@@ -56,6 +56,7 @@ public class MainController : MonoBehaviour
//UIManager.ShowUserInfoPanel();
//UIManager.ShowEditUserPanel();
//UIManager.ShowBigMapPanel();
//UIManager.ShowEarthPanel();
}
}
+10 -1
View File
@@ -72,11 +72,20 @@ namespace Assets.Scripts.UI.Control
{
mOnValueChange(i);
}
SetWhite(i);
outline.enabled = false;
});
SetWhite(this.GetComponent<Dropdown>().value);
outline = transform.GetComponent<Outline>();
}
public void SetWhite(int index)
{
if (index != -1 && this.GetComponent<Dropdown>().interactable)
{
this.GetComponent<Dropdown>().captionText.color = Utils.HexToColorHtml("#ffffff");
}
}
public void SetValidate()
{
outline.enabled = true;
@@ -136,7 +145,7 @@ namespace Assets.Scripts.UI.Control
public void OnPointerClick(PointerEventData eventData)
{
if (GetComponent<Dropdown>().value == -1) return;
if (GetComponent<Dropdown>().value == -1 || !GetComponent<Dropdown>().interactable) return;
var x = transform.Find("Dropdown List").GetComponent<ScrollRect>().content;
x.GetChild(SelectedIndex + 1).Find("Item Label").GetComponent<Text>().color = Utils.HexToColorHtml("#f93086");
}
+1
View File
@@ -65,6 +65,7 @@ namespace Assets.Scripts.UI.Control
if (!string.IsNullOrWhiteSpace(Tooltips))
{
//
//tooltips.GetComponent<RectTransform>().localPosition.
tooltips.transform.Find("Text").GetComponent<Text>().text = Tooltips;
}
tooltips.SetActive(false);
@@ -8,6 +8,7 @@ using UnityEngine.EventSystems;
using UnityEngine.UI;
using Assets.Scripts.Devices.Ant.Interfaces;
using Assets.Scripts.UI.Control;
using Assets.Scripts;
public class ConnectDeviceModal : PFUIPanel
{
@@ -21,7 +22,17 @@ public class ConnectDeviceModal : PFUIPanel
{
Debug.Log(value);
mSensorType = value;
Logo.sprite = Resources.Load<Sprite>("Images/Devices/Trainer_3");
var deviceInfoStr = Utils.deviceDict[value.ToString()];
if (deviceInfoStr != null)
{
var deviceInfo = deviceInfoStr.Split('|');
if (deviceInfo.Length == 2)
{
Title.text = deviceInfo[0];
Logo.sprite = Resources.Load<Sprite>(deviceInfo[1]);
}
}
}
}
private Image Logo;
@@ -29,7 +40,7 @@ public class ConnectDeviceModal : PFUIPanel
private VerticalLayoutGroup content;
private PfUIButton connectBtn;
private Dictionary<ushort, DeviceItem> deviceList;
private Text noDevice;
private Text noDevice,Title;
private RectTransform searchIconRect;
protected override void Awake()
@@ -41,6 +52,7 @@ public class ConnectDeviceModal : PFUIPanel
var container = this.transform.Find("GameObject");
var closeBtn = container.Find("CloseBtn");
Logo = container.Find("Logo").GetComponent<Image>();
Title = container.Find("Title").GetComponent<Text>();
var panel = container.Find("Panel");
content = panel.Find("Scroll View").Find("Viewport").Find("Content").GetComponent<VerticalLayoutGroup>();
@@ -70,7 +70,7 @@ public class FeedbackController : PFUIPanel
{
if (App.CurrentUser == null) return;
main.Find("Email").Find("Value").Find("Text").GetComponent<Text>().text = App.CurrentUser.Phone;
main.Find("ID").Find("Value").Find("Text").GetComponent<Text>().text = App.CurrentUser.Id.ToString();
main.Find("ID").Find("Value").Find("Text").GetComponent<Text>().text = App.CurrentUser.Id.ToString("#000000");
main.Find("Version").Find("Value").Find("Text").GetComponent<Text>().text = App.AppVersion;
main.Find("Time").Find("Value").Find("Text").GetComponent<Text>().text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
@@ -40,7 +40,7 @@ namespace Assets.Scripts.UI.Prefab.MapList
{"HC","750-99999" },
};
public static List<Dropdown.OptionData> sorts = new string[] {
"Distance","Name","Difficulty","Hot"//,"Times"
"Hot","Name","Distance","Difficulty"//,"Times"
}.Select(x => new Dropdown.OptionData(x)).ToList();
public static Dictionary<string, string> diffDisplayDict = new Dictionary<string, string>()
{
@@ -48,24 +48,34 @@ public class BigMapController : PFUIPanel
}
}
int timer = 0;
private RawImage maskImage;
protected override void Awake()
{
var cg = this.transform.Find("Canvas").GetComponent<CanvasGroup>();
cg.alpha = 0;
//var rect = Camera.main.rect;
//rect.position = new Vector2(0, 200);
Camera.main.transform.position = new Vector3(0, 200);
Camera.main.transform.rotation = Quaternion.Euler(90, 0, 0);
//var cg = this.transform.Find("Canvas").GetComponent<CanvasGroup>();
//cg.alpha = 0;
mapApi = new MapApi();
mapboxApi = new MapBoxApi();
begin = Resources.Load("UI/Prefab/BigMap/Begin");
StartCoroutine("Main");
}
IEnumerator Main()
{
mapManager = this.transform.Find("Map").GetComponent<AbstractMap>();
mapManager.MaxZoom = 4;
mapManager.OnInitialized += MapManager_OnInitialized;
mapManager.OnUpdated += MapManager_OnUpdated;
//// mapManager.OnTileFinished += MapManager_OnTileFinished;
//mapManager.SetZoom(13);
mapManager.SetZoom(7);
//mapManager.SetCenterLatitudeLongitude(new Mapbox.Utils.Vector2d(32.051203, 118.771572));
this.transform.Find("Map").GetComponent<QuadTreeCameraMovement>()._referenceCamera = Camera.main;
@@ -84,7 +94,7 @@ public class BigMapController : PFUIPanel
});
var panel = canvas.transform.Find("Panel");
base.SetRounded(panel,30f);
base.SetRounded(panel, 30f);
content = panel.Find("Scroll View").Find("Viewport").Find("Content").gameObject;
var input = panel.Find("InputField");
@@ -99,8 +109,11 @@ public class BigMapController : PFUIPanel
BindHeadImage();
maskImage = canvas.transform.Find("MaskImage").GetComponent<RawImage>();
maskImage.DOFade(0, 0.8f);
yield return null;
}
/// <summary>
/// 绑定头像
/// </summary>
@@ -154,6 +167,19 @@ public class BigMapController : PFUIPanel
{
Debug.Log("update");
if(mapManager.Zoom <= 6)
{
mapManager.OnUpdated -= MapManager_OnUpdated;
maskImage.gameObject.SetActive(true);
maskImage.DOFade(1f, 0.9f).SetEase(Ease.InSine).OnComplete(() =>
{
this.Close();
UIManager.ShowEarthPanel(mapManager.CenterLatitudeLongitude.x, mapManager.CenterLatitudeLongitude.y);
});
return;
}
foreach (var item in linesCache)
{
//if(item.Value.LineObject != null)
@@ -431,13 +457,24 @@ public class BigMapController : PFUIPanel
}
}
public override void Show()
public void Show(double lat, double lon)
{
var cg = this.transform.Find("Canvas").GetComponent<CanvasGroup>();
cg.alpha = 0;
//var cg = this.transform.Find("Canvas").GetComponent<CanvasGroup>();
//cg.alpha = 0;
var color = maskImage.color;
color.a = 1;
maskImage.color = color;
base.Show();
cg.DOFade(1f, 0.3f);
if(lat != 0 && lon != 0)
{
mapManager.SetCenterLatitudeLongitude(new Vector2d(lat, lon));
}
maskImage.DOFade(1f, 0.5f).OnComplete(()=> {
maskImage.gameObject.SetActive(false);
});
//cg.DOFade(1f, 0.3f);
}
public override void Close()
@@ -487,7 +524,10 @@ public class BigMapController : PFUIPanel
//Debug.Log($"销毁{ item.Key }, { item.Value.Item != null }");
LineObject.Destroy();
BeginMarker.Destroy();
Item.gameObject.Destroy();
if (Item != null)
{
Item.gameObject.Destroy();
}
}
}
}
@@ -0,0 +1,232 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using WPM;
using DG.Tweening;
using UnityEngine.UI;
using Assets.Scripts.Apis;
using Newtonsoft.Json.Linq;
public class EarthController : PFUIPanel
{
private WorldMapGlobe map;
private Text Province;
private Text Country;
private RawImage maskImage;
private MapApi mapApi;
private Text CountText;
private Text OfficialText;
private Text RiderText;
private GameObject hotPanel;
private GameObject content;
private Object itemObject;
protected override void Awake()
{
base.Awake();
mapApi = new MapApi();
map = WorldMapGlobe.instance;
map.showProvinces = true;
map.showCities = true;
map.autoRotationSpeed = 0f;
//map.autoRotationSpeed = 0.1f;
//Camera.main.fieldOfView = 180;
map.SetZoomLevel(1.4f);
//map.allowUserZoom = false;
map.showLatitudeLines = false;
map.showLongitudeLines = false;
map.showCursor = false;
}
// Start is called before the first frame update
protected override void Start()
{
itemObject = Resources.Load("UI/Prefab/BigMap/Item");
var rootPanel = this.transform.Find("Canvas").Find("Panel");
var panel = rootPanel.Find("Panel");
SetRounded(panel, 60);
hotPanel = rootPanel.Find("HotPanel").gameObject;
SetRounded(hotPanel.transform, 60);
maskImage = rootPanel.Find("MaskImage").GetComponent<RawImage>();
Country = panel.Find("Country").GetComponent<Text>();
Province = panel.Find("Province").GetComponent<Text>();
CountText = panel.Find("CountPanel").Find("Count").GetComponent<Text>();
OfficialText = panel.Find("OfficialPanel").Find("Count").GetComponent<Text>();
RiderText = panel.Find("RiderPanel").Find("Count").GetComponent<Text>();
content = hotPanel.transform.Find("Scroll View").Find("Viewport").Find("Content").gameObject;
//map.SetZoomLevel(10);
//var mainCanvas = GameObject.Find("Canvas");
//mainCanvas.gameObject.SetActive(false);
UIManager.Instance.MainPanel.gameObject.SetActive(false);
Camera.main.transform.position = new Vector3(0, 0);
Camera.main.transform.rotation = Quaternion.Euler(0, 0, 0);
var zoom = map.GetZoomLevel();
map.OnZoomStart += Map_OnZoomStart;
map.OnZoomEnd += Map_OnZoomEnd;
map.OnClick += Map_OnClick;
map.OnCountryEnter += (int countryIndex, int regionIndex) =>
{
var country = map.countries[countryIndex];
if (country.name.ToLower().Contains("taiwan"))
{
Country.text = "China";
Province.text = "TaiWan";
ShowSummary(country.latlonCenter);
}
else {
Country.text = country.name;
}
};
map.OnCountryClick += (int countryIndex, int regionIndex) =>
{
var country = map.countries[countryIndex];
if (country.name.ToLower().Contains("taiwan"))
{
var latLon = country.latlonCenter;
EnterBigMap(latLon);
}
};
map.OnProvinceEnter += async (int provinceIndex, int regionIndex) =>
{
var province = map.provinces[provinceIndex];
Province.text = province.name;
ShowSummary(province.latlonCenter);
};
map.OnProvinceExit += (int provinceIndex, int regionIndex) =>
{
};
map.OnProvinceClick += (int provinceIndex, int regionIndex) =>
{
var province = map.provinces[provinceIndex];
var latLon = province.latlonCenter;
EnterBigMap(latLon);
};
}
/// <summary>
/// 显示概要信息
/// </summary>
/// <param name="latlonCenter"></param>
private async void ShowSummary(Vector2 latlonCenter)
{
var result = await mapApi.GetEarthData(latlonCenter.x, latlonCenter.y);
if (result.result == false)
{
return;
}
var obj = JObject.FromObject(result.data);
CountText.text = obj.Value<string>("count");
OfficialText.text = obj.Value<string>("officialCount");
RiderText.text = obj.Value<string>("riderCount");
//for (int i = 0; i < content.transform.childCount; i++)
//{
// DestroyImmediate(content.transform.GetChild(i));
//}
foreach (Transform item in content.transform)
{
GameObject.Destroy(item.gameObject);
}
var list = JArray.FromObject(obj["list"]);
foreach (var item in list)
{
var itemObject1 = (GameObject)Instantiate(itemObject, content.transform, false);
var iii = itemObject1.GetComponent<Item>();
iii.SetModel(new Assets.Scripts.Apis.Models.NearRouteModel
{
Id = item.Value<int>("Id"),
Name = item.Value<string>("Name"),
TheHeat = item.Value<int>("TheHat"),
IsFire = item.Value<bool>("IsFire")
});
}
}
/// <summary>
/// 进入大地图
/// </summary>
/// <param name="latLon"></param>
private void EnterBigMap(Vector2 latLon)
{
map.FlyToLocation(latLon.x, latLon.y, 1f, 0.1f).Then(() => {
//Close();
//UIManager.ShowBigMapPanel();
});
maskImage.gameObject.SetActive(true);
maskImage.DOFade(1f, 0.9f).SetEase(Ease.InSine).OnComplete(() => {
Close();
UIManager.ShowBigMapPanel(latLon.x, latLon.y);
});
}
private void Map_OnClick(Vector3 sphereLocation, int mouseButtonIndex)
{
Debug.Log("click");
Vector2 latLon = Conversion.GetLatLonFromSpherePoint(sphereLocation);
Debug.Log("Clicked on Latitude: " + latLon.x + ", Longitude: " + latLon.y);
}
private void Map_OnZoomStart(float zoomLevel)
{
//throw new System.NotImplementedException();
Debug.Log(zoomLevel);
}
private void Map_OnZoomEnd(float zoomLevel)
{
Debug.Log(zoomLevel);
}
// Update is called once per frame
void Update()
{
//var zoom = map.GetZoomLevel();
//Debug.Log(zoom);
}
public void Show(double lat, double lon)
{
if (lat != 0 && lon != 0)
{
map.FlyToLocation(new Vector2((float)lat, (float)lon), 0.1f);
}
}
public override void Close()
{
//base.Close();
DestroyImmediate(this.gameObject);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ad7c4b0fd31e47d40858215e0bd78fb8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -205,7 +205,7 @@ public class EditUserController : PFUIPanel
mMonthDropdown.SelectValue(birthday.Month.ToString());
mDayDropdown.SelectValue(birthday.Day.ToString());
}
mID.text = currentUser.Id.ToString();
mID.text = currentUser.Id.ToString("000000");
mNickName.Text = currentUser.Nickname;
mFTP.Text = currentUser.FTP.ToString();
mWeight.Text = currentUser.Weight.ToString();
@@ -324,7 +324,8 @@ public class EditUserController : PFUIPanel
userinfos[i].NickName = user.Nickname;
UIManager.Instance.userInfos = userinfos;
}
UIManager.ShowAlert("Success");
Utils.showToast(gameObject, "Success", type: 1);
//UIManager.ShowAlert("Success");
}
LoadDataSync();
//App.CurrentUser = user;
@@ -346,11 +347,13 @@ public class EditUserController : PFUIPanel
UIManager.Instance.userInfos = userinfos;
}
App.CurrentUser.WxHeadImg = img;
UIManager.ShowAlert("Success");
Utils.showToast(gameObject, "Success", type: 1);
//UIManager.ShowAlert();
}
else
{
UIManager.ShowAlert(r.errMsg);
Utils.showToast(gameObject, r.errMsg);
//UIManager.ShowAlert();
}
}
void Cancel(BaseEventData e)
@@ -54,7 +54,8 @@ public class MapListController : PFUIPanel
UIManager.AddEvent(btnMapMode.transform.Find("GoList").gameObject, EventTriggerType.PointerClick, (e) =>
{
UIManager.PopStack();
UIManager.ShowBigMapPanel();
//UIManager.ShowBigMapPanel();
UIManager.ShowEarthPanel(App.latitude, App.longitude);
});
if (content!=null)
{
@@ -169,7 +170,7 @@ public class MapListController : PFUIPanel
{
var drop = sorts.GetComponent<Dropdown>();
drop.options = MapFilterOptions.sorts;
drop.value = 3;
drop.value = 0;
drop.onValueChanged.AddListener((int index)=>
{
sort = drop.options[index].text;
@@ -84,7 +84,10 @@ public class UserInfoController : PFUIPanel
infoPanel.Find("Weight").Find("Value").GetComponent<Text>().text = $"{user.Weight}KG";
infoPanel.Find("BW").Find("Value").GetComponent<Text>().text = $"{user.BicycleWeight}KG";
infoPanel.Find("WD").Find("Value").GetComponent<Text>().text = $"{user.WheelDiameter}MM";
if (user.Sex == 2)
{
infoPanel.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/woman");
}
summaryPanel.Find("Number").Find("Value").GetComponent<Text>().text = summary.Count.ToString();
summaryPanel.Find("Time").Find("Value").GetComponent<Text>().text = summary.TotalTicks.ToString();
summaryPanel.Find("KM").Find("Value").GetComponent<Text>().text = summary.TotalDistance.ToString();
@@ -36,7 +36,7 @@ public class RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandle
row2 = left.Find("Main").Find("Row2");
Utils.DisplayImage(StartCoroutine, transform.Find("CoverImage").GetComponent<RawImage>(), result.RouteImage);
left.Find("Main").Find("Name").GetComponent<Text>().text = result.RouteName;
left.Find("Main").Find("Time").GetComponent<Text>().text = result.CreateTime.ToString("yyyy-MM-dd HH-mm-ss");
left.Find("Main").Find("Time").GetComponent<Text>().text = result.CreateTime.ToString("yyyy-MM-dd HH:mm:ss");
row1.Find("Time").GetComponent<Text>().text = $"<color={titleColor}>Riding time:</color>{result.TrainingTime}";
row1.Find("Distance").GetComponent<Text>().text = $"<color={titleColor}>Mileage:</color>{result.EndDistance.ToString("#0.00")}KM";
row1.Find("Times").GetComponent<Text>().text = $"<color={titleColor}>Times:</color>{result.Count}";
+19 -3
View File
@@ -394,17 +394,33 @@ public class UIManager : MonoBehaviour
// UIManager.Show(prePanel, UIManager.Instance.MainPanel);
//}
}
public static void ShowBigMapPanel()
public static void ShowBigMapPanel(double lat = 0, double lon = 0)
{
UIManager.Instance.MainPanel.gameObject.SetActive(false);
var obj = Resources.Load("UI/Prefab/Panel/BigMapPanel");
//var root = UIManager.Instance.MainPanel.transform.parent.parent;
var bigMap = (GameObject)Instantiate(obj, UIManager.Instance.Root.transform);
bigMap.GetComponent<BigMapController>().Show();
bigMap.GetComponent<BigMapController>().Show(lat, lon);
stack.Push(bigMap.GetComponent<PFUIPanel>());
//prePanel = bigMap.GetComponent<PFUIPanel>();
}
static GameObject earthPanel = null;
public static void ShowEarthPanel(double lat = 0, double lon = 0)
{
if (UIManager.Instance.MainPanel != null)
{
UIManager.Instance.MainPanel.gameObject.SetActive(false);
}
if (earthPanel == null)
{
var obj = Resources.Load("UI/Prefab/Panel/EarthPanel");
//var root = UIManager.Instance.MainPanel.transform.parent.parent;
earthPanel = (GameObject)Instantiate(obj, UIManager.Instance.Root.transform);
}
earthPanel.GetComponent<EarthController>().Show(lat, lon);
}
static Texture2D cursor;
public static void RemoveEvent(GameObject gameObject)
{
+30 -6
View File
@@ -97,19 +97,43 @@ namespace Assets.Scripts
_toastDict = value;
}
}
private static Dictionary<string, string> _deviceDict;
public static Dictionary<string, string> deviceDict
{
get
{
if (_deviceDict == null)
{
_deviceDict = new Dictionary<string, string>
{
{"Trainer","Smart Trainer|Images/Devices/Trainer_3" },
{"Power","Power Meter|Images/Devices/Power_3" },
{"Cadence","Cadence Sensor|Images/Devices/Cadence_3" },
{"HeartRate","Heart Rate Monitor|Images/Devices/Heart Rate_3" },
{"SpeedCadence","Speed Meter|Images/Devices/Speed_3" },
};
}
return _deviceDict;
}
private set
{
_deviceDict = value;
}
}
public static void showToast(GameObject game,string text,int duration = 1,int type = 0)
{
//type 0错误 1正确
var parent = Utils.FindUpParent(game.transform);
var toast = parent.Find("ToastContainer");
if (toast == null)
if (toast != null)
{
var newToast = MonoBehaviour.Instantiate(Resources.Load<GameObject>("UI/Prefab/ToastContainer"));
newToast.name = "ToastContainer";
newToast.GetComponent<RectTransform>().position = new Vector3(Screen.width / 2, Screen.height / 2, 0);
newToast.transform.parent = parent;
toast = newToast.transform;
MonoBehaviour.DestroyImmediate(toast.gameObject);
}
var newToast = MonoBehaviour.Instantiate(Resources.Load<GameObject>("UI/Prefab/ToastContainer"));
newToast.name = "ToastContainer";
newToast.GetComponent<RectTransform>().position = new Vector3(Screen.width / 2, Screen.height / 2, 0);
newToast.transform.parent = parent;
toast = newToast.transform;
var toastStyle = toastDict[type].Split('|');
toast.Find("Image").GetComponent<Image>().sprite = Resources.Load<Sprite>(toastStyle[0]);
toast.GetComponent<Image>().color = HexToColorHtml(toastStyle[1]);