优化ui,谱面替换,以及科研模糊
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4d5a2e5cc69ece34faba0659b1b1d58d, type: 3}
|
||||
m_Name: RankConfig
|
||||
m_EditorClassIdentifier:
|
||||
baseScore: 1350000
|
||||
defaultSprite: {fileID: 21300000, guid: 17b11910f9586834c9a6498bf3d82d7f, type: 3}
|
||||
thresholds:
|
||||
- rankName: EASE
|
||||
thresholdPercent: 1
|
||||
rankSprite: {fileID: 21300000, guid: b655fb5d2fbc50d4aae689e5d560e980, type: 3}
|
||||
- rankName: SS
|
||||
thresholdPercent: 0.95
|
||||
rankSprite: {fileID: 21300000, guid: aea32035a52c6cd4e9450249679785f5, type: 3}
|
||||
- rankName: S
|
||||
thresholdPercent: 0.9
|
||||
rankSprite: {fileID: 21300000, guid: ad076cf7fd05ad543bffae7ade0cb30a, type: 3}
|
||||
- rankName: A
|
||||
thresholdPercent: 0.8
|
||||
rankSprite: {fileID: 21300000, guid: 86594eb83b6da0e45bdf258eb02d3a5b, type: 3}
|
||||
- rankName: B
|
||||
thresholdPercent: 0.7
|
||||
rankSprite: {fileID: 21300000, guid: 521b0de5679c4e443b1f8b3a044acc20, type: 3}
|
||||
- rankName: C
|
||||
thresholdPercent: 0.6
|
||||
rankSprite: {fileID: 21300000, guid: 56822bd778d96eb49ba31eb35f164069, type: 3}
|
||||
- rankName: D
|
||||
thresholdPercent: 0.5
|
||||
rankSprite: {fileID: 21300000, guid: 7df9558287709694a888743398e3fb3e, type: 3}
|
||||
- rankName: E
|
||||
thresholdPercent: 0.4
|
||||
rankSprite: {fileID: 21300000, guid: 85308a91d726ee54e84a2384baf1187c, type: 3}
|
||||
- rankName: F
|
||||
thresholdPercent: 0.3
|
||||
rankSprite: {fileID: 21300000, guid: 989584d7d2836774a9de80daf200e38f, type: 3}
|
||||
- rankName: UF
|
||||
thresholdPercent: 0
|
||||
rankSprite: {fileID: 21300000, guid: 17b11910f9586834c9a6498bf3d82d7f, type: 3}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 951debb97a9b89f48885c82bb601533a
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[System.Serializable]
|
||||
public class RankThreshold
|
||||
{
|
||||
public string rankName;
|
||||
public float thresholdPercent;
|
||||
public Sprite rankSprite;
|
||||
}
|
||||
|
||||
[CreateAssetMenu(fileName = "RankConfig", menuName = "Config/RankConfig")]
|
||||
public class RankConfig : ScriptableObject
|
||||
{
|
||||
public float baseScore = 2000000f;
|
||||
public Sprite defaultSprite; // Equivalent to ufSprite
|
||||
|
||||
[Tooltip("Thresholds should be ordered from highest to lowest percent.")]
|
||||
public List<RankThreshold> thresholds = new List<RankThreshold>();
|
||||
|
||||
public Sprite GetRankSprite(float score)
|
||||
{
|
||||
if (score <= 0) return defaultSprite;
|
||||
|
||||
Sprite bestSprite = defaultSprite;
|
||||
float highestMatchingPercent = -1f;
|
||||
|
||||
// Ensure we handle baseScore correctly to avoid division by zero if we were to use percentages
|
||||
// But multiplying is safer as long as baseScore is set.
|
||||
|
||||
foreach (var threshold in thresholds)
|
||||
{
|
||||
if (threshold == null || threshold.rankSprite == null) continue;
|
||||
|
||||
float requiredScore = baseScore * threshold.thresholdPercent;
|
||||
if (score >= requiredScore)
|
||||
{
|
||||
// We want the threshold with the HIGHEST percentage that the score satisfies
|
||||
if (threshold.thresholdPercent > highestMatchingPercent)
|
||||
{
|
||||
highestMatchingPercent = threshold.thresholdPercent;
|
||||
bestSprite = threshold.rankSprite;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bestSprite;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d5a2e5cc69ece34faba0659b1b1d58d
|
||||
Reference in New Issue
Block a user