231 lines
6.8 KiB
C#
231 lines
6.8 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using DG.Tweening;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
namespace GuruClient
|
|
{
|
|
public class UIGameWin : MonoBehaviour
|
|
{
|
|
public GameObject btnContinue;
|
|
public Transform puzzleWhole;
|
|
public Transform txtTitle;
|
|
public Transform btnMain;
|
|
public GameObject imgFlag;
|
|
public GameObject imgLight;
|
|
public GameObject winPFX;
|
|
public GameObject imgBg1;
|
|
public GameObject imgBg2;
|
|
public GameObject btnTestPass;
|
|
public GameObject btnTestFail;
|
|
public Text txtPassCount;
|
|
public Transform pnlPuzzleBase;
|
|
public Button btnPuzzleBase;
|
|
public GameObject bigBG;
|
|
public GameObject objBGClose;
|
|
public GameObject btnBGClose;
|
|
|
|
public GameObject objReward;
|
|
public Slider slider;
|
|
public Button btnRewardClaim;
|
|
public Button btnRewardContinue;
|
|
public Button btnRewardContinueOld;
|
|
public AnimationCurve rewardCurve;
|
|
public GameObject objTitle;
|
|
public GameObject objMidNode;
|
|
public CanvasGroup canvasGroupNode;
|
|
public Text txtUp;
|
|
public Text txtCurCoin;
|
|
public Text txtContinueCoin;
|
|
public Image imgClaim;
|
|
public List<Text> txtMultList;
|
|
|
|
|
|
|
|
private Sequence _sequence;
|
|
private ALevel _curLevel;
|
|
private int _bgTimer = -1;
|
|
private float _bigAnimDuration = 0.6f;
|
|
private Sequence _sliderSq;
|
|
private Sequence _rewardObjSq;
|
|
private int _animCoinNum = 10;
|
|
private Vector3 _initScale = new Vector3(0.8f, 0.8f, 0.8f);
|
|
private int _timerId = -1;
|
|
private float _mulSpeed;
|
|
private Color _hasADColor = new Color(0.2156863f, 0.5254902f, 0.9490196f, 1);
|
|
//字的的透明度变成0.86
|
|
private Color _noADColor = new Color(1, 1, 1, 0.3f);
|
|
private bool _hasAD = false;
|
|
private bool _isDrop;
|
|
private int _removeTimerId = -1;
|
|
private GameModel _model;
|
|
private List<int> _rewardMult;
|
|
private int _rewardTimerId = -1;
|
|
|
|
private bool _isClose = false;
|
|
private bool _canTouch = true;
|
|
|
|
|
|
public GameObject clickToDownload;
|
|
|
|
public void OnBeforStart(ALevel aLevel)
|
|
{
|
|
Luna.Unity.Analytics.LogEvent("EnterGameWin", 0);
|
|
clickToDownload.GetComponent<Button>().onClick.AddListener(delegate
|
|
{
|
|
Luna.Unity.Analytics.LogEvent("ClickInstall", 0);
|
|
Luna.Unity.Playable.InstallFullGame();
|
|
});
|
|
_isClose = false;
|
|
_canTouch = true;
|
|
|
|
float delayTime = 3.0f;
|
|
|
|
_curLevel = aLevel;
|
|
|
|
_model = GameManager.Instance.GetModel();
|
|
|
|
bigBG.SetActive(false);
|
|
objBGClose.SetActive(false);
|
|
btnBGClose.SetActive(false);
|
|
btnPuzzleBase.enabled = false;
|
|
|
|
Image img = pnlPuzzleBase.GetComponent<Image>();
|
|
string imgPath = $"Levels/{aLevel.psdID}/Texture/finish";
|
|
try
|
|
{
|
|
Sprite sp = Resources.Load<Sprite>(imgPath);
|
|
if (sp != null)
|
|
{
|
|
img.sprite = sp;
|
|
}
|
|
}
|
|
catch (System.Exception)
|
|
{
|
|
Debug.Log($"Load Sprite Error: {imgPath}");
|
|
}
|
|
|
|
imgBg1.SetActive(true);
|
|
imgBg2.SetActive(false);
|
|
_bgTimer = Timer.Instance.SetTimeout(delayTime, () => {
|
|
imgBg1.SetActive(false);
|
|
imgBg2.SetActive(true);
|
|
});
|
|
|
|
pnlPuzzleBase.transform.localScale = new Vector3(1.044f, 1.044f, 1);
|
|
pnlPuzzleBase.DOScale(new Vector3(1.094f, 1.094f, 1f), delayTime).OnComplete(
|
|
() => {
|
|
pnlPuzzleBase.DOScale(new Vector3(0.95f, 0.95f, 1.0f), 1f);
|
|
}
|
|
);
|
|
|
|
Sequence mySequence = DOTween.Sequence();
|
|
mySequence.PrependInterval(delayTime);
|
|
mySequence.Append(puzzleWhole.DOScale(new Vector3(0.475f, 0.475f, 0.475f), 1).OnComplete(() => {
|
|
winPFX.SetActive(true);
|
|
|
|
clickToDownload.SetActive(true);
|
|
}));
|
|
mySequence.Join(puzzleWhole.DOLocalMoveY(puzzleWhole.localPosition.y - 144, 1));
|
|
|
|
txtTitle.GetComponent<Text>().DOFade(1, 0.5f).SetDelay(delayTime + 1);
|
|
|
|
imgFlag.GetComponent<Image>().DOFade(1, 0.5f).SetDelay(delayTime + 1);
|
|
|
|
}
|
|
|
|
public GameObject objNormalUI;
|
|
private void ShowNormalUI()
|
|
{
|
|
objNormalUI.SetActive(true);
|
|
|
|
}
|
|
|
|
public FlyAnimComp flyAnimComp;
|
|
public void PlayCoinAnim(bool hasMul)
|
|
{
|
|
if (_isClose)
|
|
{
|
|
return;
|
|
}
|
|
|
|
canvasGroupNode.DOFade(0, 0.2f).OnComplete(delegate { canvasGroupNode.gameObject.SetActive(false); });
|
|
|
|
int changeVal = 20;
|
|
flyAnimComp.Play(changeVal, 10, FlyAnimType.Coin);
|
|
|
|
if (_timerId != -1)
|
|
{
|
|
Timer.Instance.Stop(_timerId);
|
|
_timerId = -1;
|
|
}
|
|
|
|
_timerId = Timer.Instance.SetTimeout(1.2f + 0.05f * (_animCoinNum-1), delegate
|
|
{
|
|
objReward.SetActive(false);
|
|
btnContinue.gameObject.SetActive(true);
|
|
bool showMain = false;
|
|
|
|
|
|
btnMain.gameObject.SetActive(showMain);
|
|
btnPuzzleBase.enabled = true;
|
|
});
|
|
}
|
|
|
|
protected void AddEvent()
|
|
{
|
|
//下载按钮
|
|
}
|
|
|
|
private void BtnRewardContinueCallback()
|
|
{
|
|
if (!_canTouch)
|
|
{
|
|
return;
|
|
}
|
|
PlayCoinAnim(false);
|
|
}
|
|
|
|
|
|
void OnDestroy()
|
|
{
|
|
_isClose = true;
|
|
if (_timerId != -1)
|
|
{
|
|
Timer.Instance.Stop(_timerId);
|
|
_timerId = -1;
|
|
}
|
|
if (_bgTimer != -1)
|
|
{
|
|
Timer.Instance.Stop(_bgTimer);
|
|
_bgTimer = -1;
|
|
}
|
|
if (_removeTimerId != -1)
|
|
{
|
|
Timer.Instance.Stop(_removeTimerId);
|
|
_removeTimerId = -1;
|
|
}
|
|
|
|
if (_rewardTimerId != -1)
|
|
{
|
|
Timer.Instance.Stop(_rewardTimerId);
|
|
_rewardTimerId = -1;
|
|
}
|
|
|
|
if (_sliderSq != null)
|
|
{
|
|
_sliderSq.Kill();
|
|
}
|
|
_sliderSq = null;
|
|
|
|
if (_rewardObjSq != null)
|
|
{
|
|
_rewardObjSq.Kill();
|
|
}
|
|
|
|
_rewardObjSq = null;
|
|
}
|
|
}
|
|
} |