1003 lines
27 KiB
C#
Raw Normal View History

2025-05-18 01:04:31 +08:00
// ***********************************************************************
// Assembly : Game
// Author : Kimch
// Created : 2022-03-02
// Description :
// Last Modified By :
// Last Modified On :
// ***********************************************************************
// <copyright file= "OpenBoxWindow.View" company="Kunpo"></copyright>
// <summary></summary>
// ***********************************************************************
namespace G.UI
{
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
/// <summary>
/// 打开宝箱动画
/// </summary>
partial class OpenBoxWindow
{
/// <summary>
/// 特效移动到指定位置
/// </summary>
class MoveVFX : KUIWidget
{
private Transform _transform;
private Transform _trg;
private Vector3 _sta;
private float _time = 0.7f; //飞向目标点所需的时间
private KUIPool _pool;
public override void Refresh()
{
if (this.data is PropItemWidget _trgTransform)
{
_trg = _trgTransform.transform;
_transform.localPosition = Vector3.zero;
_sta = this.transform.position;
//StartCoroutine(StartMove(_trg));
_transform.DOMove(_trg.position, _time).SetEase(Ease.OutCubic)
.OnComplete(() =>
{
_trgTransform.transform.GetChild(0).gameObject.SetActive(true);
if (_pool)
{
_pool.ReturnItem(this.transform);
}
else
{
#if UNITY_EDITOR
Debug.Log("有错误得检查:没找到对象池");
#endif
Destroy(this.gameObject);
}
});
}
}
public void OpenVFXClick(int index)
{
for (int i = 0; i < _transform.childCount; i++)
{
_transform.GetChild(i).gameObject.SetActive(index == i);
}
}
IEnumerator StartMove(Transform trg)//开始移动
{
var dur = 0.0f;
if (this.data is PropItemWidget _trgTransform)
{
while (dur <= _time)
{
dur += Time.deltaTime;
transform.position = Vector3.Lerp(_sta, trg.position, (dur * dur) / (_time * _time));
yield return null;
}
_trgTransform.transform.GetChild(0).gameObject.SetActive(true);
}
if (_pool)
{
_pool.ReturnItem(this.transform);
}
else
{
#if UNITY_EDITOR && !UNITY_WEBGL
Debug.Log("有错误得检查:没找到对象池");
#endif
Destroy(this.gameObject);
}
}
private void Awake()
{
_pool = this.transform.parent.GetComponent<KUIPool>();
_transform = this.transform;
}
}
/// <summary>
/// 道具信息处理
/// </summary>
class PropItemWidget : KUIWidget
{
#region Auto Generate
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
[KUIFlag]
TextMeshProUGUI _tmpName;
[KUIFlag]
TextMeshProUGUI _tmpCount;
[KUIFlag]
Image _imgIcon;
[KUIFlag]
KUIImage _imgQuality;
[KUIFlag]
KUIImage _imgLevel;
[KUIFlag]
TextMeshProUGUI _tmpLevel;
[KUIFlag]
GameObject _goVFX_yellow;
[KUIFlag]
GameObject _goVFX_red;
[KUIFlag]
GameObject _goCloseVFX_yellow;
[KUIFlag]
GameObject _goCloseVFX_red;
[KUIFlag]
GameObject _goCloseVFX_yellowRed;
[KUIFlag]
GameObject _goCloseVFX_yellowQuick;
[KUIFlag]
GameObject _goCloseVFX_redQuick;
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
private bool _isShowRed = false;
#endregion
#region Method
public override void Refresh()
{
if (this.data is Item.ItemInfo info)
{
_isShowRed = false;
var prop = ItemProxy.Instance.GetStaticItem<ItemProp>(info.id);
_imgQuality.ShowSprite(prop.quality);
IconProxy.Instance.SetSprite(_imgIcon, prop.icon);
_tmpCount.text = "X" + info.count;
if (prop.type == 3 || prop.type == 4)
{
if (prop.quality == 6)
{
_goVFX_red.SetActive(true);
_goVFX_yellow.SetActive(false);
}
else if (prop.quality == 5)
{
if (Random.Range(1, 101) > 50)
{
_goVFX_red.SetActive(false);
_goVFX_yellow.SetActive(true);
}
else
{
_goVFX_red.SetActive(true);
_goVFX_yellow.SetActive(false);
_isShowRed = true;
}
}
else
{
_goVFX_yellow.SetActive(false);
_goVFX_red.SetActive(false);
}
_goCloseVFX_red.SetActive(false);
_goCloseVFX_yellow.SetActive(false);
_goCloseVFX_yellowRed.SetActive(false);
_goCloseVFX_redQuick.SetActive(false);
_goCloseVFX_yellowQuick.SetActive(false);
}
else
{
//if (prop.quality == 6)
//{
// _goVFX_red.SetActive(false);
// _goVFX_yellow.SetActive(false);
// _goCloseVFX_red.SetActive(true);
// _goCloseVFX_yellow.SetActive(false);
//}
//else if (prop.quality == 5)
//{
// _goVFX_red.SetActive(false);
// _goVFX_yellow.SetActive(false);
// _goCloseVFX_red.SetActive(false);
// _goCloseVFX_yellow.SetActive(true);
//}
//else
//{
// _goVFX_yellow.SetActive(false);
// _goVFX_red.SetActive(false);
// _goCloseVFX_red.SetActive(false);
// _goCloseVFX_yellow.SetActive(false);
//}
_goVFX_yellow.SetActive(false);
_goVFX_red.SetActive(false);
_goCloseVFX_red.SetActive(false);
_goCloseVFX_yellow.SetActive(false);
_goCloseVFX_yellowRed.SetActive(false);
_goCloseVFX_redQuick.SetActive(false);
_goCloseVFX_yellowQuick.SetActive(false);
}
}
}
public void AllVFXCloce()
{
_goVFX_yellow.SetActive(false);
_goVFX_red.SetActive(false);
_goCloseVFX_red.SetActive(false);
_goCloseVFX_yellow.SetActive(false);
_goCloseVFX_yellowRed.SetActive(false);
_goCloseVFX_redQuick.SetActive(false);
_goCloseVFX_yellowQuick.SetActive(false);
}
public void OnGetBtnClick() //关闭自身遮罩,显示内容
{
if (this.data is Item.ItemInfo info)
{
var prop = ItemProxy.Instance.GetStaticItem<ItemProp>(info.id);
if (!IsOpenKeepOut())
{
if (prop.quality == 6)
{
_goVFX_red.SetActive(false);
_goCloseVFX_red.SetActive(true);
Invoke(nameof(OpenCheck), 2f);
}
else if (prop.quality == 5)
{
if (!IsOpenKeepOut())
{
if (_isShowRed)
{
_goVFX_red.SetActive(false);
_goCloseVFX_yellowRed.SetActive(true);
Invoke(nameof(OpenCheck), 2f);
}
else
{
_goVFX_yellow.SetActive(false);
_goCloseVFX_yellow.SetActive(true);
Invoke(nameof(OpenCheck), 2f);
}
}
}
}
}
}
private void OpenCheck()
{
GetWindow<OpenBoxWindow>().CheckIsOpenAll();
}
public void OpenKeepOut() //关闭自身遮罩,显示内容(被调用)
{
if (this.data is Item.ItemInfo info)
{
var prop = ItemProxy.Instance.GetStaticItem<ItemProp>(info.id);
if (!IsOpenKeepOut())
{
if (prop.quality == 6)
{
_goVFX_red.SetActive(false);
_goCloseVFX_redQuick.SetActive(true);
}
else if (prop.quality == 5)
{
if (_isShowRed)
{
_goVFX_red.SetActive(false);
_goCloseVFX_yellowQuick.SetActive(true);
}
else
{
_goVFX_yellow.SetActive(false);
_goCloseVFX_yellowQuick.SetActive(true);
}
}
}
}
}
public bool IsOpenKeepOut() //返回自身的遮罩已关闭
{
return (_goVFX_yellow.activeSelf || _goVFX_red.activeSelf) ? false : true;
}
public int propQuality() //返回传入道具的品质
{
if (this.data is Item.ItemInfo info)
{
var prop = ItemProxy.Instance.GetStaticItem<ItemProp>(info.id);
if (_isShowRed && prop.quality ==5)
{
return 5;
}
return (prop.quality - 1);
}
return 0;
}
private void Awake()
{
SetViewData();
var button = GetComponent<Button>();
if (button)
{
button.onClick.AddListener(this.OnGetBtnClick);
}
}
#endregion
}
#region Auto Generate
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
[KUIFlag]
Animator _aniBox_01;//宝箱动画
[KUIFlag]
Animator _aniBox_02;//宝箱动画
[KUIFlag]
Animator _aniBox_03;//装备宝箱动画
[KUIFlag]
Animator _aniBox_04;//江湖宝箱动画
[KUIFlag]
KUIList __listRewards;
[KUIFlag]
KUIPool _flightVFXPool;//对象池
[KUIFlag]
Button _btnGet;
[KUIFlag]
Button _btnOpenBox;
[KUIFlag]
Button _btnOneKeyOpen;
[KUIFlag]
TextMeshProUGUI _tmpHint;
[KUIFlag]
Button _btnMultifunction;
[KUIFlag]
GameObject _goBoxClickGuideVFX;
[KUIFlag]
GameObject _goBoxOpenVFX;
[KUIFlag]
GameObject _goDustVFX;
[KUIFlag]
GameObject _goBoxGapVFX;
[KUIFlag]
GameObject _goImgGetReward;
[KUIFlag]
GameObject _gobgFocuse;
[KUIFlag]
GameObject _goRewardBg;
[KUIFlag]
GameObject _goScenes;
[KUIFlag]
GameObject _goShineVFX;
[KUIFlag]
Toggle _tgIsSkipAnim;//是否跳过动画
[KUIFlag]
GameObject _gobgFocuse_sipk;
[KUIFlag]
GameObject _goRewardBg_sipk;
[KUIFlag]
GameObject _goSkipOff;
[KUIFlag]
GameObject _goSkipOn;
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
private static Dictionary<int, PropItemWidget> _highQualityProp = new Dictionary<int, PropItemWidget>();//储存有几个需开启界面
bool _closeBoxShake = false;
int _isFirstOpen;
Coroutine _shake;
Coroutine _boxClickGuide;
bool _isFirstOpenTenBox = false;
int _boxId;
#endregion
#region Field
#endregion
#region Method
private void OnIsSkipToggleClick(bool tg)
{
PlayerPrefs.SetInt("IsSkipBoxAnim", tg ? 0 : 1);
_goSkipOff.SetActive(!tg);
_goSkipOn.SetActive(tg);
}
public void CheckIsOpenAll()//检查是否所有的都开启了
{
bool isAllOpen = true;
foreach (var item in _highQualityProp.Values)
{
if (!item.IsOpenKeepOut())
{
isAllOpen = false;
break;
}
}
if (_isFirstOpenTenBox)
{
_tmpHint.text = "请翻开全部卡牌";
}
if (isAllOpen)
{
_tmpHint.text = "点击空白关闭页面";
_btnMultifunction.onClick.RemoveAllListeners();
_btnMultifunction.onClick.AddListener(this.OnCloseBtnClick);
_goImgGetReward.SetActive(true);
_tgIsSkipAnim.gameObject.SetActive(true);
}
}
private void OnGetBtnClick()
{
_tmpHint.text = "";
StartCoroutine(OpemBoxAnimation());//打开宝箱依次飞出
_btnGet.onClick.RemoveAllListeners();
_btnMultifunction.onClick.RemoveAllListeners();
StopCoroutine(_boxClickGuide);
_goBoxClickGuideVFX.SetActive(false);
}
private void OnOpenBoxBtnClick()
{
StartCoroutine(StateAutoPanle());//打开宝箱全部飞出
_btnGet.onClick.RemoveAllListeners();
_btnMultifunction.onClick.RemoveAllListeners();
StopCoroutine(_boxClickGuide);
_goBoxClickGuideVFX.SetActive(false);
}
private void OnOneKeyOpenBtnClick()//一键打开遮罩
{
foreach (var item in _highQualityProp.Values)
{
item.OpenKeepOut();
}
_btnMultifunction.onClick.RemoveAllListeners();
_btnGet.onClick.RemoveAllListeners();
StartCoroutine(DelayClick());
}
IEnumerator DelayClick()
{
yield return new WaitForSeconds(2.3f);
_tmpHint.text = "点击空白关闭页面";
_btnMultifunction.onClick.AddListener(this.OnCloseBtnClick);
_btnGet.onClick.AddListener(this.OnCloseBtnClick);
_goImgGetReward.SetActive(true);
_tgIsSkipAnim.gameObject.SetActive(true);
}
private void OnCloseBtnClick()
{
if (this.data is RewardWindow.RewardData rewardData)
{
foreach (var item in _highQualityProp.Values)
{
item.AllVFXCloce();
}
ResetSetActive();
rewardData.Complete();
}
CloseWindow(this);
}
private void BtnClickEventGive() //给按钮添加点击事件
{
if (this.data is RewardWindow.RewardData rewardData)
{
var prop = rewardData.items[0].propItem;
if (prop.type == 3 || prop.type == 4)
{
if (rewardData.items.Count > 1)
{
_tmpHint.text = "点击空白快速翻卡";
_btnMultifunction.onClick.AddListener(this.OnOneKeyOpenBtnClick);
_btnGet.onClick.AddListener(this.OnOneKeyOpenBtnClick);
}
else
{
if (prop.quality > 4)
{
_tmpHint.text = "点击空白快速翻卡";
_btnMultifunction.onClick.AddListener(this.OnOneKeyOpenBtnClick);
_btnGet.onClick.AddListener(this.OnOneKeyOpenBtnClick);
}
else
{
StartCoroutine(DelayAddBtnClick());
}
}
}
else
{
StartCoroutine(DelayAddBtnClick());
}
}
else
{
_tmpHint.text = "点击空白关闭页面";
_btnMultifunction.onClick.AddListener(this.OnCloseBtnClick);
_goImgGetReward.SetActive(true);
_tgIsSkipAnim.gameObject.SetActive(true);
}
}
private IEnumerator DelayAddBtnClick()
{
yield return new WaitForSeconds(1.1f);
_tmpHint.text = "点击空白关闭页面";
_btnMultifunction.onClick.AddListener(this.OnCloseBtnClick);
_goImgGetReward.SetActive(true);
_tgIsSkipAnim.gameObject.SetActive(true);
}
/// ///////////////////////////////////////动画播放控制
///////////////////////////第一段
IEnumerator StatePanle()//开始
{
//++++++播放第一段宝箱掉落
_tmpHint.text = "";
_tmpHint.gameObject.SetActive(false);
StartCoroutine(OpenDustVFX());//灰尘特效
yield return new WaitForSeconds(1.75f);//给宝箱掉落的时间(到时间后按钮才能点击进行下一步)
_closeBoxShake = true;
_shake = StartCoroutine(BoxShake());
_tmpHint.gameObject.SetActive(true);
_isFirstOpen = PlayerPrefs.GetInt("BoxIsFirstOpen", 0);
if (_isFirstOpen == 0)
{
PlayerPrefs.SetInt("BoxIsFirstOpen", 1);
_tmpHint.text = "点击开箱";
_btnGet.onClick.AddListener(this.OnGetBtnClick);
_goBoxClickGuideVFX.SetActive(true);
_goScenes.SetActive(false);
_gobgFocuse.SetActive(true);
_boxClickGuide = StartCoroutine(BoxClickGuideVFX());
}
else
{
_tmpHint.text = "点击空白快速开箱";
_btnGet.onClick.AddListener(this.OnGetBtnClick);
//_btnMultifunction.onClick.AddListener(this.OnGetBtnClick);//点击空白处依次飞
_btnMultifunction.onClick.AddListener(this.OnOpenBoxBtnClick);//点击空白处全部飞出
_boxClickGuide = StartCoroutine(BoxClickGuideVFX());
}
}
IEnumerator BoxShake()//宝箱抖动
{
bool look = true;
while (_closeBoxShake)
{
yield return new WaitForSeconds(2f);//宝箱抖动的时间间隔
if (look)
{
if (_boxId == 1)
{
_aniBox_01.Play("shake");
}
else if (_boxId == 2)
{
_aniBox_02.Play("shake");
}
else if (_boxId == 3)
{
_aniBox_03.Play("shake");
}
else
{
_aniBox_04.Play("shake");
}
look = false;
}
else
{
if (_boxId == 1)
{
_aniBox_01.Play("idle_close");
}
else if (_boxId == 2)
{
_aniBox_02.Play("idle_close");
}
else if (_boxId == 3)
{
_aniBox_03.Play("idle_close");
}
else
{
_aniBox_04.Play("idle_close");
}
look = true;
}
}
}
///////////////////////////////第二段
IEnumerator StateAutoPanle()//打开箱子全部飞出(第一种打开形式)
{
StopCoroutine(_shake);
_closeBoxShake = false;
_goScenes.SetActive(false);
_gobgFocuse.SetActive(true);
_goRewardBg.SetActive(true);
if (_boxId == 1)
{
_aniBox_01.Play("close_open");
}
else if (_boxId == 2)
{
_aniBox_02.Play("close_open");
}
else if (_boxId == 3)
{
_aniBox_03.Play("close_open");
}
else
{
_aniBox_04.Play("close_open");
}
StartCoroutine(BoxOpenVFX());//打开特效
yield return new WaitForSeconds(0.15f);//开始打开箱子多久后生成飞行的特效
foreach (var item in _highQualityProp.Values) //打开特效,给定飞行目标
{
var obj = _flightVFXPool.GetItem<MoveVFX>();
obj.OpenVFXClick(item.propQuality());
obj.SetData(item);
}
yield return new WaitForSeconds(0.75f);//给按钮开启点击事件
var openTenBoxTime = PlayerPrefs.GetInt("TenBoxTime", 0);//检测是否是第一次10连宝箱开启
if (openTenBoxTime == 1)
{
PlayerPrefs.SetInt("TenBoxTime", 2);
_tmpHint.text = "点击卡牌翻卡";
_isFirstOpenTenBox = true;
yield return new WaitForSeconds(8f);
bool isAllOpen = false;
foreach (var item in _highQualityProp.Values)
{
if (!item.IsOpenKeepOut())
{
isAllOpen = true;
break;
}
}
if (isAllOpen)
{
_isFirstOpenTenBox = false;
BtnClickEventGive();
}
}
else
{
BtnClickEventGive();
}
}
IEnumerator OpemBoxAnimation()//打开箱子依次飞出(第二种打开形式)
{
StopCoroutine(_shake);
_closeBoxShake = false;
_goScenes.SetActive(false);
_gobgFocuse.SetActive(true);
_goRewardBg.SetActive(true);
if (_boxId == 1)
{
_aniBox_01.Play("close_open_gap");
}
else if (_boxId == 2)
{
_aniBox_02.Play("close_open_gap");
}
else if (_boxId == 3)
{
_aniBox_03.Play("close_open_gap");
}
else
{
_aniBox_04.Play("close_open_gap");
}
StartCoroutine(BoxGapVFX());//缝隙特效
yield return StartCoroutine(OpenMoveFVXAnimation());
var openTenBoxTime = PlayerPrefs.GetInt("TenBoxTime", 0);
if (openTenBoxTime == 1)
{
PlayerPrefs.SetInt("TenBoxTime", 2);
_tmpHint.text = "点击卡牌翻卡";
_isFirstOpenTenBox = true;
yield return new WaitForSeconds(2.5f);//第一次10连装备宝箱时才使用间隔多久打开一键开启全部遮罩的按钮
bool isAllOpen = false;
foreach (var item in _highQualityProp.Values)
{
if (!item.IsOpenKeepOut())
{
isAllOpen = true;
break;
}
}
if (isAllOpen)
{
_isFirstOpenTenBox = false;
BtnClickEventGive();
}
}
else
{
BtnClickEventGive();
}
}
IEnumerator OpenMoveFVXAnimation()//飞向装备框特效
{
yield return new WaitForSeconds(1.65f);//开始打开箱子多久后生成飞行的特效
foreach (var item in _highQualityProp.Values) //打开特效,给定飞行目标
{
if (item.propQuality() == 5)
{
yield return new WaitForSeconds(1.0f);//生成两个飞行特效的时间间隔
}
else if (item.propQuality() == 4)
{
yield return new WaitForSeconds(0.6f);//生成两个飞行特效的时间间隔
}
else
{
yield return new WaitForSeconds(0.18f);//生成两个飞行特效的时间间隔
}
var obj = _flightVFXPool.GetItem<MoveVFX>();
obj.OpenVFXClick(item.propQuality());
obj.SetData(item);
}
yield return new WaitForSeconds(1f);
}
/////////////////////////////////////////////// 特效显示控制
IEnumerator OpenDustVFX()//打开灰尘特效
{
yield return new WaitForSeconds(0.9f);//开始掉落箱子多久后开播放灰尘特效
_goDustVFX.SetActive(true);
yield return new WaitForSeconds(1.8f);//开启多久后再把它关了
_goDustVFX.SetActive(false);
}
IEnumerator BoxClickGuideVFX() //引导宝箱点击的特效
{
yield return new WaitForSeconds(8f);//箱子掉落多久后显示引导开箱的特效
_goBoxClickGuideVFX.SetActive(true);
_goScenes.SetActive(false);
_gobgFocuse.SetActive(true);
}
IEnumerator BoxOpenVFX() //宝箱打开的特效
{
//yield return new WaitForSeconds(0f);//箱子开始开启多久后显示开箱特效
_goBoxOpenVFX.SetActive(true);
//yield return new WaitForSeconds(0f);//开启播放闪光多久后开启持续光
_goShineVFX.SetActive(true);
yield return new WaitForSeconds(1.5f);//这个特效打开多久后再给他关了,然后打开持续的光
_goBoxOpenVFX.SetActive(false);
}
IEnumerator BoxGapVFX() //缝隙特效后跟宝箱特效
{
//yield return new WaitForSeconds(0f);//箱子开始开启多久后打开缝隙特效
_goBoxGapVFX.SetActive(true);
yield return new WaitForSeconds(1.65f);//关闭缝隙特效
_goBoxGapVFX.SetActive(false);
//yield return new WaitForSeconds(0.5f);//如果中间有间隔把这行的注释取消掉
_goBoxOpenVFX.SetActive(true);//打开开箱特效
//yield return new WaitForSeconds(0f);//开启播放闪光多久后开启持续光
_goShineVFX.SetActive(true);
yield return new WaitForSeconds(1.5f); //这个特效完事后再给他关了,然后打开持续的光
_goBoxOpenVFX.SetActive(false);
}
//////////////////////////////////////////////////////////////////////////////////////////
///跳过///
IEnumerator SpikAnim()
{
yield return new WaitForSeconds(2f);
foreach (var item in _highQualityProp.Values)
{
item.transform.GetChild(0).gameObject.SetActive(true);
item.OpenKeepOut();
yield return new WaitForSeconds(0.2f);
}
StartCoroutine(SpikAnimBtnCLick());
}
IEnumerator SpikAnimBtnCLick()
{
if (this.data is RewardWindow.RewardData rewardData)
{
var prop = rewardData.items[0].propItem;
if (prop.type == 3 || prop.type == 4)
{
yield return new WaitForSeconds(1.5f);
_tmpHint.text = "点击空白关闭页面";
_btnMultifunction.onClick.AddListener(this.OnCloseBtnClick);
_btnGet.onClick.AddListener(this.OnCloseBtnClick);
_goImgGetReward.SetActive(true);
_tgIsSkipAnim.gameObject.SetActive(true);
}
else
{
yield return new WaitForSeconds(0.6f);
_tmpHint.text = "点击空白关闭页面";
_btnMultifunction.onClick.AddListener(this.OnCloseBtnClick);
_btnGet.onClick.AddListener(this.OnCloseBtnClick);
_goImgGetReward.SetActive(true);
_tgIsSkipAnim.gameObject.SetActive(true);
}
}
}
public void InitView()
{
SetViewData();
__listRewards.AddTemplate<PropItemWidget>(true);
_flightVFXPool.AddTemplate<MoveVFX>(true);
_tgIsSkipAnim.onValueChanged.AddListener(this.OnIsSkipToggleClick);
}
public void RefreshView()
{
if (this.data is RewardWindow.RewardData rewardData)
{
ResetSetActive();
int time = -1;
_highQualityProp.Clear();
__listRewards.Clear();
rewardData.items.Sort(PropSort);//排序
foreach (var item in rewardData.items)
{
time++;
var info = __listRewards.GetItem();
info.SetData(item);
_highQualityProp.Add(time, info as PropItemWidget);
}
_tgIsSkipAnim.isOn = PlayerPrefs.GetInt("IsSkipBoxAnim", 1) == 1 ? false : true;
_goSkipOff.SetActive(!_tgIsSkipAnim.isOn);
_goSkipOn.SetActive(_tgIsSkipAnim.isOn);
var openTenBoxTime = PlayerPrefs.GetInt("TenBoxTime", 0);//检测是否是第一次10连宝箱开启
if (openTenBoxTime ==1)
{
_tgIsSkipAnim.gameObject.SetActive(false);
foreach (var item in _highQualityProp.Values)
{
item.transform.GetChild(0).gameObject.SetActive(false);
}
_boxId = ShopProxy.Instance.boxShowIndex;
if (_boxId == 1)
{
_aniBox_01.gameObject.SetActive(true);
}
else if (_boxId == 2)
{
_aniBox_02.gameObject.SetActive(true);
}
else if (_boxId == 3)
{
_aniBox_03.gameObject.SetActive(true);
}
else
{
_aniBox_04.gameObject.SetActive(true);
}
StartCoroutine(StatePanle());
return;
}
else
_tgIsSkipAnim.gameObject.SetActive(true);
if (_tgIsSkipAnim.isOn)
{
foreach (var item in _highQualityProp.Values)
{
item.AllVFXCloce();
}
_goRewardBg_sipk.SetActive(true);
_gobgFocuse_sipk.SetActive(true);
_boxId = BoxShopProxy.Instance.boxId;
if (_boxId == 1)
{
_aniBox_01.gameObject.SetActive(true);
_aniBox_01.Play("close_open");
}
else if (_boxId == 2)
{
_aniBox_02.gameObject.SetActive(true);
_aniBox_02.Play("close_open");
}
else if (_boxId == 3)
{
_aniBox_03.gameObject.SetActive(true);
_aniBox_03.Play("close_open");
}
else
{
_aniBox_04.gameObject.SetActive(true);
_aniBox_04.Play("close_open");
}
//StartCoroutine(SpikAnim());
_tmpHint.text = "点击空白关闭页面";
_btnMultifunction.onClick.AddListener(this.OnCloseBtnClick);
_btnGet.onClick.AddListener(this.OnCloseBtnClick);
_goImgGetReward.SetActive(true);
}
else
{
_tgIsSkipAnim.gameObject.SetActive(false);
foreach (var item in _highQualityProp.Values)
{
item.transform.GetChild(0).gameObject.SetActive(false);
}
_boxId = BoxShopProxy.Instance.boxId;
if (_boxId == 1)
{
_aniBox_01.gameObject.SetActive(true);
}
else if (_boxId == 2)
{
_aniBox_02.gameObject.SetActive(true);
}
else if (_boxId == 3)
{
_aniBox_03.gameObject.SetActive(true);
}
else
{
_aniBox_04.gameObject.SetActive(true);
}
StartCoroutine(StatePanle());
}
}
}
private void ResetSetActive()//重置激活状态
{
_btnMultifunction.onClick.RemoveAllListeners();
_btnGet.onClick.RemoveAllListeners();
_goRewardBg.SetActive(false);
_gobgFocuse.SetActive(false);
_goImgGetReward.SetActive(false);
_aniBox_01.gameObject.SetActive(false);
_aniBox_02.gameObject.SetActive(false);
_aniBox_03.gameObject.SetActive(false);
_aniBox_04.gameObject.SetActive(false);
_goScenes.SetActive(true);
_goShineVFX.SetActive(false);
_goBoxOpenVFX.SetActive(false);
_goRewardBg_sipk.SetActive(false);
_gobgFocuse_sipk.SetActive(false);
}
private int PropSort(Item.ItemInfo x,Item.ItemInfo y)//排序
{
if (x.propItem.quality < 5)
{
if (y.propItem.quality > 4)
{
return -1;
}
}
else
{
if (y.propItem.quality > 4)
{
if (Random.Range(1, 3) ==1)
{
return -1;
}
}
}
return 0;
//return x.propItem.quality > y.propItem.quality ? 0 : -1;
}
#endregion
}
}