关卡选择界面

This commit is contained in:
yangjing 2022-02-10 17:21:59 +08:00
parent aa28adf6b7
commit a426055616
22 changed files with 1992 additions and 562 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c5bfb2498e6764b8d93104b25bb17a6e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -271,12 +271,6 @@ Transform:
m_Father: {fileID: 493959136}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!224 &923398010 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
m_PrefabInstance: {fileID: 1549853548646788175}
m_PrefabAsset: {fileID: 0}
--- !u!1 &981190535
GameObject:
m_ObjectHideFlags: 0
@ -309,7 +303,7 @@ RectTransform:
- {fileID: 7676866811056894034}
- {fileID: 987875187}
- {fileID: 1714038173902949465}
- {fileID: 923398010}
- {fileID: 8174312654083100069}
m_Father: {fileID: 1041748534}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -538,195 +532,6 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1001 &1549853548646788175
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 981190536}
m_Modifications:
- target: {fileID: 1549853547539696658, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1549853547539696658, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchorMin.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1549853547539696658, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 69
objectReference: {fileID: 0}
- target: {fileID: 1549853547539696658, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -20
objectReference: {fileID: 0}
- target: {fileID: 1549853547584295392, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_SizeDelta.y
value: 40
objectReference: {fileID: 0}
- target: {fileID: 1549853548418705246, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1549853548418705246, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchorMin.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1549853548418705246, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 31
objectReference: {fileID: 0}
- target: {fileID: 1549853548418705246, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -20
objectReference: {fileID: 0}
- target: {fileID: 1549853549197227371, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1549853549197227371, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchorMin.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1549853549197227371, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 50
objectReference: {fileID: 0}
- target: {fileID: 1549853549197227371, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -20
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchorMax.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864438, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_Name
value: PanelLevel
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864438, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 30cc95837c5a74b1ca4757bb85a4abfa, type: 3}
--- !u!224 &1714038173902949465 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 539047986927620545, guid: 25cbbba289b6a49d6916bc6215534770,
@ -900,6 +705,11 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.x
value: 414
objectReference: {fileID: 0}
- target: {fileID: 5510529009573689666, guid: 841ca4be8d96342da81473d244f04f57,
type: 3}
propertyPath: m_Controller
value:
objectReference: {fileID: 9100000, guid: c5bfb2498e6764b8d93104b25bb17a6e, type: 2}
- target: {fileID: 6887168215451146749, guid: 841ca4be8d96342da81473d244f04f57,
type: 3}
propertyPath: m_AnchorMax.y
@ -1068,6 +878,141 @@ RectTransform:
type: 3}
m_PrefabInstance: {fileID: 1969282075732289138}
m_PrefabAsset: {fileID: 0}
--- !u!224 &8174312654083100069 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
m_PrefabInstance: {fileID: 8225385738963814813}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &8225385738963814813
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 981190536}
m_Modifications:
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchorMax.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864437, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864438, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_Name
value: PanelLevel
objectReference: {fileID: 0}
- target: {fileID: 1549853549434864438, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7274106814343902015, guid: 30cc95837c5a74b1ca4757bb85a4abfa,
type: 3}
propertyPath: m_SizeDelta.y
value: 40
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 30cc95837c5a74b1ca4757bb85a4abfa, type: 3}
--- !u!1001 &9049642900195122466
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -27,6 +27,7 @@ public class LevelData
{
int tEndingID = -1;
//first check accurately
for (int i = 0; i < Endings.Count; i++)
{
if (Endings[i].IsMatching(pEndingStr))
@ -36,6 +37,19 @@ public class LevelData
}
}
//if no match,check with X
if (tEndingID == -1)
{
for (int i = 0; i < Endings.Count; i++)
{
if (Endings[i].IsMatching(pEndingStr, true))
{
tEndingID = i;
break;
}
}
}
return tEndingID;
}
}
@ -47,13 +61,18 @@ public class EndingData
public bool IsGoodEnding;
public string EndingCode;//eg: 12X;132;
public bool IsMatching(string pEndingStr)
public bool IsMatching(string pEndingStr, bool pWithX = false)
{
bool tMatching = false;
string[] tTemplateEndingStrs = EndingCode.Split(';');
for (int i = 0; i < tTemplateEndingStrs.Length; i++)
{
if ((pWithX && !tTemplateEndingStrs[i].Contains("X")) || (!pWithX && tTemplateEndingStrs[i].Contains("X")))
{
continue;
}
if (CompareEndingStr(pEndingStr, tTemplateEndingStrs[i]))
{
tMatching = true;

View File

@ -37,5 +37,10 @@ public partial class Const
string tLevelIDStr = (pLevelID + 1).ToString().PadLeft(3, '0');
return string.Format("Audio/GameSound/{0}/{1}", tLevelIDStr, tLevelIDStr + "_" + (pSoundIndex + 1).ToString());
}
public static string GetNumPicA(string pNum)
{
return string.Format("Image/NumPic/NumA_{0}", pNum);
}
}
}

View File

@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ImageNum : MonoBehaviour
{
[SerializeField] Image mImgOnes;
[SerializeField] Image mImgTens;
[SerializeField] Image mImgHundreds;
public void SetNum(int pNum)
{
pNum = pNum % 1000;
string tNumStr = pNum.ToString().PadLeft(3, '0');
mImgHundreds.sprite = ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetNumPicA(tNumStr[0].ToString()));
mImgTens.sprite = ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetNumPicA(tNumStr[1].ToString()));
mImgOnes.sprite = ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetNumPicA(tNumStr[2].ToString()));
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e5684c0a0e8754b99bc58afde52624b3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,18 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LevelCell : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6aae01851068f446fb96764f7b0852bd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,51 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LevelCell : UIListCell
{
public Action<int> DelClick;
[SerializeField] Button mBtnBg;
[SerializeField] ImageNum mInmLevel;
[SerializeField] Image mImgIconBg;
[SerializeField] Image mImgIcon;
[SerializeField] GameObject mGobDone;
[SerializeField] GameObject mGobComplete;
[SerializeField] Image mImgProgress;
private int mLevelID;
private void Awake()
{
UIUtils.BindBtn(mBtnBg, OnClick);
}
public void Init()
{
mLevelID = GameConfig.Instance.LevelSort[mIndex];
LevelData tLvData = GameConfig.Instance.GetLevelData(mLevelID);
mInmLevel.SetNum(mIndex + 1);
if (ColorUtility.TryParseHtmlString(tLvData.LevelColorCode, out Color tBgColor))
{
mImgIconBg.color = tBgColor;
}
mImgIcon.sprite = ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetLevelIconSmall(mLevelID));
int tUnlockedEndingCount = PlayerData.Instance.EndingCountOfLevel(mLevelID);
bool tIsAllEndingsDone = tUnlockedEndingCount == tLvData.Endings.Count;
mGobDone.SetActive(tIsAllEndingsDone);
mGobComplete.SetActive(tIsAllEndingsDone);
mImgProgress.fillAmount = (float)tUnlockedEndingCount / tLvData.Endings.Count;
}
private void OnClick()
{
DelClick?.Invoke(mIndex);
}
}

