304 lines
8.1 KiB
C#
304 lines
8.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[CreateAssetMenu(fileName = "NewEquipment", menuName = "Equipment/Equipment SO")]
|
|
public class equipmentSO : ScriptableObject
|
|
{
|
|
public enum EquipmentSkillType
|
|
{
|
|
题海战术,
|
|
诛锄异己,
|
|
逸乐共谋,
|
|
完美至上,
|
|
涵养心境,
|
|
众志成城,
|
|
过激行为,
|
|
二次形变
|
|
}
|
|
|
|
public enum EquipmentSpecialEffectType
|
|
{
|
|
MaxHp,
|
|
Attack,
|
|
MaxMana,
|
|
DamageResistance,
|
|
ScoreEfficiency,
|
|
HitManaRecovery,
|
|
HitDamageMultiplier,
|
|
HpLoseBase,
|
|
Skill
|
|
}
|
|
|
|
[Serializable]
|
|
public class EquipmentStatTuning
|
|
{
|
|
[Range(-0.1f, 0.1f)]
|
|
public float basicGain = 0f;
|
|
|
|
[Min(0f)]
|
|
public float cultivationInterval = 0f;
|
|
|
|
public void Normalize()
|
|
{
|
|
basicGain = Mathf.Clamp(basicGain, -0.1f, 0.1f);
|
|
cultivationInterval = Mathf.Max(0f, cultivationInterval);
|
|
}
|
|
}
|
|
|
|
[Serializable]
|
|
public class EquipmentTierPresentation
|
|
{
|
|
public string tierName;
|
|
public Sprite equipmentSprite;
|
|
[TextArea(2, 6)] public string tierDescription;
|
|
}
|
|
|
|
[Serializable]
|
|
public class EquipmentSpecialEffect
|
|
{
|
|
public EquipmentSpecialEffectType effectType;
|
|
public float value;
|
|
}
|
|
|
|
[Header("技能类型")]
|
|
public EquipmentSkillType skillType;
|
|
|
|
[Header("Basic Attributes")]
|
|
[Min(0)] public int level = 0;
|
|
public equipmentTierNameConfigSO tierNameConfig;
|
|
|
|
[Header("Max HP")]
|
|
public EquipmentStatTuning maxHp = new EquipmentStatTuning();
|
|
|
|
[Header("Attack")]
|
|
public EquipmentStatTuning attack = new EquipmentStatTuning();
|
|
|
|
[Header("Max Mana")]
|
|
public EquipmentStatTuning maxMana = new EquipmentStatTuning();
|
|
|
|
[Header("Damage Resistance")]
|
|
public EquipmentStatTuning damageResistance = new EquipmentStatTuning();
|
|
|
|
[Header("Score Efficiency")]
|
|
public EquipmentStatTuning scoreEfficiency = new EquipmentStatTuning();
|
|
|
|
[Header("Special Effects")]
|
|
public EquipmentSpecialEffect[] specialEffects = Array.Empty<EquipmentSpecialEffect>();
|
|
|
|
[Header("是否共鸣")]
|
|
public bool enableTypeSameEffects = false;
|
|
|
|
[Header("共鸣特效")]
|
|
public EquipmentSpecialEffect[] typeSameEffects = Array.Empty<EquipmentSpecialEffect>();
|
|
|
|
[Header("幻化效果")]
|
|
public EquipmentSpecialEffect[] illusionEffects = Array.Empty<EquipmentSpecialEffect>();
|
|
|
|
[Header("满级效果")]
|
|
public EquipmentSpecialEffect[] maxLevelEffects = Array.Empty<EquipmentSpecialEffect>();
|
|
|
|
[Header("携带技能id")]
|
|
public int sa_skillID;
|
|
public int ia_skillID;
|
|
|
|
public bool HasFinalDreamEffect()
|
|
{
|
|
return maxLevelEffects != null && maxLevelEffects.Length > 0;
|
|
}
|
|
|
|
public int GetTierStageIndex()
|
|
{
|
|
if (level >= 20)
|
|
{
|
|
return 4;
|
|
}
|
|
|
|
if (level >= 15)
|
|
{
|
|
return 3;
|
|
}
|
|
|
|
if (level >= 10)
|
|
{
|
|
return 2;
|
|
}
|
|
|
|
if (level >= 5)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
public int GetVisualTierStageIndex()
|
|
{
|
|
if (level >= 20 && !HasFinalDreamEffect())
|
|
{
|
|
return 3;
|
|
}
|
|
|
|
return GetTierStageIndex();
|
|
}
|
|
|
|
public int GetVisualQualityColorIndex()
|
|
{
|
|
return GetVisualTierStageIndex() + 1;
|
|
}
|
|
|
|
public EquipmentTierPresentation GetCurrentTierPresentation()
|
|
{
|
|
return GetTierPresentationByStageIndex(GetTierStageIndex());
|
|
}
|
|
|
|
public EquipmentTierPresentation GetVisualTierPresentation()
|
|
{
|
|
return GetTierPresentationByStageIndex(GetVisualTierStageIndex());
|
|
}
|
|
|
|
public EquipmentTierPresentation GetIdentityTierPresentation()
|
|
{
|
|
if (level >= 20)
|
|
{
|
|
return GetTierPresentationByStageIndex(3);
|
|
}
|
|
|
|
return GetTierPresentationByStageIndex(GetTierStageIndex());
|
|
}
|
|
|
|
public string GetDisplayTierName()
|
|
{
|
|
string baseName = GetIdentityTierPresentation() != null ? GetIdentityTierPresentation().tierName : string.Empty;
|
|
if (level >= 20 && HasFinalDreamEffect())
|
|
{
|
|
return string.IsNullOrWhiteSpace(baseName) ? "梦醒记忆" : $"梦醒·{baseName}";
|
|
}
|
|
|
|
string visualName = GetVisualTierPresentation() != null ? GetVisualTierPresentation().tierName : string.Empty;
|
|
return !string.IsNullOrWhiteSpace(visualName) ? visualName : baseName;
|
|
}
|
|
|
|
public string GetDisplayTierDescription()
|
|
{
|
|
if (level >= 20 && HasFinalDreamEffect())
|
|
{
|
|
return GetIdentityTierPresentation() != null ? GetIdentityTierPresentation().tierDescription : string.Empty;
|
|
}
|
|
|
|
return GetVisualTierPresentation() != null ? GetVisualTierPresentation().tierDescription : string.Empty;
|
|
}
|
|
|
|
public EquipmentTierPresentation GetTierPresentationByStageIndex(int stageIndex)
|
|
{
|
|
if (tierNameConfig == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
if (tierNameConfig.TryGetStagePresentation(skillType, stageIndex, out equipmentTierNameConfigSO.StagePresentation configured))
|
|
{
|
|
return new EquipmentTierPresentation
|
|
{
|
|
tierName = configured.tierName,
|
|
equipmentSprite = configured.equipmentSprite,
|
|
tierDescription = configured.tierDescription
|
|
};
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public string GetCurrentTierDisplayName()
|
|
{
|
|
EquipmentTierPresentation current = GetCurrentTierPresentation();
|
|
return current != null ? current.tierName : string.Empty;
|
|
}
|
|
|
|
public Sprite GetCurrentEquipmentSprite()
|
|
{
|
|
EquipmentTierPresentation current = GetCurrentTierPresentation();
|
|
return current != null ? current.equipmentSprite : null;
|
|
}
|
|
|
|
public SkillGroup GetSpecialSkillGroup()
|
|
{
|
|
return EquipmentSkillGroupLibrary.ResolveSpecialSkillGroup(sa_skillID);
|
|
}
|
|
|
|
public SkillGroup GetIllusionSkillGroup()
|
|
{
|
|
return EquipmentSkillGroupLibrary.ResolveIllusionSkillGroup(ia_skillID);
|
|
}
|
|
|
|
public EquipmentSpecialEffect[] GetNormalizedIllusionEffects()
|
|
{
|
|
if (illusionEffects == null || illusionEffects.Length == 0)
|
|
{
|
|
return Array.Empty<EquipmentSpecialEffect>();
|
|
}
|
|
|
|
var normalized = new List<EquipmentSpecialEffect>();
|
|
var bestValues = new Dictionary<EquipmentSpecialEffectType, float>();
|
|
bool hasSkill = false;
|
|
|
|
for (int i = 0; i < illusionEffects.Length; i++)
|
|
{
|
|
EquipmentSpecialEffect effect = illusionEffects[i];
|
|
if (effect == null)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (effect.effectType == EquipmentSpecialEffectType.Skill)
|
|
{
|
|
if (!hasSkill)
|
|
{
|
|
normalized.Add(new EquipmentSpecialEffect
|
|
{
|
|
effectType = EquipmentSpecialEffectType.Skill,
|
|
value = effect.value
|
|
});
|
|
hasSkill = true;
|
|
}
|
|
|
|
continue;
|
|
}
|
|
|
|
if (!bestValues.TryGetValue(effect.effectType, out float currentBest) || effect.value > currentBest)
|
|
{
|
|
bestValues[effect.effectType] = effect.value;
|
|
}
|
|
}
|
|
|
|
foreach (KeyValuePair<EquipmentSpecialEffectType, float> pair in bestValues)
|
|
{
|
|
normalized.Add(new EquipmentSpecialEffect
|
|
{
|
|
effectType = pair.Key,
|
|
value = pair.Value
|
|
});
|
|
}
|
|
|
|
return normalized.ToArray();
|
|
}
|
|
|
|
public void NormalizeIllusionEffectsInPlace()
|
|
{
|
|
illusionEffects = GetNormalizedIllusionEffects();
|
|
}
|
|
|
|
private void OnValidate()
|
|
{
|
|
level = Mathf.Max(0, level);
|
|
sa_skillID = Mathf.Max(0, sa_skillID);
|
|
ia_skillID = Mathf.Max(0, ia_skillID);
|
|
maxHp?.Normalize();
|
|
attack?.Normalize();
|
|
maxMana?.Normalize();
|
|
damageResistance?.Normalize();
|
|
scoreEfficiency?.Normalize();
|
|
NormalizeIllusionEffectsInPlace();
|
|
}
|
|
}
|