mergemilitary/Assets/TKGSDK/Config/TKGLoadConfig.cs

251 lines
8.9 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Touka
{
public static class TKGLoadConfig
{
static string toukaconfigFile = "tkg_config";
static string toukaconfigPathCN = "CN";
static string toukaconfigPathGB = "GB";
/// <summary>
/// Load SDK Config
/// </summary>
public static void LoadSDKConfig()
{
#if UNITY_IOS
ParseiOSConfig();
#elif UNITY_ANDROID
ParseAndroidConfig();
#else
ParseiOSConfig();
#endif
}
/// <summary>
/// Parse iOS Config
/// .plist file
/// </summary>
private static PlayerPrefPair[] ParseiOSConfig()
{
PlayerPrefPair[] configs = TKGLoadConfig.ParseiOSConfigInner();
return configs;
}
/// <summary>
/// Parse Android Config
/// </summary>
private static PlayerPrefPair[] ParseAndroidConfig()
{
#if GooglePlay
PlayerPrefPair[] configs = TKGLoadPropertiesConfig.GetToukaConfig(AppChannel.GooglePlay);
ParseConfigsInner(configs);
return configs;
#else
PlayerPrefPair[] configs = TKGLoadPropertiesConfig.GetToukaConfig(AppChannel.GW002);
ParseConfigsInner(configs);
return configs;
#endif
}
/// <summary>
/// Parse iOS Config
/// .plist file
/// </summary>
private static PlayerPrefPair[] ParseiOSConfigInner()
{
#if AppStore_GB
PlayerPrefPair[] configs = TKGLoadPlistConfig.GetToukaConfig(toukaconfigFile, toukaconfigPathGB);
ParseConfigsInner(configs);
return configs;
#elif AppStore_CN
PlayerPrefPair[] configs = TKGLoadPlistConfig.GetToukaConfig(toukaconfigFile, toukaconfigPathCN);
ParseConfigsInner(configs);
return configs;
#else
return null;
#endif
}
/// <summary>
/// Parse Android Config
/// </summary>
private static PlayerPrefPair[] ParseAndroidConfig(AppChannel _appChannel)
{
PlayerPrefPair[] configs = TKGLoadPropertiesConfig.GetToukaConfig(_appChannel);
ParseConfigsInner(configs);
return configs;
}
// get config value by key
public static string GetConfigByKey(string _key, AppChannel _appChannel)
{
PlayerPrefPair[] configs = new PlayerPrefPair[0];
#if UNITY_IOS
configs = ParseiOSConfigInner();
#elif UNITY_ANDROID
configs = ParseAndroidConfig(_appChannel);
#endif
for (int i = 0; i < configs.Length; i++)
{
if (configs[i].Key.Equals(_key))
{
return configs[i].Value.ToString();
}
}
return "";
}
#region parse inner
// parse config
private static void ParseConfigsInner(PlayerPrefPair[] _configs)
{
TKGDebugger.LogDebug("----------- config content begin-----------");
for (int i = 0; i < _configs.Length; i++)
{
bool isDebug = false;
string valueTemp = _configs[i].Value.ToString();
// app info
if (_configs[i].Key.ToLower() == ConfigKeys.KEY_AppName.ToLower())
{
StaticStringsKey.AppName = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_BunldId.ToLower())
{
StaticStringsKey.BundleId = valueTemp;
isDebug = true;
}
// Analytics
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_UMENG_APPKEY.ToLower())
{
StaticStringsKey.UMENG_APPKEY = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_UMENG_CHANNELID.ToLower())
{
StaticStringsKey.UMENG_CHANNELID = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_GA_gameKey.ToLower())
{
StaticStringsKey.GA_gameKey = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_GA_secretKey.ToLower())
{
StaticStringsKey.GA_secretKey = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_TENJIN_KEY.ToLower())
{
StaticStringsKey.TENJIN_KEY = valueTemp;
isDebug = true;
}
// Ads
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_Admob_AppID.ToLower())
{
StaticStringsKey.Admob_AppID = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_TOUKA_SDK_APPID.ToLower())
{
StaticStringsKey.TOUKA_SDK_APPID = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_TOUKA_SDK_APPKEY.ToLower())
{
StaticStringsKey.TOUKA_SDK_APPKEY = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_TOUKA_SDK_INTERID.ToLower())
{
StaticStringsKey.TOUKA_SDK_INTERID = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_TOUKA_SDK_REWARDID.ToLower())
{
StaticStringsKey.TOUKA_SDK_REWARDID = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_TOUKA_SDK_SPLASHID.ToLower())
{
StaticStringsKey.TOUKA_SDK_SPLASHID = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_TOUKA_SDK_NATIVEID.ToLower())
{
StaticStringsKey.TOUKA_SDK_NATIVEID = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_TOUKA_SDK_RENDERNATIVEID.ToLower())
{
StaticStringsKey.TOUKA_SDK_NATIVEID = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_TOUKA_SDK_BANNERID.ToLower())
{
StaticStringsKey.TOUKA_SDK_BANNERID = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_TOUKA_SDK_NATIVEBANNERID.ToLower())
{
StaticStringsKey.TOUKA_SDK_NATIVEBANNERID = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_TOUKA_SDK_NATIVESPLASHID.ToLower())
{
StaticStringsKey.TOUKA_SDK_NATIVESPLASHID = valueTemp;
isDebug = true;
}
// Basic Config
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_PlayerAge.ToLower())
{
StaticStringsKey.PlayerAge = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_GameTheme.ToLower())
{
StaticStringsKey.GameTheme = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_PrivacyURL.ToLower())
{
StaticStringsKey.PrivacyURL = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_AgreementURL.ToLower())
{
StaticStringsKey.AgreementURL = valueTemp;
isDebug = true;
}
else if (_configs[i].Key.ToLower() == ConfigKeys.KEY_MoreGameURL.ToLower())
{
StaticStringsKey.MoreGameURL = valueTemp;
isDebug = true;
}
if (isDebug)
{
TKGDebugger.LogDebug(_configs[i].Key + " - " + _configs[i].Value);
}
}
TKGDebugger.LogDebug("----------- config content end -----------");
}
#endregion
}
}