Files
aibis-dream/Assets/Scripts/Framework/Config/Character.cs
T
2026-07-30 21:25:36 +08:00

124 lines
3.5 KiB
C#

using AibisDream.Framework;
namespace AibisDream.Kit
{
public class Character
{
public string Key { get; set; }
public string Cn { get; set; }
public string En { get; set; }
public string Ja { get; set; }
public string Ru { get; set; }
public string Es { get; set; }
public string PtBr { get; set; }
public string NameColor { get; set; }
public string HeadPicPath { get; set; }
public string VoicePath { get; set; }
public int BubbleIdx { get; set; }
public ActorRole Role { get; set; }
public DialogViewType DialogViewType { get; set; }
/// <summary>
/// 避免干扰,复制结构体出来使用
/// </summary>
/// <returns></returns>
public CharacterVo GetStructVo()
{
CharacterVo vo;
vo.key = Key;
vo.cn = Cn;
vo.en = En;
vo.ja = Ja;
vo.ru = Ru;
vo.es = Es;
vo.ptBr = PtBr;
vo.nameColor = NameColor;
vo.headPicPath = HeadPicPath;
vo.voicePath = VoicePath;
vo.bubbleIdx = BubbleIdx;
vo.role = Role;
vo.dialogViewType = DialogViewType;
return vo;
}
}
public struct CharacterVo
{
public string key;
public string cn;
public string en;
public string ja;
public string ru;
public string es;
public string ptBr;
public string nameColor;
public string headPicPath;
public string voicePath;
public int bubbleIdx;
public ActorRole role;
public DialogViewType dialogViewType;
/// <summary>
/// 获取角色应该显示的名字
/// </summary>
/// <returns></returns>
public string GetActorName()
{
string rawName;
// 人名部分直接为空
if (string.IsNullOrWhiteSpace(key))
{
rawName = "";
}
else
{
rawName = GetLocalizedNameByKind(LocalizationKit.CurrentLocaleKind);
}
return string.IsNullOrEmpty(nameColor) ? rawName : $"<color={nameColor}>{rawName}</color>";
}
private string GetLocalizedNameByKind(LocaleKind kind)
{
switch (kind)
{
case LocaleKind.En:
return string.IsNullOrWhiteSpace(en) ? key : en;
case LocaleKind.Ja:
if (!string.IsNullOrWhiteSpace(ja)) return ja;
return string.IsNullOrWhiteSpace(cn) ? key : cn;
case LocaleKind.Ru:
return string.IsNullOrWhiteSpace(ru) ? key : ru;
case LocaleKind.Es:
return string.IsNullOrWhiteSpace(es) ? key : es;
case LocaleKind.PtBr:
return string.IsNullOrWhiteSpace(ptBr) ? key : ptBr;
case LocaleKind.Cn:
default:
return string.IsNullOrWhiteSpace(cn) ? key : cn;
}
}
public string VoicePath
{
get
{
if (!string.IsNullOrEmpty(voicePath) && !voicePath.StartsWith("event:/"))
{
return "event:/" + voicePath;
}
return voicePath;
}
}
}
public enum ActorRole
{
Aside,
Player,
MainActor
}
}