fix:1、更换项目,使用winter来创建
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using System.Text;
|
||||
using FutureCore;
|
||||
using FlowerPower;
|
||||
using LoveLegend;
|
||||
|
||||
public class Base64Kit
|
||||
{
|
||||
@@ -23,10 +23,10 @@ public class Base64Kit
|
||||
return loginData;
|
||||
}
|
||||
|
||||
public static string Encode(string data, bool is_apple_pay = false)
|
||||
public static string Encode(string data, bool is_google_pay = false)
|
||||
{
|
||||
var key = NetworkManager.DomainRelease;
|
||||
if (is_apple_pay) key = NetworkManager.identifier;
|
||||
if (is_google_pay) key = NetworkManager.identifier;
|
||||
|
||||
var keyMD5 = MD5Kit.MD5String1(key);
|
||||
var str = Base64EncodeUtil.Base64Encode(data + keyMD5);
|
||||
@@ -44,6 +44,25 @@ public class Base64Kit
|
||||
return loginData;
|
||||
}
|
||||
|
||||
public static string Decode(string data)
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(data);
|
||||
for (int i = 0, j = bytes.Length - 1; i < j; i += 1, j -= 1)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
(bytes[i], bytes[j]) = (bytes[j], bytes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
var str = Encoding.UTF8.GetString(bytes);
|
||||
var str1 = Base64EncodeUtil.Base64Decode(str);
|
||||
var key = NetworkManager.DomainRelease;
|
||||
var keyMD5 = MD5Kit.MD5String1(key);
|
||||
var result = str1.Replace(keyMD5, string.Empty);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string Decode(string data, string key)
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(data);
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37576943a7ef4dfb8a513089cc4fd50b
|
||||
timeCreated: 1699346255
|
||||
guid: 1ddfec3608bd54db781f2ad54f0c14a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public class CameraAdaptive : MonoBehaviour
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public class EngineEventSystem : MonoBehaviour
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public static class EventKit
|
||||
{
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
namespace LoveLegend
|
||||
{
|
||||
public class GLoaderPool
|
||||
{
|
||||
private static GLoaderPool _instance;
|
||||
public static GLoaderPool Instance => _instance ??= new GLoaderPool();
|
||||
|
||||
private readonly Queue<GLoader> pool = new Queue<GLoader>();
|
||||
private readonly LinkedList<GLoader> inUseLoaders = new LinkedList<GLoader>(); // 维护活跃顺序(LRU)
|
||||
|
||||
private int maxCount = 10; // 最大池子数量
|
||||
private int _width = 0;
|
||||
private int _height = 0;
|
||||
|
||||
private bool _autoDisposeTexture = true; // 是否自动释放贴图
|
||||
|
||||
private GLoaderPool() { }
|
||||
|
||||
/// <summary>
|
||||
/// 初始化 Loader 池
|
||||
/// </summary>
|
||||
public void Init(GComponent parentObj, int maxPoolCount, int width, int height, bool autoDisposeTexture = true)
|
||||
{
|
||||
maxCount = maxPoolCount;
|
||||
_width = width;
|
||||
_height = height;
|
||||
_autoDisposeTexture = autoDisposeTexture;
|
||||
|
||||
DisposeAll();
|
||||
|
||||
// 预创建 loader
|
||||
for (int i = 0; i < maxCount; i++)
|
||||
{
|
||||
var loader = CreateLoader();
|
||||
pool.Enqueue(loader);
|
||||
}
|
||||
}
|
||||
|
||||
private GLoader CreateLoader()
|
||||
{
|
||||
var loader = new GLoader
|
||||
{
|
||||
fill = FillType.ScaleMatchWidth,
|
||||
align = AlignType.Center,
|
||||
verticalAlign = VertAlignType.Top,
|
||||
visible = false
|
||||
};
|
||||
loader.SetSize(_width, _height);
|
||||
return loader;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从池中获取 Loader
|
||||
/// </summary>
|
||||
public GLoader GetLoader()
|
||||
{
|
||||
GLoader loader = null;
|
||||
|
||||
// 如果池子里有,直接取
|
||||
if (pool.Count > 0)
|
||||
{
|
||||
loader = pool.Dequeue();
|
||||
}
|
||||
else if (inUseLoaders.Count >= maxCount)
|
||||
{
|
||||
// 如果池满了,回收最久未使用的一个(LRU)
|
||||
loader = inUseLoaders.First.Value;
|
||||
inUseLoaders.RemoveFirst();
|
||||
RecycleLoader(loader);
|
||||
Debug.Log($"[LRU回收] 回收并复用一个 Loader");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 未达到上限,新建
|
||||
loader = CreateLoader();
|
||||
}
|
||||
|
||||
// 标记为使用中,放到链表末尾(最近使用)
|
||||
inUseLoaders.AddLast(loader);
|
||||
loader.visible = true;
|
||||
return loader;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 归还 Loader
|
||||
/// </summary>
|
||||
public void ReturnLoader(GLoader loader)
|
||||
{
|
||||
if (loader == null) return;
|
||||
|
||||
if (inUseLoaders.Contains(loader))
|
||||
{
|
||||
inUseLoaders.Remove(loader);
|
||||
RecycleLoader(loader);
|
||||
pool.Enqueue(loader);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("尝试归还未分配的 GLoader");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 回收 loader 的资源
|
||||
/// </summary>
|
||||
private void RecycleLoader(GLoader loader)
|
||||
{
|
||||
if (_autoDisposeTexture && loader.texture != null)
|
||||
{
|
||||
loader.texture.Dispose();
|
||||
}
|
||||
loader.url = null;
|
||||
loader.texture = null;
|
||||
loader.visible = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新 Loader 的使用顺序(需要主动调用,避免 LRU 误判)
|
||||
/// </summary>
|
||||
public void TouchLoader(GLoader loader)
|
||||
{
|
||||
if (loader == null || !inUseLoaders.Contains(loader)) return;
|
||||
inUseLoaders.Remove(loader);
|
||||
inUseLoaders.AddLast(loader); // 移到链表末尾,标记为最新使用
|
||||
}
|
||||
|
||||
public bool IsFromPool(GLoader loader)
|
||||
{
|
||||
return inUseLoaders.Contains(loader) || pool.Contains(loader);
|
||||
}
|
||||
|
||||
public int GetPoolCount() => pool.Count;
|
||||
public int GetInUseCount() => inUseLoaders.Count;
|
||||
|
||||
/// <summary>
|
||||
/// 清理全部
|
||||
/// </summary>
|
||||
public void DisposeAll()
|
||||
{
|
||||
foreach (var loader in pool)
|
||||
{
|
||||
loader?.Dispose();
|
||||
}
|
||||
foreach (var loader in inUseLoaders)
|
||||
{
|
||||
loader?.Dispose();
|
||||
}
|
||||
pool.Clear();
|
||||
inUseLoaders.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3954ee171192c47759324388524141f0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +1,6 @@
|
||||
using UObject = UnityEngine.Object;
|
||||
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public static class GeneralKit
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public class TaskSequence
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Linq;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public class EasyTimer : MonoBehaviour
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Linq;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public class NormalTimer : MonoBehaviour
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public class TimerTask
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public static class TimerHelper
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public class UnitConvertUtil
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using DG.Tweening;
|
||||
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public static class DOTweenHelper
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using FairyGUI;
|
||||
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public static class FGUIHelper
|
||||
{
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
using System.Globalization;
|
||||
using LoveLegend;
|
||||
|
||||
public static class Language
|
||||
{
|
||||
private static Dictionary<string, Dictionary<string, string>> _localizedText;
|
||||
private static string _currentLanguage;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
var lang = PlayerPrefsKit.ReadString("LangIdKey");
|
||||
if (lang.IsNullOrWhiteSpace())
|
||||
{
|
||||
var systemLanguage = Application.systemLanguage;
|
||||
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";
|
||||
} else
|
||||
{
|
||||
lang = "en";
|
||||
}
|
||||
}
|
||||
|
||||
setCurrentLanguage(lang);
|
||||
}
|
||||
|
||||
public static void setCurrentLanguage(string lang)
|
||||
{
|
||||
_currentLanguage = lang;
|
||||
PlayerPrefsKit.WriteString("LangIdKey", lang);
|
||||
UIManager.Instance.SetSwitchLanguage(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";
|
||||
}
|
||||
|
||||
public static SystemLanguage GetSystemLanguageCode(string ISO_Code)
|
||||
{
|
||||
if (ISO_Code == "fr") {
|
||||
return SystemLanguage.French;
|
||||
} else if (ISO_Code == "de") {
|
||||
return SystemLanguage.German;
|
||||
} else if (ISO_Code == "es") {
|
||||
return SystemLanguage.Spanish;
|
||||
} else if (ISO_Code == "ja") {
|
||||
return SystemLanguage.Japanese;
|
||||
} else if (ISO_Code == "ko") {
|
||||
return SystemLanguage.Korean;
|
||||
} else if (ISO_Code == "ru") {
|
||||
return SystemLanguage.Russian;
|
||||
} else if (ISO_Code == "pt") {
|
||||
return SystemLanguage.Portuguese;
|
||||
} else {
|
||||
return SystemLanguage.English;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2f5416f8c41487d85b9a37327291366
|
||||
timeCreated: 1751964505
|
||||
@@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public class ParticleUnscaledTime : MonoBehaviour
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public static class PlayerPrefsKit
|
||||
{
|
||||
|
||||
@@ -0,0 +1,382 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
|
||||
namespace LoveLegend
|
||||
{
|
||||
public static class PreDownloadManager
|
||||
{
|
||||
#region Live
|
||||
|
||||
public static void InitializeLiveData()
|
||||
{
|
||||
var liveConfigList = ConfigSystem.GetConfig<Live>();
|
||||
|
||||
Debug.Log($"[预下载视频 数据初始化]-0-----{DataMgr.LiveDataDic.Value.Count}");
|
||||
|
||||
var newData = new Dictionary<int, LiveData>();
|
||||
|
||||
for (var i = 0; i < liveConfigList.Count; i++)
|
||||
{
|
||||
var oldData = GetLiveDataByIndex(liveConfigList[i], i);
|
||||
|
||||
if (oldData.progress > 0) newData[i] = oldData;
|
||||
}
|
||||
|
||||
Debug.Log($"[预下载视频 数据初始化]--1----- {newData.Count}");
|
||||
DataMgr.LiveDataDic.Value = newData;
|
||||
}
|
||||
|
||||
public static LiveData GetLiveDataByIndex(Live liveConfig, int i)
|
||||
{
|
||||
DataMgr.LiveDataDic.Value.TryGetValue(i, out var oldData);
|
||||
|
||||
oldData ??= new LiveData
|
||||
{
|
||||
progress = liveConfig.Progress,
|
||||
AD_num = 0,
|
||||
Singleprogress = (100 - liveConfig.Progress) / liveConfig.AD
|
||||
};
|
||||
|
||||
if (oldData.progress < liveConfig.Progress) oldData.progress = liveConfig.Progress;
|
||||
|
||||
return oldData;
|
||||
}
|
||||
|
||||
// 最大同时下载数量
|
||||
private const int MaxConcurrentDownloads = 1;
|
||||
|
||||
public static void StartDownload()
|
||||
{
|
||||
CrazyAsyKit.StartCoroutine(DownloadVideosCoroutine());
|
||||
}
|
||||
|
||||
private static IEnumerator DownloadVideosCoroutine()
|
||||
{
|
||||
var liveConfigList = ConfigSystem.GetConfig<Live>();
|
||||
var liveDic = DataMgr.LiveDataDic.Value;
|
||||
|
||||
var downloadNameList = new List<string>();
|
||||
|
||||
// 先加入已有进度的视频
|
||||
foreach (var kvp in liveDic)
|
||||
{
|
||||
var index = kvp.Key;
|
||||
var data = kvp.Value;
|
||||
|
||||
if (data.progress > 0 && index < liveConfigList.Count) downloadNameList.Add(liveConfigList[index].Name);
|
||||
}
|
||||
|
||||
Debug.Log($"[init down video]---1---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||
|
||||
// 添加不在downloadNameList中的项,最多添加6个
|
||||
var addedCount = 0;
|
||||
for (var i = 0; i < liveConfigList.Count && addedCount < 6; i++)
|
||||
if (!downloadNameList.Contains(liveConfigList[i].Name))
|
||||
{
|
||||
downloadNameList.Add(liveConfigList[i].Name);
|
||||
addedCount++;
|
||||
}
|
||||
|
||||
Debug.Log($"[init down video]---2---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||
|
||||
// 当前正在下载的协程数量
|
||||
var runningCount = 0;
|
||||
var currentIndex = 0;
|
||||
|
||||
if (downloadNameList.Count > 0)
|
||||
{
|
||||
var name = downloadNameList[currentIndex];
|
||||
|
||||
var localPath = Path.Combine(TextureHelper.getResPath(), FolderNames.VideoName, name + ".enc");
|
||||
Debug.Log($"[预下载 视频 路径]-------localPath===={localPath}");
|
||||
|
||||
if (!File.Exists(localPath))
|
||||
{
|
||||
Debug.Log("[开始预下载 视频 ]---------------");
|
||||
runningCount++;
|
||||
CrazyAsyKit.StartCoroutine(DownloadSingleVideoCoroutine(name, () => { runningCount--; }));
|
||||
}
|
||||
}
|
||||
|
||||
// 等待下一帧再检查
|
||||
yield return null;
|
||||
Debug.Log("[init down video]---All downloads finished---");
|
||||
}
|
||||
|
||||
|
||||
private static IEnumerator DownloadSingleVideoCoroutine(string name, Action onComplete)
|
||||
{
|
||||
var isDone = false;
|
||||
|
||||
LiveVideoManager.Instance.GetVideoLocalPath(name, tex =>
|
||||
{
|
||||
Debug.Log($"[init down video]----------------{name}");
|
||||
isDone = true;
|
||||
}, false);
|
||||
|
||||
// 等待下载完成
|
||||
while (!isDone) yield return null;
|
||||
|
||||
onComplete?.Invoke();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Picture
|
||||
|
||||
public static void StartDownloadSecretPicture()
|
||||
{
|
||||
var liveConfigList = ConfigSystem.GetConfig<SecretAlbums>();
|
||||
var liveList = DataMgr.SecretUnlockList.Value;
|
||||
|
||||
var downloadNameList = new List<string>();
|
||||
|
||||
// 先加入所有可用的图片
|
||||
for (var i = 0; i < liveList.Count; i++)
|
||||
if (liveConfigList[i] != null && !downloadNameList.Contains(liveConfigList[i].Name))
|
||||
downloadNameList.Add(liveConfigList[i].Name);
|
||||
|
||||
Debug.Log(
|
||||
$"[init down picture Secret]---1---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||
|
||||
// 添加不在downloadNameList中的项,最多添加6个
|
||||
var addedCount = 0;
|
||||
for (var i = 0; i < liveConfigList.Count && addedCount < 6; i++)
|
||||
if (!downloadNameList.Contains(liveConfigList[i].Name))
|
||||
{
|
||||
downloadNameList.Add(liveConfigList[i].Name);
|
||||
addedCount++;
|
||||
}
|
||||
|
||||
Debug.Log(
|
||||
$"[init down picture Secret]---2---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||
|
||||
foreach (var name in downloadNameList)
|
||||
{
|
||||
var localPath = Path.Combine(TextureHelper.getResPath(), FolderNames.SecretName, name + ".jpg");
|
||||
Debug.Log($"[预下载 Secret 路径]-------localPath===={localPath}");
|
||||
if (!File.Exists(localPath))
|
||||
{
|
||||
Debug.Log("[开始预下载 Secret ]---------------");
|
||||
TextureHelper.SetImgLoader(null, name,
|
||||
s =>
|
||||
{
|
||||
Debug.Log($"[init down Secret picture]----------------{name}");
|
||||
}, "SecretAlbums/", FolderNames.SecretName, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void StartDownloadAlbumsPicture()
|
||||
{
|
||||
int Free_Alubum_0 = PlayerPrefs.GetInt("Free_Alubum_0", -1);
|
||||
int Free_Alubum_1 = PlayerPrefs.GetInt("Free_Alubum_1", -1);
|
||||
int AD_Alubum = PlayerPrefs.GetInt("AD_Alubum", -1);
|
||||
int Spec_Alubum = PlayerPrefs.GetInt("Spec_Alubum", -1);
|
||||
int Vip_Alubum = PlayerPrefs.GetInt("Vip_Alubum", -1);
|
||||
|
||||
if (Free_Alubum_0 >= 0) return;
|
||||
|
||||
var FreeImageLibrary_ = ConfigSystem.GetConfig<FreeImageLibrary>();
|
||||
var ADImageLibrary_ = ConfigSystem.GetConfig<ADImageLibrary>();
|
||||
var SpecialImageLibrary_ = ConfigSystem.GetConfig<SpecialImageLibrary>();
|
||||
var VIPImageLibrary_ = ConfigSystem.GetConfig<VIPImageLibrary>();
|
||||
|
||||
List<int> free_level_list = new List<int>();
|
||||
List<int> ad_level_list = new List<int>();
|
||||
List<int> special_level_list = new List<int>();
|
||||
List<int> vip_level_list = new List<int>();
|
||||
for (int i = 0; i < DataMgr.LevelUnlockListNew.Value.Count; i++)
|
||||
{
|
||||
if (DataMgr.LevelUnlockListNew.Value[i].type == 0) free_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
||||
else if (DataMgr.LevelUnlockListNew.Value[i].type == 1) ad_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
||||
else if (DataMgr.LevelUnlockListNew.Value[i].type == 2) special_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
||||
else if (DataMgr.LevelUnlockListNew.Value[i].type == 3) vip_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
||||
}
|
||||
|
||||
|
||||
if (Free_Alubum_0 < 0)
|
||||
{
|
||||
HashSet<int> levelIds = new HashSet<int>(free_level_list);
|
||||
List<FreeImageLibrary> filtered = ConfigSystem.GetConfig<FreeImageLibrary>().Where(x => !levelIds.Contains(x.id)).ToList();
|
||||
if (filtered.Count > 0)
|
||||
{
|
||||
Free_Alubum_0 = filtered[UnityEngine.Random.Range(0, filtered.Count)].id;
|
||||
}
|
||||
else
|
||||
{
|
||||
Free_Alubum_0 = ConfigSystem.GetConfig<FreeImageLibrary>()[UnityEngine.Random.Range(0, ConfigSystem.GetConfig<FreeImageLibrary>().Count)].id;
|
||||
}
|
||||
free_level_list.Add(Free_Alubum_0);
|
||||
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
|
||||
}
|
||||
if (Free_Alubum_1 < 0)
|
||||
{
|
||||
HashSet<int> levelIds = new HashSet<int>(free_level_list);
|
||||
List<FreeImageLibrary> filtered = ConfigSystem.GetConfig<FreeImageLibrary>().Where(x => !levelIds.Contains(x.id)).ToList();
|
||||
if (filtered.Count > 0)
|
||||
{
|
||||
Free_Alubum_1 = filtered[UnityEngine.Random.Range(0, filtered.Count)].id;
|
||||
}
|
||||
else
|
||||
{
|
||||
Free_Alubum_1 = ConfigSystem.GetConfig<FreeImageLibrary>()[UnityEngine.Random.Range(0, ConfigSystem.GetConfig<FreeImageLibrary>().Count)].id;
|
||||
}
|
||||
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
|
||||
}
|
||||
|
||||
|
||||
if (AD_Alubum < 0)
|
||||
{
|
||||
HashSet<int> levelIds = new HashSet<int>(ad_level_list);
|
||||
List<ADImageLibrary> filtered = ConfigSystem.GetConfig<ADImageLibrary>().Where(x => !levelIds.Contains(x.id)).ToList();
|
||||
if (filtered.Count > 0)
|
||||
{
|
||||
AD_Alubum = filtered[UnityEngine.Random.Range(0, filtered.Count)].id;
|
||||
}
|
||||
else
|
||||
{
|
||||
AD_Alubum = ConfigSystem.GetConfig<ADImageLibrary>()[UnityEngine.Random.Range(0, ConfigSystem.GetConfig<ADImageLibrary>().Count)].id;
|
||||
}
|
||||
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
|
||||
}
|
||||
|
||||
if (Spec_Alubum < 0)
|
||||
{
|
||||
HashSet<int> levelIds = new HashSet<int>(special_level_list);
|
||||
List<SpecialImageLibrary> filtered = ConfigSystem.GetConfig<SpecialImageLibrary>().Where(x => !levelIds.Contains(x.id)).ToList();
|
||||
if (filtered.Count > 0)
|
||||
{
|
||||
Spec_Alubum = filtered[UnityEngine.Random.Range(0, filtered.Count)].id;
|
||||
}
|
||||
else
|
||||
{
|
||||
Spec_Alubum = ConfigSystem.GetConfig<SpecialImageLibrary>()[UnityEngine.Random.Range(0, ConfigSystem.GetConfig<SpecialImageLibrary>().Count)].id;
|
||||
}
|
||||
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
|
||||
}
|
||||
|
||||
if (Vip_Alubum < 0)
|
||||
{
|
||||
HashSet<int> levelIds = new HashSet<int>(vip_level_list);
|
||||
List<VIPImageLibrary> filtered = ConfigSystem.GetConfig<VIPImageLibrary>().Where(x => !levelIds.Contains(x.id)).ToList();
|
||||
if (filtered.Count > 0)
|
||||
{
|
||||
Vip_Alubum = filtered[UnityEngine.Random.Range(0, filtered.Count)].id;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vip_Alubum = ConfigSystem.GetConfig<VIPImageLibrary>()[UnityEngine.Random.Range(0, ConfigSystem.GetConfig<VIPImageLibrary>().Count)].id;
|
||||
}
|
||||
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
|
||||
}
|
||||
PlayerPrefs.SetInt("Free_Alubum_0", Free_Alubum_0);
|
||||
PlayerPrefs.SetInt("Free_Alubum_1", Free_Alubum_1);
|
||||
PlayerPrefs.SetInt("AD_Alubum", AD_Alubum);
|
||||
PlayerPrefs.SetInt("Spec_Alubum", Spec_Alubum);
|
||||
PlayerPrefs.SetInt("Vip_Alubum", Vip_Alubum);
|
||||
|
||||
var downloadNameList = new List<string>
|
||||
{
|
||||
FreeImageLibrary_[Free_Alubum_0].Name,
|
||||
FreeImageLibrary_[Free_Alubum_1].Name,
|
||||
ADImageLibrary_[AD_Alubum].Name,
|
||||
SpecialImageLibrary_[Spec_Alubum].Name,
|
||||
VIPImageLibrary_[Vip_Alubum].Name
|
||||
};
|
||||
|
||||
Debug.Log(
|
||||
$"[init down picture Album]---1---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||
|
||||
// 添加不在downloadNameList中的项,最多添加12个
|
||||
// var addedCount = 0;
|
||||
// for (var i = 0; i < liveConfigList.Count && addedCount < 6; i++)
|
||||
// if (!downloadNameList.Contains(liveConfigList[i].Name))
|
||||
// {
|
||||
// downloadNameList.Add(liveConfigList[i].Name);
|
||||
// addedCount++;
|
||||
// }
|
||||
|
||||
Debug.Log(
|
||||
$"[init down picture Album]---2---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||
|
||||
// int centerIndex = GameHelper.GetLevel();
|
||||
// int totalCount = downloadNameList.Count;
|
||||
|
||||
// // 计算起始索引和实际要取的数量
|
||||
// int rangeStart = Math.Max(0, centerIndex - 5);
|
||||
// int rangeEnd = Math.Min(totalCount, centerIndex + 5);
|
||||
// int rangeCount = rangeEnd - rangeStart;
|
||||
|
||||
// // 获取范围内元素并反转
|
||||
// var segment = downloadNameList.GetRange(rangeStart, rangeCount);
|
||||
// segment.Reverse();
|
||||
|
||||
// // 移除原始位置的元素
|
||||
// downloadNameList.RemoveRange(rangeStart, rangeCount);
|
||||
|
||||
// // 插入反转后的元素到最前面
|
||||
// downloadNameList.InsertRange(0, segment);
|
||||
|
||||
|
||||
Debug.Log(
|
||||
$"[init down picture Album]---3---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||
|
||||
foreach (var name in downloadNameList)
|
||||
{
|
||||
var localPath = Path.Combine(TextureHelper.getResPath(), FolderNames.AlbumName, name + ".jpg");
|
||||
Debug.Log($"[预下载 Albums 路径]-------localPath===={localPath}");
|
||||
if (!File.Exists(localPath))
|
||||
{
|
||||
Debug.Log($"[开始预下载 Albums ]--------------name-{name}");
|
||||
TextureHelper.SetImgLoader(null, name,
|
||||
s =>
|
||||
{
|
||||
Debug.Log($"[init down Album picture]----------------{name}");
|
||||
}, "LevelAlbums/", FolderNames.AlbumName, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void StartDownloadLivePicture()
|
||||
{
|
||||
var liveConfigList = ConfigSystem.GetConfig<Live>();
|
||||
var liveList = DataMgr.SecretUnlockList.Value;
|
||||
|
||||
var downloadNameList = new List<string>();
|
||||
|
||||
// 先加入所有可用的图片
|
||||
for (var i = 0; i < liveConfigList.Count; i++)
|
||||
if (liveConfigList[i] != null && !downloadNameList.Contains(liveConfigList[i].Name))
|
||||
downloadNameList.Add(liveConfigList[i].Name);
|
||||
|
||||
Debug.Log(
|
||||
$"[init down picture LiveCover]---1---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||
|
||||
// 添加不在downloadNameList中的项,最多添加6个
|
||||
|
||||
foreach (var name in downloadNameList)
|
||||
{
|
||||
var localPath = Path.Combine(TextureHelper.getResPath(), FolderNames.VideoCoversName, name + "_cover" + ".jpg");
|
||||
Debug.Log($"[预下载 Secret 路径]-------localPath===={localPath}");
|
||||
if (!File.Exists(localPath))
|
||||
{
|
||||
Debug.Log("[开始预下载 Secret ]---------------");
|
||||
TextureHelper.SetImgLoader(null, name + "_cover",
|
||||
s =>
|
||||
{
|
||||
Debug.Log($"[init down VideoCovers picture]----------------{name}");
|
||||
}, "LiveAlbums/", FolderNames.VideoCoversName, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0a11e2b27329409282f78c585416391
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using LoveLegend;
|
||||
|
||||
namespace LoveLegend
|
||||
{
|
||||
|
||||
public class Rescrypt
|
||||
{
|
||||
// 魔法字节标记
|
||||
private static readonly byte[] Magic = Encoding.UTF8.GetBytes("SGENCRY");
|
||||
// 解密文件:从 src 读出,解密后写到 dst
|
||||
public static void DecryptFile(string src, string dst)
|
||||
{
|
||||
var key = ConfigSystem.GetCommonConf().ResVersion;
|
||||
var data = File.ReadAllBytes(src);
|
||||
// 检查魔法字节
|
||||
if (data.Length < Magic.Length || !data.Take(Magic.Length).SequenceEqual(Magic)) throw new InvalidDataException("文件未加密或格式错误");
|
||||
// 去掉魔法字节
|
||||
var raw = data.Skip(Magic.Length).ToArray();
|
||||
|
||||
// 使用 MD5.Create() 计算 MD5
|
||||
byte[] rawHash;
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
rawHash = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
|
||||
}
|
||||
// 转成 32 字节十六进制 ASCII,与 Go 端 hex.EncodeToString 对应
|
||||
var keyBytes = Encoding.ASCII.GetBytes(BitConverter.ToString(rawHash).Replace("-", "").ToLower());
|
||||
// 解密
|
||||
var dec = KeyReverseDecryptData(raw, keyBytes);
|
||||
// 写出解密后的文件
|
||||
File.WriteAllBytes(dst, dec);
|
||||
// 删除临时源文件(加密的)
|
||||
File.Delete(src);
|
||||
}
|
||||
|
||||
public static byte[] DecryptFileToBytes(string src)
|
||||
{
|
||||
var data = File.ReadAllBytes(src);
|
||||
|
||||
var key = ConfigSystem.GetCommonConf().ResVersion;
|
||||
|
||||
// 检查魔法字节
|
||||
if (data.Length < Magic.Length || !data.Take(Magic.Length).SequenceEqual(Magic))
|
||||
throw new InvalidDataException("文件未加密或格式错误");
|
||||
|
||||
// 去掉魔法字节
|
||||
var raw = data.Skip(Magic.Length).ToArray();
|
||||
|
||||
// 使用 MD5.Create() 计算 MD5
|
||||
byte[] rawHash;
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
rawHash = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
|
||||
}
|
||||
// 转成 32 字节十六进制 ASCII,与 Go 端 hex.EncodeToString 对应
|
||||
var keyBytes = Encoding.ASCII.GetBytes(BitConverter.ToString(rawHash).Replace("-", "").ToLower());
|
||||
|
||||
// 解密并返回
|
||||
return KeyReverseDecryptData(raw, keyBytes);
|
||||
}
|
||||
|
||||
public static byte[] DecryptVideoToBytes(string src)
|
||||
{
|
||||
var key = ConfigSystem.GetCommonConf().ResVersion;
|
||||
|
||||
var data = File.ReadAllBytes(src);
|
||||
if (data.Length < Magic.Length || !data.Take(Magic.Length).SequenceEqual(Magic))
|
||||
throw new InvalidDataException("视频未加密或格式错误");
|
||||
|
||||
var raw = data.Skip(Magic.Length).ToArray();
|
||||
|
||||
// 使用 MD5.Create() 计算 MD5
|
||||
byte[] rawHash;
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
rawHash = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
|
||||
}
|
||||
// 转成 32 字节十六进制 ASCII,与 Go 端 hex.EncodeToString 对应
|
||||
var keyBytes = Encoding.ASCII.GetBytes(BitConverter.ToString(rawHash).Replace("-", "").ToLower());
|
||||
|
||||
return KeyReverseDecryptData(raw, keyBytes);
|
||||
}
|
||||
|
||||
|
||||
// 基础解密:XOR + 反序
|
||||
private static byte[] KeyReverseDecryptData(byte[] data, byte[] key)
|
||||
{
|
||||
var keyLen = key.Length;
|
||||
// XOR
|
||||
for (var i = 0; i < data.Length; i++)
|
||||
data[i] ^= key[i % keyLen];
|
||||
// 反序
|
||||
for (int i = 0, j = data.Length - 1; i < j; i++, j--)
|
||||
(data[i], data[j]) = (data[j], data[i]);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37b4a56da851f4f2b93c638554b51445
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,46 +1,42 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using AppsFlyerSDK;
|
||||
using DG.Tweening;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using SGModule.NetKit;
|
||||
|
||||
// using AppsFlyerSDK;
|
||||
|
||||
// using AppsFlyerSDK;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public class MaxADKit
|
||||
{
|
||||
public static string SDKKey =
|
||||
"oXM0CzVDi7P1HstOpKvFMInPMOzpQ9uA6t3x75q5f5wQvsEy9vuiiiM94ZJCJSV7PcZGroSSInQCTGsu04QEiE";
|
||||
|
||||
public static string interstitialADUnitID = "12480e9974faffec";
|
||||
public static string interstitialADUnitID = "e3b89b902a31fb28";
|
||||
|
||||
|
||||
public static string rewardedADUnitID = "487d531ebc72302d";
|
||||
public static string AppOpenAdUnitId = "df561dae26462676";
|
||||
public static string rewardedADUnitID = "a19836405c24924d";
|
||||
|
||||
|
||||
private const float RevenueThreshold = 0.1f;
|
||||
private const float RevenueThreshold = 0;
|
||||
|
||||
|
||||
public static Dictionary<string, string> adCallbackInfo;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
MaxSdkCallbacks.OnSdkInitializedEvent += sdkConfiguration =>
|
||||
{
|
||||
if (PlayerPrefs.GetInt("OpenAD", 1) == 1) InitOpenAds();
|
||||
else GameDispatcher.Instance.Dispatch(GameMsg.CloseMask);
|
||||
|
||||
DOVirtual.DelayedCall(7, () =>
|
||||
{
|
||||
InitializeRewardedAds();
|
||||
InitializeInterstitialAds();
|
||||
});
|
||||
InitializeRewardedAds();
|
||||
InitializeInterstitialAds();
|
||||
};
|
||||
|
||||
|
||||
@@ -56,8 +52,15 @@ namespace FlowerPower
|
||||
MaxSdk.InitializeSdk();
|
||||
|
||||
// MaxSdk.ShowMediationDebugger();
|
||||
// #if !UNITY_EDITOR
|
||||
// MBridgeSDKManager.initialize("368295", "fc0155e8f6e8bda23b06d22414379609");
|
||||
// #endif
|
||||
}
|
||||
|
||||
adCallbackInfo = new Dictionary<string, string>();
|
||||
public static void SetUserID(string userID)
|
||||
{
|
||||
user_id = userID;
|
||||
MaxSdk.SetUserId(user_id);
|
||||
}
|
||||
|
||||
#region 插屏广告相关
|
||||
@@ -100,12 +103,15 @@ namespace FlowerPower
|
||||
private static void LoadInterstitial()
|
||||
{
|
||||
MaxSdk.LoadInterstitial(interstitialADUnitID);
|
||||
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_REQUEST, "Interstitial");
|
||||
}
|
||||
|
||||
private static void OnInterstitialLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
retryAttemptInterstitial = 0;
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.video_type, BuriedPointEvent.Interstitial_videos_fill_number, 1);
|
||||
// NetworkKit.BuriedPoint(BuriedPointEvent.video_type, BuriedPointEvent.Interstitial_videos_fill_number, 1);
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_INVENTORY, "Interstitial", adInfo.Placement, adInfo.NetworkName);
|
||||
}
|
||||
|
||||
private static void OnInterstitialLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
||||
@@ -118,6 +124,9 @@ namespace FlowerPower
|
||||
|
||||
private static void OnInterstitialDisplayedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_IMP, "Interstitial", adInfo.Placement, adInfo.NetworkName,
|
||||
adInfo.Revenue, _placement);
|
||||
}
|
||||
|
||||
private static void OnInterstitialAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo,
|
||||
@@ -128,6 +137,7 @@ namespace FlowerPower
|
||||
|
||||
private static void OnInterstitialClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_CLICK, "Interstitial", adInfo.Placement, adInfo.NetworkName);
|
||||
}
|
||||
|
||||
private static void OnInterstitialHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
@@ -135,112 +145,71 @@ namespace FlowerPower
|
||||
LoadInterstitial();
|
||||
onInterstitialAdCompleted?.Invoke(true);
|
||||
onInterstitialAdCompleted = null;
|
||||
#if !GAME_RELEASE
|
||||
GameHelper.AdOverRevenueEvent(2, 0.1f);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 开屏相关
|
||||
public static UnityAction<bool> onAppOpenAdCompleted;
|
||||
private static void LoadAppOpenAd()
|
||||
{
|
||||
Debug.Log("LOAD APP. AD");
|
||||
MaxSdk.LoadAppOpenAd(AppOpenAdUnitId);
|
||||
}
|
||||
|
||||
|
||||
public static void ShowOpenAdIfReady(UnityAction<bool> onCompleted = null)
|
||||
{
|
||||
// #if UNITY_EDITOR
|
||||
// onCompleted?.Invoke(true);
|
||||
// #else
|
||||
onAppOpenAdCompleted = onCompleted;
|
||||
if (!IsLoaded)
|
||||
{
|
||||
MaxSdkCallbacks.AppOpen.OnAdLoadedEvent += ShowOpenAd;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// bool isFinished = NetworkManager.isWatchedAD;
|
||||
// onCompleted?.Invoke(isFinished);
|
||||
ShowOpenAd(null, null);
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
public static void ShowOpenAd(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
MaxSdk.ShowAppOpenAd(AppOpenAdUnitId);
|
||||
}
|
||||
|
||||
|
||||
public static void InitOpenAds()
|
||||
{
|
||||
|
||||
MaxSdkCallbacks.AppOpen.OnAdLoadedEvent += OnAppOpenLoadedEvent;
|
||||
MaxSdkCallbacks.AppOpen.OnAdLoadFailedEvent += OnOpendAdLoadFailedEvent;
|
||||
// MaxSdkCallbacks.AppOpen.OnAdDisplayedEvent += OnInterstitialDisplayedEvent;
|
||||
MaxSdkCallbacks.AppOpen.OnAdClickedEvent += OnOpenClickedEvent;
|
||||
MaxSdkCallbacks.AppOpen.OnAdHiddenEvent += OnOpenAdHiddenEvent;
|
||||
// MaxSdkCallbacks.AppOpen.OnAdDisplayFailedEvent += OnInterstitialAdFailedToDisplayEvent;
|
||||
MaxSdkCallbacks.AppOpen.OnAdRevenuePaidEvent += OnOpenAdRevenueEvent;
|
||||
LoadAppOpenAd();
|
||||
}
|
||||
private static void OnOpenClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.open_ad, BuriedPointEvent.open_show, 1);
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.open_ad, BuriedPointEvent.open_show_people, 1);
|
||||
}
|
||||
private static bool IsLoaded = false;
|
||||
private static void OnAppOpenLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
IsLoaded = true;
|
||||
}
|
||||
private static void OnOpendAdLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
||||
{
|
||||
// retryAttempt++;
|
||||
// double retryDelay = Math.Pow(2, Math.Min(6, retryAttempt));
|
||||
|
||||
// CrazyAsyKit.StartAction("LoadRewardedAd", LoadRewardedAd, (float)retryDelay);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.CloseMask);
|
||||
InitializeRewardedAds();
|
||||
InitializeInterstitialAds();
|
||||
}
|
||||
private static void OnOpenAdHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
// LoadAppOpenAd();
|
||||
onAppOpenAdCompleted?.Invoke(true);
|
||||
onAppOpenAdCompleted = null;
|
||||
// if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveObject().is_get_removead && (Random.Range(0, 100) < GameHelper.GetCommonModel().rewardinsertion))
|
||||
// {
|
||||
// TrackManager.GetInstance.SendTrackEvent(TrackKeys.AfterRewardAdShow);
|
||||
|
||||
// GameHelper.ShowInterstitial("AfterReward");
|
||||
// }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 激励视频广告相关
|
||||
|
||||
|
||||
public static UnityAction<bool> onVideoAdCompleted = null;
|
||||
private static string _placement = "";
|
||||
private static Coroutine _waitForVideoAd = null;
|
||||
public static void ShowVideo(string placement = "DefaultVideo", UnityAction<bool> onCompleted = null)
|
||||
{
|
||||
onVideoAdCompleted = onCompleted;
|
||||
_placement = placement;
|
||||
#if UNITY_EDITOR
|
||||
onCompleted?.Invoke(true);
|
||||
onVideoAdCompleted?.Invoke(true);
|
||||
#else
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.video_behavior,BuriedPointEvent.watch_ad_people,1);
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.video_type,BuriedPointEvent.Rewarded_videos_trigger_number,1);
|
||||
TrackKit.SendEvent(VideoBehaviorTrack.Event, VideoBehaviorTrack.Property.watch_ad_people);
|
||||
TrackKit.SendEvent(VideoBehaviorTrack.Event, VideoBehaviorTrack.Property.Rewarded_videos_trigger_number);
|
||||
|
||||
if (MaxSdk.IsRewardedAdReady(rewardedADUnitID))
|
||||
{
|
||||
MaxSdk.ShowRewardedAd(rewardedADUnitID, placement);
|
||||
onVideoAdCompleted=onCompleted;
|
||||
MaxSdk.ShowRewardedAd(rewardedADUnitID, _placement);
|
||||
}
|
||||
else
|
||||
{
|
||||
onCompleted?.Invoke(false);
|
||||
if (_waitForVideoAd != null)
|
||||
{
|
||||
CrazyAsyKit.StopCoroutine(_waitForVideoAd);
|
||||
}
|
||||
_waitForVideoAd = CrazyAsyKit.StartCoroutine(WaitForVideoAd());
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
private static IEnumerator WaitForVideoAd()
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Open);
|
||||
var count = 0;
|
||||
var result = false;
|
||||
while (count < 6)
|
||||
{
|
||||
if (MaxSdk.IsRewardedAdReady(rewardedADUnitID))
|
||||
{
|
||||
result = true;
|
||||
MaxSdk.ShowRewardedAd(rewardedADUnitID, _placement);
|
||||
break;
|
||||
}
|
||||
|
||||
count++;
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
}
|
||||
|
||||
if (!result)
|
||||
{
|
||||
onVideoAdCompleted?.Invoke(result);
|
||||
}
|
||||
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
||||
_waitForVideoAd = null;
|
||||
}
|
||||
|
||||
static int retryAttempt;
|
||||
@@ -264,32 +233,24 @@ namespace FlowerPower
|
||||
private static void LoadRewardedAd()
|
||||
{
|
||||
MaxSdk.LoadRewardedAd(rewardedADUnitID);
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_REQUEST, "RewardedVideo");
|
||||
}
|
||||
|
||||
private static void OnInterstitialAdRevenueEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
OnAdRevenuePaidEvent(adUnitId, adInfo, 2);
|
||||
#if !FlowerPowerRelease
|
||||
GameHelper.AdOverRevenueEvent(2, 0.1f);
|
||||
#endif
|
||||
DOVirtual.DelayedCall(0.1f, () =>
|
||||
{
|
||||
OnAdRevenuePaidEvent(adUnitId, adInfo, 2);
|
||||
});
|
||||
}
|
||||
|
||||
private static void OnRewardedAdRevenueEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
OnAdRevenuePaidEvent(adUnitId, adInfo, 1);
|
||||
#if !FlowerPowerRelease
|
||||
GameHelper.AdOverRevenueEvent(1, 0.1f);
|
||||
#endif
|
||||
DOVirtual.DelayedCall(0.1f, () =>
|
||||
{
|
||||
OnAdRevenuePaidEvent(adUnitId, adInfo, 1);
|
||||
});
|
||||
}
|
||||
|
||||
private static void OnOpenAdRevenueEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
OnAdRevenuePaidEvent(adUnitId, adInfo, 3);
|
||||
#if !FlowerPowerRelease
|
||||
GameHelper.AdOverRevenueEvent(3, 0.1f);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string user_id = "";
|
||||
private static void OnAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo, int adType)
|
||||
{
|
||||
@@ -297,40 +258,27 @@ namespace FlowerPower
|
||||
// //string networkName = adInfo.NetworkName; // Display name of the network that showed the ad
|
||||
// // string adUnitIdentifier = adInfo.AdUnitIdentifier; // The MAX Ad Unit ID
|
||||
// //string placement = adInfo.Placement; // The placement this ad's postbacks are tied to
|
||||
// // string networkPlacement = adInfo.NetworkPlacement; // The placement ID from the network that showed the ad
|
||||
string countryCode = "USD";
|
||||
|
||||
adCallbackInfo.Clear();
|
||||
adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
|
||||
adCallbackInfo.Add("customer_user_id", user_id);
|
||||
adCallbackInfo.Add("af_currency", countryCode);
|
||||
|
||||
//广告收益上传(扣量)((用户累计收益大于0.1上报50%,50%可配置))
|
||||
double revenue = Convert.ToDouble(PlayerPrefs.GetString($"adInfoRevenue_{user_id}", "0"));
|
||||
revenue += adInfo.Revenue;
|
||||
|
||||
if (adInfo.Revenue > 0)
|
||||
|
||||
//广告收益上传(用户收益,每次上传)
|
||||
double revenue = adInfo.Revenue;
|
||||
|
||||
if (revenue > 0)
|
||||
{
|
||||
GameHelper.AdOverRevenueEvent(adType, (float)adInfo.Revenue);
|
||||
GameHelper.AdOverRevenueEvent(adType, (float)revenue);
|
||||
}
|
||||
|
||||
// Debug.Log($"revenue: {revenue} \n adInfo.Revenue: {adInfo.Revenue}");
|
||||
Debug.Log($"[OnAdRevenuePaidEvent] revenue: {revenue} \n adInfo.Revenue: {JsonConvert.SerializeObject(adInfo)}");
|
||||
|
||||
// if (revenue >= RevenueThreshold)
|
||||
// {
|
||||
Dictionary<string, string> adCallbackInfo = new Dictionary<string, string>();
|
||||
if (revenue > RevenueThreshold)
|
||||
{
|
||||
adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
|
||||
AppsFlyer.sendEvent("af_ad_revenue", adCallbackInfo);
|
||||
PlayerPrefs.SetString($"adInfoRevenue_{user_id}", "0");
|
||||
|
||||
int adrate = ConfigSystem.GetConfig<CommonModel>().adrate / 100;
|
||||
double revenueAdrate = revenue * adrate;
|
||||
adCallbackInfo["af_revenue"] = revenueAdrate.ToString(CultureInfo.InvariantCulture);
|
||||
AppsFlyer.sendEvent("Af_new_ad_revenue", adCallbackInfo);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// PlayerPrefs.SetString($"adInfoRevenue_{user_id}", revenue.ToString());
|
||||
// }
|
||||
}
|
||||
|
||||
int highSend;
|
||||
if (!PlayerPrefs.HasKey($"sendHighRevenue_{user_id}"))
|
||||
@@ -359,58 +307,91 @@ namespace FlowerPower
|
||||
PlayerPrefs.SetString($"adRevenueTotal_{user_id}", totalNum.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ATTRIBUTION_PLATFORM_APPSFLYER = "AppsFlyer";
|
||||
ATTRIBUTION_PLATFORM_ADJUST = "Adjust";
|
||||
ATTRIBUTION_PLATFORM_TENJIN = "Tenjin";
|
||||
ATTRIBUTION_PLATFORM_SINGULAR = "Singular";
|
||||
ATTRIBUTION_PLATFORM_KOCHAVA = "Kochava";
|
||||
ATTRIBUTION_PLATFORM_BRANCH = "Branch";
|
||||
ATTRIBUTION_PLATFORM_REYUN = "Reyun";
|
||||
ATTRIBUTION_PLATFORM_SOLAR_ENGINE = "SolarEngine";
|
||||
...
|
||||
...
|
||||
*/
|
||||
|
||||
//这里需要改成自己的归因平台名称,这里以Adjust为例,"userid"替换为归因平台UID
|
||||
// MBridgeRevenueParamsEntity mBridgeRevenueParamsEntity = new MBridgeRevenueParamsEntity(MBridgeRevenueParamsEntity.ATTRIBUTION_PLATFORM_ADJUST, PlayerPrefs.GetString("adjust_adid", "default"));
|
||||
|
||||
///MaxSdkBase.AdInfo类型的adInfo
|
||||
// mBridgeRevenueParamsEntity.SetMaxAdInfo(adInfo);
|
||||
// MBridgeRevenueManager.Track(mBridgeRevenueParamsEntity);
|
||||
|
||||
}
|
||||
private static void OnRewardedAdLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
retryAttempt = 0;
|
||||
TrackKit.SendEvent(ADEventTrack.Event, $"{ADEventTrack.Property.ad_load_code}Succeed");
|
||||
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_INVENTORY, "RewardedVideo", adInfo.Placement, adInfo.NetworkName);
|
||||
}
|
||||
|
||||
private static void OnRewardedAdLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
||||
{
|
||||
retryAttempt++;
|
||||
double retryDelay = Math.Pow(2, Math.Min(6, retryAttempt));
|
||||
double retryDelay = Math.Pow(2, Math.Min(3, retryAttempt));
|
||||
|
||||
TrackKit.SendEvent(ADEventTrack.Event, $"{ADEventTrack.Property.ad_load_code}{errorInfo.Code}");
|
||||
CrazyAsyKit.StartAction("LoadRewardedAd", LoadRewardedAd, (float)retryDelay);
|
||||
}
|
||||
|
||||
private static void OnRewardedAdDisplayedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.Event, $"{ADEventTrack.Property.ad_show_code}Succeed");
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_IMP, "RewardedVideo", adInfo.Placement, adInfo.NetworkName, adInfo.Revenue, _placement);
|
||||
}
|
||||
|
||||
private static void OnRewardedAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo,
|
||||
MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.Event, $"{ADEventTrack.Property.ad_show_code}{errorInfo.Code}");
|
||||
|
||||
LoadRewardedAd();
|
||||
}
|
||||
|
||||
private static void OnRewardedAdClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_CLICK, "RewardedVideo", adInfo.Placement, adInfo.NetworkName);
|
||||
}
|
||||
|
||||
private static bool hasReceivedReward = false;
|
||||
private static void OnRewardedAdHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
LoadRewardedAd();
|
||||
if (hasReceivedReward && onVideoAdCompleted != null)
|
||||
|
||||
if (_hasReceivedReward && onVideoAdCompleted != null)
|
||||
{
|
||||
onVideoAdCompleted(true);
|
||||
}
|
||||
// 重置标志
|
||||
hasReceivedReward = false;
|
||||
onVideoAdCompleted = null;
|
||||
_hasReceivedReward = false;
|
||||
|
||||
if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveobject().is_get_removead && (UnityEngine.Random.Range(0, 100) < GameHelper.GetCommonModel().rewardinsertion))
|
||||
if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveObject().is_get_removead && (UnityEngine.Random.Range(0, 100) < GameHelper.GetCommonModel().rewardinsertion))
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.afterRewardAdShow, 1);
|
||||
TrackKit.SendEvent(ADEventTrack.Event, ADEventTrack.Property.afterRewardAdShow);
|
||||
|
||||
GameHelper.ShowInterstitial("AfterReward");
|
||||
}
|
||||
#if !GAME_RELEASE
|
||||
GameHelper.AdOverRevenueEvent(1, 0.1f);
|
||||
#endif
|
||||
}
|
||||
|
||||
private static bool _hasReceivedReward = false;
|
||||
private static void OnRewardedAdReceivedRewardEvent(string adUnitId, MaxSdk.Reward reward,
|
||||
MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
hasReceivedReward = true;
|
||||
_hasReceivedReward = true;
|
||||
}
|
||||
|
||||
private static void OnRewardedAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54652c0a462944f279bc642cf7d854a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
guid: d3991d0dfc5a46ddbb4a020f0c5e0abf
|
||||
timeCreated: 1704883729
|
||||
Reference in New Issue
Block a user