using System.Collections.Generic;
using UnityEngine;
namespace NBC
{
public class LanguageImage : ILanguage
{
///
/// 多语言图片配置数据
///
private readonly Dictionary> _languages =
new Dictionary>();
///
/// 当前语言图片配置键值对
///
private Dictionary _currentLanguageDictionary = new Dictionary();
///
/// 获得对应图片路径
///
///
///
public string Get(string key)
{
if (_currentLanguageDictionary != null && _currentLanguageDictionary.TryGetValue(key, out var value))
{
return "Assets/ResRaw/languageImage/" + value;
}
return null;
}
public void AddLanguage(SystemLanguage language)
{
var keys = Lan.Inst.GetLanguageImageConfig(LanguageConst.languageMap[language]);
if (keys != null)
{
_languages[language] = keys;
}
else
{
_languages[language] = new Dictionary();
}
}
public bool UseLanguage(SystemLanguage language)
{
if (_languages.TryGetValue(language, out var language1))
{
_currentLanguageDictionary = language1;
return true;
}
Debug.LogError("语言图片配置不存在");
return false;
}
}
}