124 lines
3.3 KiB
C#
124 lines
3.3 KiB
C#
using Games.GlobeDefine;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using GCGame.Table;
|
|
|
|
public class MeditateProgress : MonoBehaviour {
|
|
|
|
public static MeditateProgress Instance;
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
//Mesh重绘.父节点添加Canvas
|
|
public Text _DotDesc;
|
|
public Slider _ProgressSlider;
|
|
|
|
private const float _TotalCountTime = 5.0f; //每个进度条时间
|
|
private const int _AnimtionId = 42;
|
|
private void OnEnable()
|
|
{
|
|
ResetData();
|
|
}
|
|
|
|
public void OnPacket(RetSit packet)
|
|
{
|
|
if (packet.state == 1)
|
|
{
|
|
EnterMeditateState();
|
|
StartCoroutine(Progressing());
|
|
}
|
|
else
|
|
{
|
|
StopAllCoroutines();
|
|
if (Singleton<ObjManager>.Instance.MainPlayer
|
|
&& Singleton<ObjManager>.Instance.MainPlayer.CurObjAnimState != GameDefine_Globe.OBJ_ANIMSTATE.STATE_NORMOR)
|
|
{
|
|
Singleton<ObjManager>.Instance.MainPlayer.OnSwithObjAnimState(GameDefine_Globe.OBJ_ANIMSTATE.STATE_NORMOR);
|
|
}
|
|
OnClose();
|
|
}
|
|
}
|
|
|
|
public void EnterMeditateState()
|
|
{
|
|
var mainPlayer = Singleton<ObjManager>.Instance.MainPlayer;
|
|
if(mainPlayer)
|
|
{
|
|
mainPlayer.EnterMeditateState(GameManager.gameManager.PlayerDataPool.m_objMountParam.AdvanceMountId);
|
|
|
|
var fellow = mainPlayer.GetCurFellow();
|
|
if (fellow && fellow.CurObjAnimState != Games.GlobeDefine.GameDefine_Globe.OBJ_ANIMSTATE.STATE_NORMOR)
|
|
{
|
|
if (fellow.MoveModule != null)
|
|
fellow.MoveModule.EndMove();
|
|
fellow.OnSwithObjAnimState(Games.GlobeDefine.GameDefine_Globe.OBJ_ANIMSTATE.STATE_NORMOR);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
float _CountTime = 0.0f;
|
|
IEnumerator Progressing()
|
|
{
|
|
while(true)
|
|
{
|
|
yield return null;
|
|
_CountTime += (Time.deltaTime / _TotalCountTime);
|
|
SetDotDesc(_CountTime);
|
|
_ProgressSlider.value = Mathf.Clamp(_CountTime, 0, 1);
|
|
//if (_ProgressSlider.value >= 1.0f)
|
|
//{
|
|
// //ReqSitProcessFinish req = new ReqSitProcessFinish();
|
|
// //req.flag = 1;
|
|
// //req.SendMsg();
|
|
// ResetData();//服务器大爷要求
|
|
// //yield break;
|
|
//}
|
|
}
|
|
}
|
|
|
|
void ResetData()
|
|
{
|
|
_CountTime = 0.0f;
|
|
_ProgressSlider.value = 0;
|
|
}
|
|
|
|
public void ResetCoroutine()
|
|
{
|
|
_CountTime = 0.0f;
|
|
_ProgressSlider.value = 0;
|
|
StopAllCoroutines();
|
|
StartCoroutine(Progressing());
|
|
}
|
|
|
|
StringBuilder dotStr = new StringBuilder("......", 5);
|
|
void SetDotDesc(float _CountTime)
|
|
{
|
|
|
|
for (int index = 0; index < dotStr.Length; index++)
|
|
{
|
|
if (_CountTime < 1.0f / 5 * index)
|
|
{
|
|
if (!_DotDesc.text.Equals(dotStr.ToString(0, index)))
|
|
_DotDesc.text = dotStr.ToString(0, index);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void OnClose()
|
|
{
|
|
UIManager.CloseUI(UIInfo.MeditateProgress);
|
|
}
|
|
}
|