优化道具稀有度的 UI 表现
This commit is contained in:
@@ -6,10 +6,18 @@ namespace SepCore.UI
|
||||
{
|
||||
public class IconArea : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Image _board;
|
||||
public enum RarityDisplayMode
|
||||
{
|
||||
Background = 1,
|
||||
Neutral = 2
|
||||
}
|
||||
|
||||
[SerializeField] private Image _icon;
|
||||
|
||||
[SerializeField] private Image _background = null;
|
||||
[SerializeField] private RarityPalette _rarityPalette = null;
|
||||
[SerializeField] private RarityDisplayMode _rarityDisplayMode = RarityDisplayMode.Background;
|
||||
|
||||
public void OnInit(Sprite sprite, Rarity rarity)
|
||||
{
|
||||
SetIcon(sprite);
|
||||
@@ -23,14 +31,8 @@ namespace SepCore.UI
|
||||
|
||||
public void SetRarity(Rarity rarity)
|
||||
{
|
||||
_board.color = rarity switch
|
||||
{
|
||||
Rarity.White => Color.white,
|
||||
Rarity.Blue => Color.blue,
|
||||
Rarity.Purple => Color.magenta,
|
||||
Rarity.Red => Color.red,
|
||||
_ => Color.clear,
|
||||
};
|
||||
Rarity displayRarity = _rarityDisplayMode == RarityDisplayMode.Background ? rarity : Rarity.None;
|
||||
_background.color = _rarityPalette.Get(displayRarity).IconBackground;
|
||||
}
|
||||
|
||||
public void OnReset()
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
[CreateAssetMenu(menuName = "UI/Rarity Palette")]
|
||||
public class RarityPalette : ScriptableObject
|
||||
{
|
||||
[Serializable]
|
||||
public struct Colors
|
||||
{
|
||||
public Color Border;
|
||||
public Color CardBackground;
|
||||
public Color IconBackground;
|
||||
}
|
||||
|
||||
[SerializeField] private Colors _none;
|
||||
[SerializeField] private Colors _white;
|
||||
[SerializeField] private Colors _blue;
|
||||
[SerializeField] private Colors _purple;
|
||||
[SerializeField] private Colors _red;
|
||||
|
||||
public Colors Get(Rarity rarity)
|
||||
{
|
||||
return rarity switch
|
||||
{
|
||||
Rarity.None => _none,
|
||||
Rarity.White => _white,
|
||||
Rarity.Blue => _blue,
|
||||
Rarity.Purple => _purple,
|
||||
Rarity.Red => _red,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(rarity), rarity, "Unsupported UI rarity.")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05db5e8e6e7f7e14c84c787effce4933
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class RarityPanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private RarityPalette _palette = null;
|
||||
[SerializeField] private Image _background = null;
|
||||
[SerializeField] private Image _border = null;
|
||||
|
||||
public void SetRarity(Rarity rarity)
|
||||
{
|
||||
RarityPalette.Colors colors = _palette.Get(rarity);
|
||||
_background.color = colors.CardBackground;
|
||||
_border.color = colors.Border;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95abff91edc12444c880476c4cf00ab6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user