Merge remote-tracking branch 'origin/dev_ani3' into dev_cyp

# Conflicts:
#	Assets/Scripts/UI/Prefab/Panel/RowerHomeScript.cs
This commit is contained in:
CaiYanPeng 2022-05-31 16:51:37 +08:00
commit 167a424505
3 changed files with 100 additions and 22 deletions

View File

@ -117,6 +117,7 @@ public class RowerHomeScript : PFUIPanel
}
protected override void Awake()
{
Id = Guid.NewGuid().ToString();
rowerType = new RowerType() { type=1,value=500};
spriteDict = new Dictionary<object, Sprite>()
{
@ -342,6 +343,7 @@ public class RowerHomeScript : PFUIPanel
//Debug.Log("140,开始扫描");
//App.MainDeviceAdapter.StartScan();
Init();
CheckLocalData();
//transform.Find("Left/Rower").GetComponent<RowerAnimation>().StartAnimation();
}
void Disconnect()
@ -394,11 +396,12 @@ public class RowerHomeScript : PFUIPanel
f.Invoke();
}
}
private string Id { get; set; }
int truelyTime = 0;
private void StartFunc(object sender, EventArgs e)
{
if (openTimer) return;
Id = Guid.NewGuid().ToString();
if (transform.parent.parent.Find("ModalPanel/RowerWelldone(Clone)") && transform.parent.parent.Find("ModalPanel/RowerWelldone(Clone)").gameObject.activeInHierarchy)
{
return;
@ -443,6 +446,17 @@ public class RowerHomeScript : PFUIPanel
if (res.result)
{
UIManager.ShowRowerWelldone(model.Id, Init);
try
{
if (File.Exists(files[0]))
{
File.Delete(files[0]);
}
}
catch (Exception ex)
{
Debug.LogError(ex);
}
}
else
{
@ -472,7 +486,7 @@ public class RowerHomeScript : PFUIPanel
model.ManufacturerName = bleDevice.Name + " " + bleDevice.Network + " " + bleDevice.Sensor;
model.DeviceNumber = $"{ bleDevice.Address },{ bleDevice.Sensor }";
}
model.Id = Guid.NewGuid().ToString();
model.Id = Id;//Guid.NewGuid().ToString();
model.Weight = App.CurrentUser.Weight;
model.Kj = RowerData.TotalEnergy;
model.StartTime = startTime;
@ -838,7 +852,60 @@ public class RowerHomeScript : PFUIPanel
{
HandleSaveDirect();
}
//Debug.Log(1);
if (ticks % 5 == 0)
{
SaveRealTimes();//实时保存数据
}
}
//检查本地数据
private void CheckLocalData()
{
try
{
var files = Directory.GetFiles(PFConstants.RowerRecordFolder);
if (files.Length > 0)
{
UIManager.ShowConfirm(App.GetLocalString("Warn"), App.GetLocalString("continue a game?"), () =>
{
var str = File.ReadAllText(files[0]);
var list = str.Replace("\r\n", " ").Split(' ');
records.Clear();
foreach (var item in list)
{
if (!string.IsNullOrEmpty(item))
{
records.Add(item);
}
}
UIManager.CloseConfirm();
}, 2,
() =>
{
if (files.Length > 0)
{
File.Delete(files[0]);
}
UIManager.CloseConfirm();
});
}
}
catch (Exception e)
{
Debug.LogError(e);
}
}
//5s钟保存
private void SaveRealTimes()
{
try
{
var path = $"{PFConstants.RowerRecordFolder}/{Id}.txt";
File.WriteAllText(path, string.Join("\r\n", records));
}
catch (Exception e)
{
Debug.LogError(e);
}
}
void SendDataToRace(TempRowerCalc tmpdata)
{
@ -945,6 +1012,7 @@ public class RowerHomeScript : PFUIPanel
transform.Find("Rower/Modes/Scroll/M2/MyData/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(v1);
}
float staticTimer = 1f,shortTimer = 0.25f;
int ticks { get; set; } = 0;
void Update()
{
#if UNITY_EDITOR
@ -963,6 +1031,7 @@ public class RowerHomeScript : PFUIPanel
if (openTimer && timer <= 0)
{
TimerTicks();
ticks++;
timer = 1f + timer;
}
}

View File

@ -6,8 +6,11 @@ using System.Collections.Generic;
public class RowerGraphChartFeed : MonoBehaviour
{
void Start ()
GraphChartBase graph { get; set; }
void Start ()
{
graph = GetComponent<GraphChartBase>();
//GraphChartBase graph = GetComponent<GraphChartBase>();
//if (graph != null)
//{
@ -16,7 +19,7 @@ public class RowerGraphChartFeed : MonoBehaviour
// graph.DataSource.StartBatch();
// graph.DataSource.ClearCategory("Player 1");
// graph.DataSource.ClearAndMakeBezierCurve("Player 2");
// for (int i = 0; i <10000; i++)
// {
// graph.DataSource.AddPointToCategory("Player 1",i*5,Random.value*10f + 20f);
@ -29,23 +32,22 @@ public class RowerGraphChartFeed : MonoBehaviour
// graph.DataSource.MakeCurveCategorySmooth("Player 2");
// graph.DataSource.EndBatch();
//}
// StartCoroutine(ClearAll());
// StartCoroutine(ClearAll());
}
public void SetData(List<DoubleVector2> list,List<DoubleVector2> list2 = null)
{
GraphChartBase graph = GetComponent<GraphChartBase>();
if (graph != null)
{
graph.Scrollable = false;
//graph.HorizontalValueToStringMap[0.0] = "Zero"; // example of how to set custom axis strings
graph.DataSource.StartBatch();
//graph.DataSource.StartBatch();
graph.DataSource.ClearCategory("Player 1");
graph.DataSource.ClearCategory("Player 2");
for (int i = 0; i < list.Count; i++)
{
var item = list[i];
graph.DataSource.AddPointToCategory("Player 2", item.x, item.y);
graph.DataSource.AddPointToCategoryRealtime("Player 2", item.x, item.y);
//if (i == 0)
// graph.DataSource.SetCurveInitialPoint("Player 1", item.x, item.y);
//else
@ -56,11 +58,11 @@ public class RowerGraphChartFeed : MonoBehaviour
for (int i = 0; i < list2.Count; i++)
{
var item = list2[i];
graph.DataSource.AddPointToCategory("Player 1", item.x, item.y);
graph.DataSource.AddPointToCategoryRealtime("Player 1", item.x, item.y);
}
}
//graph.DataSource.MakeCurveCategorySmooth("Player 1");
graph.DataSource.EndBatch();
//graph.DataSource.EndBatch();
}
}
IEnumerator ClearAll()

View File

@ -43,9 +43,14 @@ public class RowerMultiModeScript : MonoBehaviour
}
List<Trace> traceList;
List<float> initialPosYList;
Sprite bg_myself { get; set; }
Sprite bg_other { get; set; }
Sprite img_overline_myself { get; set; }
Sprite img_overline_others { get; set; }
void Awake()
{
scroll = transform.Find("Rower/Modes/Scroll");
scroll = transform.Find("Rower/Modes/Scroll");
startPosition = scroll.localPosition;
@ -100,8 +105,13 @@ public class RowerMultiModeScript : MonoBehaviour
// m2.Find("Track/T5").localPosition.y,
//};
scrollRank = transform.Find("Rower/Modes/Scroll/M1/Rank/Scroll View").GetComponent<ScrollRect>();
var countryJson = Resources.Load<TextAsset>("UI/flags-mini").text;
countryList = JsonConvert.DeserializeObject<List<CountryModel>>(countryJson);
//var countryJson = Resources.Load<TextAsset>("UI/flags-mini").text;
//countryList = JsonConvert.DeserializeObject<List<CountryModel>>(countryJson);
//UIManager.Instance.loginRegOptions.GetCountryIndexByCode();
bg_myself = Resources.Load<Sprite>("Images/RowerNew/动画用/bg_myself");
bg_other = Resources.Load<Sprite>("Images/RowerNew/动画用/bg_other");
img_overline_myself = Resources.Load<Sprite>("Images/RowerNew/动画用/img_overline_myself");
img_overline_others = Resources.Load<Sprite>("Images/RowerNew/动画用/img_overline_others");
}
public void HandleTimeTick(RowerChartModel data)
@ -246,8 +256,8 @@ public class RowerMultiModeScript : MonoBehaviour
private void DisplayTrace(Transform t,TraceData data,TraceData mineData,bool isAni = false)
{
//增加新设计稿逻辑
t.Find("Left").GetComponent<Image>().sprite = data.isMine ? Resources.Load<Sprite>("Images/RowerNew/动画用/bg_myself") : Resources.Load<Sprite>("Images/RowerNew/动画用/bg_other");
t.Find("Main/Boat/Head").GetComponent<Image>().sprite = data.isMine ? Resources.Load<Sprite>("Images/RowerNew/动画用/img_overline_myself") : Resources.Load<Sprite>("Images/RowerNew/动画用/img_overline_others");
t.Find("Left").GetComponent<Image>().sprite = data.isMine ? bg_myself : bg_other;
t.Find("Main/Boat/Head").GetComponent<Image>().sprite = data.isMine ? img_overline_myself : img_overline_others;
t.Find("Main/Boat/Head").gameObject.SetActive(data.currentDistance > 0);
t.Find("Main/Rowed").GetComponent<Image>().color = data.isMine ? Utils.HexToColorHtml("#f9308699") : Utils.HexToColorHtml("#27dfe399");
t.GetComponent<Image>().color = data.isMine ? Utils.HexToColorHtml("#f930861a") : Utils.HexToColorHtml("#27dfe31a");
@ -261,11 +271,8 @@ public class RowerMultiModeScript : MonoBehaviour
{
Utils.DisplayImageTempDict(t.Find("Left/Avatar").GetComponent<RawImage>(), data.Avatar, caches);
}
var _c = countryList.SingleOrDefault(x => x.country == data.Country);
if (_c != null)
{
t.Find("Left/Avatar/Country").GetComponent<Image>().sprite = Resources.Load<Sprite>(_c.source);
}
t.Find("Left/Avatar/Country").GetComponent<Image>().ShowImageWithTexture(UIManager.Instance.loginRegOptions.GetCountryImage(data.Country));
t.Find("Left/NickName").GetComponent<Text>().text = data.NickName;
if (data.list.Count == 0 || !GetComponent<RowerHomeScript>().openTimer)
@ -1165,7 +1172,7 @@ public class RowerMultiModeScript : MonoBehaviour
//}
float timer = 1f;
int currentSecond = -1;
private List<CountryModel> countryList;
//private List<CountryModel> countryList;
public RowerTaskPanel.RowerType rowerType { get; set; }
int _testdis = 0;