graph优化
# Conflicts: # Assets/Scripts/UI/Prefab/Panel/RowerHomeScript.cs
This commit is contained in:
parent
bfc56dded5
commit
b236e939f4
@ -7,7 +7,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace ChartAndGraph
|
namespace ChartAndGraph
|
||||||
{
|
{
|
||||||
[Serializable ]
|
[Serializable]
|
||||||
public struct DoubleVector2
|
public struct DoubleVector2
|
||||||
{
|
{
|
||||||
public double x, y;
|
public double x, y;
|
||||||
|
|||||||
@ -89,6 +89,8 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
}
|
}
|
||||||
GameObject btnStart;
|
GameObject btnStart;
|
||||||
Transform left, bottom, mid,rmydata;
|
Transform left, bottom, mid,rmydata;
|
||||||
|
Image leftImage;
|
||||||
|
Image rightImage;
|
||||||
float timer = 1.0f;
|
float timer = 1.0f;
|
||||||
List<DoubleVector2> pullList, historyPullList;
|
List<DoubleVector2> pullList, historyPullList;
|
||||||
public Dictionary<object, Sprite> spriteDict,spriteDict2;
|
public Dictionary<object, Sprite> spriteDict,spriteDict2;
|
||||||
@ -617,8 +619,10 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
btnStart.tag = "Start";
|
btnStart.tag = "Start";
|
||||||
btnStart.GetComponent<Image>().sprite = spriteDict["Start"];
|
btnStart.GetComponent<Image>().sprite = spriteDict["Start"];
|
||||||
left.Find("Rower").GetComponent<Image>().sprite = spriteDict[0];
|
left.Find("Rower").GetComponent<Image>().sprite = spriteDict[0];
|
||||||
left.Find("LeftImage/Value").GetComponent<Image>().fillAmount = 0;
|
leftImage = left.Find("LeftImage/Value").GetComponent<Image>();
|
||||||
left.Find("RightImage/Value").GetComponent<Image>().fillAmount = 0;
|
rightImage = left.Find("RightImage/Value").GetComponent<Image>();
|
||||||
|
leftImage.fillAmount = 0;
|
||||||
|
rightImage.fillAmount = 0;
|
||||||
TimesText.text = "---";
|
TimesText.text = "---";
|
||||||
Caloriestext.text = "---";
|
Caloriestext.text = "---";
|
||||||
rmyCaloriestext.text = "---";
|
rmyCaloriestext.text = "---";
|
||||||
@ -996,6 +1000,7 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
{
|
{
|
||||||
Helper.DelectDir(dir);
|
Helper.DelectDir(dir);
|
||||||
UIManager.CloseConfirm();
|
UIManager.CloseConfirm();
|
||||||
|
Init();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1051,6 +1056,7 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
{
|
{
|
||||||
Helper.DelectDir(dir);
|
Helper.DelectDir(dir);
|
||||||
UIManager.CloseConfirm();
|
UIManager.CloseConfirm();
|
||||||
|
Init();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1106,15 +1112,10 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
PaintPullCurve(ftms.PullValue);
|
PaintPullCurve(ftms.PullValue);
|
||||||
}
|
}
|
||||||
bool isPlay = false;
|
bool isPlay = false;
|
||||||
float preTime = 0f;
|
int pointCount = 0;
|
||||||
float curTime = 0f;
|
|
||||||
void PaintPullCurve(ushort y)
|
void PaintPullCurve(ushort y)
|
||||||
{
|
{
|
||||||
//if (y!=0 && curTime-preTime < 0.1f)
|
|
||||||
//{
|
|
||||||
// return;
|
|
||||||
//}
|
|
||||||
preTime = curTime;
|
|
||||||
Debug.Log("收到拉力" + y + ","+ DateTime.Now.Ticks);
|
Debug.Log("收到拉力" + y + ","+ DateTime.Now.Ticks);
|
||||||
//#if !UNITY_EDITOR
|
//#if !UNITY_EDITOR
|
||||||
// if (!openTimer)
|
// if (!openTimer)
|
||||||
@ -1131,30 +1132,43 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
//#endif
|
//#endif
|
||||||
//if (y > 1200) y = 1200;
|
//if (y > 1200) y = 1200;
|
||||||
//拉力条
|
//拉力条
|
||||||
|
|
||||||
var rate = ((float)y) * 2 / 120;
|
var rate = ((float)y) * 2 / 120;
|
||||||
if (rate > 1) rate = 1f;
|
if (rate > 1) rate = 1f;
|
||||||
left.Find("LeftImage/Value").GetComponent<Image>().fillAmount = rate;
|
leftImage.fillAmount = rate;
|
||||||
left.Find("RightImage/Value").GetComponent<Image>().fillAmount = rate;
|
rightImage.fillAmount = rate;
|
||||||
|
|
||||||
//动画
|
//动画
|
||||||
//left.Find("Rower").GetComponent<Image>().sprite = spriteDict[y / 67];
|
//left.Find("Rower").GetComponent<Image>().sprite = spriteDict[y / 67];
|
||||||
//曲线
|
//曲线
|
||||||
if (y == 0)
|
if (y == 0)
|
||||||
{
|
{
|
||||||
if (pullList.Count == 0)
|
//if (pullList.Count == 0)
|
||||||
|
if(pointCount == 0)
|
||||||
{
|
{
|
||||||
isPlay = true;
|
isPlay = true;
|
||||||
x = 0.1;
|
x = 0.1;
|
||||||
|
pointCount++;
|
||||||
pullList.Add(new DoubleVector2(x, y));
|
pullList.Add(new DoubleVector2(x, y));
|
||||||
SetChartData(pullList, historyPullList);
|
//SetChartData(pullList, historyPullList);
|
||||||
|
ClearChart();
|
||||||
|
SetChartData(x, y);
|
||||||
}
|
}
|
||||||
else if (pullList.Count > 1)
|
//else if (pullList.Count > 1)
|
||||||
|
else if(pointCount > 1)
|
||||||
{
|
{
|
||||||
x += 0.1;
|
x += 0.1;
|
||||||
|
pointCount++;
|
||||||
pullList.Add(new DoubleVector2(x, y));
|
pullList.Add(new DoubleVector2(x, y));
|
||||||
SetChartData(pullList, historyPullList);
|
SetChartData(x, y);
|
||||||
|
//SetChartData(pullList, historyPullList);
|
||||||
historyPullList = pullList.Select(x => x).ToList();
|
historyPullList = pullList.Select(x => x).ToList();
|
||||||
pullList.Clear();
|
pullList.Clear();
|
||||||
|
pointCount = 0;
|
||||||
|
//ClearChart();
|
||||||
x = 0.1;
|
x = 0.1;
|
||||||
|
SetChartData(x, y);
|
||||||
|
pointCount = 1;
|
||||||
isPlay = true;
|
isPlay = true;
|
||||||
pullList.Add(new DoubleVector2(x, y));
|
pullList.Add(new DoubleVector2(x, y));
|
||||||
}
|
}
|
||||||
@ -1163,21 +1177,25 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
//只有0并且两秒没拉,曲线消失
|
//只有0并且两秒没拉,曲线消失
|
||||||
if (stopSeconds == 1)
|
if (stopSeconds == 1)
|
||||||
{
|
{
|
||||||
SetChartData(new List<DoubleVector2>(), new List<DoubleVector2>());
|
ClearChart();
|
||||||
|
//SetChartData(new List<DoubleVector2>(), new List<DoubleVector2>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
x += 0.1;
|
x += 0.1;
|
||||||
|
pointCount++;
|
||||||
pullList.Add(new DoubleVector2(x, y));
|
pullList.Add(new DoubleVector2(x, y));
|
||||||
if (pullList.Count > 5 && isPlay)
|
//if (pullList.Count > 5 && isPlay)
|
||||||
|
if (pointCount > 5 && isPlay)
|
||||||
{
|
{
|
||||||
Debug.Log("开始动画");
|
Debug.Log("开始动画");
|
||||||
isPlay = false;
|
isPlay = false;
|
||||||
//left.Find("Rower").GetComponent<RowerAnimation>().StartAnimation();
|
//left.Find("Rower").GetComponent<RowerAnimation>().StartAnimation();
|
||||||
}
|
}
|
||||||
SetChartData(pullList, historyPullList);
|
//SetChartData(pullList, historyPullList);
|
||||||
|
SetChartData(x, y);
|
||||||
}
|
}
|
||||||
//Debug.Log($"{x},{y}");
|
//Debug.Log($"{x},{y}");
|
||||||
//transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
|
//transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
|
||||||
@ -1192,8 +1210,28 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
// x += 0.1f;
|
// x += 0.1f;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
void ClearChart()
|
||||||
|
{
|
||||||
|
rowerGraphChartFeed.ClearChart();
|
||||||
|
graphChartFeed.ClearChart();
|
||||||
|
}
|
||||||
|
double preX, preY;
|
||||||
|
void SetChartData(double x, double y)
|
||||||
|
{
|
||||||
|
if (M1.localPosition.x == 0)
|
||||||
|
{
|
||||||
|
rowerGraphChartFeed.SetCurrentPoint(x, y);
|
||||||
|
rowerGraphChartFeed.SetHistoryData(historyPullList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
graphChartFeed.SetCurrentPoint(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
void SetChartData(List<DoubleVector2> v1, List<DoubleVector2> v2)
|
void SetChartData(List<DoubleVector2> v1, List<DoubleVector2> v2)
|
||||||
{
|
{
|
||||||
|
//graph.DataSource.AddPointToCategoryRealtime("Player 2", item.x, item.y);
|
||||||
if (M1.localPosition.x == 0)
|
if (M1.localPosition.x == 0)
|
||||||
{
|
{
|
||||||
rowerGraphChartFeed.SetData(v1, v2);
|
rowerGraphChartFeed.SetData(v1, v2);
|
||||||
@ -1208,7 +1246,6 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
int ticks { get; set; } = 0;
|
int ticks { get; set; } = 0;
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
curTime += Time.deltaTime;
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (openTimer || true)
|
if (openTimer || true)
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -7,10 +7,12 @@ using System.Collections.Generic;
|
|||||||
public class RowerGraphChartFeed : MonoBehaviour
|
public class RowerGraphChartFeed : MonoBehaviour
|
||||||
{
|
{
|
||||||
GraphChartBase graph { get; set; }
|
GraphChartBase graph { get; set; }
|
||||||
|
GraphData dataSource { get; set; }
|
||||||
|
|
||||||
void Start ()
|
void Start ()
|
||||||
{
|
{
|
||||||
graph = GetComponent<GraphChartBase>();
|
graph = GetComponent<GraphChartBase>();
|
||||||
|
dataSource = graph.DataSource;
|
||||||
//GraphChartBase graph = GetComponent<GraphChartBase>();
|
//GraphChartBase graph = GetComponent<GraphChartBase>();
|
||||||
//if (graph != null)
|
//if (graph != null)
|
||||||
//{
|
//{
|
||||||
@ -34,6 +36,31 @@ public class RowerGraphChartFeed : MonoBehaviour
|
|||||||
//}
|
//}
|
||||||
// StartCoroutine(ClearAll());
|
// StartCoroutine(ClearAll());
|
||||||
}
|
}
|
||||||
|
public void SetPrePoint(double x, double y)
|
||||||
|
{
|
||||||
|
dataSource?.AddPointToCategoryRealtime("Player 1", x, y);
|
||||||
|
}
|
||||||
|
public void SetCurrentPoint(double x,double y)
|
||||||
|
{
|
||||||
|
dataSource?.AddPointToCategoryRealtime("Player 2", x, y);
|
||||||
|
}
|
||||||
|
public void ClearChart(string cat = "Player 2")
|
||||||
|
{
|
||||||
|
dataSource?.ClearCategory(cat);
|
||||||
|
}
|
||||||
|
public void SetHistoryData(List<DoubleVector2> list2 = null)
|
||||||
|
{
|
||||||
|
if (list2 != null)
|
||||||
|
{
|
||||||
|
dataSource?.ClearCategory("Player 1");
|
||||||
|
for (int i = 0; i < list2.Count; i++)
|
||||||
|
{
|
||||||
|
var item = list2[i];
|
||||||
|
graph.DataSource.AddPointToCategoryRealtime("Player 1", item.x, item.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetData(List<DoubleVector2> list,List<DoubleVector2> list2 = null)
|
public void SetData(List<DoubleVector2> list,List<DoubleVector2> list2 = null)
|
||||||
{
|
{
|
||||||
@ -42,10 +69,9 @@ public class RowerGraphChartFeed : MonoBehaviour
|
|||||||
graph.Scrollable = false;
|
graph.Scrollable = false;
|
||||||
//graph.HorizontalValueToStringMap[0.0] = "Zero"; // example of how to set custom axis strings
|
//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 1");
|
||||||
graph.DataSource.ClearCategory("Player 2");
|
//graph.DataSource.ClearCategory("Player 2");
|
||||||
graph.ClearCache();
|
//graph.ClearCache();
|
||||||
|
|
||||||
for (int i = 0; i < list.Count; i++)
|
for (int i = 0; i < list.Count; i++)
|
||||||
{
|
{
|
||||||
var item = list[i];
|
var item = list[i];
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
</packages>
|
</packages>
|
||||||
<files />
|
<files />
|
||||||
<settings>
|
<settings>
|
||||||
<setting name="androidAbis" value="arm64-v8a,armeabi-v7a" />
|
<setting name="androidAbis" value="armeabi-v7a" />
|
||||||
<setting name="bundleId" value="com.ZhiXingPai.PowerFunUnity" />
|
<setting name="bundleId" value="com.ZhiXingPai.PowerFunUnity" />
|
||||||
<setting name="explodeAars" value="True" />
|
<setting name="explodeAars" value="True" />
|
||||||
<setting name="gradleBuildEnabled" value="True" />
|
<setting name="gradleBuildEnabled" value="True" />
|
||||||
|
|||||||
@ -256,7 +256,7 @@ PlayerSettings:
|
|||||||
clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea
|
clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea
|
||||||
templatePackageId: com.unity.template.3d@4.2.8
|
templatePackageId: com.unity.template.3d@4.2.8
|
||||||
templateDefaultScene: Assets/Scenes/SampleScene.unity
|
templateDefaultScene: Assets/Scenes/SampleScene.unity
|
||||||
AndroidTargetArchitectures: 3
|
AndroidTargetArchitectures: 1
|
||||||
AndroidSplashScreenScale: 0
|
AndroidSplashScreenScale: 0
|
||||||
androidSplashScreen: {fileID: 0}
|
androidSplashScreen: {fileID: 0}
|
||||||
AndroidKeystoreName: '{inproject}: Assets/Plugins/Android/powerfun.keystore'
|
AndroidKeystoreName: '{inproject}: Assets/Plugins/Android/powerfun.keystore'
|
||||||
@ -868,7 +868,7 @@ PlayerSettings:
|
|||||||
platformArchitecture:
|
platformArchitecture:
|
||||||
iPhone: 1
|
iPhone: 1
|
||||||
scriptingBackend:
|
scriptingBackend:
|
||||||
Android: 1
|
Android: 0
|
||||||
Standalone: 0
|
Standalone: 0
|
||||||
il2cppCompilerConfiguration:
|
il2cppCompilerConfiguration:
|
||||||
Standalone: 0
|
Standalone: 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user