fix:1、修复bug。 2、1.0.8版本提审

This commit is contained in:
2026-05-15 11:09:47 +08:00
parent ee55c03120
commit 978797b678
121 changed files with 67129 additions and 66253 deletions
@@ -1,71 +1,72 @@
using SGModule.ConfigLoader;
namespace IgnoreOPS
{
[ConfigKey("Common", false)]
public class CommonModel
{
public int InitialNum;
public int[] inlineLoginDown;
public int inlineMin;
public int Purchaseprops;
public int rewardrate;
public int RevivalCoins;
public int[] wheelTimes;
public float Passportgift;
public float Passportgift2;
public int addspace;
public float addspace2;
public int AddDiscount;
public float AddDiscount2;
public int playtimes;
public int interstitialtype;
public int lobbyrewrdtime;
public int roomrewardrate;
public int Activetimes;
public int adrate;
public int roomrate;
public float afSendLimit;
public float afSendNum;
public int rewardinsertion;
public int exchangeCD = 120;
public int PayRate;
public int AddDiscountLevel;
public int AddDiscountCD;
public int AddSpaceLevel;
public int RemoveADsPackDuration;
public int RemoveADsPackPopup;
public string contactUs;
public int[] UnlockSecret;
public int[] UnlockLive;
public int Live;
public int Secret;
public int Assitant;
public int LivePreview;
public int SecretPreview;
public int HomeGuideRate;
public int roomGuideRate;
public int VIPGuide;
public int VIPGuideRate;
public int HomeInterstitialAd;
public int FreeClaims;
public int TurnOffPackRate;
public int TurnOffRewardsRate;
public int TurnOffRewardsCD;
public int TurnOffRewardslimit;
public int FailedGiftProgress;
public int BonusInside;
public int UnlockAIAssistant;
public int FreeMessages;
public int[] CoinsAccess;
public int AdAccess;
public int ClearRAM;
public int CoinsDownload;
public string ResVersion;
public int MultiModal;
}
using SGModule.ConfigLoader;
namespace IgnoreOPS
{
[ConfigKey("Common", false)]
public class CommonModel
{
public int InitialNum;
public int[] inlineLoginDown;
public int inlineMin;
public int Purchaseprops;
public int rewardrate;
public int RevivalCoins;
public int[] wheelTimes;
public float Passportgift;
public float Passportgift2;
public int addspace;
public float addspace2;
public int AddDiscount;
public float AddDiscount2;
public int playtimes;
public int interstitialtype;
public int lobbyrewrdtime;
public int roomrewardrate;
public int Activetimes;
public int adrate;
public int roomrate;
public float afSendLimit;
public float afSendNum;
public int rewardinsertion;
public int exchangeCD = 120;
public int PayRate;
public int AddDiscountLevel;
public int AddDiscountCD;
public int AddSpaceLevel;
public int RemoveADsPackDuration;
public int RemoveADsPackPopup;
public string contactUs;
public int[] UnlockSecret;
public int[] UnlockLive;
public int Live;
public int Secret;
public int Assitant;
public int LivePreview;
public int SecretPreview;
public int HomeGuideRate;
public int roomGuideRate;
public int VIPGuide;
public int VIPGuideRate;
public int HomeInterstitialAd;
public int FreeClaims;
public int TurnOffPackRate;
public int TurnOffRewardsRate;
public int TurnOffRewardsCD;
public int TurnOffRewardslimit;
public int FailedGiftProgress;
public int BonusInside;
public int UnlockAIAssistant;
public int FreeMessages;
public int[] CoinsAccess;
public int AdAccess;
public int ClearRAM;
public int CoinsDownload;
public string ResVersion;
public int MultiModal;
public int WVswitch;
}
}
@@ -7,7 +7,6 @@ namespace FGUI.LG_Common
{
public partial class btn_albums : GButton
{
public GGraph anim;
public GGroup panel;
public Transition t0;
public const string URL = "ui://c9mmg3dxccp2cc";
@@ -21,7 +20,6 @@ namespace FGUI.LG_Common
{
base.ConstructFromXML(xml);
anim = (GGraph)GetChildAt(0);
panel = (GGroup)GetChildAt(4);
t0 = GetTransitionAt(0);
}
@@ -7,7 +7,7 @@ namespace FGUI.LG_Common
{
public partial class btn_vip : GButton
{
public GGraph anim;
public Transition t0;
public const string URL = "ui://c9mmg3dxpjnncg";
public static btn_vip CreateInstance()
@@ -19,7 +19,7 @@ namespace FGUI.LG_Common
{
base.ConstructFromXML(xml);
anim = (GGraph)GetChildAt(0);
t0 = GetTransitionAt(0);
}
}
}
+10 -10
View File
@@ -15,7 +15,6 @@ namespace FGUI.LG_End
public GTextField tetx_level;
public GButton btn_setting;
public GGraph congra_parent;
public GButton btn_continue;
public GTextField text_levelType;
public GGraph bg_parent;
public GGraph bg_parent_title;
@@ -24,6 +23,7 @@ namespace FGUI.LG_End
public GTextField text_award;
public GButton btn_gold;
public GComponent com_loader;
public GButton btn_continue;
public GButton btn_download;
public GButton btn_restart;
public GComponent wheel;
@@ -52,15 +52,15 @@ namespace FGUI.LG_End
tetx_level = (GTextField)GetChildAt(4);
btn_setting = (GButton)GetChildAt(5);
congra_parent = (GGraph)GetChildAt(11);
btn_continue = (GButton)GetChildAt(12);
text_levelType = (GTextField)GetChildAt(13);
bg_parent = (GGraph)GetChildAt(14);
bg_parent_title = (GGraph)GetChildAt(19);
coin_parent = (GGraph)GetChildAt(20);
btn_mult = (GButton)GetChildAt(21);
text_award = (GTextField)GetChildAt(23);
btn_gold = (GButton)GetChildAt(24);
com_loader = (GComponent)GetChildAt(27);
text_levelType = (GTextField)GetChildAt(12);
bg_parent = (GGraph)GetChildAt(13);
bg_parent_title = (GGraph)GetChildAt(18);
coin_parent = (GGraph)GetChildAt(19);
btn_mult = (GButton)GetChildAt(20);
text_award = (GTextField)GetChildAt(22);
btn_gold = (GButton)GetChildAt(23);
com_loader = (GComponent)GetChildAt(26);
btn_continue = (GButton)GetChildAt(27);
btn_download = (GButton)GetChildAt(29);
btn_restart = (GButton)GetChildAt(30);
wheel = (GComponent)GetChildAt(31);
@@ -27,13 +27,13 @@ namespace FGUI.LG_Unlock
base.ConstructFromXML(xml);
type = GetControllerAt(0);
title1 = (GTextField)GetChildAt(1);
btn_subscribe = (GButton)GetChildAt(3);
text_coin = (GTextField)GetChildAt(4);
btn_gold = (GButton)GetChildAt(5);
text_level = (GTextField)GetChildAt(6);
btn_play = (GButton)GetChildAt(8);
btn_close = (GButton)GetChildAt(12);
title1 = (GTextField)GetChildAt(2);
btn_subscribe = (GButton)GetChildAt(4);
text_coin = (GTextField)GetChildAt(5);
btn_gold = (GButton)GetChildAt(6);
text_level = (GTextField)GetChildAt(7);
btn_play = (GButton)GetChildAt(9);
btn_close = (GButton)GetChildAt(13);
}
}
}
@@ -7,6 +7,7 @@ namespace FGUI.LG_Vip
{
public partial class com_vip : GComponent
{
public Controller viplevel;
public GLoader bg_loader;
public GList list;
public btn_vipType btn_week;
@@ -29,6 +30,7 @@ namespace FGUI.LG_Vip
{
base.ConstructFromXML(xml);
viplevel = GetControllerAt(0);
bg_loader = (GLoader)GetChildAt(2);
list = (GList)GetChildAt(7);
btn_week = (btn_vipType)GetChildAt(8);
@@ -22,8 +22,8 @@ namespace FGUI.LG_Vip
base.ConstructFromXML(xml);
have = GetControllerAt(0);
title = (GTextField)GetChildAt(0);
img_check = (GImage)GetChildAt(2);
title = (GTextField)GetChildAt(1);
img_check = (GImage)GetChildAt(3);
}
}
}
@@ -28,14 +28,14 @@ namespace FGUI.ZM_AddCell_12
base.ConstructFromXML(xml);
pay_type = GetControllerAt(0);
title = (GTextField)GetChildAt(1);
com_tips = (com_title)GetChildAt(3);
btn_watch = (GButton)GetChildAt(4);
ads = (GTextField)GetChildAt(5);
tips = (GTextField)GetChildAt(6);
broad = (GComponent)GetChildAt(7);
btn_max_pay = (GButton)GetChildAt(8);
btn_close = (GButton)GetChildAt(9);
title = (GTextField)GetChildAt(3);
com_tips = (com_title)GetChildAt(5);
btn_watch = (GButton)GetChildAt(6);
ads = (GTextField)GetChildAt(7);
tips = (GTextField)GetChildAt(8);
broad = (GComponent)GetChildAt(9);
btn_max_pay = (GButton)GetChildAt(10);
btn_close = (GButton)GetChildAt(11);
}
}
}
@@ -22,10 +22,10 @@ namespace FGUI.ZM_AddCell_12
{
base.ConstructFromXML(xml);
btn_close = (GButton)GetChildAt(1);
text_goldnum = (GTextField)GetChildAt(2);
btn_receive = (GButton)GetChildAt(3);
end_point = (GTextField)GetChildAt(4);
btn_close = (GButton)GetChildAt(2);
text_goldnum = (GTextField)GetChildAt(3);
btn_receive = (GButton)GetChildAt(4);
end_point = (GTextField)GetChildAt(5);
}
}
}
@@ -7,6 +7,7 @@ namespace FGUI.ZM_Common_01
{
public partial class btn_head : GButton
{
public Controller vip;
public head head;
public const string URL = "ui://o9974uc5emjh5e";
@@ -19,6 +20,7 @@ namespace FGUI.ZM_Common_01
{
base.ConstructFromXML(xml);
vip = GetControllerAt(0);
head = (head)GetChildAt(0);
}
}
@@ -18,6 +18,7 @@ namespace FGUI.ZM_Lobby_03
UIObjectFactory.SetPackageItemExtension(com_hall.URL, typeof(com_hall));
UIObjectFactory.SetPackageItemExtension(com_payloading.URL, typeof(com_payloading));
UIObjectFactory.SetPackageItemExtension(btn_play.URL, typeof(btn_play));
UIObjectFactory.SetPackageItemExtension(btn_sign.URL, typeof(btn_sign));
}
}
}
@@ -0,0 +1,25 @@
/** This is an automatically generated class by FairyGUI. Please do not modify it. **/
using FairyGUI;
using FairyGUI.Utils;
namespace FGUI.ZM_Lobby_03
{
public partial class btn_sign : GButton
{
public GImage red;
public const string URL = "ui://gytj501cwgo41d";
public static btn_sign CreateInstance()
{
return (btn_sign)UIPackage.CreateObject("ZM_Lobby_03", "btn_sign");
}
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
red = (GImage)GetChildAt(1);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1dbbeec11949a5047b958e65a13068b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -33,6 +33,7 @@ namespace FGUI.ZM_Lobby_03
public btn_level_play btn_play10;
public GGroup play_node;
public GButton btn_task_times;
public btn_sign btn_sign;
public GButton btn_wv;
public GButton btn_noads;
public GButton btn_restore;
@@ -50,7 +51,7 @@ namespace FGUI.ZM_Lobby_03
base.ConstructFromXML(xml);
state = GetControllerAt(0);
bg_loader = (GLoader)GetChildAt(1);
bg_loader = (GLoader)GetChildAt(2);
btn_play = (btn_play)GetChildAt(4);
btn_album = (GButton)GetChildAt(5);
btn_vip = (GButton)GetChildAt(6);
@@ -75,11 +76,12 @@ namespace FGUI.ZM_Lobby_03
btn_play10 = (btn_level_play)GetChildAt(25);
play_node = (GGroup)GetChildAt(26);
btn_task_times = (GButton)GetChildAt(27);
btn_wv = (GButton)GetChildAt(28);
btn_noads = (GButton)GetChildAt(29);
btn_restore = (GButton)GetChildAt(30);
btn_secret = (GButton)GetChildAt(31);
btn_chat = (GButton)GetChildAt(32);
btn_sign = (btn_sign)GetChildAt(28);
btn_wv = (GButton)GetChildAt(29);
btn_noads = (GButton)GetChildAt(30);
btn_restore = (GButton)GetChildAt(31);
btn_secret = (GButton)GetChildAt(32);
btn_chat = (GButton)GetChildAt(33);
}
}
}
@@ -12,6 +12,7 @@ namespace FGUI.ZM_Setting_07
public btn_menu btn_terms;
public btn_menu btn_language;
public btn_menu btn_official;
public btn_menu btn_email;
public GTextField text_uid;
public GTextField text_version;
public btn_music btn_music;
@@ -33,11 +34,12 @@ namespace FGUI.ZM_Setting_07
btn_terms = (btn_menu)GetChildAt(6);
btn_language = (btn_menu)GetChildAt(7);
btn_official = (btn_menu)GetChildAt(8);
text_uid = (GTextField)GetChildAt(9);
text_version = (GTextField)GetChildAt(10);
btn_music = (btn_music)GetChildAt(11);
btn_sound = (btn_sound)GetChildAt(12);
btn_restore = (btn_menu)GetChildAt(13);
btn_email = (btn_menu)GetChildAt(9);
text_uid = (GTextField)GetChildAt(10);
text_version = (GTextField)GetChildAt(11);
btn_music = (btn_music)GetChildAt(12);
btn_sound = (btn_sound)GetChildAt(13);
btn_restore = (btn_menu)GetChildAt(14);
}
}
}
@@ -25,7 +25,7 @@ namespace FGUI.ZM_Sign_06
status = GetControllerAt(0);
fx_parent = (GGraph)GetChildAt(2);
reward_num = (GTextField)GetChildAt(3);
line = (GImage)GetChildAt(6);
line = (GImage)GetChildAt(7);
}
}
}
@@ -27,12 +27,12 @@ namespace FGUI.ZM_Tasks_13
base.ConstructFromXML(xml);
bg_parent = (GGraph)GetChildAt(2);
btn_mult = (GButton)GetChildAt(5);
fx_place = (GGraph)GetChildAt(6);
text_award = (GTextField)GetChildAt(7);
btn_claim = (GButton)GetChildAt(8);
title1 = (GTextField)GetChildAt(9);
wheel = (GComponent)GetChildAt(10);
btn_mult = (GButton)GetChildAt(4);
fx_place = (GGraph)GetChildAt(5);
text_award = (GTextField)GetChildAt(6);
btn_claim = (GButton)GetChildAt(7);
title1 = (GTextField)GetChildAt(8);
wheel = (GComponent)GetChildAt(9);
t0 = GetTransitionAt(0);
}
}
+3 -2
View File
@@ -365,8 +365,8 @@ namespace BallKingdomCrush
// return false;
return true;
bool b = GetLoginModel().IsMagic;
// return true;
// bool b = GetLoginModel().IsMagic;
return GetLoginModel().IsMagic;
}
@@ -582,6 +582,7 @@ namespace BallKingdomCrush
var currentIndex = GetValueIndex(currentRmLevel);
Debug.Log($"GetRewardValue type:{type} currentIndex:{currentIndex}");
if (currentIndex != -1)
{
if (type == 0)
File diff suppressed because it is too large Load Diff
+3 -5
View File
@@ -74,11 +74,9 @@ namespace BallKingdomCrush
// lang = "en";
// }
// UIManager.Instance.SetSwitchLanguage(lang);
DataMgr.Coin.Value = 100000;
DataMgr.GameLevel.Value = 20;
// UIManager.Instance.SetSwitchLanguage(lang);
//更新map中的value,与配置表的id对应
PurchasingManager.SetShopMapValue();
//初始化商品(谷歌支付和ios支付)
// PurchasingManager.InitProduct();
+354 -354
View File
@@ -1,355 +1,355 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using UnityEngine;
namespace BallKingdomCrush
{
public static class PreDownloadManager
{
#region Live
public static void InitializeLiveData()
{
List<Live> 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()
{
List<Live> 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);
List<string> 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
};
for (int i = 0; i < GameHelper.GetCommonModel().MultiModal - 1; i++)
{
downloadNameList.Insert(i, ConfigSystem.GetConfig<LevelUnlock>()[i].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);
}
}
}
#endregion
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using UnityEngine;
namespace BallKingdomCrush
{
public static class PreDownloadManager
{
#region Live
public static void InitializeLiveData()
{
List<Live> liveConfigList = ConfigSystem.GetLiveConfig();
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()
{
List<Live> liveConfigList = ConfigSystem.GetLiveConfig();
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.GetSecretAlbumsConfig();
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.GetFreeImageConfig();
var ADImageLibrary_ = ConfigSystem.GetADImageConfig();
var SpecialImageLibrary_ = ConfigSystem.GetSpecialImageConfig();
var VIPImageLibrary_ = ConfigSystem.GetVIPImageConfig();
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.GetFreeImageConfig().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.GetFreeImageConfig()[UnityEngine.Random.Range(0, ConfigSystem.GetFreeImageConfig().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.GetFreeImageConfig().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.GetFreeImageConfig()[UnityEngine.Random.Range(0, ConfigSystem.GetFreeImageConfig().Count)].id;
}
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
}
if (AD_Alubum < 0)
{
HashSet<int> levelIds = new HashSet<int>(ad_level_list);
List<ADImageLibrary> filtered = ConfigSystem.GetADImageConfig().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.GetADImageConfig()[UnityEngine.Random.Range(0, ConfigSystem.GetADImageConfig().Count)].id;
}
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
}
if (Spec_Alubum < 0)
{
HashSet<int> levelIds = new HashSet<int>(special_level_list);
List<SpecialImageLibrary> filtered = ConfigSystem.GetSpecialImageConfig().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.GetSpecialImageConfig()[UnityEngine.Random.Range(0, ConfigSystem.GetSpecialImageConfig().Count)].id;
}
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
}
if (Vip_Alubum < 0)
{
HashSet<int> levelIds = new HashSet<int>(vip_level_list);
List<VIPImageLibrary> filtered = ConfigSystem.GetVIPImageConfig().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.GetVIPImageConfig()[UnityEngine.Random.Range(0, ConfigSystem.GetVIPImageConfig().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);
List<string> 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
};
for (int i = 0; i < GameHelper.GetCommonModel().MultiModal - 1; i++)
{
downloadNameList.Insert(i, ConfigSystem.GetLevelUnlockConfig()[i].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);
}
}
}
#endregion
}
}