Update level select menu with icons and scrollable view
This commit is contained in:
8
Assets/Art/Sprites/DRIcons.meta
Normal file
8
Assets/Art/Sprites/DRIcons.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f6f72f272957b4439cbaf4e18106470
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -16,3 +16,5 @@ MonoBehaviour:
|
||||
targetMinigameSceneName: DivingForPictures
|
||||
description: Level loading for Quarry
|
||||
mapSprite: {fileID: -3645797367086948227, guid: fea1a8662ef819746b8073c9ba0d9047, type: 3}
|
||||
menuSprite: {fileID: 0}
|
||||
minigameMenuSprite: {fileID: 6579828237621196356, guid: 7031dc4d177f92b4f970e104cdd6de51, type: 3}
|
||||
|
||||
BIN
Assets/External/Placeholders/refresh-arrow.png
vendored
Normal file
BIN
Assets/External/Placeholders/refresh-arrow.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
195
Assets/External/Placeholders/refresh-arrow.png.meta
vendored
Normal file
195
Assets/External/Placeholders/refresh-arrow.png.meta
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d084ac2438d6f9448c61a62639581ba
|
||||
TextureImporter:
|
||||
internalIDToNameTable:
|
||||
- first:
|
||||
213: -1083306995931140661
|
||||
second: refresh-arrow_0
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 2
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: iOS
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: WindowsStoreApps
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites:
|
||||
- serializedVersion: 2
|
||||
name: refresh-arrow_0
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 464
|
||||
height: 463
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
customData:
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: -1
|
||||
bones: []
|
||||
spriteID: bcd24dcd60257f0f0800000000000000
|
||||
internalID: -1083306995931140661
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable:
|
||||
refresh-arrow_0: -1083306995931140661
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -178,13 +178,49 @@ PrefabInstance:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 1936850923066780126, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
- target: {fileID: 983415425082270079, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 983415425082270079, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 983415425082270079, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 983415425082270079, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1593702389427837575, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1804752920503555062, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1804752920503555062, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1804752920503555062, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1804752920503555062, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1936850923066780126, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 341.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1936850923066780126, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
value: 150
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2570593642998705886, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
@@ -248,19 +284,23 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4841071245403604065, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4841071245403604065, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4841071245403604065, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
value: 75
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4841071245403604065, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
value: -75
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5003708969225410361, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0.0002746582
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5275008271445494810, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
@@ -270,6 +310,50 @@ PrefabInstance:
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5315106633118420968, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5315106633118420968, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5334678823793530471, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5334678823793530471, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5334678823793530471, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5334678823793530471, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5620538142629867345, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5620538142629867345, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5620538142629867345, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5620538142629867345, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5992029148489394405, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7086790971941574277, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -28.8398
|
||||
@@ -332,19 +416,19 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9220948749313234647, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9220948749313234647, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9220948749313234647, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
value: 266.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9220948749313234647, guid: de2ed28e4200a4340a5af4086c98a0dc, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
value: -75
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
|
||||
@@ -30,8 +30,13 @@ namespace Levels
|
||||
public Sprite mapSprite;
|
||||
|
||||
/// <summary>
|
||||
/// Icon to display for this level switch.
|
||||
/// Icon to display in UI for this level switch.
|
||||
/// </summary>
|
||||
public Sprite menuSprite;
|
||||
|
||||
/// <summary>
|
||||
/// Icon to display for minigame selection, attached to this level.
|
||||
/// </summary>
|
||||
public Sprite minigameMenuSprite;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -13,20 +14,33 @@ namespace Levels
|
||||
public class LevelSwitchMenu : MonoBehaviour
|
||||
{
|
||||
[Header("UI References")]
|
||||
public Image iconImage;
|
||||
public TMP_Text levelNameText;
|
||||
public Button confirmButton;
|
||||
public Image mainLevelIconImage;
|
||||
public Image minigameIconImage;
|
||||
public TMP_Text mainLevelNameText;
|
||||
public TMP_Text minigameLevelNameText;
|
||||
public Button puzzleLevelConfirmButton;
|
||||
public Button puzzleLevelRestartButton;
|
||||
public Button cancelButton;
|
||||
public Button minigameButton;
|
||||
public GameObject padlockIcon;
|
||||
public Button restartButton;
|
||||
public Button minigameConfirmButton;
|
||||
public GameObject popupConfirmMenu;
|
||||
public Button popupConfirmButton;
|
||||
public Button popupCancelButton;
|
||||
public Image tintTargetImage;
|
||||
public Color popupTintColor = new Color(0.5f, 0.5f, 0.5f, 1f); // grey by default
|
||||
public Color disabledTintColor = new Color(0.5f, 0.5f, 0.5f, 1f); // grey by default
|
||||
|
||||
[Header("Minigame Lock")]
|
||||
public Image padlockImage;
|
||||
|
||||
[Header("Scroll View")]
|
||||
public ScrollRect scrollView;
|
||||
public Button scrollToPuzzleLevelButton;
|
||||
public Button scrollToMinigameButton;
|
||||
public float scrollDuration = 1f;
|
||||
|
||||
private Color _originalTintColor;
|
||||
private Color _originalMinigameIconColor;
|
||||
private Action _onRestart;
|
||||
private Coroutine _activeScrollCoroutine;
|
||||
|
||||
private Action _onLevelConfirm;
|
||||
private Action _onMinigameConfirm;
|
||||
@@ -43,35 +57,55 @@ namespace Levels
|
||||
_onMinigameConfirm = onMinigameConfirm;
|
||||
_onCancel = onCancel;
|
||||
_onRestart = onRestart;
|
||||
|
||||
if(switchData != null)
|
||||
{
|
||||
if (iconImage)
|
||||
if (mainLevelIconImage)
|
||||
{
|
||||
iconImage.sprite = switchData.menuSprite != null
|
||||
mainLevelIconImage.sprite = switchData.menuSprite != null
|
||||
? switchData.menuSprite
|
||||
: switchData.mapSprite;
|
||||
}
|
||||
if (levelNameText) levelNameText.text = switchData?.targetLevelSceneName ?? "";
|
||||
|
||||
if (minigameIconImage)
|
||||
{
|
||||
minigameIconImage.sprite = switchData.minigameMenuSprite;
|
||||
}
|
||||
if (mainLevelNameText) mainLevelNameText.text = switchData?.targetLevelSceneName ?? "";
|
||||
if (minigameLevelNameText) minigameLevelNameText.text = switchData.targetMinigameSceneName ?? "";
|
||||
}
|
||||
else
|
||||
{
|
||||
Logging.Warning("[LevelSwitchMenu] No level data is assigned!");
|
||||
}
|
||||
if (confirmButton) confirmButton.onClick.AddListener(OnConfirmClicked);
|
||||
|
||||
// Setup button listeners
|
||||
if (puzzleLevelConfirmButton) puzzleLevelConfirmButton.onClick.AddListener(OnPuzzleLevelConfirmClicked);
|
||||
if (puzzleLevelRestartButton) puzzleLevelRestartButton.onClick.AddListener(OnRestartClicked);
|
||||
if (cancelButton) cancelButton.onClick.AddListener(OnCancelClicked);
|
||||
if (minigameButton) minigameButton.onClick.AddListener(OnMinigameClicked);
|
||||
if (restartButton) restartButton.onClick.AddListener(OnRestartClicked);
|
||||
if (popupConfirmMenu) popupConfirmMenu.SetActive(false);
|
||||
if (tintTargetImage) _originalTintColor = tintTargetImage.color;
|
||||
if (minigameConfirmButton) minigameConfirmButton.onClick.AddListener(OnMinigameConfirmClicked);
|
||||
if (scrollToPuzzleLevelButton) scrollToPuzzleLevelButton.onClick.AddListener(OnScrollToPuzzleLevelClicked);
|
||||
if (scrollToMinigameButton) scrollToMinigameButton.onClick.AddListener(OnScrollToMinigameClicked);
|
||||
if (popupConfirmButton) popupConfirmButton.onClick.AddListener(OnPopupConfirmClicked);
|
||||
if (popupCancelButton) popupCancelButton.onClick.AddListener(OnPopupCancelClicked);
|
||||
|
||||
|
||||
if (popupConfirmMenu) popupConfirmMenu.SetActive(false);
|
||||
if (tintTargetImage) _originalTintColor = tintTargetImage.color;
|
||||
if (minigameIconImage) _originalMinigameIconColor = minigameIconImage.color;
|
||||
|
||||
// Initialize scroll view to start at left (puzzle level view)
|
||||
if (scrollView) scrollView.horizontalNormalizedPosition = 0f;
|
||||
|
||||
// Initialize scroll button visibility
|
||||
if (scrollToMinigameButton) scrollToMinigameButton.gameObject.SetActive(true);
|
||||
if (scrollToPuzzleLevelButton) scrollToPuzzleLevelButton.gameObject.SetActive(false);
|
||||
|
||||
// --- Minigame unlock state logic ---
|
||||
if (SaveLoadManager.Instance != null)
|
||||
{
|
||||
if (SaveLoadManager.Instance.IsSaveDataLoaded)
|
||||
{
|
||||
ApplyMinigameUnlockStateIfAvailable();
|
||||
ApplyMinigameUnlockState();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -82,25 +116,34 @@ namespace Levels
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (confirmButton) confirmButton.onClick.RemoveListener(OnConfirmClicked);
|
||||
if (puzzleLevelConfirmButton) puzzleLevelConfirmButton.onClick.RemoveListener(OnPuzzleLevelConfirmClicked);
|
||||
if (puzzleLevelRestartButton) puzzleLevelRestartButton.onClick.RemoveListener(OnRestartClicked);
|
||||
if (cancelButton) cancelButton.onClick.RemoveListener(OnCancelClicked);
|
||||
if (minigameButton) minigameButton.onClick.RemoveListener(OnMinigameClicked);
|
||||
if (restartButton) restartButton.onClick.RemoveListener(OnRestartClicked);
|
||||
if (minigameConfirmButton) minigameConfirmButton.onClick.RemoveListener(OnMinigameConfirmClicked);
|
||||
if (scrollToPuzzleLevelButton) scrollToPuzzleLevelButton.onClick.RemoveListener(OnScrollToPuzzleLevelClicked);
|
||||
if (scrollToMinigameButton) scrollToMinigameButton.onClick.RemoveListener(OnScrollToMinigameClicked);
|
||||
if (popupConfirmButton) popupConfirmButton.onClick.RemoveListener(OnPopupConfirmClicked);
|
||||
if (popupCancelButton) popupCancelButton.onClick.RemoveListener(OnPopupCancelClicked);
|
||||
|
||||
if (_activeScrollCoroutine != null)
|
||||
{
|
||||
StopCoroutine(_activeScrollCoroutine);
|
||||
_activeScrollCoroutine = null;
|
||||
}
|
||||
|
||||
if (SaveLoadManager.Instance != null)
|
||||
{
|
||||
SaveLoadManager.Instance.OnLoadCompleted -= OnSaveDataLoadedHandler;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnConfirmClicked()
|
||||
private void OnPuzzleLevelConfirmClicked()
|
||||
{
|
||||
_onLevelConfirm?.Invoke();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
private void OnMinigameClicked()
|
||||
private void OnMinigameConfirmClicked()
|
||||
{
|
||||
_onMinigameConfirm?.Invoke();
|
||||
Destroy(gameObject);
|
||||
@@ -115,7 +158,7 @@ namespace Levels
|
||||
private void OnRestartClicked()
|
||||
{
|
||||
if (popupConfirmMenu) popupConfirmMenu.SetActive(true);
|
||||
if (tintTargetImage) tintTargetImage.color = popupTintColor;
|
||||
if (tintTargetImage) tintTargetImage.color = disabledTintColor;
|
||||
}
|
||||
|
||||
private void OnPopupCancelClicked()
|
||||
@@ -131,20 +174,110 @@ namespace Levels
|
||||
if (tintTargetImage) tintTargetImage.color = _originalTintColor;
|
||||
}
|
||||
|
||||
private void ApplyMinigameUnlockStateIfAvailable()
|
||||
private void OnScrollToMinigameClicked()
|
||||
{
|
||||
if (minigameButton == null || padlockIcon == null || _switchData == null)
|
||||
if (_activeScrollCoroutine != null)
|
||||
{
|
||||
StopCoroutine(_activeScrollCoroutine);
|
||||
}
|
||||
_activeScrollCoroutine = StartCoroutine(ScrollToMinigameCoroutine());
|
||||
}
|
||||
|
||||
private void OnScrollToPuzzleLevelClicked()
|
||||
{
|
||||
if (_activeScrollCoroutine != null)
|
||||
{
|
||||
StopCoroutine(_activeScrollCoroutine);
|
||||
}
|
||||
_activeScrollCoroutine = StartCoroutine(ScrollToPuzzleLevelCoroutine());
|
||||
}
|
||||
|
||||
private IEnumerator ScrollToMinigameCoroutine()
|
||||
{
|
||||
// Hide the scroll to minigame button
|
||||
if (scrollToMinigameButton) scrollToMinigameButton.gameObject.SetActive(false);
|
||||
|
||||
// Scroll to the right (normalized position 0.95)
|
||||
float elapsed = 0f;
|
||||
float startPos = scrollView.horizontalNormalizedPosition;
|
||||
float targetPos = 0.9f;
|
||||
|
||||
while (elapsed < scrollDuration)
|
||||
{
|
||||
elapsed += Time.deltaTime;
|
||||
float t = Mathf.Clamp01(elapsed / scrollDuration);
|
||||
// Use SmoothStep for a smoother animation
|
||||
float smoothT = Mathf.SmoothStep(0f, 1f, t);
|
||||
scrollView.horizontalNormalizedPosition = Mathf.Lerp(startPos, targetPos, smoothT);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// Ensure we're at the final position
|
||||
scrollView.horizontalNormalizedPosition = targetPos;
|
||||
|
||||
// Show the scroll to puzzle level button
|
||||
if (scrollToPuzzleLevelButton) scrollToPuzzleLevelButton.gameObject.SetActive(true);
|
||||
|
||||
_activeScrollCoroutine = null;
|
||||
}
|
||||
|
||||
private IEnumerator ScrollToPuzzleLevelCoroutine()
|
||||
{
|
||||
// Hide the scroll to puzzle level button
|
||||
if (scrollToPuzzleLevelButton) scrollToPuzzleLevelButton.gameObject.SetActive(false);
|
||||
|
||||
// Scroll to the left (normalized position 0)
|
||||
float elapsed = 0f;
|
||||
float startPos = scrollView.horizontalNormalizedPosition;
|
||||
float targetPos = 0f;
|
||||
|
||||
while (elapsed < scrollDuration)
|
||||
{
|
||||
elapsed += Time.deltaTime;
|
||||
float t = Mathf.Clamp01(elapsed / scrollDuration);
|
||||
// Use SmoothStep for a smoother animation
|
||||
float smoothT = Mathf.SmoothStep(0f, 1f, t);
|
||||
scrollView.horizontalNormalizedPosition = Mathf.Lerp(startPos, targetPos, smoothT);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// Ensure we're at the final position
|
||||
scrollView.horizontalNormalizedPosition = targetPos;
|
||||
|
||||
// Show the scroll to minigame button
|
||||
if (scrollToMinigameButton) scrollToMinigameButton.gameObject.SetActive(true);
|
||||
|
||||
_activeScrollCoroutine = null;
|
||||
}
|
||||
|
||||
private void ApplyMinigameUnlockState()
|
||||
{
|
||||
if (_switchData == null)
|
||||
return;
|
||||
|
||||
var data = SaveLoadManager.Instance?.currentSaveData;
|
||||
string minigameName = _switchData.targetMinigameSceneName;
|
||||
bool unlocked = data?.unlockedMinigames != null && !string.IsNullOrEmpty(minigameName) && data.unlockedMinigames.Contains(minigameName);
|
||||
minigameButton.interactable = unlocked;
|
||||
padlockIcon.SetActive(!unlocked);
|
||||
|
||||
// Show/hide padlock
|
||||
if (padlockImage) padlockImage.gameObject.SetActive(!unlocked);
|
||||
|
||||
// Tint minigame icon if locked
|
||||
if (minigameIconImage)
|
||||
{
|
||||
minigameIconImage.color = unlocked ? _originalMinigameIconColor : disabledTintColor;
|
||||
}
|
||||
|
||||
// Enable/disable minigame confirm button
|
||||
if (minigameConfirmButton)
|
||||
{
|
||||
minigameConfirmButton.interactable = unlocked;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSaveDataLoadedHandler(string slot)
|
||||
{
|
||||
ApplyMinigameUnlockStateIfAvailable();
|
||||
ApplyMinigameUnlockState();
|
||||
if (SaveLoadManager.Instance != null)
|
||||
{
|
||||
SaveLoadManager.Instance.OnLoadCompleted -= OnSaveDataLoadedHandler;
|
||||
|
||||
Reference in New Issue
Block a user