159 lines
4.7 KiB
C#
159 lines
4.7 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class PanelResult : BasePanel
|
|
{
|
|
public Action DelAgain;
|
|
|
|
[SerializeField] Text mTxtEndingName;
|
|
|
|
[SerializeField] GameObject mGobWinTitle;
|
|
[SerializeField] GameObject mGobLoseTitle;
|
|
|
|
[SerializeField] GameObject mGobWinFace;
|
|
[SerializeField] GameObject mGobLoseFace;
|
|
|
|
[SerializeField] GameObject mGobWinBtns;
|
|
[SerializeField] GameObject mGobLoseBtns;
|
|
|
|
[SerializeField] GameObject mGobFx;
|
|
|
|
[SerializeField] Button mBtnLevel;
|
|
|
|
[SerializeField] Button mBtnAgain1;
|
|
[SerializeField] Button mBtnNext;
|
|
[SerializeField] Button mBtnChoose;
|
|
|
|
[SerializeField] Button mBtnAgain2;
|
|
[SerializeField] Button mBtnTip;
|
|
[SerializeField] Button mBtnSkip;
|
|
|
|
[SerializeField] ButtonEndings mBtnEndings;
|
|
|
|
public bool ReviewShowed = false;
|
|
|
|
private void Awake()
|
|
{
|
|
UIUtils.BindBtn(mBtnLevel, OnClickChoose, AudioClipType.Click_Normal);
|
|
|
|
UIUtils.BindBtn(mBtnAgain1, OnClickAgain, AudioClipType.Click_Normal);
|
|
UIUtils.BindBtn(mBtnNext, OnClickNext, AudioClipType.Click_Normal);
|
|
UIUtils.BindBtn(mBtnChoose, OnClickChoose, AudioClipType.Click_Normal);
|
|
|
|
UIUtils.BindBtn(mBtnAgain2, OnClickAgain, AudioClipType.Click_Normal);
|
|
UIUtils.BindBtn(mBtnTip, OnClickEndings, AudioClipType.Click_Normal);
|
|
UIUtils.BindBtn(mBtnSkip, OnClickSkip, AudioClipType.Click_Normal);
|
|
|
|
mBtnEndings.DelClick = OnClickEndings;
|
|
}
|
|
|
|
public override void OnFocus(bool pFocus)
|
|
{
|
|
base.OnFocus(pFocus);
|
|
|
|
mGobFx.SetActive(pFocus);
|
|
}
|
|
|
|
public void Init(int pLevelID, string pEndingName, bool pIsWin, bool pNextLevelClear, bool pHasNew = false, bool pHasComplete = false)
|
|
{
|
|
mTxtEndingName.text = pEndingName;
|
|
|
|
mGobWinTitle.SetActive(pIsWin);
|
|
mGobLoseTitle.SetActive(!pIsWin);
|
|
|
|
mGobWinFace.SetActive(pIsWin);
|
|
mGobLoseFace.SetActive(!pIsWin);
|
|
|
|
mGobWinBtns.SetActive(pIsWin);
|
|
mGobLoseBtns.SetActive(!pIsWin);
|
|
|
|
mBtnNext.gameObject.SetActive(!pNextLevelClear);
|
|
mBtnChoose.gameObject.SetActive(pNextLevelClear);
|
|
|
|
mBtnSkip.gameObject.SetActive(PlayerData.Instance.CurrentLevel >= PlayerData.Instance.UnlockedLevel);
|
|
if (mBtnSkip.gameObject.activeSelf)
|
|
{
|
|
//TKGSDKManager.Instance.LogRewardAdBtnShow(Const.AdsEvtValue.EndSkip);
|
|
}
|
|
|
|
LevelData tLvData = GameConfig.Instance.GetLevelData(pLevelID);
|
|
mBtnEndings.Init(pLevelID, PlayerData.Instance.EndingCountOfLevel(pLevelID), tLvData.Endings.Count);
|
|
|
|
if (pHasNew)
|
|
{
|
|
if (pHasComplete)
|
|
{
|
|
TimerManager.Instance.Schedule(() => mBtnEndings.ShowComplete(true), 0.7f);
|
|
}
|
|
else
|
|
{
|
|
TimerManager.Instance.Schedule(() => mBtnEndings.ShowNew(true), 0.7f);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
mBtnEndings.ShowTip(!pIsWin && !pHasComplete);
|
|
}
|
|
}
|
|
|
|
private void OnClickAgain()
|
|
{
|
|
//TKGSDKManager.Instance.LogEvent(Const.AdsEvent.EndRetry, Const.AdsEvtID.Level, PlayerData.Instance.CurrentLevel.ToString());
|
|
|
|
DelAgain?.Invoke();
|
|
|
|
if (!ReviewShowed)
|
|
{
|
|
//TKGSDKManager.Instance.PlayInterstitialAd(Const.AdsEvtValue.EndRetry);
|
|
}
|
|
}
|
|
|
|
private void OnClickNext()
|
|
{
|
|
//TKGSDKManager.Instance.LogEvent(Const.AdsEvent.EndNext, Const.AdsEvtID.Level, PlayerData.Instance.CurrentLevel.ToString());
|
|
|
|
GameManager.Instance.NextLevel();
|
|
|
|
if (!ReviewShowed)
|
|
{
|
|
//TKGSDKManager.Instance.PlayInterstitialAd(Const.AdsEvtValue.EndNext);
|
|
}
|
|
}
|
|
|
|
private void OnClickChoose()
|
|
{
|
|
//TKGSDKManager.Instance.LogEvent(Const.AdsEvent.EndSelect, Const.AdsEvtID.Level, PlayerData.Instance.CurrentLevel.ToString());
|
|
|
|
PanelLevel tUILevel = UIManager.Instance.OpenUI<PanelLevel>();
|
|
tUILevel.Init(true);
|
|
|
|
if (!ReviewShowed)
|
|
{
|
|
//TKGSDKManager.Instance.PlayInterstitialAd(Const.AdsEvtValue.EndSelect);
|
|
}
|
|
}
|
|
|
|
private void OnClickEndings()
|
|
{
|
|
PanelEndings tUIEndings = UIManager.Instance.OpenUI<PanelEndings>();
|
|
tUIEndings.Init(PlayerData.Instance.CurrentLevelID);
|
|
}
|
|
|
|
private void OnClickSkip()
|
|
{
|
|
//TKGSDKManager.Instance.PlayRewardAd(Const.AdsEvtValue.EndSkip, (pResult) =>
|
|
//{
|
|
// if (pResult)
|
|
// {
|
|
// PlayerData.Instance.UnlockNewLevel();
|
|
// GameManager.Instance.NextLevel();
|
|
// }
|
|
//});
|
|
|
|
PlayerData.Instance.UnlockNewLevel();
|
|
GameManager.Instance.NextLevel();
|
|
}
|
|
} |