音效&骑行loading优化

This commit is contained in:
lishuo committed 2021-12-16 16:53:38 +08:00
1 parent 40ac7e1397
commit b9d14a590c
11 files changed
+1264 -1207

No files matched your search

@@ -57,7 +57,7 @@ namespace Assets.Scenes.Ride.Scripts
return;
}
if (targetAlpha != canvasGroup.alpha && depressFlag)
if (targetAlpha != canvasGroup.alpha && depressFlag && slider.value >= 100)
{
canvasGroup.alpha = Mathf.Lerp(canvasGroup.alpha, targetAlpha, alphaSpeed * Time.deltaTime);
if (Mathf.Abs(targetAlpha - canvasGroup.alpha) <= 0.01f)
@@ -66,6 +66,7 @@ namespace Assets.Scenes.Ride.Scripts
}
if (canvasGroup.alpha == 0)
{
StartGame();
transform.gameObject.SetActive(false);
}
}
@@ -108,12 +109,16 @@ namespace Assets.Scenes.Ride.Scripts
_map.OnInitialized += _map_OnInitialized;
canvasGroup = transform.GetComponent<CanvasGroup>();
rideNow.interactable = false;
//rideNow.interactable = false;
//rideNow.enabled = false;
UIManager.AddEvent(rideNow.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, StartRide);
UIManager.AddEvent(cancel.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, Cancel);
slider.onValueChanged.AddListener((f) =>
{
processText.text = $"{(f).ToString("#0")}%";
});
}
}
//加载数据
protected virtual void InitGameObjectData()
{
@@ -155,25 +160,30 @@ namespace Assets.Scenes.Ride.Scripts
//设定当前loading进度
public virtual void AddProcess(float v)
{
process += v;
slider.value = process;
slider.onValueChanged.AddListener((f) =>
{
processText.text = $"{(f).ToString("#0")}%";
});
if (process >= 100)
return;
process += v;
if (depressFlag)
{
rideNow.interactable = true;
//rideNow.enabled = true;
slider.DOKill();
slider.DOValue(process, 0.5f);
}
}
}
protected string GetMaxString(string value, int length)
{
var s = Helper.SubStr(value, length);
return s;
}
private void StartGame()
{
Debug.Log("StartGame");
cyclingController.InitTcp();
MapUDPService.SendGizpModel();
cyclingController.ReSetUIManager();
cyclingController.GoContinueRide();
}
protected virtual void StartRide(BaseEventData baseEvent)
{
if (!rideNow.IsInteractable())
@@ -181,31 +191,10 @@ namespace Assets.Scenes.Ride.Scripts
rideNow.interactable = false;
processText.gameObject.SetActive(true);
slider.gameObject.SetActive(true);
var preValue = slider.value;
slider.value = 0;
slider.DOValue(preValue, 2).onComplete+=()=> {
cyclingController.InitTcp();
MapUDPService.SendGizpModel();
cyclingController.ReSetUIManager();
cyclingController.GoContinueRide();
//启用ridenow
canvasGroup.blocksRaycasts = false;
depressFlag = true;
};
//var checkAnt = cyclingController.CheckAnt();
//#if UNITY_EDITOR
// checkAnt = true;
//#endif
// if (!checkAnt && !cyclingController.isWatch)
// {
//#if UNITY_IOS || UNITY_ANDROID
// var alert = (GameObject)Instantiate(Resources.Load("UI/Prefab/Ride/Mobile/Alert"), panel.transform);
//#else
// var alert = (GameObject)Instantiate(Resources.Load("UI/Prefab/Ride/Alert"), panel.transform);
//#endif
// alert.SetActive(true);
// }
// else
canvasGroup.blocksRaycasts = false;
depressFlag = true;
slider.DOValue(process, 1);
}
protected virtual void Cancel(BaseEventData baseEvent)
{
@@ -224,6 +213,7 @@ namespace Assets.Scenes.Ride.Scripts
if (s == ModuleState.Finished)
{
AddProcess(40);
Debug.Log($"add 40");
}
};
}
@@ -366,8 +366,9 @@ public class CyclingController : DeviceServiceMonoBase
{
case 1:
{
UnityEngine.Debug.Log($"{Input.touches[0]}{Input.touches[0].phase }");
//单击切换极简模式
if (Input.touches[0].tapCount==1 && isStart && singleUIManager.clearLock && competitionId == 0)
if (Input.touches[0].tapCount==1 && Input.touches[0].phase == TouchPhase.Moved && isStart && singleUIManager.clearLock && competitionId == 0)
{
if (IsPointerOverGameObject(Input.mousePosition))
{
@@ -673,7 +674,7 @@ public class CyclingController : DeviceServiceMonoBase
private IEnumerator MoveCamera(Vector3 prePos, Vector3 nextPos)
{
float t = 0;
while (t < 0.5f)
while (t < 0.37f)
{
t += Time.deltaTime;
Vector3 v = Vector3.Lerp(prePos, nextPos, t);