using AibisDream.Framework;
using UnityEngine;
namespace AibisDream.Kit
{
public class Character
{
public string Key { get; set; }
public string Cn { 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; }
///
/// 避免干扰,复制结构体出来使用
///
///
public CharacterVo GetStructVo()
{
CharacterVo vo;
vo.key = Key;
vo.cn = Cn;
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 nameColor;
public string headPicPath;
public string voicePath;
public int bubbleIdx;
public ActorRole role;
public DialogViewType dialogViewType;
///
/// 获取角色应该显示的名字
///
///
public string GetActorName()
{
string rawName;
// 人名部分直接为空
if (string.IsNullOrWhiteSpace(key))
{
rawName = "";
}
else
{
// 人名能找到
var entry = LocalizationKit.ActorTable[key];
rawName = entry == null ? key : entry.LocalizedValue;
}
return string.IsNullOrEmpty(nameColor) ? rawName : $"{rawName}";
}
public string VoicePath
{
get
{
if (!string.IsNullOrEmpty(voicePath) && !voicePath.StartsWith("event:/"))
{
return "event:/" + voicePath;
}
return voicePath;
}
}
}
public enum ActorRole
{
Aside,
Player,
MainActor
}
}