划船机实时保存
This commit is contained in:
parent
95df03e540
commit
2524e3a004
@ -117,6 +117,7 @@ public class RowerHomeScript : PFUIPanel
|
||||
}
|
||||
protected override void Awake()
|
||||
{
|
||||
Id = Guid.NewGuid().ToString();
|
||||
rowerType = new RowerType();
|
||||
spriteDict = new Dictionary<object, Sprite>()
|
||||
{
|
||||
@ -335,6 +336,7 @@ public class RowerHomeScript : PFUIPanel
|
||||
//Debug.Log("140,开始扫描");
|
||||
//App.MainDeviceAdapter.StartScan();
|
||||
Init();
|
||||
CheckLocalData();
|
||||
//transform.Find("Left/Rower").GetComponent<RowerAnimation>().StartAnimation();
|
||||
}
|
||||
void Disconnect()
|
||||
@ -387,11 +389,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;
|
||||
@ -436,6 +439,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
|
||||
{
|
||||
@ -465,7 +479,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;
|
||||
@ -833,7 +847,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)
|
||||
{
|
||||
@ -940,6 +1007,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
|
||||
@ -958,6 +1026,7 @@ public class RowerHomeScript : PFUIPanel
|
||||
if (openTimer && timer <= 0)
|
||||
{
|
||||
TimerTicks();
|
||||
ticks++;
|
||||
timer = 1f + timer;
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,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)
|
||||
@ -1175,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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user