|
@@ -5,8 +5,6 @@ using System.Collections.Generic;
|
|
using System;
|
|
using System;
|
|
using UnityEngine;
|
|
using UnityEngine;
|
|
using System.Collections;
|
|
using System.Collections;
|
|
-using Live2D.Cubism.Rendering;
|
|
|
|
-using DG.Tweening;
|
|
|
|
|
|
|
|
namespace GFGGame
|
|
namespace GFGGame
|
|
{
|
|
{
|
|
@@ -15,23 +13,15 @@ namespace GFGGame
|
|
private GComponent _com;
|
|
private GComponent _com;
|
|
// private UI_ComModel _comModel;
|
|
// private UI_ComModel _comModel;
|
|
private DressUpObjUI _dressUpObjUI;
|
|
private DressUpObjUI _dressUpObjUI;
|
|
- private DressUpObjUI _dressUpObjUI2;
|
|
|
|
-
|
|
|
|
private LuckyBoxCfg _luckyBoxCfg;
|
|
private LuckyBoxCfg _luckyBoxCfg;
|
|
private const int _turnTime = 8;
|
|
private const int _turnTime = 8;
|
|
private int _curTime = _turnTime;
|
|
private int _curTime = _turnTime;
|
|
private int _bgIndex = 0;
|
|
private int _bgIndex = 0;
|
|
private int _modelIndex = 0;
|
|
private int _modelIndex = 0;
|
|
- private List<DressUpObjUI> _dressUpObjUIs = new List<DressUpObjUI>(2);
|
|
|
|
|
|
|
|
public LuckyBoxController(GComponent comModel)
|
|
public LuckyBoxController(GComponent comModel)
|
|
{
|
|
{
|
|
_dressUpObjUI = new DressUpObjUI("SceneDressUp");
|
|
_dressUpObjUI = new DressUpObjUI("SceneDressUp");
|
|
- _dressUpObjUI2 = new DressUpObjUI("SceneDressUp");
|
|
|
|
-
|
|
|
|
- _dressUpObjUIs.Add(_dressUpObjUI);
|
|
|
|
- _dressUpObjUIs.Add(_dressUpObjUI2);
|
|
|
|
-
|
|
|
|
_com = comModel;
|
|
_com = comModel;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -41,9 +31,7 @@ namespace GFGGame
|
|
_curTime = _turnTime;
|
|
_curTime = _turnTime;
|
|
_luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(luckyBoxId);
|
|
_luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(luckyBoxId);
|
|
_com.GetChild("loaMask").asLoader.url = ResPathUtil.GetBgImgPath(_luckyBoxCfg.bgResArr[_bgIndex]);
|
|
_com.GetChild("loaMask").asLoader.url = ResPathUtil.GetBgImgPath(_luckyBoxCfg.bgResArr[_bgIndex]);
|
|
- InitDressUpObj();
|
|
|
|
ChangeRes();
|
|
ChangeRes();
|
|
- InitModel();
|
|
|
|
Timers.inst.Remove(UpdateTime);
|
|
Timers.inst.Remove(UpdateTime);
|
|
if (_luckyBoxCfg.resArr.Length > 1 || _luckyBoxCfg.suitIdArr.Length > 1)
|
|
if (_luckyBoxCfg.resArr.Length > 1 || _luckyBoxCfg.suitIdArr.Length > 1)
|
|
{
|
|
{
|
|
@@ -64,27 +52,24 @@ namespace GFGGame
|
|
_modelIndex = _modelIndex + 1 == _luckyBoxCfg.suitIdArr.Length ? 0 : _modelIndex + 1;
|
|
_modelIndex = _modelIndex + 1 == _luckyBoxCfg.suitIdArr.Length ? 0 : _modelIndex + 1;
|
|
}
|
|
}
|
|
|
|
|
|
- HideModel();
|
|
|
|
- UpdateIndex();
|
|
|
|
- ChangeRes();
|
|
|
|
- //_com.GetTransition("t0").Play(ChangeRes);
|
|
|
|
|
|
+ _com.GetTransition("t0").Play(ChangeRes);
|
|
|
|
+ // ChangeRes();
|
|
}
|
|
}
|
|
-
|
|
|
|
- private int index = 0;
|
|
|
|
-
|
|
|
|
|
|
+ // private void UpdateRes()
|
|
|
|
+ // {
|
|
|
|
+ // Timers.inst.StartCoroutine(ChangeRes());
|
|
|
|
+ // }
|
|
private void ChangeRes()
|
|
private void ChangeRes()
|
|
{
|
|
{
|
|
UI_ComModel _comModel = UI_ComModel.Proxy(_com);
|
|
UI_ComModel _comModel = UI_ComModel.Proxy(_com);
|
|
-
|
|
|
|
- UI_ComModelRes comRes = _comModel.m_comModelRes;
|
|
|
|
_comModel.m_loaBg.url = ResPathUtil.GetBgImgPath(_luckyBoxCfg.bgResArr[_bgIndex]);
|
|
_comModel.m_loaBg.url = ResPathUtil.GetBgImgPath(_luckyBoxCfg.bgResArr[_bgIndex]);
|
|
if (_luckyBoxCfg.resArr.Length > 0)
|
|
if (_luckyBoxCfg.resArr.Length > 0)
|
|
{
|
|
{
|
|
int direction = _luckyBoxCfg.scaleArr[_modelIndex] >= 0 ? 1 : -1;
|
|
int direction = _luckyBoxCfg.scaleArr[_modelIndex] >= 0 ? 1 : -1;
|
|
float scale = _luckyBoxCfg.scaleArr.Length > 0 ? Math.Abs(_luckyBoxCfg.scaleArr[_modelIndex]) / 10000f : 1;
|
|
float scale = _luckyBoxCfg.scaleArr.Length > 0 ? Math.Abs(_luckyBoxCfg.scaleArr[_modelIndex]) / 10000f : 1;
|
|
- comRes.m_loaRes.url = string.Format("ui://LuckyBox/{0}", _luckyBoxCfg.resArr[_modelIndex]);
|
|
|
|
- comRes.m_loaRes.SetPosition(_luckyBoxCfg.posArr[_modelIndex][0], _luckyBoxCfg.posArr[_modelIndex][1], 1);
|
|
|
|
- comRes.m_loaRes.SetScale(direction * scale, scale);
|
|
|
|
|
|
+ _comModel.m_comModelRes.m_loaRes.url = string.Format("ui://LuckyBox/{0}", _luckyBoxCfg.resArr[_modelIndex]);
|
|
|
|
+ _comModel.m_comModelRes.m_loaRes.SetPosition(_luckyBoxCfg.posArr[_modelIndex][0], _luckyBoxCfg.posArr[_modelIndex][1], 1);
|
|
|
|
+ _comModel.m_comModelRes.m_loaRes.SetScale(direction * scale, scale);
|
|
}
|
|
}
|
|
else if (_luckyBoxCfg.suitIdArr.Length > 0)
|
|
else if (_luckyBoxCfg.suitIdArr.Length > 0)
|
|
{
|
|
{
|
|
@@ -96,24 +81,27 @@ namespace GFGGame
|
|
if (_luckyBoxCfg.isAni == 0)
|
|
if (_luckyBoxCfg.isAni == 0)
|
|
{
|
|
{
|
|
SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_luckyBoxCfg.suitIdArr[_modelIndex]);
|
|
SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_luckyBoxCfg.suitIdArr[_modelIndex]);
|
|
- comRes.m_loaRes.url = ResPathUtil.GetDressUpPath(suitCfg.aniRes);
|
|
|
|
|
|
+ _comModel.m_comModelRes.m_loaRes.url = ResPathUtil.GetDressUpPath(suitCfg.aniRes);
|
|
|
|
+
|
|
float scale = _luckyBoxCfg.scaleArr.Length > 0 ? Math.Abs(_luckyBoxCfg.scaleArr[_modelIndex]) / 10000f : 1;
|
|
float scale = _luckyBoxCfg.scaleArr.Length > 0 ? Math.Abs(_luckyBoxCfg.scaleArr[_modelIndex]) / 10000f : 1;
|
|
- comRes.m_loaRes.SetScale(direction * scale, scale);
|
|
|
|
- comRes.m_loaRes.SetPosition(_luckyBoxCfg.posArr[_modelIndex][0], _luckyBoxCfg.posArr[_modelIndex][1], 1);
|
|
|
|
|
|
+ _comModel.m_comModelRes.m_loaRes.SetScale(direction * scale, scale);
|
|
|
|
+ _comModel.m_comModelRes.m_loaRes.SetPosition(_luckyBoxCfg.posArr[_modelIndex][0], _luckyBoxCfg.posArr[_modelIndex][1], 1);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- comRes = (index == 0 ? _comModel.m_comModelRes : _comModel.m_comModelRes2);
|
|
|
|
- int scale = _luckyBoxCfg.scaleArr.Length > 0 ? Math.Abs(_luckyBoxCfg.scaleArr[_modelIndex]) / 10000 : 100;
|
|
|
|
|
|
+ _comModel.m_comModelRes.m_loaRes.url = "";
|
|
_comModel.m_loaMask.alpha = 1;
|
|
_comModel.m_loaMask.alpha = 1;
|
|
- comRes.m_loaRes.url = "";
|
|
|
|
- _dressUpObjUIs[index].UpdateWrapper(comRes.m_holder);
|
|
|
|
- comRes.m_holder.SetPosition(_luckyBoxCfg.posArr[_modelIndex][0], _luckyBoxCfg.posArr[_modelIndex][1], 1);
|
|
|
|
- _dressUpObjUIs[index].ResetSceneObj(scale, false, false, null, false);
|
|
|
|
- _dressUpObjUIs[index].dressUpObj.PutOnSuitCfg(_luckyBoxCfg.suitIdArr[_modelIndex], true, new int[] { ConstDressUpItemType.BEI_JING }, false, false);
|
|
|
|
- _dressUpObjUIs[index].sceneObject.transform.localScale = new Vector3(direction * scale, scale, scale);
|
|
|
|
|
|
+ // yield return null;
|
|
|
|
+ int scale = _luckyBoxCfg.scaleArr.Length > 0 ? Math.Abs(_luckyBoxCfg.scaleArr[_modelIndex]) / 10000 : 100;
|
|
|
|
+ _dressUpObjUI.ResetSceneObj(scale, false, false, null, false);
|
|
|
|
+ _dressUpObjUI.dressUpObj.PutOnSuitCfg(_luckyBoxCfg.suitIdArr[_modelIndex], true, new int[] { ConstDressUpItemType.BEI_JING }, false, false);
|
|
|
|
+ _dressUpObjUI.UpdateWrapper(_comModel.m_comModelRes.m_holder);
|
|
|
|
+ _dressUpObjUI.sceneObject.transform.localScale = new Vector3(direction * scale, scale, scale);
|
|
|
|
+ _comModel.m_comModelRes.m_holder.SetPosition(_luckyBoxCfg.posArr[_modelIndex][0], _luckyBoxCfg.posArr[_modelIndex][1], 1);
|
|
|
|
+ // yield return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ _comModel.m_t1.Play();
|
|
UI_ComModel.ProxyEnd();
|
|
UI_ComModel.ProxyEnd();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -121,7 +109,7 @@ namespace GFGGame
|
|
{
|
|
{
|
|
_bgIndex = 0;
|
|
_bgIndex = 0;
|
|
_modelIndex = 0;
|
|
_modelIndex = 0;
|
|
- _dressUpObjUI.dressUpObj.TakeOffAll();
|
|
|
|
|
|
+ _dressUpObjUI.ResetSceneObj(0, false, false, null, false);
|
|
UI_ComModel _comModel = UI_ComModel.Proxy(_com);
|
|
UI_ComModel _comModel = UI_ComModel.Proxy(_com);
|
|
_comModel.m_comModelRes.m_loaRes.url = "";
|
|
_comModel.m_comModelRes.m_loaRes.url = "";
|
|
UI_ComModel.ProxyEnd();
|
|
UI_ComModel.ProxyEnd();
|
|
@@ -136,94 +124,5 @@ namespace GFGGame
|
|
_dressUpObjUI = null;
|
|
_dressUpObjUI = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- private void UpdateIndex()
|
|
|
|
- {
|
|
|
|
- index ^= 1;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private CubismRenderController[] cubismModels;
|
|
|
|
- private List<SpriteRenderer> spriteRenderers = new List<SpriteRenderer>();
|
|
|
|
- private void InitModel()
|
|
|
|
- {
|
|
|
|
- Transform model = _dressUpObjUIs[index].sceneObject.transform.Find("Role");
|
|
|
|
- cubismModels = model.GetComponentsInChildren<CubismRenderController>();
|
|
|
|
- spriteRenderers = new List<SpriteRenderer>(model.GetComponentsInChildren<SpriteRenderer>());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void ShowModel()
|
|
|
|
- {
|
|
|
|
- //InitModel();
|
|
|
|
- int temp = 1 - index;
|
|
|
|
- if (_dressUpObjUIs[temp].sceneObject == null)
|
|
|
|
- {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- Transform model = _dressUpObjUIs[temp].sceneObject.transform.Find("Role");
|
|
|
|
- cubismModels = model.GetComponentsInChildren<CubismRenderController>();
|
|
|
|
- spriteRenderers = new List<SpriteRenderer>(model.GetComponentsInChildren<SpriteRenderer>());
|
|
|
|
- //ChangeModelAlphaAnim(0, 1);
|
|
|
|
- ChangeModelAlpha(1);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void HideModel()
|
|
|
|
- {
|
|
|
|
- ShowModel();
|
|
|
|
- InitModel();
|
|
|
|
- ChangeModelAlphaAnim(1, 0, ChangeComResLayer);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void ChangeComResLayer()
|
|
|
|
- {
|
|
|
|
- UI_ComModel _comModel = UI_ComModel.Proxy(_com);
|
|
|
|
- int index = _comModel.target.GetChildIndex(_comModel.m_comModelRes.target);
|
|
|
|
- int index2 = _comModel.target.GetChildIndex(_comModel.m_comModelRes2.target);
|
|
|
|
- _comModel.target.SetChildIndex(_comModel.m_comModelRes.target, index2);
|
|
|
|
- _comModel.target.SetChildIndex(_comModel.m_comModelRes2.target, index);
|
|
|
|
-
|
|
|
|
- UI_ComModel.ProxyEnd();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void ChangeModelAlpha(float value)
|
|
|
|
- {
|
|
|
|
- for (int j = 0; j < cubismModels.Length; j++)
|
|
|
|
- {
|
|
|
|
- cubismModels[j].Opacity = value;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (int i = 0; i < spriteRenderers.Count; i++)
|
|
|
|
- {
|
|
|
|
- if (spriteRenderers[i] == null)
|
|
|
|
- {
|
|
|
|
- spriteRenderers.RemoveAt(i);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- Color color = spriteRenderers[i].color;
|
|
|
|
- color.a = value;
|
|
|
|
- spriteRenderers[i].color = color;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void ChangeModelAlphaAnim(float start, float end, Action action = null)
|
|
|
|
- {
|
|
|
|
- Ease ease = start < end ? Ease.InQuad : Ease.OutQuad;
|
|
|
|
- DOTween.To(() => start, (value) =>
|
|
|
|
- {
|
|
|
|
- ChangeModelAlpha(value);
|
|
|
|
- }, end, 1f).SetEase(ease).OnComplete(() =>
|
|
|
|
- {
|
|
|
|
- action?.Invoke();
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void InitDressUpObj()
|
|
|
|
- {
|
|
|
|
- UI_ComModel _comModel = UI_ComModel.Proxy(_com);
|
|
|
|
-
|
|
|
|
- _dressUpObjUI.UpdateWrapper(_comModel.m_comModelRes.m_holder);
|
|
|
|
- _dressUpObjUI2.UpdateWrapper(_comModel.m_comModelRes2.m_holder);
|
|
|
|
-
|
|
|
|
- UI_ComModel.ProxyEnd();
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|