View File

@ -0,0 +1,28 @@
using System.Collections;
using System;
using System.Collections.Generic;
using UnityEngine;
public class LevelList : UIListView<LevelCell>
{
public Action<int> DelClickLevel;
public override int Count
{
get
{
return PlayerData.Instance.UnlockedLevel;
}
}
protected override void ConfigCell(LevelCell pCell)
{
pCell.Init();
pCell.DelClick = OnClickLevel;
}
private void OnClickLevel(int pLevelIndex)
{
DelClickLevel?.Invoke(pLevelIndex);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2a46c284f255c46569f976045d5ccae9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -89,7 +89,8 @@ public class PanelGame : BasePanel
private void OnClickLevel()
{
PanelLevel tUILevel = UIManager.Instance.OpenUI<PanelLevel>();
tUILevel.Init(true);
}
private void OnClickMenu()
@ -121,7 +122,7 @@ public class PanelGame : BasePanel
mAtrAction.gameObject.SetActive(true);
mAtrAction.Play("Action");
TimerManager.Instance.Schedule(StartPlay, 1.5f);
TimerManager.Instance.Schedule(StartPlay, 2f);
}
private void StartPlay()

View File

@ -1,8 +1,52 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PanelLevel : BasePanel
{
[SerializeField] Button mBtnBack;
[SerializeField] Button mBtnBackToMain;
[SerializeField] LevelList mLvList;
private bool mOpenInLevel = false;
private void Awake()
{
UIUtils.BindBtn(mBtnBack, Close);
UIUtils.BindBtn(mBtnBackToMain, OnClickBackToMain);
mLvList.DelClickLevel = OnClickLevel;
}
protected override void OnOpen()
{
base.OnOpen();
mLvList.LoadData();
}
public void Init(bool pOpenInLevel)
{
mOpenInLevel = pOpenInLevel;
mBtnBackToMain.gameObject.SetActive(pOpenInLevel);
}
private void OnClickLevel(int pLevelIndex)
{
if (mOpenInLevel && PlayerData.Instance.CurrentLevel == (pLevelIndex + 1))
{
Close();
}
else
{
PlayerData.Instance.CurrentLevel = pLevelIndex + 1;
GameManager.Instance.LoadGame();
}
}
private void OnClickBackToMain()
{
GameManager.Instance.LoadMain();
}
}

View File

@ -65,7 +65,8 @@ public class PanelResult : BasePanel
private void OnClickChoose()
{
PanelLevel tUILevel = UIManager.Instance.OpenUI<PanelLevel>();
tUILevel.Init(true);
}
private void OnClickEndings()

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 295cb5ee3c53041c2bb000090add301b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UIListCell : MonoBehaviour
{
public int Index => mIndex;
protected int mIndex;
public void SetIndex(int pIndex)
{
mIndex = pIndex;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c862f27d824654b41bea209813d96ac1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,80 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class UIListView<T> : MonoBehaviour, IListView where T : UIListCell
{
public abstract int Count
{
get;
}
[SerializeField] GameObject mTplCell;
[SerializeField] Transform mCtnCells;
protected List<T> mCellList;
public virtual void Show(bool pShow)
{
gameObject.SetActive(pShow);
}
public virtual void LoadData()
{
if (mCellList == null)
{
mCellList = new List<T>();
}
for (int i = 0; i < Count; i++)
{
T tCell = null;
if (i < mCellList.Count)
{
tCell = mCellList[i];
}
else
{
tCell = SpawnCell();
mCellList.Add(tCell);
}
tCell.gameObject.SetActive(true);
tCell.SetIndex(i);
ConfigCell(tCell);
}
HideUnused();
}
public virtual void ClearSelection()
{
}
protected abstract void ConfigCell(T pCell);
private T SpawnCell()
{
GameObject tCellOb = Instantiate(mTplCell, mCtnCells);
tCellOb.transform.localScale = Vector3.one;
return tCellOb.GetComponent<T>();
}
private void HideUnused()
{
for (int i = Count; i < mCellList.Count; i++)
{
mCellList[i].gameObject.SetActive(false);
}
}
}
public interface IListView
{
void Show(bool pShow);
void LoadData();
void ClearSelection();
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 127f5e3ec25fd45ef9877982381e48d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: