Commit df03b0d8 authored by SherryChaos's avatar SherryChaos

monster cutin bug fix

parent d4a71944
MDPro3 v1.3.7更新: MDPro3 v1.3.7更新:
1.卡组编辑界面的[测试]按钮恢复功能,并以第一位WindBot为对手,不洗牌进行决斗。 1.卡组编辑界面的[测试]按钮恢复功能,并以第一位WindBot为对手,不洗牌进行决斗;
2.修复外观设置中,壁纸的[无设置]与[随机]不生效的错误;
3.修复 召唤兽 梅尔卡巴[75286622] 在非Windows端的Spine动画资源丢失的错误。
MDPro3 v1.3.6更新: MDPro3 v1.3.6更新:
1.新卡片特效:小丑与锁鸟[94145021]; 1.新卡片特效:小丑与锁鸟[94145021];
......
using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks;
using Org.Brotli.Dec; using Spine.Unity;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Threading; using System.Threading;
using UnityEngine; using UnityEngine;
using UnityEngine.Playables; using UnityEngine.Playables;
...@@ -285,6 +286,72 @@ namespace MDPro3 ...@@ -285,6 +286,72 @@ namespace MDPro3
return returnValue; return returnValue;
} }
public static async UniTask<GameObject> LoadMonsterCutinAsync(int code)
{
GameObject returnValue = null;
var path = $"MonsterCutin/{code}";
DirectoryInfo dir = new(Program.root + path);
#if !UNITY_EDITOR && (UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN)
dir = new DirectoryInfo(Path.Combine(Application.dataPath, Program.root + path));
#endif
FileInfo[] files = dir.GetFiles("*");
List<AssetBundle> bundles = new();
for (int i = 0; i < files.Length; i++)
bundles.Add(await AssetBundle.LoadFromFileAsync(files[i].FullName));
var loadedPrefabs = new List<GameObject>();
foreach (AssetBundle bundle in bundles)
{
var prefabs = bundle.LoadAllAssets();
for (int j = 0; j < prefabs.Length; j++)
if (typeof(GameObject).IsInstanceOfType(prefabs[j]))
loadedPrefabs.Add(prefabs[j] as GameObject);
}
foreach (var prefab in loadedPrefabs)
{
if (prefab.TryGetComponent<PlayableDirector>(out _))
{
returnValue = prefab;
break;
}
}
if(returnValue == null)
{
Debug.LogError("[ABLoader]: Monster Cutin load null.");
return null;
}
//召唤兽 梅尔卡巴[75286622]在安卓端和iOS端的Spine动画资源丢失,
//临时修复方案为从已加载的AssetBundle中寻找SkeletonDataAsset并赋值。
if (returnValue.transform.GetChild(0).GetChild(0).TryGetComponent<SkeletonAnimation>(out var sa))
{
if (sa.skeletonDataAsset == null)
{
var allAssets = new List<Object>();
foreach (AssetBundle bundle in bundles)
{
var assets = bundle.LoadAllAssets();
allAssets.AddRange(assets.ToList());
}
foreach(var asset in allAssets)
if (asset is SkeletonDataAsset sda)
{
sa.skeletonDataAsset = sda;
break;
}
}
}
foreach (AssetBundle bundle in bundles)
bundle.Unload(false);
var instance = UnityEngine.Object.Instantiate(returnValue);
return instance;
}
public static async UniTask<Material> LoadProtectorMaterial(string code, CancellationToken token) public static async UniTask<Material> LoadProtectorMaterial(string code, CancellationToken token)
{ {
await protectorSemaphoreSlim.WaitAsync(token); await protectorSemaphoreSlim.WaitAsync(token);
......
...@@ -3,6 +3,7 @@ using DG.Tweening; ...@@ -3,6 +3,7 @@ using DG.Tweening;
using MDPro3.Duel.YGOSharp; using MDPro3.Duel.YGOSharp;
using MDPro3.UI; using MDPro3.UI;
using MDPro3.UI.ServantUI; using MDPro3.UI.ServantUI;
using Spine.Unity;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
...@@ -228,7 +229,8 @@ namespace MDPro3.Servant ...@@ -228,7 +229,8 @@ namespace MDPro3.Servant
GameObject cutin = null; GameObject cutin = null;
bool diy = false; bool diy = false;
if (codes.Contains(code)) if (codes.Contains(code))
cutin = await ABLoader.LoadFromFolderAsync<PlayableDirector>("MonsterCutin/" + code, false, true); //cutin = await ABLoader.LoadFromFolderAsync<PlayableDirector>("MonsterCutin/" + code, false, true);
cutin = await ABLoader.LoadMonsterCutinAsync(code);
else else
{ {
cutin = await ABLoader.LoadFromFileAsync("MonsterCutin2/" + code, false, true); cutin = await ABLoader.LoadFromFileAsync("MonsterCutin2/" + code, false, true);
...@@ -243,17 +245,17 @@ namespace MDPro3.Servant ...@@ -243,17 +245,17 @@ namespace MDPro3.Servant
//BackEffects //BackEffects
string backPath; string backPath;
if ((card.Attribute & (uint)CardAttribute.Dark) > 0) // 125 if (card.IsAttribute(CardAttribute.Dark)) // 125
backPath = "SummonMonster_Bgdak_S2"; backPath = "SummonMonster_Bgdak_S2";
else if ((card.Attribute & (uint)CardAttribute.Light) > 0) // 100 else if (card.IsAttribute(CardAttribute.Light)) // 100
backPath = "SummonMonster_Bglit_S2"; backPath = "SummonMonster_Bglit_S2";
else if ((card.Attribute & (uint)CardAttribute.Earth) > 0) // 56 else if (card.IsAttribute(CardAttribute.Earth)) // 56
backPath = "SummonMonster_Bgeah_S2"; backPath = "SummonMonster_Bgeah_S2";
else if ((card.Attribute & (uint)CardAttribute.Water) > 0) // 35 else if (card.IsAttribute(CardAttribute.Water)) // 35
backPath = "SummonMonster_Bgwtr_S2"; backPath = "SummonMonster_Bgwtr_S2";
else if ((card.Attribute & (uint)CardAttribute.Fire) > 0) // 31 else if (card.IsAttribute(CardAttribute.Fire)) // 31
backPath = "SummonMonster_Bgfie_S2"; backPath = "SummonMonster_Bgfie_S2";
else if ((card.Attribute & (uint)CardAttribute.Wind) > 0) // 25 else if (card.IsAttribute(CardAttribute.Wind)) // 25
backPath = "SummonMonster_Bgwid_S2"; backPath = "SummonMonster_Bgwid_S2";
else // 4 else // 4
backPath = "SummonMonster_Bgdve_S2"; backPath = "SummonMonster_Bgdve_S2";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment