183 lines
5.0 KiB
C#
183 lines
5.0 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
using Games.GlobeDefine;
|
|
|
|
public class MaskAndCountTImePanelCtr : MonoBehaviour
|
|
{
|
|
|
|
public Image isWinOrDefeatIcon;
|
|
public Image beginFightIcon;
|
|
public GameObject winObj;
|
|
public GameObject defeatObj;
|
|
|
|
public GameObject maskBG; //在显示开始战斗的时候撤除maskBG
|
|
|
|
// public Text timeText;
|
|
public GameObject _CountTimeObj;
|
|
public UIImgText timeText;
|
|
|
|
//门派挑战特殊提示
|
|
public Text _FactionSpecialDesc;
|
|
|
|
private UnityEngine.Events.UnityAction TimeOverCall;
|
|
|
|
public static MaskAndCountTImePanelCtr Instance;
|
|
void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
private bool isCounTime = false;
|
|
private int m_forbid = -1;
|
|
public void SetTime(int time, float copyAllTime = 0, int Forbid = 0 , UnityEngine.Events.UnityAction Call = null) //Forbid 倒计时时禁止的行为 (见宏 DISABLESTATE)
|
|
{
|
|
if(_FactionSpecialDesc.isActiveAndEnabled)
|
|
_FactionSpecialDesc.gameObject.SetActive(false);
|
|
|
|
_CountTimeObj.gameObject.SetActive(time > 0);
|
|
if (SceneData.ForbidOverTime <= 0 || (SceneData.ForbidOverTime - Time.realtimeSinceStartup) <= 0)
|
|
{
|
|
CloseWindow();
|
|
return;
|
|
}
|
|
|
|
timeText.text = ((int)(SceneData.ForbidOverTime - Time.realtimeSinceStartup)).ToString();
|
|
_CountTimeObj.gameObject.SetActive(true);
|
|
if (Forbid > 0)
|
|
{
|
|
if (Singleton<ObjManager>.Instance.MainPlayer != null)
|
|
{
|
|
Singleton<ObjManager>.Instance.MainPlayer.AddDisableState(Forbid);
|
|
}
|
|
m_forbid = Forbid;
|
|
}
|
|
TimeOverCall = Call;
|
|
InvokeRepeating("UpdateTimeDown", 1, 1);
|
|
}
|
|
|
|
void OnEnable()
|
|
{
|
|
HideWinOrDefeatBG();
|
|
InitFactionChallengeDesc();
|
|
}
|
|
|
|
void InitFactionChallengeDesc()
|
|
{
|
|
if(GameManager.gameManager.RunningScene == (int)GameDefine_Globe.SCENE_DEFINE.SCENE_FACIONCHALLENGE)
|
|
{
|
|
_FactionSpecialDesc.gameObject.SetActive(true);
|
|
_FactionSpecialDesc.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{48009}");
|
|
}
|
|
else
|
|
{
|
|
_FactionSpecialDesc.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void HideWinOrDefeatBG()
|
|
{
|
|
winObj.gameObject.SetActive(false);
|
|
defeatObj.gameObject.SetActive(false);
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
CancelInvoke();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void UpdateTimeDown()
|
|
{
|
|
|
|
if (SceneData.ForbidOverTime - Time.realtimeSinceStartup > 0)
|
|
{
|
|
int leave = (int)(SceneData.ForbidOverTime - Time.realtimeSinceStartup);
|
|
timeText.text = leave.ToString();
|
|
}
|
|
else
|
|
{
|
|
//显示战斗开始的图片
|
|
BeginFight();
|
|
_CountTimeObj.gameObject.SetActive(false);
|
|
if (m_forbid > 0)
|
|
{
|
|
if (Singleton<ObjManager>.Instance.MainPlayer != null)
|
|
{
|
|
Singleton<ObjManager>.Instance.MainPlayer.DelDisableState(m_forbid);
|
|
}
|
|
}
|
|
if (TimeOverCall != null)
|
|
TimeOverCall.Invoke();
|
|
m_forbid = -1;
|
|
}
|
|
}
|
|
|
|
void BeginFight()
|
|
{
|
|
beginFightIcon.gameObject.SetActive(true);
|
|
maskBG.gameObject.SetActive(false);
|
|
|
|
Invoke("CloseWindow", 1.0f);
|
|
}
|
|
|
|
public void WinTheFight()
|
|
{
|
|
_CountTimeObj.gameObject.SetActive(false);
|
|
maskBG.gameObject.SetActive(true);
|
|
if (beginFightIcon.isActiveAndEnabled)
|
|
{
|
|
beginFightIcon.gameObject.SetActive(false);
|
|
}
|
|
if (!winObj.gameObject.activeInHierarchy)
|
|
{
|
|
winObj.gameObject.SetActive(true);
|
|
}
|
|
if (defeatObj.gameObject.activeInHierarchy)
|
|
{
|
|
defeatObj.gameObject.SetActive(false);
|
|
}
|
|
|
|
Invoke("CloseWindow", 3.0f);
|
|
}
|
|
|
|
public void DefeatTheFight()
|
|
{
|
|
_CountTimeObj.gameObject.SetActive(false);
|
|
maskBG.gameObject.SetActive(true);
|
|
if (beginFightIcon.isActiveAndEnabled)
|
|
{
|
|
beginFightIcon.gameObject.SetActive(false);
|
|
}
|
|
if (winObj.gameObject.activeInHierarchy)
|
|
{
|
|
winObj.gameObject.SetActive(false);
|
|
}
|
|
if (!defeatObj.gameObject.activeInHierarchy)
|
|
{
|
|
defeatObj.gameObject.SetActive(true);
|
|
}
|
|
|
|
Invoke("CloseWindow", 3.0f);
|
|
}
|
|
|
|
|
|
void CloseWindow()
|
|
{
|
|
beginFightIcon.gameObject.SetActive(false);
|
|
UIManager.CloseUI(UIInfo.MaskAndCountTimePanel);
|
|
if(defeatObj.activeSelf || winObj.activeSelf)
|
|
{
|
|
if (GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID == (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_GUILDWARMAIN)
|
|
{
|
|
UIManager.ShowUI(UIInfo.GuildWarInfo);
|
|
}
|
|
}
|
|
}
|
|
}
|