250 lines
7.0 KiB
C#
250 lines
7.0 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using GCGame;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Module.Log;
|
|||
|
using Games.LogicObj;
|
|||
|
using Games.GlobeDefine;
|
|||
|
using GCGame.Table;
|
|||
|
using Games.UserCommonData;
|
|||
|
using Games.Events;
|
|||
|
using Games.Mission;
|
|||
|
|
|||
|
public class CenterTipsLogic : UIControllerBase<CenterTipsLogic>
|
|||
|
{
|
|||
|
public GameObject _CompleteMissionImage; // 任务完成
|
|||
|
public GameObject levelUpTip; // 等级提升
|
|||
|
public GameObject equipEnhanceTip; // 装备强化提示
|
|||
|
public GameObject equipFrenzy; // 装备狂化
|
|||
|
public enum ShowInfoType
|
|||
|
{
|
|||
|
|
|||
|
MissionComplete,
|
|||
|
LevelUp,
|
|||
|
EquipEnhance,
|
|||
|
EquipFrenzy,
|
|||
|
Invalid,
|
|||
|
}
|
|||
|
|
|||
|
private ShowInfoType curShowType = ShowInfoType.Invalid;
|
|||
|
|
|||
|
// 关于任务完成的特效较长,当存在其他消息在队列时需要特殊处理
|
|||
|
// 当后面有消息,缩短显示时间
|
|||
|
// 当后面没消息,按正常时间显示
|
|||
|
private float shortTime_Mission = 1.0f; // 短时间显示
|
|||
|
private float longTime_Mission = 2.5f; // 长时间显示
|
|||
|
|
|||
|
private float missionHasShowTime = 0.0f; // 记录任务特效一播放时间
|
|||
|
|
|||
|
private Queue<ShowInfoType> showQueue = new Queue<ShowInfoType>();
|
|||
|
|
|||
|
public void EnShowQueue(ShowInfoType showType)
|
|||
|
{
|
|||
|
if(showQueue.Contains(showType))
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if(showQueue.Count == 0)
|
|||
|
{
|
|||
|
showQueue.Enqueue(showType);
|
|||
|
switch (showType)
|
|||
|
{
|
|||
|
case ShowInfoType.LevelUp:
|
|||
|
ShowLevelUp();
|
|||
|
break;
|
|||
|
case ShowInfoType.MissionComplete:
|
|||
|
ShowMissionComplete();
|
|||
|
break;
|
|||
|
case ShowInfoType.EquipEnhance:
|
|||
|
ShowEnhanceTip();
|
|||
|
break;
|
|||
|
case ShowInfoType.EquipFrenzy:
|
|||
|
ShowEnhanceFrenzyTip();
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
curShowType = showType;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
showQueue.Enqueue(showType);
|
|||
|
if(curShowType == ShowInfoType.MissionComplete)
|
|||
|
{
|
|||
|
float remainTime = shortTime_Mission - missionHasShowTime;
|
|||
|
StopAllCoroutines();
|
|||
|
|
|||
|
StartCoroutine(FinishOne(ShowInfoType.MissionComplete, remainTime));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void Dequeue()
|
|||
|
{
|
|||
|
showQueue.Dequeue();
|
|||
|
curShowType = ShowInfoType.Invalid;
|
|||
|
|
|||
|
if(showQueue.Count > 0)
|
|||
|
{
|
|||
|
ShowInfoType needShow = showQueue.Peek();
|
|||
|
switch(needShow)
|
|||
|
{
|
|||
|
case ShowInfoType.LevelUp:
|
|||
|
ShowLevelUp();
|
|||
|
break;
|
|||
|
case ShowInfoType.MissionComplete:
|
|||
|
ShowMissionComplete();
|
|||
|
break;
|
|||
|
case ShowInfoType.EquipEnhance:
|
|||
|
ShowEnhanceTip();
|
|||
|
break;
|
|||
|
case ShowInfoType.EquipFrenzy:
|
|||
|
ShowEnhanceFrenzyTip();
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
curShowType = needShow;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected override void Init()
|
|||
|
{
|
|||
|
base.Init();
|
|||
|
SetInstance(this);
|
|||
|
OnAutoMoveStateChange();
|
|||
|
//注册任务完成显示Image事件
|
|||
|
MissionManager.m_completeMission += ShowCompleteImage;
|
|||
|
|
|||
|
// 开启新手指引
|
|||
|
//UIManager.ShowUI(UIInfo.GuideRoot);
|
|||
|
}
|
|||
|
|
|||
|
public void ShowEnhanceTip()
|
|||
|
{
|
|||
|
equipEnhanceTip.gameObject.SetActive(true);
|
|||
|
|
|||
|
StartCoroutine(FinishOne(ShowInfoType.EquipEnhance, 2.0f));
|
|||
|
}
|
|||
|
|
|||
|
public void ShowEnhanceFrenzyTip()
|
|||
|
{
|
|||
|
equipFrenzy.gameObject.SetActive(true);
|
|||
|
StartCoroutine(FinishOne(ShowInfoType.EquipFrenzy, 2.0f));
|
|||
|
}
|
|||
|
|
|||
|
public void OnDisable()
|
|||
|
{
|
|||
|
MissionManager.m_completeMission -= ShowCompleteImage;
|
|||
|
}
|
|||
|
|
|||
|
//public GameObject m_AutoCombatImage;
|
|||
|
//public void OnAutoCombatStateChange()
|
|||
|
//{
|
|||
|
// if (m_AutoMoveImage != null)
|
|||
|
// {
|
|||
|
// //m_AutoCombatImage.SetActive(GameManager.gameManager.PlayerDataPool.IsOpenAutoCombat);
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
public GameObject m_AutoMoveImage;
|
|||
|
public void OnAutoMoveStateChange()
|
|||
|
{
|
|||
|
if (m_AutoMoveImage != null)
|
|||
|
{
|
|||
|
m_AutoMoveImage.SetActive(GameManager.gameManager.AutoSearch.IsAutoSearching);
|
|||
|
if (GameManager.gameManager.PlayerDataPool.AutoComabat)
|
|||
|
{
|
|||
|
m_AutoMoveImage.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void OnBtnAutoFly()
|
|||
|
{
|
|||
|
var searchPoint = GameManager.gameManager.AutoSearch.EndPointCache;
|
|||
|
searchPoint.ChangeMapType = AutoSearchPoint.ChangeMap_Type.MISSIONFLY;
|
|||
|
GameManager.gameManager.AutoSearch.BuildPath(searchPoint, GameManager.gameManager.AutoSearch._IsNetAsk, GameManager.gameManager.AutoSearch.Path.AutoSearchTargetName, GameManager.gameManager.AutoSearch.Path.autoSearchRadius);
|
|||
|
}
|
|||
|
|
|||
|
#region mission
|
|||
|
|
|||
|
public void ShowCompleteImage(string value)
|
|||
|
{
|
|||
|
EnShowQueue(ShowInfoType.MissionComplete);
|
|||
|
}
|
|||
|
|
|||
|
private void ShowMissionComplete()
|
|||
|
{
|
|||
|
_CompleteMissionImage.SetActive(true);
|
|||
|
|
|||
|
// 如果任务后面还有其他消息,加快关闭时间
|
|||
|
if (showQueue.Count > 1)
|
|||
|
{
|
|||
|
StartCoroutine(FinishOne(ShowInfoType.MissionComplete, shortTime_Mission));
|
|||
|
}
|
|||
|
// 如果任务无消息,降低关闭速度
|
|||
|
else
|
|||
|
{
|
|||
|
StartCoroutine(FinishOne(ShowInfoType.MissionComplete, longTime_Mission));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Level up
|
|||
|
|
|||
|
public UIImgText imgText;
|
|||
|
|
|||
|
private void ShowLevelUp()
|
|||
|
{
|
|||
|
if(Singleton<ObjManager>.GetInstance().MainPlayer != null)
|
|||
|
{
|
|||
|
Singleton<ObjManager>.GetInstance().MainPlayer.PlayEffect(52);
|
|||
|
}
|
|||
|
|
|||
|
levelUpTip.SetActive(true);
|
|||
|
imgText.text = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level.ToString();
|
|||
|
StartCoroutine(FinishOne(ShowInfoType.LevelUp, 2.0f));
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
private IEnumerator FinishOne(ShowInfoType showType, float dalyTime)
|
|||
|
{
|
|||
|
if(showType == ShowInfoType.MissionComplete)
|
|||
|
{
|
|||
|
missionHasShowTime = 0.0f;
|
|||
|
}
|
|||
|
|
|||
|
missionHasShowTime = 0.0f;
|
|||
|
for (float i = dalyTime; i >= 0; i -= Time.deltaTime)
|
|||
|
{
|
|||
|
if(showType == ShowInfoType.MissionComplete)
|
|||
|
{
|
|||
|
missionHasShowTime += Time.deltaTime;
|
|||
|
}
|
|||
|
|
|||
|
yield return 0;
|
|||
|
}
|
|||
|
|
|||
|
switch(showType)
|
|||
|
{
|
|||
|
case ShowInfoType.LevelUp:
|
|||
|
levelUpTip.SetActive(false);
|
|||
|
break;
|
|||
|
case ShowInfoType.MissionComplete:
|
|||
|
_CompleteMissionImage.SetActive(false);
|
|||
|
break;
|
|||
|
case ShowInfoType.EquipEnhance:
|
|||
|
equipEnhanceTip.SetActive(false);
|
|||
|
break;
|
|||
|
case ShowInfoType.EquipFrenzy:
|
|||
|
equipFrenzy.SetActive(false);
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
Dequeue();
|
|||
|
}
|
|||
|
}
|