fix:1、sdk更换。2、修复bug
This commit is contained in:
@@ -0,0 +1,145 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using ChillConnect;
|
||||
using UnityEngine;
|
||||
using System.Globalization;
|
||||
|
||||
public static class Language
|
||||
{
|
||||
private static Dictionary<string, Dictionary<string, string>> _localizedText;
|
||||
private static string _currentLanguage;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
|
||||
var systemLanguage = Application.systemLanguage;
|
||||
|
||||
Debug.Log($"languageInitialize systemLanguage = {systemLanguage}");
|
||||
|
||||
var lang = "en";
|
||||
// if (DataMgr.selectLanguage.Value != -1)
|
||||
// {
|
||||
// lang = getISOCode((SystemLanguage)DataMgr.selectLanguage.Value);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
if (systemLanguage == SystemLanguage.English)
|
||||
{
|
||||
lang = "en";
|
||||
}
|
||||
else if (systemLanguage == SystemLanguage.French)
|
||||
{
|
||||
lang = "fr";
|
||||
}
|
||||
else if (systemLanguage == SystemLanguage.German)
|
||||
{
|
||||
lang = "de";
|
||||
}
|
||||
else if (systemLanguage == SystemLanguage.Spanish)
|
||||
{
|
||||
lang = "es";
|
||||
}
|
||||
else if (systemLanguage == SystemLanguage.Portuguese)
|
||||
{
|
||||
lang = "pt";
|
||||
}
|
||||
else if (systemLanguage == SystemLanguage.Japanese)
|
||||
{
|
||||
lang = "ja";
|
||||
}
|
||||
else if (systemLanguage == SystemLanguage.Korean)
|
||||
{
|
||||
lang = "ko";
|
||||
}
|
||||
else if (systemLanguage == SystemLanguage.Russian)
|
||||
{
|
||||
lang = "ru";
|
||||
}
|
||||
// }
|
||||
lang = "ja";
|
||||
setCurrentLanguage(lang);
|
||||
}
|
||||
|
||||
public static void setCurrentLanguage(string lang)
|
||||
{
|
||||
_currentLanguage = lang;
|
||||
PlayerPrefsKit.WriteString("LangIdKey", lang);
|
||||
}
|
||||
|
||||
public static string getCurrentLanguage()
|
||||
{
|
||||
return _currentLanguage;
|
||||
}
|
||||
|
||||
public static void LoadLocalizedText()
|
||||
{
|
||||
if (_localizedText == null)
|
||||
{
|
||||
_localizedText = new Dictionary<string, Dictionary<string, string>>();
|
||||
}
|
||||
|
||||
var localization = LoadKit.Instance.LoadAsset<TextAsset>("TextAsset", "localization");
|
||||
string json = localization.text;
|
||||
_localizedText = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(json);
|
||||
}
|
||||
|
||||
public static string GetContent(string key)
|
||||
{
|
||||
if (_localizedText == null || !_localizedText.ContainsKey(_currentLanguage) || !_localizedText[_currentLanguage].ContainsKey(key))
|
||||
{
|
||||
return key; // 如果找不到对应的键,返回键本身
|
||||
}
|
||||
|
||||
return _localizedText[_currentLanguage][key];
|
||||
}
|
||||
|
||||
public static string GetContentParams(string key, params object[] args)
|
||||
{
|
||||
if (_localizedText == null || !_localizedText.ContainsKey(_currentLanguage) || !_localizedText[_currentLanguage].ContainsKey(key))
|
||||
{
|
||||
return key; // 如果找不到对应的键,返回键本身
|
||||
}
|
||||
|
||||
string localizedString = _localizedText[_currentLanguage][key];
|
||||
return string.Format(localizedString, args);
|
||||
}
|
||||
|
||||
public static string getISOCode(SystemLanguage code)
|
||||
{
|
||||
if (code == SystemLanguage.English)
|
||||
{
|
||||
return "en";
|
||||
}
|
||||
else if (code == SystemLanguage.French)
|
||||
{
|
||||
return "fr";
|
||||
}
|
||||
else if (code == SystemLanguage.German)
|
||||
{
|
||||
return "de";
|
||||
}
|
||||
else if (code == SystemLanguage.Spanish)
|
||||
{
|
||||
return "es";
|
||||
}
|
||||
else if (code == SystemLanguage.Portuguese)
|
||||
{
|
||||
return "pt";
|
||||
}
|
||||
else if (code == SystemLanguage.Japanese)
|
||||
{
|
||||
return "ja";
|
||||
}
|
||||
else if (code == SystemLanguage.Korean)
|
||||
{
|
||||
return "ko";
|
||||
}
|
||||
else if (code == SystemLanguage.Russian)
|
||||
{
|
||||
return "ru";
|
||||
}
|
||||
return "en";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2efe38f44f1a4db5a678ff2def90e205
|
||||
timeCreated: 1783394342
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using DFFFQTVUv39wKIBSDK;
|
||||
// using AppsFlyerSDK;
|
||||
using DG.Tweening;
|
||||
using IgnoreOPS;
|
||||
@@ -34,52 +35,53 @@ namespace ChillConnect
|
||||
public static void Init()
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
// // 注册 ab事件,0或1,0为自然量版本,1为激励版本
|
||||
// NCWWA6A0SDK_Manager.Instance.RegistIosParam(i =>
|
||||
// {
|
||||
// SuperApplication.Instance.attribution = i == 0 ? "organic" : "non_organic";
|
||||
// Debug.Log($"ios ab param : {i} attribution=== {SuperApplication.Instance.attribution}");
|
||||
// NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
//
|
||||
// });
|
||||
//
|
||||
// void GameConfig(bool result, string config)
|
||||
// {
|
||||
// Debug.Log($"************* game config result : {result}, config : {config}");
|
||||
// }
|
||||
// // SDK初始化方法
|
||||
// NCWWA6A0SDK_Manager.Instance.Init(null, null, GameConfig);
|
||||
|
||||
// 注册 ab事件,0或1,0为自然量版本,1为激励版本
|
||||
DFFFQTVUv39wKIBSDK_Client.Instance.RegistIosParam(i =>
|
||||
{
|
||||
SuperApplication.Instance.attribution = i == 0 ? "organic" : "non_organic";
|
||||
Debug.Log($"ios ab param : {i} attribution=== {SuperApplication.Instance.attribution}");
|
||||
NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
|
||||
});
|
||||
|
||||
void GameConfig(bool result, string config)
|
||||
{
|
||||
Debug.Log($"************* game config result : {result}, config : {config}");
|
||||
}
|
||||
// SDK初始化方法
|
||||
DFFFQTVUv39wKIBSDK_Client.Instance.Init(null, null, GameConfig);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// public static bool CheckInterstitialReady()
|
||||
// {
|
||||
// return NCWWA6A0SDK_Manager.Instance.IsInterReady();
|
||||
// }
|
||||
public static bool CheckInterstitialReady()
|
||||
{
|
||||
return DFFFQTVUv39wKIBSDK_Client.Instance.IsInterReady();
|
||||
}
|
||||
#region 插屏广告相关
|
||||
public static UnityAction<bool> onInterstitialAdCompleted;
|
||||
|
||||
public static void ShowInterstitial(string placement = "DefaultInterstitial",
|
||||
UnityAction<bool> onCompleted = null)
|
||||
{
|
||||
// if (CheckInterstitialReady())
|
||||
// {
|
||||
// Debug.Log($"广告已经准备好,播放");
|
||||
// NCWWA6A0SDK_Manager.Instance.ShowInter(placement, () =>
|
||||
// {
|
||||
// DOVirtual.DelayedCall(0.1f, () =>
|
||||
// {
|
||||
// onCompleted?.Invoke(true);
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.Log($"广告未准备好,不播放");
|
||||
// onCompleted?.Invoke(false);
|
||||
// }
|
||||
if (CheckInterstitialReady())
|
||||
{
|
||||
Debug.Log($"广告已经准备好,播放");
|
||||
DFFFQTVUv39wKIBSDK_Client.Instance.ShowInter(placement, () =>
|
||||
{
|
||||
DOVirtual.DelayedCall(0.1f, () =>
|
||||
{
|
||||
onCompleted?.Invoke(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"广告未准备好,不播放");
|
||||
onCompleted?.Invoke(false);
|
||||
}
|
||||
}
|
||||
|
||||
static int retryAttemptInterstitial;
|
||||
@@ -90,7 +92,7 @@ namespace ChillConnect
|
||||
private static void LoadAppOpenAd()
|
||||
{
|
||||
Debug.Log("LOAD APP. AD");
|
||||
MaxSdk.LoadAppOpenAd(AppOpenAdUnitId);
|
||||
// MaxSdk.LoadAppOpenAd(AppOpenAdUnitId);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,57 +116,57 @@ namespace ChillConnect
|
||||
// }
|
||||
// #endif
|
||||
}
|
||||
public static void ShowOpenAd(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
MaxSdk.ShowAppOpenAd(AppOpenAdUnitId);
|
||||
}
|
||||
// public static void ShowOpenAd(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
// {
|
||||
// MaxSdk.ShowAppOpenAd(AppOpenAdUnitId);
|
||||
// }
|
||||
|
||||
|
||||
#region 激励视频广告相关
|
||||
|
||||
public static UnityAction<bool> onVideoAdCompleted;
|
||||
private static string _placement = "";
|
||||
// public static bool CheckRewardedReady()
|
||||
// {
|
||||
// return NCWWA6A0SDK_Manager.Instance.IsVideoReady();
|
||||
// }
|
||||
public static bool CheckRewardedReady()
|
||||
{
|
||||
return DFFFQTVUv39wKIBSDK_Client.Instance.IsVideoReady();
|
||||
}
|
||||
public static void ShowVideo(string placement = "DefaultVideo", UnityAction<bool> onCompleted = null)
|
||||
{
|
||||
onVideoAdCompleted = onCompleted;
|
||||
_placement = placement;
|
||||
#if UNITY_EDITOR || !GAME_RELEASE
|
||||
#if UNITY_EDITOR
|
||||
onVideoAdCompleted?.Invoke(true);
|
||||
#else
|
||||
TrackKit.SendEvent(Property.adEvent,Property.watch_ad_people);
|
||||
TrackKit.SendEvent(Property.adEvent,Property.Rewarded_videos_trigger_number);
|
||||
|
||||
// if (CheckRewardedReady())
|
||||
// {
|
||||
// NCWWA6A0SDK_Manager.Instance.ShowRewardVideo(_placement, b =>
|
||||
// {
|
||||
// DOVirtual.DelayedCall(0.1f, () =>
|
||||
// {
|
||||
// onVideoAdCompleted?.Invoke(b);
|
||||
// });
|
||||
// }, ()=>
|
||||
// {
|
||||
// DOVirtual.DelayedCall(0.25f, () =>
|
||||
// {
|
||||
// Debug.Log($"激励广告关闭");
|
||||
// if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveObject().is_get_removead && (UnityEngine.Random.Range(0, 100) < GameHelper.GetCommonModel().rewardinsertion))
|
||||
// {
|
||||
// TrackKit.SendEvent(Property.adEvent, Property.AfterRewardAdShow);
|
||||
//
|
||||
// GameHelper.ShowInterstitial("AfterReward");
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.Log($"广告未准备好,不播放");
|
||||
// onVideoAdCompleted?.Invoke(false);
|
||||
// }
|
||||
if (CheckRewardedReady())
|
||||
{
|
||||
DFFFQTVUv39wKIBSDK_Client.Instance.ShowRewardVideo(_placement, b =>
|
||||
{
|
||||
DOVirtual.DelayedCall(0.1f, () =>
|
||||
{
|
||||
onVideoAdCompleted?.Invoke(b);
|
||||
});
|
||||
}, ()=>
|
||||
{
|
||||
DOVirtual.DelayedCall(0.25f, () =>
|
||||
{
|
||||
Debug.Log($"激励广告关闭");
|
||||
if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveObject().is_get_removead && (UnityEngine.Random.Range(0, 100) < GameHelper.GetCommonModel().rewardinsertion))
|
||||
{
|
||||
TrackKit.SendEvent(Property.adEvent, Property.AfterRewardAdShow);
|
||||
|
||||
GameHelper.ShowInterstitial("AfterReward");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"广告未准备好,不播放");
|
||||
onVideoAdCompleted?.Invoke(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user