start开发完成
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Stary.Evo;
|
||||
@@ -9,26 +7,50 @@ public interface IGlobalConfigSystem : ISystem
|
||||
{
|
||||
public string GetConnectionId();
|
||||
public void SetConnectionId(string connectionId);
|
||||
|
||||
|
||||
public string GetConnectionName();
|
||||
public void SetConnectionName(string connectionName);
|
||||
|
||||
|
||||
public UniTaskVoid StartConnectionTime();
|
||||
public string GetConnectionTime();
|
||||
|
||||
|
||||
public void StopConnectionTime();
|
||||
|
||||
|
||||
public int GetConnectionTimeType();
|
||||
public void SetConnectionTimeType(int connectionTimeType);
|
||||
|
||||
public Texture2D GetConnectionTexture();
|
||||
public void SetConnectionTexture(Texture2D connectionTexture);
|
||||
}
|
||||
|
||||
public class GlobalConfigSystem : AbstractSystem, IGlobalConfigSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// 连接ID
|
||||
/// </summary>
|
||||
private string _connectionId;
|
||||
|
||||
/// <summary>
|
||||
/// 连接名称
|
||||
/// </summary>
|
||||
private string _connectionName;
|
||||
|
||||
/// <summary>
|
||||
/// 连接图标
|
||||
/// </summary>
|
||||
private Texture2D _connectionTexture;
|
||||
|
||||
/// <summary>
|
||||
/// 连接时间
|
||||
/// </summary>
|
||||
private float _connectionTime;
|
||||
|
||||
/// <summary>
|
||||
/// 连接时间类型
|
||||
/// </summary>
|
||||
private int _connectionTimeType;
|
||||
|
||||
private CancellationTokenSource _cts;
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public override void Dispose()
|
||||
@@ -74,17 +96,17 @@ public class GlobalConfigSystem : AbstractSystem, IGlobalConfigSystem
|
||||
_connectionTime = 0;
|
||||
while (!_cts.IsCancellationRequested)
|
||||
{
|
||||
_connectionTime+=Time.deltaTime;
|
||||
_connectionTime += Time.deltaTime;
|
||||
await UniTask.Yield(_cts.Token); // 等一帧,等价于 Update
|
||||
}
|
||||
}
|
||||
|
||||
public string GetConnectionTime()
|
||||
{
|
||||
int totalSeconds = (int)_connectionTime;
|
||||
int hours = totalSeconds / 3600;
|
||||
int minutes = totalSeconds % 3600 / 60;
|
||||
int seconds = totalSeconds % 60;
|
||||
var totalSeconds = (int)_connectionTime;
|
||||
var hours = totalSeconds / 3600;
|
||||
var minutes = totalSeconds % 3600 / 60;
|
||||
var seconds = totalSeconds % 60;
|
||||
return $"{hours:D2}:{minutes:D2}:{seconds:D2}";
|
||||
}
|
||||
|
||||
@@ -94,4 +116,34 @@ public class GlobalConfigSystem : AbstractSystem, IGlobalConfigSystem
|
||||
_cts?.Dispose();
|
||||
_cts = null;
|
||||
}
|
||||
|
||||
public int GetConnectionTimeType()
|
||||
{
|
||||
return _connectionTimeType;
|
||||
}
|
||||
|
||||
public void SetConnectionTimeType(int connectionTimeType)
|
||||
{
|
||||
_connectionTimeType = connectionTimeType;
|
||||
}
|
||||
|
||||
public Texture2D GetConnectionTexture()
|
||||
{
|
||||
if (_connectionTexture == null)
|
||||
{
|
||||
Debug.LogWarning("GlobalConfigSystem: GetConnectionTexture not set");
|
||||
return null;
|
||||
}
|
||||
|
||||
return _connectionTexture;
|
||||
}
|
||||
|
||||
public void SetConnectionTexture(Texture2D connectionTexture)
|
||||
{
|
||||
_connectionTexture = connectionTexture;
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user