AR骑行动画&换装基本交互逻辑
This commit is contained in:
1 parent
d938a0c8be
commit
995aef63f8
117 files changed
+60802
-2718
No files matched your search
@@ -0,0 +1,181 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Assets.Scripts.UI.Prefab.Player;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public class ChangePlayerController : PFUIPanel
|
||||
{
|
||||
public Transform Panel;
|
||||
public Transform InfoPanel;
|
||||
|
||||
public GameObject BikeBtn;
|
||||
public GameObject HelmetBtn;
|
||||
public GameObject UniformBtn;
|
||||
public GameObject SkinBtn;
|
||||
public GameObject SuitBtn;
|
||||
|
||||
public GameObject SaveBtn;
|
||||
public GameObject ViewBtn;
|
||||
|
||||
public GameObject CaputureBtn;
|
||||
public GameObject BackBtn;
|
||||
|
||||
public Transform Content;
|
||||
|
||||
|
||||
public GameObject BikePrefab;
|
||||
public GameObject HelmetPrefab;
|
||||
public GameObject UniformPrefab;
|
||||
public GameObject SkinPrefab;
|
||||
public GameObject SuitPrefab;
|
||||
|
||||
List<EquitmentModel> data { get; set; }
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
UIManager.AddEvent(BikeBtn, EventTriggerType.PointerClick, BikeBtn_Click);
|
||||
UIManager.AddEvent(HelmetBtn, EventTriggerType.PointerClick, HelmetBtn_Click);
|
||||
UIManager.AddEvent(UniformBtn, EventTriggerType.PointerClick, UniformBtn_Click);
|
||||
UIManager.AddEvent(SkinBtn, EventTriggerType.PointerClick, SkinBtn_Click);
|
||||
UIManager.AddEvent(SuitBtn, EventTriggerType.PointerClick, SuitBtn_Click);
|
||||
|
||||
UIManager.AddEvent(SaveBtn, EventTriggerType.PointerClick, SuitBtn_Click);
|
||||
UIManager.AddEvent(ViewBtn, EventTriggerType.PointerClick, ViewBtn_Click);
|
||||
UIManager.AddEvent(CaputureBtn, EventTriggerType.PointerClick, SuitBtn_Click);
|
||||
UIManager.AddEvent(BackBtn, EventTriggerType.PointerClick, BackBtn_Click);
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
transform.Find("MainNav").GetComponent<MainNav>().ShowBack();
|
||||
GetData();
|
||||
}
|
||||
|
||||
private void GetData()
|
||||
{
|
||||
//获取装备信息列表初始化
|
||||
var res = ConfigHelper.userApi.GetEquitmentList();
|
||||
if (res.Result.result)
|
||||
{
|
||||
data = res.Result.data;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
private void Refresh(int type = 1)
|
||||
{
|
||||
if (data == null)
|
||||
return;
|
||||
|
||||
BikeBtn.transform.Find("bg").gameObject.SetActive(type == 0);
|
||||
HelmetBtn.transform.Find("bg").gameObject.SetActive(type == 1);
|
||||
UniformBtn.transform.Find("bg").gameObject.SetActive(type == 2);
|
||||
SkinBtn.transform.Find("bg").gameObject.SetActive(type == 3);
|
||||
SuitBtn.transform.Find("bg").gameObject.SetActive(type == 4);
|
||||
|
||||
var list = data.Where(c => c.Type == type).ToList();
|
||||
|
||||
//清空内容
|
||||
Utils.DestroyChildren(Content);
|
||||
GameObject prefab = null;
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
prefab = BikePrefab;
|
||||
break;
|
||||
case 1:
|
||||
prefab = HelmetPrefab;
|
||||
break;
|
||||
case 2:
|
||||
prefab = UniformPrefab;
|
||||
break;
|
||||
case 3:
|
||||
prefab = SkinPrefab;
|
||||
break;
|
||||
case 4:
|
||||
prefab = SuitPrefab;
|
||||
break;
|
||||
}
|
||||
|
||||
if (type == 3)
|
||||
{
|
||||
GameObject colorPicker = null;
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
var item = list[i];
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
colorPicker = Instantiate(prefab, Content);
|
||||
colorPicker.SetActive(true);
|
||||
var left = colorPicker.transform.Find("Left");
|
||||
left.GetComponent<AbstractEquipmentScript>().Init(item.Id, item.Name, item.Remark, item.Url, item.IsLock);
|
||||
}
|
||||
else
|
||||
{
|
||||
var right = colorPicker.transform.Find("Right");
|
||||
right.GetComponent<AbstractEquipmentScript>().Init(item.Id, item.Name, item.Remark, item.Url, item.IsLock);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
var o = Instantiate(prefab, Content);
|
||||
o.GetComponent<AbstractEquipmentScript>().Init(item.Id, item.Name, item.Remark, item.Url, item.IsLock);
|
||||
o.SetActive(true);
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)Content);
|
||||
}
|
||||
}
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)Content);
|
||||
}
|
||||
|
||||
private void ViewBtn_Click(BaseEventData baseEventData)
|
||||
{
|
||||
Panel.DOLocalMoveX(-1007, 1f);
|
||||
InfoPanel.DOLocalMoveX(931, 1f);
|
||||
ViewBtn.SetActive(false);
|
||||
SaveBtn.SetActive(false);
|
||||
}
|
||||
private void BackBtn_Click(BaseEventData baseEventData)
|
||||
{
|
||||
Panel.DOLocalMoveX(-538.5f, 1f);
|
||||
InfoPanel.DOLocalMoveX(541, 1f);
|
||||
ViewBtn.SetActive(true);
|
||||
SaveBtn.SetActive(true);
|
||||
}
|
||||
|
||||
private void BikeBtn_Click(BaseEventData baseEventData)
|
||||
{
|
||||
Refresh(0);
|
||||
}
|
||||
private void HelmetBtn_Click(BaseEventData baseEventData)
|
||||
{
|
||||
Refresh(1);
|
||||
}
|
||||
private void UniformBtn_Click(BaseEventData baseEventData)
|
||||
{
|
||||
Refresh(2);
|
||||
}
|
||||
private void SkinBtn_Click(BaseEventData baseEventData)
|
||||
{
|
||||
Refresh(3);
|
||||
}
|
||||
private void SuitBtn_Click(BaseEventData baseEventData)
|
||||
{
|
||||
Refresh(4);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12590f2048a2e184f96275f612967772
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,406 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Assets.Scripts.UI.Control;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NewHomeController : PFUIPanel
|
||||
{
|
||||
//[SerializeField] Text Ftp;
|
||||
//[SerializeField] RawImage Avatar;
|
||||
//[SerializeField] Text Weight;
|
||||
//[SerializeField] Text WKG;
|
||||
//[SerializeField] Text Calories;
|
||||
//[SerializeField] Text KM;
|
||||
//[SerializeField] Text Climb;
|
||||
//[SerializeField] Text NickName;
|
||||
//[SerializeField] Button More;
|
||||
[SerializeField] Button BtnRide;
|
||||
[SerializeField] Transform userInfo;
|
||||
Transform BtnMatch, BtnTraining;
|
||||
private MainNav mainNav;
|
||||
private Dictionary<string, Sprite[]> dict;
|
||||
// Start is called before the first frame update
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
UIManager.AddEvent(transform.Find("TodayData/Avatar").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowUserInfoPanel();
|
||||
});
|
||||
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
var nav = transform.Find("MainNav-mobile").GetComponent<NewMainNav>();
|
||||
nav.SetButtonActive(new List<int> { 1, 3, 4, 6 });
|
||||
newNav = nav;
|
||||
UIManager.AddEvent(transform.Find("TodayData/Datas/Distance").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowResultListPanel();
|
||||
});
|
||||
#else
|
||||
UIManager.AddEvent(transform.Find("TodayData/Distance").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowUserInfoPanel();
|
||||
});
|
||||
UIManager.AddEvent(transform.Find("ProfileBtn").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowEditUserPanel();
|
||||
});
|
||||
UIManager.AddEvent(transform.Find("ChangeBtn").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowChangePlayerPanel();
|
||||
});
|
||||
mainNav = this.transform.Find("MainNav").GetComponent<MainNav>();
|
||||
mainNav.ShowExit();
|
||||
#endif
|
||||
var BtnContainer = transform.Find("MainFuncContainer");
|
||||
UIManager.AddEvent(BtnRide.gameObject, EventTriggerType.PointerClick, GoRide);
|
||||
UIManager.AddEvent(BtnRide.gameObject, EventTriggerType.PointerEnter, OnHover);
|
||||
UIManager.AddEvent(BtnRide.gameObject, EventTriggerType.PointerExit, OnExit);
|
||||
BtnMatch = BtnContainer.Find("BtnMatch");
|
||||
//BtnMatch.GetComponent<Button>().onClick.AddListener(() =>
|
||||
//{
|
||||
// Debug.Log(45);
|
||||
//});
|
||||
UIManager.AddEvent(BtnMatch.gameObject, EventTriggerType.PointerClick, GoMatch);
|
||||
UIManager.AddEvent(BtnMatch.gameObject, EventTriggerType.PointerEnter, OnHover);
|
||||
UIManager.AddEvent(BtnMatch.gameObject, EventTriggerType.PointerExit, OnExit);
|
||||
BtnTraining = BtnContainer.Find("BtnTraining");
|
||||
UIManager.AddEvent(BtnTraining.gameObject, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
Debug.Log(Application.platform);
|
||||
goTraining(e);
|
||||
});
|
||||
UIManager.AddEvent(BtnTraining.gameObject, EventTriggerType.PointerEnter, OnHover);
|
||||
UIManager.AddEvent(BtnTraining.gameObject, EventTriggerType.PointerExit, OnExit);
|
||||
var avatar = userInfo.Find("Avatar").GetComponent<RawImage>();
|
||||
var rect = ((RectTransform)avatar.transform).rect;
|
||||
SetRounded(avatar.transform, rect.height);
|
||||
|
||||
UIManager.AddEvent(avatar.gameObject, EventTriggerType.PointerClick, x =>
|
||||
{
|
||||
UIManager.ShowUserInfoPanel();
|
||||
});
|
||||
|
||||
UIManager.AddEvent(userInfo.Find("BtnMore").gameObject, EventTriggerType.PointerClick, x =>
|
||||
{
|
||||
UIManager.ShowUserInfoPanel();
|
||||
//UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", null);
|
||||
});
|
||||
if (transform.Find("Other/BtnRower"))
|
||||
{
|
||||
UIManager.AddEvent(transform.Find("Other/BtnRower").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowRowerPanel();
|
||||
});
|
||||
}
|
||||
|
||||
//GetSummary();
|
||||
dict = new Dictionary<string, Sprite[]>
|
||||
{
|
||||
//{
|
||||
// "BtnMatch",new Sprite[]
|
||||
// {
|
||||
// Resources.Load<Sprite>("Images/home/Entrance - MATCH_soon"),
|
||||
// Resources.Load<Sprite>("Images/home/Entrance - MATCH_soon_hover"),
|
||||
// }
|
||||
//},
|
||||
//{
|
||||
// "BtnTraining",new Sprite[]
|
||||
// {
|
||||
// Resources.Load<Sprite>("Images/home/Entrance - TRAINING_soon"),
|
||||
// Resources.Load<Sprite>("Images/home/Entrance - TRAINING_soon_hover"),
|
||||
// }
|
||||
//},
|
||||
};
|
||||
|
||||
}
|
||||
private void GoRide(BaseEventData e)
|
||||
{
|
||||
Debug.Log(App.firstEnter.ToString());
|
||||
//UIManager.ShowEarthPanel(App.latitude, App.longitude);
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
UIManager.ShowNewRouteOverviewPanel();
|
||||
#else
|
||||
if (App.firstEnter == 0)
|
||||
{
|
||||
App.firstEnter = 1;
|
||||
UIManager.ShowEarthPanel(App.latitude, App.longitude);
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.ShowNewRouteOverviewPanel();
|
||||
}
|
||||
|
||||
#endif
|
||||
OnExit(e);
|
||||
}
|
||||
void goTraining(BaseEventData e)
|
||||
{
|
||||
#if !(UNITY_IOS || UNITY_ANDROID)
|
||||
var path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\PowerFun\Rhino.PowerFun.exe";
|
||||
//Debug.Log(System.IO.File.Exists(path + ));
|
||||
if (!System.IO.File.Exists(path))
|
||||
{
|
||||
//TODO: auto update
|
||||
UIManager.ShowDownloadWorkoutsPanel();
|
||||
//Application.OpenURL("https://powerfun.oss-cn-shanghai.aliyuncs.com/Releases/PowerFunWorkouts.exe");
|
||||
return;
|
||||
}
|
||||
UIManager.ShowConfirm("Switch to PowerFun Workouts?", "We will close the Powerfun and start PowerFun Workouts.", () =>
|
||||
{
|
||||
Utils.ExecFile(path);
|
||||
Application.Quit();
|
||||
});
|
||||
#else
|
||||
if (App.weChatController.isApplicationAvilible("com.zhixingpai.powerfun", "powerfun"))
|
||||
{
|
||||
UIManager.ShowConfirm("Switch to PowerFun Workouts?", "We will close the Powerfun and start PowerFun Workouts.", () =>
|
||||
{
|
||||
UIManager.CloseConfirm();
|
||||
Application.OpenURL("powerfun://app");
|
||||
Application.Quit();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.ShowConfirm("Workouts not installed", "Go to the official website to download?", () =>
|
||||
{
|
||||
UIManager.CloseConfirm();
|
||||
Application.OpenURL(App.WorkoutsUrl);
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
//进入比赛
|
||||
private void GoMatch(BaseEventData e)
|
||||
{
|
||||
UIManager.ShowRaceHomePanel();
|
||||
OnExit(e);
|
||||
}
|
||||
private void OnHover(BaseEventData e)
|
||||
{
|
||||
var pe = (PointerEventData)e;
|
||||
var parent = pe.pointerEnter.transform.parent;
|
||||
if (dict.ContainsKey(parent.name))
|
||||
{
|
||||
parent.Find("Image").GetComponent<Image>().sprite = dict[parent.name][1];
|
||||
}
|
||||
//parent.Find("Image").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/home/Entrance - ROUTES_hover");
|
||||
//parent.Find("Text").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
parent.DOScale(new Vector3(1.05f, 1.05f, 0), 0.3f);
|
||||
//parent.GetComponent<RectTransform>().localScale = ;
|
||||
}
|
||||
private void OnExit(BaseEventData e)
|
||||
{
|
||||
var pe = (PointerEventData)e;
|
||||
var parent = pe.pointerEnter.transform.parent;
|
||||
//parent.Find("Image").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/home/Entrance - ROUTES_nomal");
|
||||
//parent.Find("Text").GetComponent<Text>().color = Utils.HexToColorHtml("#5C5C6E");
|
||||
if (dict.ContainsKey(parent.name))
|
||||
{
|
||||
parent.Find("Image").GetComponent<Image>().sprite = dict[parent.name][0];
|
||||
}
|
||||
parent.DOScale(new Vector3(1f, 1f, 0), 0.3f);
|
||||
//parent.GetComponent<RectTransform>().localScale = new Vector3(1f, 1f, 0);
|
||||
}
|
||||
void MoreFunc()
|
||||
{
|
||||
//Utils.showToast(gameObject, "更多信息", 1);
|
||||
|
||||
//DOTween.ToAlpha(() => )
|
||||
}
|
||||
|
||||
void SetCurrentUser(SummaryResultModel summary)
|
||||
{
|
||||
userInfo.Find("NickName").GetComponent<Text>().text = App.CurrentUser.Nickname;
|
||||
userInfo.Find("GroupTop").Find("FtpContainer").Find("FtpValue").GetComponent<Text>().text = App.CurrentUser.FTP.ToString();
|
||||
userInfo.Find("GroupTop").Find("WeightContainer").Find("WeightValue").GetComponent<Text>().text = App.CurrentUser.Weight.ToString();
|
||||
userInfo.Find("GroupTop").Find("WKGContainer").Find("WKGValue").GetComponent<Text>().text = $"{ (App.CurrentUser.FTP/ App.CurrentUser.Weight).ToString("0.0") }";
|
||||
userInfo.Find("IDText").GetComponent<Text>().text = "ID:" + App.CurrentUser.Id.ToString("000000");
|
||||
if (!string.IsNullOrWhiteSpace(App.CurrentUser.Unionid))
|
||||
{
|
||||
userInfo.Find("Wx").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/Wechat_person_1");
|
||||
}
|
||||
if (App.CurrentUser.Sex == 2)
|
||||
{
|
||||
userInfo.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/woman");
|
||||
}
|
||||
else
|
||||
{
|
||||
userInfo.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/man");
|
||||
}
|
||||
Utils.DisplayHead(userInfo.Find("Avatar").GetComponent<RawImage>(), App.CurrentUser.WxHeadImg);
|
||||
|
||||
userInfo.Find("Country").GetComponent<RawImage>().texture = UIManager.Instance.loginRegOptions.GetCountryImageByName(App.CurrentUser.Country);
|
||||
userInfo.Find("CaloriesContainer").Find("CaloriesValue").GetComponent<Text>().text = double.Parse(summary.Kcal,CultureInfo.InvariantCulture).ToString("0") +" KCAL";
|
||||
userInfo.Find("KMContainer").Find("KMValue").GetComponent<Text>().text = summary.TotalDistance.ToString("0") +" KM";
|
||||
userInfo.Find("ClimbContainer").Find("ClimbValue").GetComponent<Text>().text = double.Parse(summary.TotalClimb,CultureInfo.InvariantCulture).ToString("0") + " M";
|
||||
|
||||
userInfo.Find("GroupTop").Find("FtpContainer").Find("FtpTime").GetComponent<Text>().text = App.CurrentUser.LastUpdateFtpTime.ToString("dd.MM.yyyy");
|
||||
userInfo.Find("GroupTop").Find("WeightContainer").Find("WeightTime").GetComponent<Text>().text = App.CurrentUser.LastUpdateWeightTime.ToString("dd.MM.yyyy");
|
||||
userInfo.Find("GroupTop").Find("WKGContainer").Find("WKGTime").GetComponent<Text>().text =
|
||||
DateTime.Compare(App.CurrentUser.LastUpdateFtpTime, App.CurrentUser.LastUpdateWeightTime)>0
|
||||
? App.CurrentUser.LastUpdateFtpTime.ToString("dd.MM.yyyy")
|
||||
: App.CurrentUser.LastUpdateWeightTime.ToString("dd.MM.yyyy");
|
||||
//新版设计稿
|
||||
var todayData = transform.Find("TodayData");
|
||||
if (todayData)
|
||||
{
|
||||
Utils.DisplayHead(todayData.Find("Avatar").GetComponent<RawImage>(), App.CurrentUser.WxHeadImg);
|
||||
todayData.Find("Distance/Value").GetComponent<Text>().text = $"{summary.ContinuesDay}"+ (summary.ContinuesDay > 1 ? App.GetLocalString("DAYS") : App.GetLocalString("DAY"));
|
||||
todayData.Find("Datas/Climb/Value").GetComponent<Text>().text = $"{summary.ContinuesKm.ToString("#0.0")}";//$"{double.Parse(summary.TotalClimb, CultureInfo.InvariantCulture).ToString("0")}M";
|
||||
todayData.Find("Datas/Carlories/Value").GetComponent<Text>().text = $"{summary.ContinuesKcal.ToString("#0")}";
|
||||
//todayData.Find("Datas/Distance/Rank").GetComponent<Text>().text = summary.CurrentTotalDistance == 0 ? "——" : $"+{summary.CurrentTotalDistance.ToString("#0")}";
|
||||
todayData.Find("Datas/Climb/Rank").GetComponent<Text>().text = summary.CurrentTotalDistance == 0 ? "——" : $"+{summary.CurrentTotalDistance.ToString("#0.0")}";
|
||||
todayData.Find("Datas/Carlories/Rank").GetComponent<Text>().text = summary.CurrentTotalKcal == 0 ? "——" : $"+{summary.CurrentTotalKcal.ToString("#0")}";
|
||||
#if UNITY_STANDALONE_WIN
|
||||
//todayData.Find("NickName").GetComponent<Text>().text = App.CurrentUser.Nickname;
|
||||
//todayData.Find("ID").GetComponent<Text>().text = $"ID:{App.CurrentUser.Id.ToString("000000")}";
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
async void GetSummary()
|
||||
{
|
||||
var res = await ConfigHelper.userApi.GetSummary();
|
||||
if (res.result)
|
||||
{
|
||||
//App.CurrentUser.Distance = res.data.TotalDistance;
|
||||
//App.CurrentUser.Climb = res.data.TotalClimb;
|
||||
//App.CurrentUser.Carlories = res.data.Kcal;
|
||||
SetCurrentUser(res.data);
|
||||
//Climb.text = $"{res.data.TotalClimb.ToString()}M";
|
||||
//Calories.text = $"{res.data.Kcal.ToString()}KCAL";
|
||||
//Calories.text = res.data.
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(gameObject, res.errMsg);
|
||||
}
|
||||
//var res = await NoAuthApi.GetCurrentUser();
|
||||
//if (res.result)
|
||||
//{
|
||||
// Global.CurrentUser = res.data;
|
||||
// SetCurrentUser();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Utils.showToast(gameObject, res.errMsg);
|
||||
//}
|
||||
}
|
||||
float maxt = 0f; //用于获取全服最值内容
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//maxt -= Time.deltaTime;
|
||||
//if (maxt <= 0)
|
||||
//{
|
||||
// GetMaxRanking();
|
||||
// maxt += 60f * 5;
|
||||
//}
|
||||
//if (maxdataTime > 0)
|
||||
//{
|
||||
// maxdataTime -= Time.deltaTime;
|
||||
//}
|
||||
//else if (maxdataTime < 0)
|
||||
//{
|
||||
// DORotateMaxData();
|
||||
// maxdataTime += 10f;
|
||||
//}
|
||||
}
|
||||
private async void GetMaxRanking()
|
||||
{
|
||||
var res = await ConfigHelper.mapApi.GetMaxRanking();
|
||||
if (res.result)
|
||||
{
|
||||
maxList = res.data;
|
||||
if (maxList.Count > 0)
|
||||
{
|
||||
maxdataTime = 3;
|
||||
maxdataIndex = 0;
|
||||
SetMessage(maxList[maxdataIndex++]);
|
||||
//Transform p = transform.Find("MaxRankingData/Power"),
|
||||
//d = transform.Find("MaxRankingData/Distance"),
|
||||
//c = transform.Find("MaxRankingData/Climb");
|
||||
//Utils.DisplayHead(p.Find("Avatar").GetComponent<RawImage>(), list[1].WxHeadImg);
|
||||
//Utils.DisplayHead(d.Find("Avatar").GetComponent<RawImage>(), list[0].WxHeadImg);
|
||||
//Utils.DisplayHead(c.Find("Avatar").GetComponent<RawImage>(), list[2].WxHeadImg);
|
||||
//p.Find("NickName").GetComponent<Text>().text = list[1].NickName;
|
||||
//d.Find("NickName").GetComponent<Text>().text = list[0].NickName;
|
||||
//c.Find("NickName").GetComponent<Text>().text = list[2].NickName;
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.Find("MaxRankingData").gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int maxdataIndex = 0;
|
||||
float maxdataTime = 0;
|
||||
private List<MapMaxRanking> maxList;
|
||||
|
||||
private void DORotateMaxData()
|
||||
{
|
||||
var t = transform.Find("MaxRankingData");
|
||||
var se = DOTween.Sequence();
|
||||
var s1 = t.DORotate(new Vector3(-90, 0, 0), 0.5f);
|
||||
s1.onComplete = () =>
|
||||
{
|
||||
SetMessage(maxList[(maxdataIndex++) % maxList.Count]);
|
||||
};
|
||||
se.Append(s1);
|
||||
se.Append(t.DORotate(Vector3.zero, 0.5f));
|
||||
}
|
||||
void SetMessage(MapMaxRanking e)
|
||||
{
|
||||
var m = transform.Find("MaxRankingData");
|
||||
Utils.DisplayHead(m.transform.Find("Avatar").GetComponent<RawImage>(), e.WxHeadImg);
|
||||
m.transform.Find("Nickname").GetComponent<Text>().text = e.NickName;
|
||||
var txt = m.transform.Find("TextContainer/Content").GetComponent<RectTransform>();
|
||||
txt.GetComponent<Text>().text = e.Message;
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(txt);
|
||||
m.GetComponent<HomeMessageController>().Initial(txt.sizeDelta.x);
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
transform.MyDOFade();
|
||||
GetSummary();
|
||||
#if UNITY_STANDALONE_WIN
|
||||
//GetNotify();
|
||||
#endif
|
||||
//transform.Find("Panel (1)").GetComponent<test>().startPage();
|
||||
}
|
||||
|
||||
private async Task GetNotify()
|
||||
{
|
||||
var r = await ConfigHelper.userApi.GetNotify();
|
||||
if (r.result)
|
||||
{
|
||||
var lm = transform.Find("LongMessage");
|
||||
if (r.data.Value<int>("Id") > 1)
|
||||
{
|
||||
lm.gameObject.SetActive(true);
|
||||
lm.GetComponent<LongMessageScript>().Initial(r.data["Content"].ToString().Replace("\r\n"," "));
|
||||
}
|
||||
else
|
||||
{
|
||||
lm.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6e427bcdfce6c747a8ffae9688f1583
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b68882e4f82116149b50cdcd42bb2e5e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,89 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.Prefab.Player
|
||||
{
|
||||
public abstract class AbstractEquipmentScript : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler, IPointerUpHandler
|
||||
{
|
||||
public Image Content;//装备图片
|
||||
public GameObject bglock;
|
||||
public GameObject bglockLight;//选中样式
|
||||
public GameObject Click;//选中勾选
|
||||
public GameObject lockGrey;//灰色的锁定
|
||||
public GameObject lockLight;//白色的锁定 选中时使用
|
||||
public Text Title;
|
||||
public Text Desc;
|
||||
|
||||
protected int Id { get; set; }
|
||||
protected string Name { get; set; }
|
||||
protected string Remark { get; set; }
|
||||
|
||||
protected string URL { get; set; }
|
||||
protected bool IsLock { get; set; }
|
||||
protected virtual void Start()
|
||||
{
|
||||
var btn = GetComponent<Button>();
|
||||
btn.onClick.AddListener(() =>
|
||||
{
|
||||
Select();
|
||||
});
|
||||
}
|
||||
public virtual void Init(int id, string name, string remark, string url, bool isLock)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
Remark = remark;
|
||||
IsLock = isLock;
|
||||
URL = url;
|
||||
Utils.DisplayImage(Content, url);
|
||||
}
|
||||
|
||||
public virtual void Select()
|
||||
{
|
||||
UnSelectAll();
|
||||
bglockLight.SetActive(true);
|
||||
if (lockGrey != null && lockLight != null)
|
||||
{
|
||||
lockLight.SetActive(IsLock);
|
||||
lockGrey.SetActive(false);
|
||||
}
|
||||
Title.text = Name;
|
||||
Desc.text = Remark;
|
||||
}
|
||||
|
||||
public virtual void UnSelect()
|
||||
{
|
||||
bglockLight.SetActive(false);
|
||||
if (lockGrey != null && lockLight != null)
|
||||
{
|
||||
lockGrey.SetActive(IsLock);
|
||||
lockLight.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void UnSelectAll()
|
||||
{
|
||||
var list = FindObjectsOfType<AbstractEquipmentScript>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.UnSelect();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
Cursor.SetCursor(Resources.Load<Texture2D>("Images/PointerButtonHover"), Vector2.zero, CursorMode.Auto);
|
||||
}
|
||||
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81da3ad384a6846459d84bd58925d0ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.Prefab.Player
|
||||
{
|
||||
public class HelmetCardScript : AbstractEquipmentScript
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b43f05d0792ff6749a81a69b0cabdda4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.Prefab.Player
|
||||
{
|
||||
public class SkinCardScript : AbstractEquipmentScript
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00e2ed46366547b449f316f20524f2bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.Prefab.Player
|
||||
{
|
||||
public class SuitCardScript : AbstractEquipmentScript
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ad006bec4fe71b42838dc07592fcb99
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.Prefab.Player
|
||||
{
|
||||
public class UniformCardScript : AbstractEquipmentScript
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ac75d1b22152d54c94bf747ca64c677
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user