719 lines
25 KiB
C#
719 lines
25 KiB
C#
using BansheeGz.BGDatabase;
|
||
using CodeJay.Enum;
|
||
using DG.Tweening;
|
||
using System.Collections.Generic;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
|
||
public class ResultPopup : PopupBase
|
||
{
|
||
public ResultxList m_ResultxList;
|
||
public GameObject[] gos_bankrupt; // 0 상대 파산, 1 내가 파산
|
||
public GameObject[] gos_result; // 0 승리, 1 패배
|
||
public TextMeshProUGUI t_Cal;
|
||
[SerializeField] private TextMeshProUGUI GoldTMP;
|
||
public TextMeshProUGUI t_enemygold, t_mygold;
|
||
|
||
public GameObject go_milgiad;
|
||
[SerializeField] private TextMeshProUGUI ButtonlabelTMP; // 밀기 버튼
|
||
|
||
[SerializeField] private GameObject[] NormalGameObjects; // 0 다음게임, 1 밀기
|
||
|
||
private CanvasGroup canvasGroup;
|
||
|
||
private bool _appliedButtonEffect = false;
|
||
private bool _gameResult = false;
|
||
private long _resultTotalGold = 0;
|
||
private bool _isDetail = false;
|
||
List<ResultxInfoData> list_xinfo = new List<ResultxInfoData>
|
||
{
|
||
new ResultxInfoData{ type = EScoreMutiplyType.Go, name = "고" },
|
||
new ResultxInfoData{ type = EScoreMutiplyType.Gobak, name = "고박" },
|
||
new ResultxInfoData{ type = EScoreMutiplyType.Meongbak, name = "멍박" },
|
||
new ResultxInfoData{ type = EScoreMutiplyType.Peebak, name = "피박" },
|
||
new ResultxInfoData{ type = EScoreMutiplyType.Gwhangbak, name = "광박" },
|
||
new ResultxInfoData{ type = EScoreMutiplyType.Shake, name = "흔듦" },
|
||
new ResultxInfoData{ type = EScoreMutiplyType.Nagari, name = "나가리" },
|
||
new ResultxInfoData{ type = EScoreMutiplyType.ClickedFromResultPopup, name = "밀기" },
|
||
};
|
||
|
||
long enemyBeforeGold;
|
||
long myBeforeGold;
|
||
|
||
protected override void Awake()
|
||
{
|
||
base.Awake();
|
||
canvasGroup = this.GetComponent<CanvasGroup>();
|
||
|
||
if (GameManager.Instance != null)
|
||
{
|
||
GameManager.Event.RegistEvent(EEventType.MoveToStore_Heart_DuringGame, this.MoveToStore_Heart_DuringGameCallback);
|
||
GameManager.Event.RegistEvent(EEventType.OnReturnToGameFromStore, this.OnReturnToGameFromStoreCallback);
|
||
|
||
GameManager.ADS.OnCompletedInterstitialAd += OnCompletedInterstitialAd;
|
||
GameManager.ADS.OnCompletedRewardedAd += OnCompletedRewardedAd;
|
||
}
|
||
}
|
||
|
||
private void OnDestroy()
|
||
{
|
||
if (GameManager.Instance != null)
|
||
{
|
||
GameManager.Event.RemoveEvent(EEventType.MoveToStore_Heart_DuringGame, this.MoveToStore_Heart_DuringGameCallback);
|
||
GameManager.Event.RemoveEvent(EEventType.OnReturnToGameFromStore, this.OnReturnToGameFromStoreCallback);
|
||
|
||
GameManager.ADS.OnCompletedInterstitialAd -= OnCompletedInterstitialAd;
|
||
GameManager.ADS.OnCompletedRewardedAd -= OnCompletedRewardedAd;
|
||
}
|
||
}
|
||
|
||
private void MoveToStore_Heart_DuringGameCallback()
|
||
{
|
||
canvasGroup.alpha = 0;
|
||
canvasGroup.blocksRaycasts = false;
|
||
}
|
||
|
||
private void OnReturnToGameFromStoreCallback()
|
||
{
|
||
canvasGroup.alpha = 1;
|
||
canvasGroup.blocksRaycasts = true;
|
||
canvasGroup.blocksRaycasts = true;
|
||
}
|
||
|
||
public void SetData(bool gameResult, int fixedScore = 0)
|
||
{
|
||
_gameResult = gameResult;
|
||
DSUtil.InActivateGameObjects(gos_bankrupt);
|
||
DSUtil.InActivateGameObjects(gos_result, _gameResult ? 0 : 1);
|
||
|
||
GoldTMP.enabled = true;
|
||
|
||
if (GamePanel.Instance.Player_Milgi > 0) NormalGameObjects[1].SetActive(false);
|
||
ButtonlabelTMP.text = _gameResult ? "밀기 2배\n<size=35>이번 판 무효" : "밀기 4배\n<size=35>이번 판 무효";
|
||
list_xinfo.ForEach(f => f.mul = 0); // 초기화
|
||
go_milgiad.SetActive(false);
|
||
enemyBeforeGold = GameManager.DB.GetRemainigNormalGameAIGold();
|
||
myBeforeGold = GameManager.DB.Gold;
|
||
|
||
if (gameResult)
|
||
{ // win
|
||
if (fixedScore <= 0)
|
||
{
|
||
int score = GamePanel.Instance.GetTotalScore(true, false);
|
||
int goNumer = GamePanel.Instance.Player_Go;
|
||
string str = $"{score}점";
|
||
int multiply = 0;
|
||
|
||
if (goNumer == 1)
|
||
{
|
||
str += " + 1고(1점) ";
|
||
score += 1;
|
||
}
|
||
else if (goNumer == 2)
|
||
{
|
||
str += " + 2고(2점) ";
|
||
score += 2;
|
||
}
|
||
else if (goNumer >= 3)
|
||
{
|
||
GamePanel.Instance.AddMultiplyType(EScoreMutiplyType.Go);
|
||
}
|
||
|
||
var multipleType = GamePanel.Instance.GetAndUpdateScoreMultiplyType(gameResult);
|
||
|
||
if (multipleType != null)
|
||
{
|
||
for (int i = 0; i < multipleType.Count; i++)
|
||
{
|
||
if (multiply <= 0)
|
||
multiply = 1;
|
||
|
||
var val = CodeJay.CodeJayUtility.Utility.GetScoreMultiplyValue(multipleType[i]);
|
||
if (multipleType[i] == EScoreMutiplyType.Shake)
|
||
val *= GamePanel.Instance.Player_Bell;
|
||
else if (multipleType[i] == EScoreMutiplyType.ClickedFromResultPopup)
|
||
val *= GamePanel.Instance.Player_Milgi;
|
||
else if (multipleType[i] == EScoreMutiplyType.Go)
|
||
val *= goNumer - 2;
|
||
multiply *= val;
|
||
list_xinfo.Find(f => f.type == multipleType[i]).mul = val;
|
||
}
|
||
}
|
||
|
||
if (multiply > 0)
|
||
{
|
||
t_Cal.text = str + $" x {multiply}배\n= 총 {score * multiply}점\n";
|
||
_resultTotalGold = score * multiply * GamePanel.Instance.Stake;
|
||
}
|
||
else
|
||
{
|
||
t_Cal.text = str + $" \n= 총 {score}점\n";
|
||
_resultTotalGold = score * GamePanel.Instance.Stake;
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
_resultTotalGold = GamePanel.Instance.Stake * fixedScore;
|
||
t_Cal.text = $"{fixedScore}점 \n= 총 {fixedScore}점\n";
|
||
}
|
||
|
||
t_Cal.text += $"x {GamePanel.Instance.Stake}냥";
|
||
|
||
if (GamePanel.Instance.IsChallengeMode)
|
||
{
|
||
long reamainingAIMoney = GameManager.DB.GetReaminingTargetCondition(true);
|
||
|
||
if (GameManager.DB.AddCurrentChallengeCondition(_resultTotalGold, true))
|
||
{
|
||
_resultTotalGold = reamainingAIMoney;
|
||
GameManager.Sound.PlaySFX(ESFXType.Win_2);
|
||
DSUtil.InActivateGameObjects(gos_bankrupt, 0);
|
||
gos_bankrupt[0].GetComponent<RectTransform>().DOScale(1f, 1f).From(3f).SetEase(Ease.InExpo);
|
||
gos_bankrupt[0].GetComponent<Image>().DOFade(1f, 1f).From(0f).SetEase(Ease.InExpo);
|
||
|
||
for (int i = 0; i < NormalGameObjects.Length; i++)
|
||
NormalGameObjects[i].SetActive(false);
|
||
}
|
||
else
|
||
{
|
||
GameManager.Sound.PlaySFX(ESFXType.Win);
|
||
|
||
for (int i = 0; i < NormalGameObjects.Length; i++)
|
||
NormalGameObjects[i].SetActive(true);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
long reamainingAIMoney = GameManager.DB.GetRemainigNormalGameAIGold();
|
||
|
||
if (GameManager.DB.AddNormalGameProgress(_resultTotalGold))
|
||
{
|
||
_resultTotalGold = reamainingAIMoney;
|
||
GameManager.Sound.PlaySFX(ESFXType.Win_2);
|
||
DSUtil.InActivateGameObjects(gos_bankrupt, 0);
|
||
gos_bankrupt[0].GetComponent<RectTransform>().DOScale(1f, 1f).From(3f).SetEase(Ease.InExpo);
|
||
gos_bankrupt[0].GetComponent<Image>().DOFade(1f, 1f).From(0f).SetEase(Ease.InExpo);
|
||
|
||
for (int i = 0; i < NormalGameObjects.Length; i++)
|
||
NormalGameObjects[i].SetActive(false);
|
||
|
||
GameManager.DB.AddHeart(1, this.name);
|
||
}
|
||
else
|
||
{
|
||
GameManager.Sound.PlaySFX(ESFXType.Win);
|
||
|
||
for (int i = 0; i < NormalGameObjects.Length; i++)
|
||
NormalGameObjects[i].SetActive(true);
|
||
}
|
||
}
|
||
|
||
GoldTMP.text = "+" + CodeJay.CodeJayUtility.Converter.MoneyToString(_resultTotalGold);
|
||
GameManager.DB.AddGold(_resultTotalGold, this.name);
|
||
|
||
//ForcedMoveButtonGO.SetActive(false);
|
||
}
|
||
else
|
||
{ // lose
|
||
go_milgiad.SetActive(true);
|
||
|
||
GameManager.Sound.PlaySFX(ESFXType.Lose);
|
||
|
||
if (fixedScore <= 0)
|
||
{
|
||
int score = GamePanel.Instance.GetTotalScore(false, false);
|
||
int goNumer = GamePanel.Instance.AI_Go;
|
||
int multiply = 0;
|
||
string str = $"{score}점";
|
||
|
||
if (goNumer == 1)
|
||
{
|
||
str += " + 1고(1점) ";
|
||
score += 1;
|
||
}
|
||
else if (goNumer == 2)
|
||
{
|
||
str += " + 2고(2점) ";
|
||
score += 2;
|
||
}
|
||
else if (goNumer >= 3)
|
||
{
|
||
GamePanel.Instance.AddMultiplyType(EScoreMutiplyType.Go);
|
||
}
|
||
|
||
|
||
var multipleType = GamePanel.Instance.GetAndUpdateScoreMultiplyType(gameResult);
|
||
|
||
if (multipleType != null)
|
||
{
|
||
for (int i = 0; i < multipleType.Count; i++)
|
||
{
|
||
if (multiply <= 0)
|
||
multiply = 1;
|
||
|
||
var val = CodeJay.CodeJayUtility.Utility.GetScoreMultiplyValue(multipleType[i]);
|
||
if (multipleType[i] == EScoreMutiplyType.Shake)
|
||
val *= GamePanel.Instance.Player_Bell;
|
||
else if (multipleType[i] == EScoreMutiplyType.ClickedFromResultPopup)
|
||
val *= GamePanel.Instance.Player_Milgi;
|
||
else if (multipleType[i] == EScoreMutiplyType.Go)
|
||
val *= goNumer - 2;
|
||
multiply *= val;
|
||
list_xinfo.Find(f => f.type == multipleType[i]).mul = val;
|
||
}
|
||
}
|
||
|
||
if (multiply > 0)
|
||
{
|
||
t_Cal.text = str + $" x {multiply}배\n= 총 {score * multiply}점";
|
||
_resultTotalGold = score * multiply * GamePanel.Instance.Stake;
|
||
}
|
||
else
|
||
{
|
||
t_Cal.text = str + $"\n= 총 {score}점";
|
||
_resultTotalGold = score * GamePanel.Instance.Stake;
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
_resultTotalGold = GamePanel.Instance.Stake * fixedScore;
|
||
t_Cal.text = $"{fixedScore}점\n= 총 {fixedScore}점";
|
||
}
|
||
|
||
GoldTMP.text = "-" + CodeJay.CodeJayUtility.Converter.MoneyToString(_resultTotalGold);
|
||
GameManager.DB.SubGold(_resultTotalGold, this.name);
|
||
GameManager.DB.AddGoldToAI(GamePanel.Instance.IsChallengeMode, _resultTotalGold);
|
||
|
||
if (GameManager.DB.Gold <= 0)
|
||
{
|
||
GameManager.Sound.ReserveSFX(ESFXType.Stamp, 0.6f);
|
||
DSUtil.InActivateGameObjects(gos_bankrupt, 1);
|
||
gos_bankrupt[1].GetComponent<RectTransform>().DOScale(1f, 1f).From(3f).SetEase(Ease.InExpo);
|
||
gos_bankrupt[1].GetComponent<Image>().DOFade(1f, 1f).From(0f).SetEase(Ease.InExpo);
|
||
|
||
for (int i = 0; i < NormalGameObjects.Length; i++)
|
||
NormalGameObjects[i].SetActive(false);
|
||
}
|
||
else
|
||
{
|
||
for (int i = 0; i < NormalGameObjects.Length; i++)
|
||
NormalGameObjects[i].SetActive(true);
|
||
}
|
||
}
|
||
|
||
m_ResultxList.Set(list_xinfo);
|
||
t_enemygold.text = gos_bankrupt[0].activeSelf ? "0냥" : CodeJay.CodeJayUtility.Converter.MoneyToString(GameManager.DB.GetRemainigNormalGameAIGold());
|
||
t_mygold.text = CodeJay.CodeJayUtility.Converter.MoneyToString(GameManager.DB.Gold);
|
||
|
||
GameManager.Event.InvokeEvent(EEventType.OnSynchronizeGold);
|
||
GameManager.Event.InvokeEvent(EEventType.OnGameEnd);
|
||
GameManager.DB.SaveDatas();
|
||
}
|
||
|
||
public void WinWithFirstBbug(long resultGold)
|
||
{
|
||
_gameResult = true;
|
||
if (GamePanel.Instance.Player_Milgi > 0) NormalGameObjects[1].SetActive(false);
|
||
ButtonlabelTMP.text = _gameResult ? "밀기 4배\n<size=35>이번 판 무효" : "밀기 2배\n<size=35>이번 판 무효";
|
||
GoldTMP.enabled = true;
|
||
GameManager.Sound.PlaySFX(ESFXType.Win);
|
||
|
||
DSUtil.InActivateGameObjects(gos_result, 0);
|
||
|
||
list_xinfo.ForEach(f => f.mul = 0); // 초기화
|
||
var multipleType = GamePanel.Instance.GetAndUpdateScoreMultiplyType(_gameResult);
|
||
int multiply = 0;
|
||
if (multipleType != null)
|
||
{
|
||
for (int i = 0; i < multipleType.Count; i++)
|
||
{
|
||
if (multiply <= 0)
|
||
multiply = 1;
|
||
|
||
var val = CodeJay.CodeJayUtility.Utility.GetScoreMultiplyValue(multipleType[i]);
|
||
if (multipleType[i] == EScoreMutiplyType.Shake)
|
||
val *= GamePanel.Instance.Player_Bell;
|
||
else if (multipleType[i] == EScoreMutiplyType.ClickedFromResultPopup)
|
||
val *= GamePanel.Instance.Player_Milgi;
|
||
multiply *= val;
|
||
list_xinfo.Find(f => f.type == multipleType[i]).mul = val;
|
||
}
|
||
}
|
||
|
||
go_milgiad.SetActive(false);
|
||
var lastPoint = 7 * (multiply > 1 ? multiply : 1);
|
||
_resultTotalGold = resultGold * (multiply > 1 ? multiply : 1);
|
||
|
||
if (multiply > 1)
|
||
t_Cal.text = $"7점 x {multiply}배\n= 총 {lastPoint}점\nx {GamePanel.Instance.Stake}냥";
|
||
else
|
||
t_Cal.text = $"{lastPoint}점\n= 총 {lastPoint}점\nx {GamePanel.Instance.Stake}냥";
|
||
|
||
GoldTMP.text = "+" + CodeJay.CodeJayUtility.Converter.MoneyToString(_resultTotalGold);
|
||
|
||
if (GamePanel.Instance.IsChallengeMode)
|
||
{
|
||
if (GameManager.DB.AddCurrentChallengeCondition(_resultTotalGold, true))
|
||
{
|
||
GameManager.Sound.PlaySFX(ESFXType.Win_2);
|
||
|
||
for (int i = 0; i < NormalGameObjects.Length; i++)
|
||
NormalGameObjects[i].SetActive(false);
|
||
}
|
||
else
|
||
{
|
||
GameManager.Sound.PlaySFX(ESFXType.Win);
|
||
|
||
for (int i = 0; i < NormalGameObjects.Length; i++)
|
||
NormalGameObjects[i].SetActive(true);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (GameManager.DB.AddNormalGameProgress(_resultTotalGold))
|
||
{
|
||
GameManager.Sound.PlaySFX(ESFXType.Win_2);
|
||
|
||
for (int i = 0; i < NormalGameObjects.Length; i++)
|
||
NormalGameObjects[i].SetActive(false);
|
||
}
|
||
else
|
||
{
|
||
GameManager.Sound.PlaySFX(ESFXType.Win);
|
||
|
||
for (int i = 0; i < NormalGameObjects.Length; i++)
|
||
NormalGameObjects[i].SetActive(true);
|
||
}
|
||
}
|
||
|
||
m_ResultxList.Set(list_xinfo);
|
||
DSUtil.InActivateGameObjects(gos_bankrupt, 0);
|
||
gos_bankrupt[0].GetComponent<RectTransform>().DOScale(1f, 1f).From(3f).SetEase(Ease.InExpo);
|
||
gos_bankrupt[0].GetComponent<Image>().DOFade(1f, 1f).From(0f).SetEase(Ease.InExpo);
|
||
t_enemygold.text = "0냥";
|
||
t_mygold.text = CodeJay.CodeJayUtility.Converter.MoneyToString(GameManager.DB.Gold);
|
||
|
||
GameManager.Event.InvokeEvent(EEventType.OnSynchronizeGold);
|
||
GameManager.Event.InvokeEvent(EEventType.OnGameEnd);
|
||
GameManager.DB.SaveDatas();
|
||
}
|
||
|
||
public void ClickShop()
|
||
{
|
||
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
||
CanvasControl.Ins.Go_Shop();
|
||
GameManager.UI.HideTopPopup();
|
||
}
|
||
|
||
public void ClickMilgi()
|
||
{
|
||
if (!_gameResult)
|
||
GameManager.ADS.ShowInterstitialAd(Set_Milgi);
|
||
else
|
||
Set_Milgi();
|
||
}
|
||
void Set_Milgi()
|
||
{
|
||
var curgold = GameManager.DB.GetRemainigNormalGameAIGold();
|
||
GameManager.DB.AddGoldToAI(false, _gameResult ? enemyBeforeGold - curgold : curgold - enemyBeforeGold);
|
||
var mygold = GameManager.DB.Gold;
|
||
GameManager.DB.AddGold(_gameResult ? -(mygold - myBeforeGold) : -(myBeforeGold - mygold), name);
|
||
GameManager.DB.SaveDatas();
|
||
|
||
GamePanel.Instance.AddMultiplyType(EScoreMutiplyType.ClickedFromResultPopup);
|
||
GamePanel.Instance.Player_Milgi = _gameResult ? 1 : 2;
|
||
ClickNextGame();
|
||
}
|
||
|
||
public void ClickHome()
|
||
{
|
||
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
||
if (GamePanel.Instance.IsChallengeMode)
|
||
{
|
||
GameManager.Event.InvokeEvent(EEventType.OnReturnToHunting);
|
||
}
|
||
else
|
||
{
|
||
GameManager.Event.InvokeEvent(EEventType.OnReturnToHome);
|
||
}
|
||
GameManager.UI.HideTopPopup();
|
||
GamePanel.Instance.Player_Milgi = 0;
|
||
}
|
||
|
||
public void ClickNext()
|
||
{
|
||
GamePanel.Instance.Player_Milgi = 0;
|
||
if (GamePanel.Instance.IsChallengeMode)
|
||
{
|
||
BGId huntingDataID = GameManager.BGDatabase.GetLastUnolockHuntingDataID();
|
||
BGId huntingListDataID = GameManager.BGDatabase.GetLastUnolockHuntingListDataID();
|
||
if (huntingDataID != BGId.Empty && huntingListDataID != BGId.Empty)
|
||
{
|
||
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
||
GameManager.Event.InvokeEvent(EEventType.OnReturnToHunting);
|
||
GameManager.Event.InvokeEvent(EEventType.OnClickFullView, huntingDataID, huntingListDataID);
|
||
|
||
GameManager.UI.HideTopPopup();
|
||
}
|
||
|
||
/*if (GameManager.DB.Heart > 0)
|
||
{
|
||
GameManager.DB.SubHeart(1);
|
||
GameManager.DB.SaveDatas();
|
||
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
||
GamePanel.Instance.StartNextGame();
|
||
GameManager.UI.HideTopPopup();
|
||
}
|
||
else
|
||
{
|
||
GameManager.UI.ShowNStackPopup(EPopupType.HeartChargePopup);
|
||
}*/
|
||
}
|
||
else
|
||
{
|
||
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
||
GamePanel.Instance.StartNextGame();
|
||
GameManager.UI.HideTopPopup();
|
||
}
|
||
}
|
||
|
||
public void ClickNextGame()
|
||
{
|
||
// Show Ad
|
||
if (CheckShowInterstitialAD())
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (GamePanel.Instance.IsChallengeMode)
|
||
{
|
||
if (GameManager.DB.Heart > 0)
|
||
{
|
||
GameManager.DB.SubHeart(1, this.name);
|
||
GameManager.DB.SaveDatas();
|
||
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
||
GamePanel.Instance.StartNextGame();
|
||
GameManager.UI.HideTopPopup();
|
||
}
|
||
else
|
||
{
|
||
GameManager.UI.ShowNStackPopup(EPopupType.HeartChargePopup);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
||
GamePanel.Instance.StartNextGame();
|
||
GameManager.UI.HideTopPopup();
|
||
}
|
||
}
|
||
|
||
public void ClickHeart()
|
||
{
|
||
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
||
|
||
if (_appliedButtonEffect)
|
||
return;
|
||
|
||
// 두배
|
||
if (_gameResult)
|
||
{
|
||
if (GamePanel.Instance.IsChallengeMode)
|
||
{
|
||
if (GameManager.DB.Heart > 1)
|
||
{
|
||
_appliedButtonEffect = true;
|
||
GameManager.DB.SubHeart(1, this.name);
|
||
GamePanel.Instance.AddMultiplyType(EScoreMutiplyType.ClickedFromResultPopup);
|
||
|
||
this.ClickNextGame();
|
||
}
|
||
else
|
||
{
|
||
GameManager.UI.ShowNStackPopup(EPopupType.DoubleHeartWarningPopup);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (GameManager.DB.Heart > 0)
|
||
{
|
||
_appliedButtonEffect = true;
|
||
GameManager.DB.SubHeart(1, this.name);
|
||
GamePanel.Instance.AddMultiplyType(EScoreMutiplyType.ClickedFromResultPopup);
|
||
|
||
this.ClickNextGame();
|
||
}
|
||
else
|
||
{
|
||
GameManager.UI.ShowNStackPopup(EPopupType.HeartChargePopup);
|
||
}
|
||
}
|
||
}
|
||
else // 무효
|
||
{
|
||
if (GameManager.DB.Heart > 0)
|
||
{
|
||
GameManager.DB.AddGold(_resultTotalGold, this.name);
|
||
GameManager.DB.SubHeart(1, this.name);
|
||
_appliedButtonEffect = true;
|
||
}
|
||
else
|
||
{
|
||
GameManager.UI.ShowNStackPopup(EPopupType.HeartChargePopup);
|
||
}
|
||
}
|
||
}
|
||
|
||
public void ClickAdButton()
|
||
{
|
||
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
||
|
||
if (_appliedButtonEffect)
|
||
return;
|
||
|
||
|
||
if (GamePanel.Instance.IsChallengeMode)
|
||
{
|
||
if (GameManager.DB.Heart <= 0)
|
||
{
|
||
GameManager.UI.ShowNStackPopup(EPopupType.HeartChargePopup);
|
||
}
|
||
else
|
||
{
|
||
GameManager.ADS.ShowResultRewardedAd(this.name);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GameManager.ADS.ShowResultRewardedAd(this.name);
|
||
}
|
||
}
|
||
|
||
private void AdCallback(bool result)
|
||
{
|
||
if (result)
|
||
{
|
||
_appliedButtonEffect = true;
|
||
|
||
if (_gameResult)
|
||
{
|
||
if (GamePanel.Instance.IsChallengeMode)
|
||
{
|
||
GameManager.DB.SubHeart(1, this.name);
|
||
GameManager.DB.SaveDatas();
|
||
}
|
||
|
||
GamePanel.Instance.AddMultiplyType(EScoreMutiplyType.ClickedFromResultPopup);
|
||
|
||
GamePanel.Instance.StartNextGame();
|
||
GameManager.UI.HideTopPopup();
|
||
}
|
||
else
|
||
{
|
||
GameManager.DB.AddGold(_resultTotalGold, this.name);
|
||
}
|
||
}
|
||
}
|
||
|
||
public void DetailToggle()
|
||
{
|
||
_isDetail = !_isDetail;
|
||
|
||
if (_isDetail)
|
||
{
|
||
GoldTMP.enabled = false;
|
||
}
|
||
else
|
||
{
|
||
GoldTMP.enabled = true;
|
||
}
|
||
}
|
||
|
||
public void ClickNextLevel()
|
||
{
|
||
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
||
|
||
// Show Ad
|
||
if (CheckShowInterstitialAD())
|
||
{
|
||
return;
|
||
}
|
||
|
||
// <20>ӽ÷<D3BD> <20>ٷ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||
this.ClickNextLevelCallback(true);
|
||
}
|
||
|
||
private void ClickNextLevelCallback(bool result)
|
||
{
|
||
if (result)
|
||
{
|
||
this.ClickNext();
|
||
}
|
||
}
|
||
|
||
public void ClickForcedMoveToHome()
|
||
{
|
||
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
||
if (GamePanel.Instance.IsChallengeMode)
|
||
{
|
||
GameManager.Event.InvokeEvent(EEventType.OnReturnToHunting);
|
||
}
|
||
else
|
||
{
|
||
GameManager.Event.InvokeEvent(EEventType.OnReturnToHome);
|
||
}
|
||
GameManager.UI.HideTopPopup();
|
||
}
|
||
|
||
private bool CheckShowInterstitialAD()
|
||
{
|
||
if (GamePanel.Instance.IsChallengeMode == false && GameManager.DB.InterstitialADCount <= CodeJay.Defines.Constants.INTERSTITIAL_AD_CYCLE)
|
||
{
|
||
if (GameManager.DB.InterstitialADCount <= 0)
|
||
{
|
||
// 광고 실행하기
|
||
GameManager.ADS.ShowInterstitialAd();
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
private void OnCompletedRewardedAd(bool isCompleted, string name)
|
||
{
|
||
if (GamePanel.Instance.IsChallengeMode == false && GameManager.DB.InterstitialADCount <= CodeJay.Defines.Constants.INTERSTITIAL_AD_CYCLE)
|
||
{
|
||
if (GameManager.DB.InterstitialADCount <= 0)
|
||
{
|
||
GameManager.DB.ResetInterstitialADCount();
|
||
}
|
||
}
|
||
|
||
if (name == this.name)
|
||
{
|
||
AdCallback(isCompleted);
|
||
}
|
||
}
|
||
|
||
private void OnCompletedInterstitialAd(bool isCompleted)
|
||
{
|
||
if(isCompleted == true || GameManager.DB.IsRemoveADS == true)
|
||
{
|
||
GameManager.DB.ResetInterstitialADCount();
|
||
|
||
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
||
GamePanel.Instance.StartNextGame();
|
||
GameManager.UI.HideTopPopup();
|
||
}
|
||
}
|
||
}
|
||
|
||
public class ResultxInfoData
|
||
{
|
||
public EScoreMutiplyType type;
|
||
public string name;
|
||
public int mul = 0;
|
||
} |