825 lines
20 KiB
C#
825 lines
20 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BehaviorDesigner.Runtime.Tasks.Unity.UnityGameObject;
|
|
using cfg.CharacterCfg;
|
|
using cfg.ShowCfg;
|
|
using Cysharp.Threading.Tasks;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.UIElements;
|
|
using Button = UnityEngine.UI.Button;
|
|
using Image = UnityEngine.UI.Image;
|
|
using Toggle = UnityEngine.UI.Toggle;
|
|
using ScrollView = PhxhSDK.PhxhScrollView;
|
|
using Framework;
|
|
using Gameplay;
|
|
using Gameplay.SubSystems;
|
|
using PhxhSDK;
|
|
|
|
public class UICameraAndPosterChangeController : UIWindow
|
|
{
|
|
//UI GameObj
|
|
///Auto Gen Start///
|
|
public Image Image_CBG;
|
|
public Button Button_Back;
|
|
public TMP_Text Text_Back;
|
|
public Button Button_Home;
|
|
public Button Button_Scene01;
|
|
public Button Button_Scene02;
|
|
public Image Image_View01;
|
|
public Image Image_View02;
|
|
public Image Image_View03;
|
|
public TMP_Text Text_ChangeThisScene;
|
|
public Button Button_Scene03;
|
|
public Button Button_Scene04;
|
|
public Button Button_Confirm;
|
|
public TMP_Text Text_BtnConfirm;
|
|
public Button Button_Cancel;
|
|
public Button Button_ChangePoster;
|
|
public TMP_Text Text_ChangePoster;
|
|
public Button Button_ChangeScene;
|
|
public TMP_Text Text_ChangeScene;
|
|
public Image Image_Menu;
|
|
public Button Button_Rarity;
|
|
public TMP_Text Text_Rarity;
|
|
public TMP_Text Text_RaritySelect;
|
|
public Button Button_Level;
|
|
public TMP_Text Text_Lv;
|
|
public TMP_Text Text_LvSelect;
|
|
public Image Image_Lv;
|
|
public Image Image_Down1;
|
|
public Button Button_AdvanceLevel;
|
|
public TMP_Text Text_AdvSelect;
|
|
public TMP_Text Text_Advance;
|
|
public Image Image_Down2;
|
|
public TMP_Dropdown Dropdown_ChangeLevel;
|
|
public TMP_Text Text_Profession;
|
|
public Button Button_Confirm01;
|
|
public TMP_Text Text_Confirm;
|
|
public Button Button_Cancel01;
|
|
|
|
///Auto Gen End///
|
|
|
|
//test data
|
|
private List<string> _testImgList = new()
|
|
{
|
|
"Assets/Art/UI/Texture/CameraChange/NewCameraChange/UI_Pic01.png",
|
|
"Assets/Art/UI/Texture/CameraChange/NewCameraChange/UI_Pic02.png",
|
|
"Assets/Art/UI/Texture/CameraChange/NewCameraChange/UI_Pic03.png",
|
|
"Assets/Art/UI/Texture/CameraChange/NewCameraChange/UI_Pic04.png",
|
|
};
|
|
|
|
private enum PageEnum
|
|
{
|
|
Scene,
|
|
Poster
|
|
}
|
|
|
|
private enum SortType
|
|
{
|
|
Rarity,
|
|
Level,
|
|
Likely
|
|
}
|
|
|
|
private PageEnum _curPage = PageEnum.Poster;//当前切页
|
|
private GameObject _sceneObj;
|
|
private GameObject _posterObj;
|
|
|
|
//场景切换页面
|
|
private ScrollRect _sceneScrollRect;
|
|
private GameObject _sceneScrollContent;
|
|
//场景滑动列表相关
|
|
private List<float> _itemPosYList;
|
|
private List<GameObject> _sceneItemList;
|
|
private int _curSceneIndex;
|
|
private int _curCameraPosIdx;
|
|
private float _scrollMidPosY;
|
|
|
|
private RectTransform _itemFullRectTrans;
|
|
private RectTransform _itemRectTrans;
|
|
|
|
//立绘切换页面
|
|
private ScrollView _scrollPosterPool;
|
|
private ScrollView _scrollSkin;
|
|
|
|
private List<uint> _charIDList;
|
|
private List<uint> _displayIDList;
|
|
private int _curSelect; //当前选择的角色
|
|
private int _curSelectSkin; //当前选择的皮肤
|
|
private List<DataCharacterSkin> _skinDataList; //当前选择角色的皮肤列表
|
|
|
|
private MainPanelSceneStoreData _saveData;
|
|
|
|
// deal with input data
|
|
public override void PreLoad(object data = null)
|
|
{
|
|
|
|
}
|
|
|
|
// Use this for initialization
|
|
public override void OnInit()
|
|
{
|
|
//bind UI GameObj
|
|
UICameraAndPosterChangeBinder.GetComponents(this);
|
|
|
|
_sceneObj = FindObj("ImageBG/SceneChange");
|
|
_posterObj = FindObj("ImageBG/PosterChange");
|
|
_sceneScrollRect = GetComponent<ScrollRect>("ImageBG/SceneChange/SceneScrollView");
|
|
_sceneScrollContent = CommonUtils.GetGameObject(_sceneScrollRect.gameObject,"Viewport/Content");
|
|
|
|
_sceneItemList = new List<GameObject>();
|
|
_itemPosYList = new List<float>();
|
|
for (int i = 0; i < _sceneScrollContent.transform.childCount; i++)
|
|
{
|
|
var item = _sceneScrollContent.transform.GetChild(i);
|
|
_sceneItemList.Add(item.gameObject);
|
|
}
|
|
|
|
_scrollMidPosY = -_sceneScrollRect.GetComponent<RectTransform>().rect.height * 0.5f;
|
|
_itemRectTrans = CommonUtils.GetComponent<RectTransform>(_sceneItemList[0], "ButtonScene");
|
|
_itemFullRectTrans = CommonUtils.GetComponent<RectTransform>(_sceneItemList[0], "ButtonSceneFull");
|
|
|
|
_scrollPosterPool = GetComponent<ScrollView>("ImageBG/PosterChange/ChangeHeadPic/PosterScrollView");
|
|
_scrollSkin = GetComponent<ScrollView>("ImageBG/PosterChange/ChangeSkin/SkinScrollView");
|
|
|
|
_charIDList = new List<uint>();
|
|
var charList = CharacterDataInfoManager.Instance.DataList;
|
|
for (int i = 0; i < charList.Count; i++)
|
|
{
|
|
_charIDList.Add(charList[i].Uid);
|
|
}
|
|
|
|
_sceneScrollRect.onValueChanged.AddListener(_OnScrollViewValChange);
|
|
|
|
BindButton(Button_Back, _OnClickClose);
|
|
BindButton(Button_ChangePoster, _OnClickPosterTab);
|
|
BindButton(Button_ChangeScene, _OnClickSceneTab);
|
|
BindButton(Button_Confirm, _OnClickSceneConfirm);
|
|
BindButton(Button_Confirm01, _OnClickPosterConfirm);
|
|
}
|
|
|
|
//invoke when open window
|
|
protected override void OnShowWindow(object data = null)
|
|
{
|
|
_InitSceneScroll();
|
|
_InitPosterScroll();
|
|
_Refresh();
|
|
}
|
|
|
|
|
|
//invoke when reload window
|
|
protected override void OnReloadWindow(object data = null)
|
|
{
|
|
|
|
}
|
|
|
|
//invoke when close window
|
|
protected override void OnHideWindow()
|
|
{
|
|
|
|
}
|
|
|
|
//invoke when destroy
|
|
public override void OnRelease()
|
|
{
|
|
base.OnRelease();
|
|
_sceneItemList.Clear();
|
|
_itemPosYList.Clear();
|
|
}
|
|
|
|
#region #Event Function
|
|
|
|
protected override void OnUpdate()
|
|
{
|
|
base.OnUpdate();
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 刷新界面
|
|
/// </summary>
|
|
#region RefreshPanel
|
|
|
|
private void _Refresh()
|
|
{
|
|
_RefreshTab();
|
|
}
|
|
|
|
private void _RefreshTab()
|
|
{
|
|
switch (_curPage)
|
|
{
|
|
case PageEnum.Scene:
|
|
{
|
|
Button_ChangePoster.gameObject.SetActive(false);
|
|
Button_ChangeScene.gameObject.SetActive(true);
|
|
_sceneObj.SetActive(true);
|
|
_posterObj.SetActive(false);
|
|
Image_CBG.gameObject.SetActive(false);
|
|
break;
|
|
}
|
|
case PageEnum.Poster:
|
|
{
|
|
Button_ChangePoster.gameObject.SetActive(true);
|
|
Button_ChangeScene.gameObject.SetActive(false);
|
|
_sceneObj.SetActive(false);
|
|
_posterObj.SetActive(true);
|
|
Image_CBG.gameObject.SetActive(true);
|
|
_RefreshPosterButton();
|
|
break;
|
|
}
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void _RefreshPanel()
|
|
{
|
|
|
|
}
|
|
|
|
#region DropDown
|
|
|
|
private void _DropDown()
|
|
{
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 更换场景
|
|
/// </summary>
|
|
#region ScenePage
|
|
|
|
private void _RefreshScenePage()
|
|
{
|
|
_RefreshSceneListView();
|
|
}
|
|
|
|
private void _RefreshSceneButtons()
|
|
{
|
|
if (_saveData != null)
|
|
{
|
|
if (_curSceneIndex == _saveData.SceneIdx && _curCameraPosIdx == _saveData.CameraPosIdx)
|
|
{
|
|
Button_Confirm.gameObject.SetActive(false);
|
|
Button_Cancel.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
Button_Confirm.gameObject.SetActive(true);
|
|
Button_Cancel.gameObject.SetActive(false);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
var storeData = StorageMgr.Instance.GetStorage<MainPanelSceneStoreData>("MainPanelSceneStoreData");
|
|
if (storeData != null)
|
|
{
|
|
if (_curSceneIndex == storeData.SceneIdx && _curCameraPosIdx == storeData.CameraPosIdx)
|
|
{
|
|
Button_Confirm.gameObject.SetActive(false);
|
|
Button_Cancel.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
Button_Confirm.gameObject.SetActive(true);
|
|
Button_Cancel.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void _RefreshSceneListView()
|
|
{
|
|
if(_sceneScrollContent)
|
|
{
|
|
_InitSceneScroll();
|
|
}
|
|
|
|
_RefreshSceneScroll();
|
|
}
|
|
|
|
private void _RefreshSceneScroll()
|
|
{
|
|
for (int i = 0; i < _sceneItemList.Count; i++)
|
|
{
|
|
var item = _sceneItemList[i];
|
|
_RefreshSingleItem(item, i);
|
|
}
|
|
|
|
_RefreshSceneButtons();
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(_sceneScrollContent.GetComponent<RectTransform>());
|
|
}
|
|
|
|
private void _RefreshSingleItem(GameObject go, int index)
|
|
{
|
|
var btnScene = CommonUtils.GetComponent<Button>(go, "ButtonScene");
|
|
var btnFull = CommonUtils.GetComponent<Button>(go, "ButtonSceneFull");
|
|
|
|
List<Button> btnViewList = new List<Button>();
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
var btn = CommonUtils.GetComponent<Button>(go, "ButtonSceneFull/ImageView" + i);
|
|
btnViewList.Add(btn);
|
|
}
|
|
|
|
if (_curSceneIndex == index)
|
|
{
|
|
btnFull.gameObject.SetActive(true);
|
|
btnScene.gameObject.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
btnScene.gameObject.SetActive(true);
|
|
btnFull.gameObject.SetActive(false);
|
|
}
|
|
|
|
for (int i = 0; i < btnViewList.Count; i++)
|
|
{
|
|
var imgSelect = CommonUtils.GetGameObject(btnViewList[i].gameObject, "ImageYellow");
|
|
var imgGray = CommonUtils.GetGameObject(btnViewList[i].gameObject, "ImageGrey");
|
|
|
|
imgSelect.SetActive(_curCameraPosIdx == i);
|
|
imgGray.SetActive(_curCameraPosIdx != i);
|
|
|
|
ClearBind(btnViewList[i]);
|
|
|
|
BindButton(btnViewList[i], _OnClickCameraPos, i);
|
|
}
|
|
|
|
}
|
|
|
|
private void _RefreshItemView(GameObject go)
|
|
{
|
|
List<GameObject> goViewList = new List<GameObject>();
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
var obj = CommonUtils.GetGameObject(go, "ButtonSceneFull/ImageView" + i);
|
|
goViewList.Add(obj);
|
|
}
|
|
|
|
for (int i = 0; i < goViewList.Count; i++)
|
|
{
|
|
var imgSelect = CommonUtils.GetGameObject(goViewList[i], "ImageYellow");
|
|
var imgGray = CommonUtils.GetGameObject(goViewList[i], "ImageGrey");
|
|
|
|
imgSelect.SetActive(_curCameraPosIdx == i);
|
|
imgGray.SetActive(_curCameraPosIdx != i);
|
|
}
|
|
}
|
|
|
|
private void _OnScrollViewValChange(Vector2 pos)
|
|
{
|
|
var curIndex = GetClosestIdx();
|
|
if (curIndex == _curSceneIndex)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_curSceneIndex = curIndex;
|
|
_curCameraPosIdx = 0;
|
|
_SetPosYListData();
|
|
_RefreshSceneScroll();
|
|
}
|
|
|
|
private int GetClosestIdx()
|
|
{
|
|
int closest = _curSceneIndex;
|
|
|
|
var minDis = CommonUtils.GetComponent<RectTransform>(_sceneItemList[0], "ButtonScene").rect.height;
|
|
var maxDis = CommonUtils.GetComponent<RectTransform>(_sceneItemList[0], "ButtonSceneFull").rect.height;
|
|
for (int i = 0; i < _itemPosYList.Count; i++)
|
|
{
|
|
var verticalGroup = _sceneScrollRect.GetComponent<VerticalLayoutGroup>();
|
|
var contentOffset = _sceneScrollContent.GetComponent<RectTransform>().localPosition.y;
|
|
var start = contentOffset + _itemPosYList[i];
|
|
var end = start - minDis;
|
|
if (_curSceneIndex == i)
|
|
{
|
|
end = start - maxDis;
|
|
}
|
|
if (_scrollMidPosY < start && _scrollMidPosY > end)
|
|
{
|
|
//minDis = dis;
|
|
closest = i;
|
|
}
|
|
}
|
|
|
|
return closest;
|
|
}
|
|
|
|
private void _SetPosYListData()
|
|
{
|
|
_itemPosYList.Clear();
|
|
for (int i = 0; i < _sceneItemList.Count; i++)
|
|
{
|
|
var item = _sceneItemList[i];
|
|
var rectTrans = item.GetComponent<RectTransform>();
|
|
var posY = rectTrans.localPosition.y;
|
|
var contentPosY = _sceneScrollContent.GetComponent<RectTransform>().localPosition.y;
|
|
_itemPosYList.Add(posY);// - _itemRectTrans.rect.height);
|
|
}
|
|
}
|
|
|
|
private async void _InitSceneScroll()
|
|
{
|
|
var storeData = StorageMgr.Instance.GetStorage<MainPanelSceneStoreData>("MainPanelSceneStoreData");
|
|
_curSceneIndex = storeData.SceneIdx;
|
|
_curCameraPosIdx = storeData.CameraPosIdx;
|
|
_RefreshSceneScroll();
|
|
await UniTask.DelayFrame(1);
|
|
_SetPosYListData();
|
|
_RefreshSceneButtons();
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
/// 更换看板娘
|
|
/// </summary>
|
|
#region PosterPage
|
|
|
|
private void _RefreshPosterPage()
|
|
{
|
|
_CreatePoolScroll();
|
|
}
|
|
|
|
private void _InitPosterScroll()
|
|
{
|
|
_InitSelectCharacter();
|
|
_CreatePoolScroll();
|
|
_CreateSkinScroll();
|
|
_InitPosterImg();
|
|
}
|
|
|
|
private async void _InitPosterImg()
|
|
{
|
|
var posterPath = CommonUtils.GetCharacterPicPath((int)_charIDList[_curSelect],
|
|
CommonUtils.ECharacterPicPathType.Poster, _curSelectSkin + 1);
|
|
var posterSprite = await AssetManager.Instance.LoadAssetAsync<Sprite>(posterPath);
|
|
Image_CBG.sprite = posterSprite;
|
|
}
|
|
|
|
//右侧角色池列表
|
|
private void _CreatePoolScroll()
|
|
{
|
|
var content = CommonUtils.GetGameObject(_scrollPosterPool.gameObject, "Viewport/Content");
|
|
if (content)
|
|
{
|
|
CommonUtils.DestoryAllChildGameObject(content);
|
|
}
|
|
|
|
_RefreshPoolScroll();
|
|
}
|
|
|
|
private void _RefreshPoolScroll()
|
|
{
|
|
_scrollPosterPool.SetUpdateFunc(_RefreshPoolItem);
|
|
_scrollPosterPool.SetItemCountFunc(_GetPoolCountFunc);
|
|
_scrollPosterPool.UpdateData(false);
|
|
_scrollPosterPool.SetButton(_SetPoolItemButton);
|
|
}
|
|
|
|
private async void _RefreshPoolItem(int index, Transform item)
|
|
{
|
|
var go = item.gameObject;
|
|
var uid = _charIDList[index];
|
|
var headPicPath = CommonUtils.GetDefaultHeadPathByUid(uid);
|
|
|
|
var imgHead = CommonUtils.GetComponent<Image>(go, "ImageHead");
|
|
var btn = CommonUtils.GetComponent<Button>(go, "ImageHead");
|
|
var goSelect = CommonUtils.GetGameObject(go, "ImageHead/ImageChooseRect");
|
|
|
|
imgHead.sprite = await AssetManager.Instance.LoadAssetAsync<Sprite>(headPicPath);
|
|
goSelect.SetActive(_curSelect == index);
|
|
ClearBind(btn);
|
|
BindButton(btn, _OnClickPoolHeadItem, index);
|
|
|
|
go.SetActive(true);
|
|
}
|
|
|
|
private int _GetPoolCountFunc()
|
|
{
|
|
return _charIDList.Count;
|
|
}
|
|
|
|
private void _SetPoolItemButton(GameObject obj)
|
|
{
|
|
|
|
}
|
|
|
|
//左侧角色皮肤列表
|
|
private void _CreateSkinScroll()
|
|
{
|
|
var content = CommonUtils.GetGameObject(_scrollSkin.gameObject, "Viewport/Content");
|
|
if (content)
|
|
{
|
|
CommonUtils.DestoryAllChildGameObject(content);
|
|
}
|
|
|
|
_RefreshSkinScroll();
|
|
}
|
|
|
|
private void _RefreshSkinScroll()
|
|
{
|
|
_scrollSkin.SetUpdateFunc(_RefreshSkinItem);
|
|
_scrollSkin.SetItemCountFunc(_GetSkinItemFunc);
|
|
_scrollSkin.UpdateData(false);
|
|
_scrollSkin.SetButton(_SetSkinItemButton);
|
|
}
|
|
|
|
private async void _RefreshSkinItem(int index, Transform item)
|
|
{
|
|
var go = item.gameObject;
|
|
//var skinDataCfg = _skinDataList[index];
|
|
var posterPic =
|
|
CommonUtils.GetCharacterPicPath((int)_charIDList[_curSelect], CommonUtils.ECharacterPicPathType.Favorable, index + 1);
|
|
var imgSkin = CommonUtils.GetComponent<Image>(go, "ButtonChange/ImageSkin");
|
|
var imgSelect = CommonUtils.GetGameObject(go, "ButtonChange/ImageChooseRect");
|
|
var imgDoSelect = CommonUtils.GetGameObject(go, "ButtonChange/ImageCover");
|
|
var btn = CommonUtils.GetComponent<Button>(go, "ButtonChange");
|
|
|
|
imgSkin.sprite = await AssetManager.Instance.LoadAssetAsync<Sprite>(posterPic);
|
|
|
|
imgSelect.SetActive(_curSelectSkin == index);
|
|
imgDoSelect.SetActive(_curSelectSkin != index);
|
|
|
|
ClearBind(btn);
|
|
BindButton(btn, _OnClickSkinItem, index);
|
|
go.SetActive(true);
|
|
}
|
|
|
|
private int _GetSkinItemFunc()
|
|
{
|
|
return _skinDataList.Count;
|
|
}
|
|
|
|
private void _SetSkinItemButton(GameObject go)
|
|
{
|
|
|
|
}
|
|
|
|
private void _ChangeSelectCharacter(int index)
|
|
{
|
|
if (_curSelect == index)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_curSelect = index;
|
|
_curSelectSkin = 0;
|
|
_skinDataList = CommonUtils.GetCharacterSkinCfgList((int)_charIDList[_curSelect]);
|
|
}
|
|
|
|
private void _InitSelectCharacter()
|
|
{
|
|
var storeData =
|
|
StorageMgr.Instance.GetStorage<MainPanelSceneStoreData>("MainPanelSceneStoreData");
|
|
if (storeData != null)
|
|
{
|
|
_curSelect = GetPosterIndexByID(storeData.PosterID);
|
|
_curSelectSkin = storeData.PosterSkinIdx;
|
|
}
|
|
_skinDataList = CommonUtils.GetCharacterSkinCfgList((int)_charIDList[_curSelect]);
|
|
}
|
|
|
|
private int GetPosterIndexByID(int id)
|
|
{
|
|
var idx = _charIDList.IndexOf((uint)id);
|
|
if (idx < 0)
|
|
{
|
|
DebugUtil.LogError($"当前选择Poster Uid: {id}不在列表中!!!");
|
|
return 0;
|
|
}
|
|
|
|
return idx;
|
|
}
|
|
|
|
private void _RefreshPosterButton()
|
|
{
|
|
if (_saveData != null)
|
|
{
|
|
if (_curSelect == GetPosterIndexByID(_saveData.PosterID) && _curSelectSkin == _saveData.PosterSkinIdx)
|
|
{
|
|
Button_Confirm01.gameObject.SetActive(false);
|
|
Button_Cancel01.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
Button_Confirm01.gameObject.SetActive(true);
|
|
Button_Cancel01.gameObject.SetActive(false);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
var storeData = StorageMgr.Instance.GetStorage<MainPanelSceneStoreData>("MainPanelSceneStoreData");
|
|
if (storeData != null)
|
|
{
|
|
if (_curSelect == GetPosterIndexByID(storeData.PosterID) && _curSelectSkin == storeData.PosterSkinIdx)
|
|
{
|
|
Button_Confirm01.gameObject.SetActive(false);
|
|
Button_Cancel01.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
Button_Confirm01.gameObject.SetActive(true);
|
|
Button_Cancel01.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
|
|
#region ClickEvent
|
|
|
|
private void _OnClickClose()
|
|
{
|
|
_CheckAndSaveChange();
|
|
CloseWindow();
|
|
}
|
|
|
|
private void _OnClickSceneConfirm()
|
|
{
|
|
_ConfirmChangeMainScene();
|
|
}
|
|
|
|
private async void _OnClickPoolHeadItem(int index)
|
|
{
|
|
if (index != _curSelect)
|
|
{
|
|
_ChangeSelectCharacter(index);
|
|
_curSelect = index;
|
|
_curSelectSkin = 0;
|
|
_scrollPosterPool.UpdateData();
|
|
_scrollSkin.UpdateData();
|
|
_RefreshPosterButton();
|
|
|
|
var posterPath = CommonUtils.GetCharacterPicPath((int)_charIDList[_curSelect],
|
|
CommonUtils.ECharacterPicPathType.Poster, _curSelectSkin + 1);
|
|
var posterSprite = await AssetManager.Instance.LoadAssetAsync<Sprite>(posterPath);
|
|
Image_CBG.sprite = posterSprite;
|
|
}
|
|
}
|
|
|
|
private void _OnClickSkinItem(int index)
|
|
{
|
|
_curSelectSkin = index;
|
|
_RefreshPosterButton();
|
|
_scrollSkin.UpdateData();
|
|
}
|
|
|
|
private void _OnClickPosterConfirm()
|
|
{
|
|
_ConfirmChangePoster();
|
|
_RefreshPosterButton();
|
|
}
|
|
|
|
private void _OnClickPosterTab()
|
|
{
|
|
_curPage = PageEnum.Scene;
|
|
_RefreshTab();
|
|
}
|
|
|
|
private void _OnClickSceneTab()
|
|
{
|
|
_curPage = PageEnum.Poster;
|
|
_RefreshTab();
|
|
}
|
|
#endregion
|
|
|
|
private void _ConfirmChangeMainScene()
|
|
{
|
|
if (_saveData == null)
|
|
{
|
|
_saveData = new MainPanelSceneStoreData(_curSceneIndex, _curCameraPosIdx, (int)_charIDList[_curSelect], _curSelectSkin);
|
|
}
|
|
else
|
|
{
|
|
_saveData.SceneIdx = _curSceneIndex;
|
|
_saveData.CameraPosIdx = _curCameraPosIdx;
|
|
}
|
|
|
|
_RefreshSceneButtons();
|
|
}
|
|
|
|
private void _ConfirmChangePoster()
|
|
{
|
|
if (_saveData == null)
|
|
{
|
|
_saveData = new MainPanelSceneStoreData(_curSceneIndex, _curCameraPosIdx, (int)_charIDList[_curSelect], _curSelectSkin);
|
|
}
|
|
else
|
|
{
|
|
_saveData.PosterID = (int)_charIDList[_curSelect];
|
|
_saveData.PosterSkinIdx = _curSelectSkin;
|
|
}
|
|
|
|
_RefreshPosterButton();
|
|
}
|
|
|
|
private async void _CheckAndSaveChange()
|
|
{
|
|
var oldSaveData = StorageMgr.Instance.GetStorage<MainPanelSceneStoreData>("MainPanelSceneStoreData");
|
|
if (oldSaveData != null && _saveData != null)
|
|
{
|
|
if (CheckIsPosterChange(_saveData, oldSaveData))
|
|
{
|
|
oldSaveData.PosterID = _saveData.PosterID;
|
|
oldSaveData.PosterSkinIdx = _saveData.PosterSkinIdx;
|
|
await ShowManager.Instance.RefreshShow(E_ShowSceneType.Main);
|
|
EventManager.Instance.Send(EventManager.EventName.ChangeMainPanelPoster);
|
|
}
|
|
|
|
if (CheckIsSceneChange(_saveData, oldSaveData))
|
|
{
|
|
oldSaveData.SceneIdx = _saveData.SceneIdx;
|
|
oldSaveData.CameraPosIdx = _saveData.CameraPosIdx;
|
|
LoadingExecutorManager.Instance.ExecuteLoading(new MainSceneReLoadingExecutor());
|
|
}
|
|
StorageMgr.Instance.SyncForce = true;
|
|
}
|
|
}
|
|
|
|
private bool CheckIsSceneChange(MainPanelSceneStoreData newStoreData, MainPanelSceneStoreData oldStoreData)
|
|
{
|
|
if (newStoreData.SceneIdx != oldStoreData.SceneIdx)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool CheckIsPosterChange(MainPanelSceneStoreData newStoreData, MainPanelSceneStoreData oldStoreData)
|
|
{
|
|
if (newStoreData.PosterID != oldStoreData.PosterID)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (newStoreData.PosterSkinIdx != oldStoreData.PosterSkinIdx)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
private void _OnClickCameraPos(int index)
|
|
{
|
|
if (_curCameraPosIdx == index)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_curCameraPosIdx = index;
|
|
_RefreshItemView(_sceneItemList[_curSceneIndex]);
|
|
}
|
|
}
|
|
|
|
public class MainPanelSceneStoreData
|
|
{
|
|
public int SceneIdx = 0;
|
|
public int CameraPosIdx = 0;
|
|
public int PosterID = 0;
|
|
public int PosterSkinIdx = 0;
|
|
|
|
public MainPanelSceneStoreData()
|
|
{
|
|
|
|
}
|
|
|
|
public MainPanelSceneStoreData(int sceneIdx, int cameraPosIdx, int posterID, int posterSkinIdx)
|
|
{
|
|
SceneIdx = sceneIdx;
|
|
CameraPosIdx = cameraPosIdx;
|
|
if (posterID <= 0)
|
|
{
|
|
if (CharacterDataInfoManager.Instance.DataList.Count > 0)
|
|
{
|
|
PosterID = CharacterDataInfoManager.Instance.DataList[0].Cfg.RoleID;
|
|
}
|
|
else
|
|
{
|
|
DebugUtil.LogError("初始角色为空咯!!!请检查数据!!!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
PosterID = posterID;
|
|
}
|
|
|
|
PosterSkinIdx = posterSkinIdx;
|
|
}
|
|
}
|