Commit 30b37364 authored by SherryChaos's avatar SherryChaos

new functions & bug fixing

parent b8c1fcc7
......@@ -48,6 +48,7 @@ CardGenerated/
[Rr]eplay/
StandaloneWindows64/
Tools/
TempFolder/
Assets/Addressables/
Assets/Fonts/
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -88,11 +88,11 @@ namespace MDPro3
}
void LoadNames()
{
LoadData(0, "Data/locales/" + language + "/IDS_ITEM.bytes");
LoadData(0, Program.localesPath + Program.slash + language + "/IDS_ITEM.bytes");
}
void LoadDescriptions()
{
LoadData(1, "Data/locales/" + language + "/IDS_ITEMDESC.bytes");
LoadData(1, Program.localesPath + Program.slash + language + "/IDS_ITEMDESC.bytes");
}
void LoadData(int type, string path)
{
......@@ -170,15 +170,49 @@ namespace MDPro3
}
return returnValue;
}
public string CodeToPath(string code)
public string CodeToPath(string code, ItemType type)
{
string returnValue = "";
foreach (var kind in kinds)
foreach (var item in kind)
if (item.id.ToString() == code)
return item.path;
switch (type)
{
case ItemType.Wallpaper:
return wallpapers[0].path;
case ItemType.Face:
return faces[0].path;
case ItemType.Frame:
return frames[0].path;
case ItemType.Protector:
return protectors[0].path;
case ItemType.Mat:
return mats[0].path;
case ItemType.Grave:
return graves[0].path;
case ItemType.Stand:
return stands[0].path;
case ItemType.Mate:
return mates[0].path;
case ItemType.Case:
return cases[0].path;
default:
return mats[0].path;
}
}
return returnValue;
public enum ItemType
{
Wallpaper,
Face,
Frame,
Protector,
Mat,
Grave,
Stand,
Mate,
Case
}
}
}
......@@ -62,20 +62,20 @@ namespace MDPro3
if (totalNum == 0)
text.text = title + dots;
else
text.text = title + "(" + nowNum + "/" + totalNum + ")";
text.text = title + "(" + nowNum + Program.slash + totalNum + ")";
}
bool InitializeLanguage()
{
if (!Directory.Exists("Data"))
if (!Directory.Exists(Program.dataPath))
{
Directory.CreateDirectory("Data");
Config.Initialize("Data/config.conf");
Directory.CreateDirectory(Program.dataPath);
Config.Initialize(Program.configPath);
return true;
}
else
{
Config.Initialize("Data/config.conf");
Config.Initialize(Program.configPath);
if(Config.Get("Version", "Version") == "Version")
return true;
InterString.Initialize();
......@@ -109,7 +109,7 @@ namespace MDPro3
nowNum = 0;
totalNum = 0;
string filePath = Application.streamingAssetsPath + "/" + type + ".zip";
string filePath = Application.streamingAssetsPath + Program.slash + type + ".zip";
var www = new WWW(filePath);
while (!www.isDone)
{
......@@ -134,7 +134,7 @@ namespace MDPro3
IEnumerator LoadMainSceneAsync()
{
Config.Initialize("Data/config.conf");
Config.Initialize(Program.configPath);
Config.Set("Version", Application.version.Substring(0, 5));
Config.Save();
var ini = Addressables.InitializeAsync();
......@@ -223,7 +223,7 @@ namespace MDPro3
if(installVersion.Length > 5 || !installVersion.EndsWith("0"))
{
title = "不能直接安装更新包。Can not install update apk directly.";
Directory.Delete("Data");
Directory.Delete(Program.dataPath);
return false;
}
else
......
......@@ -40,6 +40,8 @@ namespace MDPro3
public Font atkDef;
public RenderTexture renderTexture;
static readonly string bigSlash = "/";
public void SwitchLanguage()
{
//cardDescription
......@@ -256,7 +258,7 @@ namespace MDPro3
cardArtPendulum.texture = art;
}
var pendulumDescription = CardDescription.GetCardDescriptionSplit(data.Desc);
cardDescription.text = StringHelper.GetType(data).Replace("/", "/") + "\r\n" + TextForRender(pendulumDescription[1]);
cardDescription.text = StringHelper.GetType(data).Replace(Program.slash, bigSlash) + "\r\n" + TextForRender(pendulumDescription[1]);
cardDescriptionPendulum.text = TextForRender(pendulumDescription[0]);
lScale.text = data.LScale.ToString();
rScale.text = data.RScale.ToString();
......@@ -279,7 +281,7 @@ namespace MDPro3
cardArt.texture = art;
var description = "";
if ((data.Type & (uint)CardType.Monster) > 0)
description = StringHelper.GetType(data).Replace("/", "/") + "\r\n";
description = StringHelper.GetType(data).Replace(Program.slash, bigSlash) + "\r\n";
description += TextForRender(data.Desc);
cardDescription.text = description;
......@@ -519,7 +521,7 @@ namespace MDPro3
.Replace("\n⑨", "⑨");
}
description = description.Replace("/", "/");
description = description.Replace(Program.slash, bigSlash);
if (language != "en-US" && language != "es-ES")
description = description.Replace(" ", "\u00A0");
......
......@@ -151,18 +151,16 @@ namespace MDPro3
manager.GetElement<Image>("Limit").sprite = TextureManager.container.banned;
}
readonly string savePath = "CardGenerated";
public void GenerateCard()
{
if (!Directory.Exists(savePath))
Directory.CreateDirectory(savePath);
Texture2D texture = (Texture2D)manager.GetElement<RawImage>("Card").material.mainTexture;
var picture = texture.EncodeToPNG();
var fullPath = savePath + "/" + code + ".png";
if (!Directory.Exists(Program.cardPicPath))
Directory.CreateDirectory(Program.cardPicPath);
try
{
File.WriteAllBytes(savePath + "/" + code + ".png", picture);
Texture2D texture = (Texture2D)manager.GetElement<RawImage>("Card").texture;
var picture = texture.EncodeToPNG();
var fullPath = Program.cardPicPath + Program.slash + code + ".png";
File.WriteAllBytes(Program.cardPicPath + Program.slash + code + ".png", picture);
MessageManager.Cast(InterString.Get("卡图已保存于:[?]", fullPath));
}
catch
......
......@@ -341,11 +341,17 @@ namespace MDPro3
StartCoroutine(SetFace());
RefreshLabel();
}
if(d.Id > 0)
if ((p.location & (uint)CardLocation.Extra) > 0)
if ((p.position & (uint)CardPosition.FaceUp) > 0)
if (p.sequence == Program.I().ocgcore.GetLocationCardCount(CardLocation.Extra, p.controller) - 1)
StartCoroutine(Program.I().ocgcore.UpdateDeckTop(p.controller, this));
}
public void SetCode(int code)
{
if (code > 0)
{
if (data.Id != code)
{
SetData(CardsManager.Get(code));
......@@ -355,6 +361,7 @@ namespace MDPro3
if (!Program.I().ocgcore.sideReference.Main.Contains(code))
Program.I().ocgcore.sideReference.Main.Add(code);
}
}
}
public void RefreshData()
......@@ -1018,6 +1025,9 @@ namespace MDPro3
main.startColor = Color.red;
}
if((p.location & (uint)CardLocation.Extra) > 0
&& (p.location & (uint)CardLocation.Overlay) == 0)
Program.I().ocgcore.SetDeckTop(this);
Destroy(model);
Destroy(fx, 2);
OcgCore.messagePass = true;
......@@ -1144,7 +1154,13 @@ namespace MDPro3
var turn = manager.GetElement<Transform>("Turn");
//翋极痄雄
sequence.Append(model.transform.DOLocalMove(position, moveTime));
sequence.Append(model.transform.DOLocalMove(position, moveTime).OnStart(() =>
{
if ((cacheP.location & (uint)CardLocation.Extra) > 0
&& (p.location & (uint)CardLocation.Extra) == 0
&& cacheP.sequence == Program.I().ocgcore.GetLocationCardCount(CardLocation.Extra, cacheP.controller) - 1)
StartCoroutine(Program.I().ocgcore.UpdateDeckTop(cacheP.controller));
}));
sequence.Join(pivot.DOScale(GetCardScale(p), moveTime * 0.95f));
//Turn
if ((p.location & (uint)CardLocation.Removed) > 0
......@@ -1218,6 +1234,9 @@ namespace MDPro3
inAnimation = false;
if ((p.location & ((uint)CardLocation.Grave + (uint)CardLocation.Removed)) == 0)
OcgCore.messagePass = true;
if((p.location & (uint)CardLocation.Extra) > 0
&& (cacheP.location & (uint)CardLocation.Extra) == 0)
Program.I().ocgcore.SetDeckTop(this);
});
SummonPass:
......@@ -1266,7 +1285,13 @@ namespace MDPro3
void SequenceStrongSummon(Sequence sequence, Vector3 position, Vector3 angle, float interval, float timeBefore = 0)
{
sequence.AppendInterval(interval);
sequence.Append(manager.transform.DOMove(position, 0.2f));
sequence.Append(manager.transform.DOMove(position, 0.2f).OnStart(() =>
{
if ((cacheP.location & (uint)CardLocation.Extra) > 0
&& (p.location & (uint)CardLocation.Extra) == 0
&& cacheP.sequence == Program.I().ocgcore.GetLocationCardCount(CardLocation.Extra, cacheP.controller))
StartCoroutine(Program.I().ocgcore.UpdateDeckTop(cacheP.controller));
}));
sequence.Join(manager.transform.DOLocalRotate(Vector3.zero, 0.1f));
sequence.Join(manager.GetElement<Transform>("CardPlane").DOLocalRotate(new Vector3(0, (angle.y == 0) || (angle.y == 270) ? 0 : 180, 0), 0.2f));
sequence.Join(manager.GetElement<Transform>("Turn").DOLocalRotate(new Vector3(0, (angle.y == 0) || (angle.y == 180) ? 0 : 270, angle.z), 0.2f));
......
......@@ -25,14 +25,14 @@ namespace MDPro3.YGOSharp
nullString = string.Empty;
;
string language = Config.Get("Language", "zh-CN");
string databaseFullPath = "data/locales/" + language + "/cards.cdb";
string databaseFullPath = Program.localesPath + Program.slash + language + "/cards.cdb";
if (!File.Exists(databaseFullPath))
databaseFullPath = "data/locales/zh-CN/cards.cdb";
databaseFullPath = Program.localesPath + Program.slash + "zh-CN/cards.cdb";
_cards.Clear();
LoadCDB(databaseFullPath);
foreach(var cdb in Directory.GetFiles("Expansions", "*.cdb"))
LoadCDB(cdb);
foreach(var zip in ZipManager.zips)
foreach(var zip in ZipHelper.zips)
{
if (zip.Name.ToLower().EndsWith("script.zip"))
continue;
......@@ -41,8 +41,10 @@ namespace MDPro3.YGOSharp
if (file.ToLower().EndsWith(".cdb"))
{
var e = zip[file];
var tempFile = Path.Combine(Path.GetTempPath(), file);
e.Extract(Path.GetTempPath(), ExtractExistingFileAction.OverwriteSilently);
if (!Directory.Exists(Program.tempFolder))
Directory.CreateDirectory(Program.tempFolder);
var tempFile = Path.Combine(Path.GetFullPath(Program.tempFolder), file);
e.Extract(Path.GetFullPath(Program.tempFolder), ExtractExistingFileAction.OverwriteSilently);
LoadCDB(tempFile);
File.Delete(tempFile);
}
......@@ -1949,7 +1951,7 @@ namespace MDPro3.YGOSharp
static Dictionary<string, string> pacDic = new Dictionary<string, string>();
static string path = "data/pack";
static string path = "Data/pack";
internal static void Initialize()
{
......@@ -1958,7 +1960,7 @@ namespace MDPro3.YGOSharp
var fileInfos = new DirectoryInfo(path).GetFiles();
foreach (var file in fileInfos)
if (file.Name.ToLower().EndsWith(".db"))
LoadDataBase(path + "/" + file.Name);
LoadDataBase(path + Program.slash + file.Name);
InitializeSec();
}
}
......
......@@ -71,7 +71,7 @@ namespace MDPro3
}
else
{
foreach (var zip in ZipManager.zips)
foreach (var zip in ZipHelper.zips)
if (zip.ContainsEntry(fileName2))
{
var ms = new MemoryStream();
......
......@@ -15,7 +15,7 @@ namespace MDPro3
{
public static TcpClient tcpClient;
private static NetworkStream networkStream;
private static bool canJoin = true;
public static bool canJoin = true;
public static bool onDisConnected;
private static readonly List<byte[]> datas = new List<byte[]>();
private static readonly object locker = new object();
......
fileFormatVersion: 2
guid: a588901f0fbed654f89ebcb7ecdb5471
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -195,9 +195,9 @@ namespace MDPro3
while (loadingPMat)
yield return null;
loadingPMat = true;
if (File.Exists(Program.root + "Protector/" + code + "/" + code))
if (File.Exists(Program.root + "Protector/" + code + Program.slash + code))
{
var abr = AssetBundle.LoadFromFileAsync(Program.root + "Protector/" + code + "/" + code);
var abr = AssetBundle.LoadFromFileAsync(Program.root + "Protector/" + code + Program.slash + code);
while (!abr.isDone)
yield return null;
var abmr = AssetBundle.LoadFromFileAsync(Program.root + "Protector/" + code + "/PMat");
......@@ -212,20 +212,20 @@ namespace MDPro3
}
else
{
var ab1r = AssetBundle.LoadFromFileAsync(Program.root + "Protector/" + code + "/" + code + "_1");
var ab1r = AssetBundle.LoadFromFileAsync(Program.root + "Protector/" + code + Program.slash + code + "_1");
while (!ab1r.isDone)
yield return null;
var ab1 = ab1r.assetBundle;
var ab2r = AssetBundle.LoadFromFileAsync(Program.root + "Protector/" + code + "/" + code + "_2");
var ab2r = AssetBundle.LoadFromFileAsync(Program.root + "Protector/" + code + Program.slash + code + "_2");
while (!ab2r.isDone)
yield return null;
var ab2 = ab2r.assetBundle;
AssetBundle ab3 = null;
if (File.Exists(Program.root + "Protector/" + code + "/" + code + "_3"))
if (File.Exists(Program.root + "Protector/" + code + Program.slash + code + "_3"))
{
var ab3r = AssetBundle.LoadFromFileAsync(Program.root + "Protector/" + code + "/" + code + "_3");
var ab3r = AssetBundle.LoadFromFileAsync(Program.root + "Protector/" + code + Program.slash + code + "_3");
while (!ab3r.isDone)
yield return null;
ab3 = ab3r.assetBundle;
......@@ -274,7 +274,7 @@ namespace MDPro3
}
}
Mate.MateType type = Mate.MateType.MasterDuel;
if (item.id == 0)
if (item.id == 0 && File.Exists(Program.root + "CrossDuel/" + code + ".bundle"))
type = Mate.MateType.CrossDuel;
Mate returnValue = null;
if (type == Mate.MateType.CrossDuel)
......@@ -326,7 +326,7 @@ namespace MDPro3
}
else
{
var ie = LoadFromFileAsync(Program.items.CodeToPath(code.ToString()));
var ie = LoadFromFileAsync(Program.items.CodeToPath(code.ToString(), Items.ItemType.Mate));
while (ie.MoveNext())
yield return null;
var mateGo = ie.Current;
......
......@@ -13,7 +13,7 @@ namespace MDPro3
public static void Initialize()
{
string language = Config.Get("Language", "zh-CN");
path = "data/locales/" + language + "/translation.conf";
path = Program.localesPath + Program.slash + language + "/translation.conf";
if (!File.Exists(path))
File.Create(path).Close();
......
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SFB;
namespace MDPro3
{
public class PortHelper
{
public static void ImportFiles()
{
#if UNITY_ANDROID && !UNITY_EDITOR
NativeFilePicker.PickMultipleFiles(MoveFilesToGame, null);
#else
ChooseFiles();
#endif
}
public static void ExportAllDecks()
{
if(!Directory.Exists(Program.deckPath))
Directory.CreateDirectory(Program.deckPath);
var filePaths = Directory.GetFiles(Program.deckPath);
Export(filePaths);
}
public static void ExportAllReplays()
{
if (!Directory.Exists(Program.replayPath))
Directory.CreateDirectory(Program.replayPath);
var filePaths = Directory.GetFiles(Program.replayPath);
Export(filePaths);
}
public static void ExportAllPictures()
{
if (!Directory.Exists(Program.cardPicPath))
Directory.CreateDirectory(Program.cardPicPath);
var filePaths = Directory.GetFiles(Program.cardPicPath);
Export(filePaths);
}
static void Export(string[] filePaths)
{
#if UNITY_ANDROID && !UNITY_EDITOR
NativeFilePicker.ExportMultipleFiles(filePaths, ExportResult);
#else
StandaloneFileBrowser.OpenFolderPanelAsync("请选择导出目录", "", false, (string[] paths) =>
{
ExportFiles(paths, filePaths);
});
//var config = new FolderDialogConfiguration
//{
// Title = InterString.Get("请选择导出目录"),
//};
//var result = FileBrowser.FileBrowserService.OpenFolderDialog(config);
//ExportFiles(result, filePaths);
#endif
}
private static void ExportFiles(string[] result, string[] filePaths)
{
try
{
foreach(var file in filePaths)
File.Copy(file, Path.Combine(result.FirstOrDefault(), Path.GetFileName(file)));
ExportResult(true);
}
catch
{
ExportResult(false);
}
}
static void ChooseFiles()
{
//var config = new FileDialogConfiguration
//{
// Title = InterString.Get("请选择需要导入的文件"),
// FileDialogType = FileBrowser.FileDialogType.Open,
// Multiselect = true,
// ExtensionFilters = new[]
// {
// new ExtensionFilter(InterString.Get("所有文件"), "*"),
// new ExtensionFilter(InterString.Get("卡组码文件"), "ydk"),
// new ExtensionFilter(InterString.Get("回放文件"), "yrp", "yrp3d"),
// new ExtensionFilter(InterString.Get("扩展卡文件"), "ypk"),
// new ExtensionFilter(InterString.Get("数据库文件"), "cdb"),
// new ExtensionFilter(InterString.Get("字段文件"), "conf"),
// new ExtensionFilter(InterString.Get("图片文件"), "png", "jpg")
// }
//};
//var result = FileBrowser.FileBrowserService.OpenFileDialog(config);
//CopyFilesToGame(result);
var extensions = new[]
{
new ExtensionFilter(InterString.Get("所有文件"), "*"),
new ExtensionFilter(InterString.Get("卡组码文件"), "ydk"),
new ExtensionFilter(InterString.Get("回放文件"), "yrp", "yrp3d"),
new ExtensionFilter(InterString.Get("扩展卡文件"), "ypk"),
new ExtensionFilter(InterString.Get("数据库文件"), "cdb"),
new ExtensionFilter(InterString.Get("字段文件"), "conf"),
new ExtensionFilter(InterString.Get("图片文件"), "png", "jpg")
};
StandaloneFileBrowser.OpenFilePanelAsync(InterString.Get("请选择需要导入的文件"), "", extensions, true, (string[] paths) =>
{
CopyFilesToGame(paths);
});
}
static void CopyFilesToGame(IEnumerable<string> files)
{
bool newDataAdded = false;
foreach (string path in files)
{
try
{
if (path.ToLower().EndsWith(".ydk"))
File.Copy(path, Program.deckPath + Program.slash + Path.GetFileName(path), true);
if (path.ToLower().EndsWith(".yrp") || path.ToLower().EndsWith(".yrp3d"))
File.Copy(path, Program.replayPath + Program.slash + Path.GetFileName(path), true);
if (path.ToLower().EndsWith(".ypk") || path.ToLower().EndsWith(".zip") || path.ToLower().EndsWith(".cdb") || path.ToLower().EndsWith(".conf"))
{
File.Copy(path, Program.expansionsPath + Program.slash + Path.GetFileName(path), true);
newDataAdded = true;
}
if (path.ToLower().EndsWith(".png") || path.ToLower().EndsWith(".jpg") || path.ToLower().EndsWith(".jpeg"))
File.Copy(path, Program.altArtPath + Program.slash + Path.GetFileName(path), true);
}
catch { }
}
if (newDataAdded)
Program.I().InitializeForDataChange();
}
static void MoveFilesToGame(string[] files)
{
bool newDataAdded = false;
foreach (string path in files)
{
try
{
if (path.ToLower().EndsWith(".ydk"))
File.Move(path, Program.deckPath + Program.slash + Path.GetFileName(path));
if (path.ToLower().EndsWith(".yrp") || path.ToLower().EndsWith(".yrp3d"))
File.Move(path, Program.replayPath + Program.slash + Path.GetFileName(path));
if (path.ToLower().EndsWith(".ypk") || path.ToLower().EndsWith(".zip") || path.ToLower().EndsWith(".cdb") || path.ToLower().EndsWith(".conf"))
{
File.Move(path, Program.expansionsPath + Program.slash + Path.GetFileName(path));
newDataAdded = true;
}
if (path.ToLower().EndsWith(".png") || path.ToLower().EndsWith(".jpg") || path.ToLower().EndsWith(".jpeg"))
File.Move(path, Program.altArtPath + Program.slash + Path.GetFileName(path));
}
catch { }
}
if (newDataAdded)
Program.I().InitializeForDataChange();
}
static void ExportResult(bool sucess)
{
if (sucess)
MessageManager.Cast(InterString.Get("导出成功。"));
else
MessageManager.Cast(InterString.Get("导出失败。"));
}
}
}
fileFormatVersion: 2
guid: b99a6acfea0bb444a825a5dec29a2b12
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -34,11 +34,11 @@ namespace MDPro3
public static void Initialize()
{
var language = Config.Get("Language", "zh-CN");
var path = "data/locales/" + language + "/strings.conf";
var path = Program.localesPath + Program.slash + language + "/strings.conf";
var text = File.ReadAllText(path);
foreach (var conf in Directory.GetFiles("Expansions", "*.conf"))
text += "\r\n" + File.ReadAllText(conf);
foreach (var zip in ZipManager.zips)
foreach (var zip in ZipHelper.zips)
{
if (zip.Name.ToLower().EndsWith("script.zip"))
continue;
......@@ -179,7 +179,7 @@ namespace MDPro3
for (int i = 0; i < 7; i++)
if ((attribute & (1u << i)) > 0)
{
if (passFirst) r += "/";
if (passFirst) r += Program.slash;
r += GetUnsafe(1010 + i);
passFirst = true;
}
......@@ -192,7 +192,7 @@ namespace MDPro3
for (var i = 0; i < 26; i++)
if ((race & (1 << i)) > 0)
{
if (passFirst) r += "/";
if (passFirst) r += Program.slash;
r += GetUnsafe(1020 + i);
passFirst = true;
}
......@@ -261,7 +261,7 @@ namespace MDPro3
for (var i = 0; i < 3; i++)
if ((a & (1 << i)) > 0)
{
if (passFirst) r += "/";
if (passFirst) r += Program.slash;
r += GetUnsafe(1050 + i);
passFirst = true;
}
......@@ -277,14 +277,14 @@ namespace MDPro3
for (var i = 4; i < 27; i++)
if (((a & 0x68020C0) & (1 << i)) > 0)
{
start += "/" + GetUnsafe(1050 + i);
start += Program.slash + GetUnsafe(1050 + i);
break;
}
a -= a & 0x68020C0;
}
if ((a & (long)CardType.Pendulum) > 0)
{
start += "/" + GetUnsafe(1074);
start += Program.slash + GetUnsafe(1074);
a -= (long)CardType.Pendulum;
}
if ((a & 0x30) > 0)
......@@ -292,14 +292,14 @@ namespace MDPro3
for (var i = 4; i < 6; i++)
if ((a & (1 << i)) > 0)
{
end += "/" + GetUnsafe(1050 + i);
end += Program.slash + GetUnsafe(1050 + i);
break;
}
a -= a & 0x30;
}
for (var i = 4; i < 27; i++)
if ((a & (1 << i)) > 0)
start += "/" + GetUnsafe(1050 + i);
start += Program.slash + GetUnsafe(1050 + i);
var returnValue = start + end;
if (returnValue == "")
returnValue = GetUnsafe(1054);
......@@ -320,9 +320,9 @@ namespace MDPro3
if (CardDescription.WhetherCardIsMonster(data))
{
if (data.Race != origin.Race)
re = "" + "<color=#FD3E08>" + InterString.Get("[?]", Race(data.Race)) + "</color>" + "/" + SecondType(data.Type) + "";
re = "" + "<color=#FD3E08>" + InterString.Get("[?]", Race(data.Race)) + "</color>" + Program.slash + SecondType(data.Type) + "";
else
re = "" + InterString.Get("[?]", Race(data.Race)) + "/" + SecondType(data.Type) + "";
re = "" + InterString.Get("[?]", Race(data.Race)) + Program.slash + SecondType(data.Type) + "";
}
else
re = "" + MainType(data.Type) + "";
......
......@@ -4,13 +4,14 @@ using Ionic.Zip;
namespace MDPro3
{
public class ZipManager
public class ZipHelper
{
public static List<ZipFile> zips = new List<ZipFile>();
public static void Initialize()
{
zips.Add(new ZipFile("data/script.zip"));
zips.Clear();
zips.Add(new ZipFile("Data/script.zip"));
if (!Directory.Exists("Expansions"))
Directory.CreateDirectory("Expansions");
......@@ -19,5 +20,10 @@ namespace MDPro3
foreach (var zip in Directory.GetFiles("Expansions", "*.zip"))
zips.Add(new ZipFile(zip));
}
public static void Dispose()
{
foreach (var zip in zips)
zip.Dispose();
}
}
}
fileFormatVersion: 2
guid: 7812e1008e088e74a9dc80bee6ff57a6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -133,9 +133,9 @@ namespace MDPro3
}
string fullPath;
#if !UNITY_EDITOR && UNITY_ANDROID
fullPath = "file://" + Application.persistentDataPath + "/" + path;
fullPath = "file://" + Application.persistentDataPath + Program.slash + path;
#else
fullPath = System.Environment.CurrentDirectory + "/" + path;
fullPath = System.Environment.CurrentDirectory + Program.slash + path;
#endif
UnityWebRequest request = UnityWebRequestTexture.GetTexture(fullPath);
request.SendWebRequest();
......@@ -156,20 +156,20 @@ namespace MDPro3
//while(loadingArt)
// yield return null;
//loadingArt = true;
if (!Directory.Exists("Art"))
Directory.CreateDirectory("Art");
if (!Directory.Exists("Art2"))
Directory.CreateDirectory("Art2");
var path = "Art2/" + code;
if (!Directory.Exists(Program.artPath))
Directory.CreateDirectory(Program.artPath);
if (!Directory.Exists(Program.altArtPath))
Directory.CreateDirectory(Program.altArtPath);
var path = Program.altArtPath + Program.slash + code;
if (File.Exists(path + ".jpg"))
path += ".jpg";
else if (File.Exists(path + ".png"))
path += ".png";
else if (File.Exists("Art/" + code.ToString() + ".jpg"))
path = "Art/" + code.ToString() + ".jpg";
else if (File.Exists(Program.artPath + Program.slash + code.ToString() + ".jpg"))
path = Program.artPath + Program.slash + code.ToString() + ".jpg";
else
{
foreach (var zip in ZipManager.zips)
foreach (var zip in ZipHelper.zips)
{
if (zip.Name.ToLower().EndsWith("script.zip"))
continue;
......@@ -191,7 +191,7 @@ namespace MDPro3
}
if(returenValue == null)
{
foreach (var zip in ZipManager.zips)
foreach (var zip in ZipHelper.zips)
{
if (zip.Name.ToLower().EndsWith("script.zip"))
continue;
......
fileFormatVersion: 2
guid: d97e4be8227079543b43f212dcb2c75e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -3,14 +3,10 @@ using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
using MDPro3.YGOSharp;
using Ionic.Zip;
using UnityEngine.EventSystems;
using UnityEngine.AddressableAssets;
using MDPro3.Net;
using System.Threading;
using System.Runtime.InteropServices;
namespace MDPro3
{
......@@ -55,6 +51,19 @@ namespace MDPro3
#region State
public static bool Running = true;
public static readonly string artPath = "Art";
public static readonly string altArtPath = "Art2";
public static readonly string cardPicPath = "CardGenerated";
public static readonly string dataPath = "Data";
public static readonly string localesPath = "Data/locales";
public static readonly string configPath = "Data/config.conf";
public static readonly string lflistPath = "Data/lflist.conf";
public static readonly string deckPath = "Deck";
public static readonly string expansionsPath = "Expansions";
public static readonly string puzzlePath = "Puzzle";
public static readonly string replayPath = "Replay";
public static readonly string diyPath = "DIY";
public static readonly string slash = "/";
#endregion
public static Program I()
......@@ -79,18 +88,21 @@ namespace MDPro3
void InitializeRest()
{
ZipManager.Initialize();
if (!Directory.Exists("Data"))
Directory.CreateDirectory("Data");
Config.Initialize("Data/config.conf");
ZipHelper.Initialize();
if (!Directory.Exists(dataPath))
Directory.CreateDirectory(dataPath);
Config.Initialize(configPath);
items.Initialize();
BanlistManager.Initialize("data/lflist.conf");
BanlistManager.Initialize(lflistPath);
InitializeAllManagers();
InitializeAllServants();
}
//new Thread(Server.Main).Start();
//new Thread(Client.Main).Start();
public void InitializeForDataChange()
{
ZipHelper.Initialize();
StringHelper.Initialize();
CardsManager.Initialize();
}
private void InitializeAllManagers()
......@@ -129,6 +141,7 @@ namespace MDPro3
#region MonoBehaviors
public static string tempFolder = "TempFolder";
public static string root = "StandaloneWindows64/";
void Awake()
{
......@@ -284,7 +297,20 @@ namespace MDPro3
if (currentSubServant != null)
currentSubServant.OnReturn();
else
{
if(currentServant == null)
{
foreach(var servant in servants)
if (servant.isShowed)
{
currentServant = servant;
break;
}
}
if (currentServant == null)
currentServant = cutin;
currentServant.OnReturn();
}
}
public void ExitDuel()
......@@ -298,8 +324,34 @@ namespace MDPro3
private void OnApplicationQuit()
{
Running = false;
TcpHelper.tcpClient?.Close();
ClearCache();
TcpHelper.tcpClient = null;
YgoServer.StopServer();
}
void ClearCache()
{
#if UNITY_ANDROID && !UNITY_EDITOR
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject cacheDir = currentActivity.Call<AndroidJavaObject>("getCacheDir");
string cachePath = cacheDir.Call<string>("getAbsolutePath");
ClearDirectoryRecursively(new DirectoryInfo(cachePath));
#else
if (Directory.Exists(tempFolder))
Directory.Delete(tempFolder, true);
#endif
}
void ClearDirectoryRecursively(DirectoryInfo directory)
{
foreach(var file in directory.GetFiles())
file.Delete();
foreach(var subDir in directory.GetDirectories())
{
ClearDirectoryRecursively(subDir);
subDir.Delete();
}
}
}
}
......@@ -83,9 +83,9 @@ namespace MDPro3
Deck history;
public Deck shine;
public Deck royal;
readonly string bookPath = "data/book.ydk";
readonly string shinePath = "data/sr.ydk";
readonly string royalPath = "data/ur.ydk";
readonly string bookPath = "Data/book.ydk";
readonly string shinePath = "Data/sr.ydk";
readonly string royalPath = "Data/ur.ydk";
Card cardShowing;
public Banlist banlist;
public static string pack = "";
......@@ -201,12 +201,12 @@ namespace MDPro3
else
{
List<string> selections = new List<string>
{
InterString.Get("卡组未保存"),
InterString.Get("卡组已修改,是否保存?"),
InterString.Get("保存"),
InterString.Get("不保存")
};
{
InterString.Get("卡组未保存"),
InterString.Get("卡组已修改,是否保存?"),
InterString.Get("保存"),
InterString.Get("不保存")
};
UIManager.ShowPopupYesOrNo(selections, OnSave, OnExit);
}
}
......
This diff is collapsed.
......@@ -275,7 +275,8 @@ namespace MDPro3
MessageManager.Cast("主机地址和端口不能为空。");
return;
}
if (!TcpHelper.canJoin)
return;
Room.fromSolo = false;
Room.fromLocalHost = false;
new Thread(() => { TcpHelper.Join(ip, Config.Get("DuelPlayerName0", "@ui"), port, password, version); }).Start();
......
......@@ -405,7 +405,11 @@ namespace MDPro3
if (Program.I().ocgcore.isShowed && player < 4)
{
if (mode != 2)
player = Program.I().ocgcore.LocalPlayer(player);
{
if (Program.I().ocgcore.isFirst && selfType == 1
|| !Program.I().ocgcore.isFirst && selfType == 0)
player = (player + 1) % 2;
}
else
{
if (Program.I().ocgcore.isFirst && selfType > 1
......
......@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.AddressableAssets;
......@@ -128,6 +129,14 @@ namespace MDPro3
public Text replayCoinValue;
public Button replayAutoInfo;
public Text replayAutoInfoValue;
[Header("Port")]
public Button import;
public Button exportDeck;
public Button exportReplay;
public Button exportPicture;
public Button clearPicture;
public Button clearExpansions;
public override void Initialize()
{
depth = 1;
......@@ -195,6 +204,12 @@ namespace MDPro3
watchAutoInfo.onClick.AddListener(OnWatchAutoInfoClick);
replayAutoInfo.onClick.AddListener(OnReplayAutoInfoClick);
timing.onClick.AddListener(OnTimingClick);
import.onClick.AddListener(OnImport);
exportDeck.onClick.AddListener(OnExportDecks);
exportReplay.onClick.AddListener(OnExportReplays);
exportPicture.onClick.AddListener(OnExportPictures);
clearPicture.onClick.AddListener(OnClearPictures);
clearExpansions.onClick.AddListener(OnClearExpansions);
bgmVol.value = int.Parse(Config.Get("BgmVol", "700")) / (float)1000;
seVol.value = int.Parse(Config.Get("SeVol", "700")) / (float)1000;
......@@ -659,10 +674,10 @@ namespace MDPro3
}
List<string> selections = new List<string>
{
InterString.Get("语言")
};
DirectoryInfo[] infos = new DirectoryInfo("data/locales").GetDirectories();
{
InterString.Get("语言")
};
DirectoryInfo[] infos = new DirectoryInfo(Program.localesPath).GetDirectories();
foreach (DirectoryInfo info in infos)
selections.Add(InterString.Get(info.Name));
UIManager.ShowPopupSelection(selections, OnLanguageSelection);
......@@ -1142,6 +1157,76 @@ namespace MDPro3
timingValue.text = InterString.Get("开");
}
void OnImport()
{
if (Program.I().ocgcore.isShowed)
{
MessageManager.Cast(InterString.Get("决斗中不能进行此操作。"));
return;
}
PortHelper.ImportFiles();
}
void OnExportDecks()
{
PortHelper.ExportAllDecks();
}
void OnExportReplays()
{
PortHelper.ExportAllReplays();
}
void OnExportPictures()
{
PortHelper.ExportAllPictures();
}
void OnClearPictures()
{
if (Program.I().ocgcore.isShowed)
{
MessageManager.Cast(InterString.Get("决斗中不能进行此操作。"));
return;
}
var selections = new List<string>
{
InterString.Get("确定清空"),
InterString.Get("是否确认删除所有导入的卡图?"),
InterString.Get("确认"),
InterString.Get("取消")
};
UIManager.ShowPopupYesOrNo(selections, () =>
{
if (!Directory.Exists(Program.altArtPath))
Directory.CreateDirectory(Program.altArtPath);
foreach (var file in Directory.GetFiles(Program.altArtPath))
File.Delete(file);
}, null);
}
void OnClearExpansions()
{
if (Program.I().ocgcore.isShowed)
{
MessageManager.Cast(InterString.Get("决斗中不能进行此操作。"));
return;
}
var selections = new List<string>
{
InterString.Get("确定清空"),
InterString.Get("是否确认删除所有导入的扩展卡包?"),
InterString.Get("确认"),
InterString.Get("取消")
};
UIManager.ShowPopupYesOrNo(selections, () =>
{
ZipHelper.Dispose();
if(!Directory.Exists(Program.expansionsPath))
Directory.CreateDirectory(Program.expansionsPath);
foreach (var file in Directory.GetFiles(Program.expansionsPath))
File.Delete(file);
Program.I().InitializeForDataChange();
}, null);
}
#endregion
public void OnAboutGame()
......
......@@ -51,7 +51,7 @@ namespace MDPro3
public void Load()
{
ReadBots("Data/locales/" + Config.Get("Language", "zh-CN") + "/bot.conf");
ReadBots(Program.localesPath + Program.slash + Config.Get("Language", "zh-CN") + "/bot.conf");
Print();
StartCoroutine(SelectZero());
}
......
......@@ -98,7 +98,7 @@ namespace MDPro3.UI
mono.SelectableThis();
else
mono.UnselectableThis();
title.text = hint + "-" + OcgCore.GetSelectLevelSum(GetSelected())[0].ToString() + "/" + core.ES_level;
title.text = hint + "-" + OcgCore.GetSelectLevelSum(GetSelected())[0].ToString() + Program.slash + core.ES_level;
}
else if (core.currentMessage == GameMessage.SortCard
|| core.currentMessage == GameMessage.SortChain)
......@@ -161,7 +161,7 @@ namespace MDPro3.UI
else
btnConfirm.GetComponent<ButtonPress>().SetInteractable(false);
}
title.text = hint + "-" + selectedSum[0].ToString() + "/" + core.ES_level;
title.text = hint + "-" + selectedSum[0].ToString() + Program.slash + core.ES_level;
}
else
{
......@@ -182,7 +182,7 @@ namespace MDPro3.UI
mono.SelectableThis();
}
if (core.currentMessage == GameMessage.SelectCard)
title.text = hint + "-" + GetSelected().Count + "/" + max.ToString();
title.text = hint + "-" + GetSelected().Count + Program.slash + max.ToString();
}
}
......
......@@ -14,6 +14,7 @@
"com.unity.timeline": "1.4.8",
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.6",
"com.unity.ugui": "1.0.0",
"com.yasirkula.nativefilepicker": "https://github.com/yasirkula/UnityNativeFilePicker.git",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",
......
......@@ -195,6 +195,13 @@
"com.unity.modules.imgui": "1.0.0"
}
},
"com.yasirkula.nativefilepicker": {
"version": "https://github.com/yasirkula/UnityNativeFilePicker.git",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "c1b54d864f4dc3c4dff5d05b0c5ad7c45b505c6c"
},
"com.unity.modules.ai": {
"version": "1.0.0",
"depth": 0,
......
......@@ -134,8 +134,9 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 1.0.6
preloadedAssets: []
bundleVersion: 1.0.7
preloadedAssets:
- {fileID: 11400000, guid: 5fb02d2098f52054b89ce4a9f63ba9ee, type: 2}
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1
......@@ -171,7 +172,7 @@ PlayerSettings:
iPhoneStrippingLevel: 0
iPhoneScriptCallOptimization: 0
ForceInternetPermission: 0
ForceSDCardPermission: 0
ForceSDCardPermission: 1
CreateWallpaper: 0
APKExpansionFiles: 0
keepLoadedShadersAlive: 0
......@@ -529,7 +530,7 @@ PlayerSettings:
m_APIs: 0b000000
m_Automatic: 1
- m_BuildTarget: WindowsStandaloneSupport
m_APIs: 0b000000020000001200000015000000
m_APIs: 0200000012000000150000000b000000
m_Automatic: 0
m_BuildTargetVRSettings:
- m_BuildTarget: Standalone
......
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