任务系统一半多,商城筛选功能,一些细节和免费包
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d94caf56bd6dff64fa606eeeb6e06fa9
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,156 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31a50f150f27159408988fc7f06b2f9e
|
||||
TextureImporter:
|
||||
internalIDToNameTable:
|
||||
- first:
|
||||
213: 1981748181387760519
|
||||
second: close_256dp_B84C4C_FILL0_wght400_GRAD0_opsz48_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: 1
|
||||
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: 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: 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
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites:
|
||||
- serializedVersion: 2
|
||||
name: close_256dp_B84C4C_FILL0_wght400_GRAD0_opsz48_0
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 54
|
||||
y: 54
|
||||
width: 148
|
||||
height: 148
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
customData:
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: -1
|
||||
bones: []
|
||||
spriteID: 783d4e1a875908b10800000000000000
|
||||
internalID: 1981748181387760519
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable:
|
||||
close_256dp_B84C4C_FILL0_wght400_GRAD0_opsz48_0: 1981748181387760519
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 546ff28f6e856854fbebc725591a61c5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f4b2ea4c843e6b43ae38b5a467e393e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class expBottlesSO : ScriptableObject
|
||||
{
|
||||
public string expBottleName;
|
||||
|
||||
[TextArea(3, 3)] public string expBottleDescription;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fbbc2d4e0d333b4f9ffc73d70c317b0
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.2 KiB |
@@ -0,0 +1,156 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 419a549e3fc7324449dd5c94bf046987
|
||||
TextureImporter:
|
||||
internalIDToNameTable:
|
||||
- first:
|
||||
213: 4249592028322900263
|
||||
second: paid_256dp_00000_FILL0_wght400_GRAD0_opsz48_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: 1
|
||||
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: 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: 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
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites:
|
||||
- serializedVersion: 2
|
||||
name: paid_256dp_00000_FILL0_wght400_GRAD0_opsz48_0
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 20
|
||||
y: 20
|
||||
width: 216
|
||||
height: 216
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
customData:
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: -1
|
||||
bones: []
|
||||
spriteID: 729a4883f6599fa30800000000000000
|
||||
internalID: 4249592028322900263
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable:
|
||||
paid_256dp_00000_FILL0_wght400_GRAD0_opsz48_0: 4249592028322900263
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1259,16 +1259,16 @@ MonoBehaviour:
|
||||
m_Font: {fileID: 12800000, guid: dfa10de3e2846524089b5073175cd151, type: 3}
|
||||
m_FontSize: 24
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 2
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 0
|
||||
m_BestFit: 1
|
||||
m_MinSize: 12
|
||||
m_MaxSize: 24
|
||||
m_Alignment: 3
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: "\u7269\u54C1\u7684\u540D\u5B57"
|
||||
m_Text: "\u4ED9\u54C1\u5076\u50CF\u7075\u4E39\u5999\u836F"
|
||||
--- !u!1 &8430722678514886154
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1280,7 +1280,6 @@ GameObject:
|
||||
- component: {fileID: 5921161486854863533}
|
||||
- component: {fileID: 2471743000415371932}
|
||||
- component: {fileID: 632334460882694960}
|
||||
- component: {fileID: 4723127227539899519}
|
||||
m_Layer: 5
|
||||
m_Name: btm
|
||||
m_TagString: Untagged
|
||||
@@ -1352,50 +1351,6 @@ MonoBehaviour:
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &4723127227539899519
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8430722678514886154}
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 632334460882694960}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!1 &8617182504014183572
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -7,9 +7,18 @@ using UnityEngine.UI;
|
||||
|
||||
public class storeSystem : MonoBehaviour
|
||||
{
|
||||
private const string ShowOnlyPurchasablePrefKey = "store.show_only_can_purchase";
|
||||
private const string SortDropdownPrefKey = "store.sort_dropdown_value";
|
||||
[Header("Player Data")]
|
||||
[SerializeField] private Player_SO playerData;
|
||||
|
||||
[Header("closeButton")]
|
||||
public Button closeButton;
|
||||
|
||||
[Header("filter")]
|
||||
public Toggle show_only_canPurchase;
|
||||
public Dropdown sortDropdown;
|
||||
|
||||
[Header("list toggles")]
|
||||
public ToggleGroup toggleGroup;
|
||||
public Toggle allItems_toggle;
|
||||
@@ -45,6 +54,7 @@ public class storeSystem : MonoBehaviour
|
||||
|
||||
private const int MinPurchaseAmount = 1;
|
||||
private const int MaxPurchaseAmount = 999999;
|
||||
private static readonly Color InsufficientCostColor = new Color(0.45f, 0.08f, 0.08f, 1f);
|
||||
|
||||
private readonly List<storeItemSO> cachedItems = new List<storeItemSO>();
|
||||
private readonly List<Toggle> toggles = new List<Toggle>();
|
||||
@@ -54,6 +64,7 @@ public class storeSystem : MonoBehaviour
|
||||
private int currentSelectedItemId = -1;
|
||||
private int currentPurchaseAmount = MinPurchaseAmount;
|
||||
private bool suppressAmountInputCallback;
|
||||
private Color defaultSumCostColor = Color.white;
|
||||
|
||||
private string SaveFilePath
|
||||
{
|
||||
@@ -62,14 +73,23 @@ public class storeSystem : MonoBehaviour
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (p_sumCostText != null)
|
||||
{
|
||||
defaultSumCostColor = p_sumCostText.color;
|
||||
}
|
||||
|
||||
CacheToggles();
|
||||
RegisterHeaderControlCallbacks();
|
||||
RegisterToggleCallbacks();
|
||||
RegisterPurchasePanelCallbacks();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
PlayerEconomyLedger.EnsureInstance().AttachPlayerData(playerData);
|
||||
ExpBottleLedger.EnsureInstance().AttachPlayerData(playerData);
|
||||
ResetPriceImageObjects();
|
||||
LoadFilterPreferences();
|
||||
SetDefaultToggleState();
|
||||
LoadPersistedState();
|
||||
LoadAllStoreItems();
|
||||
@@ -79,6 +99,7 @@ public class storeSystem : MonoBehaviour
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
UnregisterHeaderControlCallbacks();
|
||||
UnregisterToggleCallbacks();
|
||||
UnregisterPurchasePanelCallbacks();
|
||||
}
|
||||
@@ -111,6 +132,42 @@ public class storeSystem : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void RegisterHeaderControlCallbacks()
|
||||
{
|
||||
if (closeButton != null)
|
||||
{
|
||||
closeButton.onClick.AddListener(OnCloseButtonClicked);
|
||||
}
|
||||
|
||||
if (show_only_canPurchase != null)
|
||||
{
|
||||
show_only_canPurchase.onValueChanged.AddListener(OnShowOnlyCanPurchaseChanged);
|
||||
}
|
||||
|
||||
if (sortDropdown != null)
|
||||
{
|
||||
sortDropdown.onValueChanged.AddListener(OnSortDropdownValueChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private void UnregisterHeaderControlCallbacks()
|
||||
{
|
||||
if (closeButton != null)
|
||||
{
|
||||
closeButton.onClick.RemoveListener(OnCloseButtonClicked);
|
||||
}
|
||||
|
||||
if (show_only_canPurchase != null)
|
||||
{
|
||||
show_only_canPurchase.onValueChanged.RemoveListener(OnShowOnlyCanPurchaseChanged);
|
||||
}
|
||||
|
||||
if (sortDropdown != null)
|
||||
{
|
||||
sortDropdown.onValueChanged.RemoveListener(OnSortDropdownValueChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private void UnregisterToggleCallbacks()
|
||||
{
|
||||
for (int i = 0; i < toggles.Count; i++)
|
||||
@@ -122,6 +179,21 @@ public class storeSystem : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadFilterPreferences()
|
||||
{
|
||||
if (show_only_canPurchase != null)
|
||||
{
|
||||
show_only_canPurchase.SetIsOnWithoutNotify(PlayerPrefs.GetInt(ShowOnlyPurchasablePrefKey, 0) == 1);
|
||||
}
|
||||
|
||||
if (sortDropdown != null)
|
||||
{
|
||||
int savedValue = PlayerPrefs.GetInt(SortDropdownPrefKey, 0);
|
||||
int safeValue = Mathf.Clamp(savedValue, 0, Mathf.Max(0, sortDropdown.options.Count - 1));
|
||||
sortDropdown.SetValueWithoutNotify(safeValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void RegisterPurchasePanelCallbacks()
|
||||
{
|
||||
if (p_iAmount_plus != null)
|
||||
@@ -136,7 +208,12 @@ public class storeSystem : MonoBehaviour
|
||||
|
||||
if (p_iAmount_input != null)
|
||||
{
|
||||
p_iAmount_input.onEndEdit.AddListener(OnPurchaseAmountInputEndEdit);
|
||||
p_iAmount_input.onValueChanged.AddListener(OnPurchaseAmountInputValueChanged);
|
||||
}
|
||||
|
||||
if (purchaseButton != null)
|
||||
{
|
||||
purchaseButton.onClick.AddListener(OnPurchaseButtonClicked);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +231,12 @@ public class storeSystem : MonoBehaviour
|
||||
|
||||
if (p_iAmount_input != null)
|
||||
{
|
||||
p_iAmount_input.onEndEdit.RemoveListener(OnPurchaseAmountInputEndEdit);
|
||||
p_iAmount_input.onValueChanged.RemoveListener(OnPurchaseAmountInputValueChanged);
|
||||
}
|
||||
|
||||
if (purchaseButton != null)
|
||||
{
|
||||
purchaseButton.onClick.RemoveListener(OnPurchaseButtonClicked);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,6 +248,32 @@ public class storeSystem : MonoBehaviour
|
||||
RefreshCurrentView();
|
||||
}
|
||||
|
||||
private void OnShowOnlyCanPurchaseChanged(bool isOn)
|
||||
{
|
||||
PlayerPrefs.SetInt(ShowOnlyPurchasablePrefKey, isOn ? 1 : 0);
|
||||
PlayerPrefs.Save();
|
||||
currentSelectedItem = null;
|
||||
currentSelectedItemId = -1;
|
||||
currentPurchaseAmount = MinPurchaseAmount;
|
||||
RefreshCurrentView();
|
||||
}
|
||||
|
||||
private void OnSortDropdownValueChanged(int _)
|
||||
{
|
||||
if (sortDropdown != null)
|
||||
{
|
||||
PlayerPrefs.SetInt(SortDropdownPrefKey, sortDropdown.value);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
RefreshCurrentView();
|
||||
}
|
||||
|
||||
private void OnCloseButtonClicked()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void SetDefaultToggleState()
|
||||
{
|
||||
if (allItems_toggle == null)
|
||||
@@ -306,7 +414,13 @@ public class storeSystem : MonoBehaviour
|
||||
}
|
||||
|
||||
visibleItems.Add(itemSO);
|
||||
SpawnItem(itemSO);
|
||||
}
|
||||
|
||||
SortVisibleItems(visibleItems);
|
||||
|
||||
for (int i = 0; i < visibleItems.Count; i++)
|
||||
{
|
||||
SpawnItem(visibleItems[i]);
|
||||
}
|
||||
|
||||
ResolveVisibleSelection(visibleItems);
|
||||
@@ -324,6 +438,11 @@ public class storeSystem : MonoBehaviour
|
||||
return false;
|
||||
}
|
||||
|
||||
if (show_only_canPurchase != null && show_only_canPurchase.isOn && !IsCurrentlyPurchasable(itemSO))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (recentlyHot_toggle != null && recentlyHot_toggle.isOn)
|
||||
{
|
||||
return itemSO.isHot;
|
||||
@@ -357,6 +476,153 @@ public class storeSystem : MonoBehaviour
|
||||
return allItems_toggle == null || allItems_toggle.isOn;
|
||||
}
|
||||
|
||||
private void SortVisibleItems(List<storeItemSO> visibleItems)
|
||||
{
|
||||
if (visibleItems == null || visibleItems.Count <= 1 || sortDropdown == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (sortDropdown.value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
visibleItems.Sort(CompareStoreItems);
|
||||
}
|
||||
|
||||
private int CompareStoreItems(storeItemSO left, storeItemSO right)
|
||||
{
|
||||
if (left == right)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (left == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (right == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int result;
|
||||
switch (sortDropdown != null ? sortDropdown.value : 0)
|
||||
{
|
||||
case 1:
|
||||
result = ComparePriceAscending(left, right);
|
||||
break;
|
||||
case 2:
|
||||
result = ComparePriceDescending(left, right);
|
||||
break;
|
||||
case 3:
|
||||
result = CompareAscending((int)left.itemType, (int)right.itemType);
|
||||
break;
|
||||
case 4:
|
||||
result = CompareDescending((int)left.itemType, (int)right.itemType);
|
||||
break;
|
||||
case 5:
|
||||
result = CompareQuotaAscending(left, right);
|
||||
break;
|
||||
case 6:
|
||||
result = CompareQuotaDescending(left, right);
|
||||
break;
|
||||
default:
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return CompareAscending(left.itemID, right.itemID);
|
||||
}
|
||||
|
||||
private static int CompareAscending(int left, int right)
|
||||
{
|
||||
return left.CompareTo(right);
|
||||
}
|
||||
|
||||
private static int CompareDescending(int left, int right)
|
||||
{
|
||||
return right.CompareTo(left);
|
||||
}
|
||||
|
||||
private static int CompareQuotaAscending(storeItemSO left, storeItemSO right)
|
||||
{
|
||||
bool leftUnlimited = left.itemPurchaseQuota < 0;
|
||||
bool rightUnlimited = right.itemPurchaseQuota < 0;
|
||||
if (leftUnlimited != rightUnlimited)
|
||||
{
|
||||
return leftUnlimited ? 1 : -1;
|
||||
}
|
||||
|
||||
return CompareAscending(left.itemPurchaseQuota, right.itemPurchaseQuota);
|
||||
}
|
||||
|
||||
private static int CompareQuotaDescending(storeItemSO left, storeItemSO right)
|
||||
{
|
||||
bool leftUnlimited = left.itemPurchaseQuota < 0;
|
||||
bool rightUnlimited = right.itemPurchaseQuota < 0;
|
||||
if (leftUnlimited != rightUnlimited)
|
||||
{
|
||||
return leftUnlimited ? -1 : 1;
|
||||
}
|
||||
|
||||
return CompareDescending(left.itemPurchaseQuota, right.itemPurchaseQuota);
|
||||
}
|
||||
|
||||
private static int ComparePriceAscending(storeItemSO left, storeItemSO right)
|
||||
{
|
||||
bool leftHasCost = HasSortableCost(left);
|
||||
bool rightHasCost = HasSortableCost(right);
|
||||
if (leftHasCost != rightHasCost)
|
||||
{
|
||||
return leftHasCost ? -1 : 1;
|
||||
}
|
||||
|
||||
return CompareAscending(GetPrimaryCostAmount(left), GetPrimaryCostAmount(right));
|
||||
}
|
||||
|
||||
private static int ComparePriceDescending(storeItemSO left, storeItemSO right)
|
||||
{
|
||||
bool leftHasCost = HasSortableCost(left);
|
||||
bool rightHasCost = HasSortableCost(right);
|
||||
if (leftHasCost != rightHasCost)
|
||||
{
|
||||
return leftHasCost ? -1 : 1;
|
||||
}
|
||||
|
||||
return CompareDescending(GetPrimaryCostAmount(left), GetPrimaryCostAmount(right));
|
||||
}
|
||||
|
||||
private static bool HasSortableCost(storeItemSO itemSO)
|
||||
{
|
||||
return itemSO != null && itemSO.costRequirements != null && itemSO.costRequirements.Count > 0;
|
||||
}
|
||||
|
||||
private static int GetPrimaryCostAmount(storeItemSO itemSO)
|
||||
{
|
||||
if (!HasSortableCost(itemSO))
|
||||
{
|
||||
return int.MaxValue;
|
||||
}
|
||||
|
||||
return itemSO.costRequirements[0].amount;
|
||||
}
|
||||
|
||||
private bool IsCurrentlyPurchasable(storeItemSO itemSO)
|
||||
{
|
||||
return itemSO != null
|
||||
&& itemSO.canbepurchased
|
||||
&& !IsSoldOut(itemSO)
|
||||
&& HasCoinRequirement(itemSO);
|
||||
}
|
||||
|
||||
private void SpawnItem(storeItemSO itemSO)
|
||||
{
|
||||
var instance = Instantiate(itemPrefab, contentParent);
|
||||
@@ -496,6 +762,7 @@ public class storeSystem : MonoBehaviour
|
||||
if (p_sumCostText != null)
|
||||
{
|
||||
p_sumCostText.text = string.Empty;
|
||||
p_sumCostText.color = defaultSumCostColor;
|
||||
}
|
||||
|
||||
SetPriceImageState(p_sumCostImage, null, false);
|
||||
@@ -515,13 +782,20 @@ public class storeSystem : MonoBehaviour
|
||||
SetPurchaseAmount(currentPurchaseAmount - 1, true);
|
||||
}
|
||||
|
||||
private void OnPurchaseAmountInputEndEdit(string value)
|
||||
private void OnPurchaseAmountInputValueChanged(string value)
|
||||
{
|
||||
if (suppressAmountInputCallback)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
currentPurchaseAmount = MinPurchaseAmount;
|
||||
RefreshPurchaseSummary();
|
||||
return;
|
||||
}
|
||||
|
||||
long parsedValue;
|
||||
if (!long.TryParse((value ?? string.Empty).Trim(), out parsedValue))
|
||||
{
|
||||
@@ -542,7 +816,23 @@ public class storeSystem : MonoBehaviour
|
||||
safeValue = (int)parsedValue;
|
||||
}
|
||||
|
||||
SetPurchaseAmount(safeValue, true);
|
||||
bool reachedUpperLimit = safeValue > MaxPurchaseAmount;
|
||||
bool reachedLowerLimit = safeValue < MinPurchaseAmount;
|
||||
int clampedValue = Mathf.Clamp(safeValue, MinPurchaseAmount, MaxPurchaseAmount);
|
||||
|
||||
currentPurchaseAmount = clampedValue;
|
||||
RefreshPurchaseSummary();
|
||||
|
||||
if (reachedUpperLimit)
|
||||
{
|
||||
gNotice.warning.display("达到单次购买限额");
|
||||
UpdatePurchaseAmountInput();
|
||||
}
|
||||
else if (reachedLowerLimit)
|
||||
{
|
||||
gNotice.warning.display("本店禁止无实物交易");
|
||||
UpdatePurchaseAmountInput();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetPurchaseAmount(int amount, bool showWarnings)
|
||||
@@ -592,6 +882,7 @@ public class storeSystem : MonoBehaviour
|
||||
if (p_sumCostText != null)
|
||||
{
|
||||
p_sumCostText.text = string.Empty;
|
||||
p_sumCostText.color = defaultSumCostColor;
|
||||
}
|
||||
|
||||
SetPriceImageState(p_sumCostImage, null, false);
|
||||
@@ -604,6 +895,7 @@ public class storeSystem : MonoBehaviour
|
||||
if (p_sumCostText != null)
|
||||
{
|
||||
p_sumCostText.text = "不可购买";
|
||||
p_sumCostText.color = defaultSumCostColor;
|
||||
}
|
||||
|
||||
SetCannotBuyImageState(p_sumCostImage);
|
||||
@@ -617,6 +909,7 @@ public class storeSystem : MonoBehaviour
|
||||
if (p_sumCostText != null)
|
||||
{
|
||||
p_sumCostText.text = totalCost.ToString();
|
||||
p_sumCostText.color = CanAffordCurrentSelection(totalCost) ? defaultSumCostColor : InsufficientCostColor;
|
||||
}
|
||||
|
||||
SetPriceImageState(p_sumCostImage, GetCurrencySprite(cost.currencyType), true);
|
||||
@@ -705,6 +998,30 @@ public class storeSystem : MonoBehaviour
|
||||
purchaseButton.interactable = CanPurchaseCurrentSelection(currentSelectedItem);
|
||||
}
|
||||
|
||||
private void OnPurchaseButtonClicked()
|
||||
{
|
||||
if (currentSelectedItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string failureMessage;
|
||||
int grantedCount;
|
||||
if (!StoreExpBottlePurchaseService.TryPurchase(playerData, currentSelectedItem, currentPurchaseAmount, out failureMessage, out grantedCount))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(failureMessage))
|
||||
{
|
||||
gNotice.warning.display(failureMessage);
|
||||
}
|
||||
|
||||
RefreshPurchaseSummary();
|
||||
return;
|
||||
}
|
||||
|
||||
RegisterPurchasedCount(currentSelectedItem.itemID, grantedCount);
|
||||
RefreshPurchaseSummary();
|
||||
}
|
||||
|
||||
private string GetAmountAndQuotaText(storeItemSO itemSO)
|
||||
{
|
||||
string prefix = itemSO.itemSinglePurchaseQty == 1 ? string.Empty : $"{itemSO.itemSinglePurchaseQty}个装/";
|
||||
@@ -758,10 +1075,17 @@ public class storeSystem : MonoBehaviour
|
||||
|
||||
private bool CanPurchaseCurrentSelection(storeItemSO itemSO)
|
||||
{
|
||||
return itemSO != null
|
||||
&& itemSO.canbepurchased
|
||||
&& !IsSoldOut(itemSO)
|
||||
&& HasCoinRequirement(itemSO);
|
||||
return IsCurrentlyPurchasable(itemSO);
|
||||
}
|
||||
|
||||
private bool CanAffordCurrentSelection(long totalCost)
|
||||
{
|
||||
if (totalCost <= 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return PlayerEconomyLedger.EnsureInstance().HasEnoughCoins(totalCost);
|
||||
}
|
||||
|
||||
private void SetupAvailabilityState(storeItemPrefab itemView, storeItemSO itemSO)
|
||||
@@ -1002,8 +1326,6 @@ public class storeSystem : MonoBehaviour
|
||||
{
|
||||
UnityEditor.EditorUtility.SetDirty(cachedItems[i]);
|
||||
}
|
||||
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user