Commit 5cf5390a authored by hex's avatar hex

1. Fixed lag issue on the settlement screen;

2. Fixed lag issue on the main screen;
3. Added EXP server and MYGO Early Access server to the server list;
4. Fixed issue where the "Settings" screen could not be closed when clicking rapidly;
5. Changed card addition from double-click to long-press (good news for those with tenosynovitis);
6. Standardized download code: now uses official asynchronous download method without affecting the main thread.
parent 17edb59b
Pipeline #37614 failed
using UnityEngine;
using System.Collections;
using System;
using System;
using UnityEngine;
public class MonoCardInDeckManager : MonoBehaviour {
public class MonoCardInDeckManager : MonoBehaviour
{
int loadedPicCode = 0;
YGOSharp.Banlist loaded_banlist = null;
public bool dying = false;
bool died = false;
public YGOSharp.Card cardData=new YGOSharp.Card();
public YGOSharp.Card cardData = new YGOSharp.Card();
void Update ()
bool isDraging = false;
private bool stopDragThisFrame = false;
void Update()
{
if (loadedPicCode != cardData.Id)
{
Texture2D pic = GameTextureManager.get(cardData.Id,GameTextureType.card_picture);
Texture2D pic = GameTextureManager.get(cardData.Id, GameTextureType.card_picture);
if (pic != null)
{
loadedPicCode = cardData.Id;
gameObject.transform.Find("face").GetComponent<Renderer>().material.mainTexture = pic;
gameObject.transform.Find("face").GetComponent<Renderer>().material.mainTexture =
pic;
}
}
if (Program.I().deckManager.currentBanlist != loaded_banlist)
{
ban_icon ico = GetComponentInChildren<ban_icon>();
loaded_banlist = Program.I().deckManager.currentBanlist;
if (loaded_banlist != null)
{
ico.show(loaded_banlist.GetQuantity(cardData.Id));
}
else
{
ico.show(3);
}
ico.show(loaded_banlist != null ? loaded_banlist.GetQuantity(cardData.Id) : 3);
}
if (stopDragThisFrame)
{
isDraging = false;
stopDragThisFrame = false;
}
if (isDraging)
{
gameObject.transform.position += (getGoodPosition(4) - gameObject.transform.position) * 0.3f;
gameObject.transform.position +=
(getGoodPosition(4) - gameObject.transform.position) * 0.3f;
}
if (Vector3.Distance(Vector3.zero, gameObject.transform.position) > 50 && bool_physicalON)
{
killIt();
......@@ -49,15 +56,13 @@ public class MonoCardInDeckManager : MonoBehaviour {
{
gameObject.transform.position = new Vector3(0, 5, 0);
endDrag();
if (Program.I().deckManager.cardInDragging==this)
if (Program.I().deckManager.cardInDragging == this)
{
Program.I().deckManager.cardInDragging = null;
}
Rigidbody rigidbody = GetComponent<Rigidbody>();
if (rigidbody == null)
{
rigidbody = gameObject.AddComponent<Rigidbody>();
}
rigidbody.Sleep();
}
else
......@@ -74,62 +79,99 @@ public class MonoCardInDeckManager : MonoBehaviour {
float y = Input.mousePosition.y;
Vector3 to_ltemp = Program.camera_game_main.ScreenToWorldPoint(new Vector3(x, y, 1));
Vector3 dv = to_ltemp - Program.camera_game_main.transform.position;
if (dv.y == 0) dv.y = 0.01f;
to_ltemp.x = ((height - Program.camera_game_main.transform.position.y)
* (dv.x) / dv.y + Program.camera_game_main.transform.position.x);
to_ltemp.y = ((height - Program.camera_game_main.transform.position.y)
* (dv.y) / dv.y + Program.camera_game_main.transform.position.y);
to_ltemp.z = ((height - Program.camera_game_main.transform.position.y)
* (dv.z) / dv.y + Program.camera_game_main.transform.position.z);
if (dv.y == 0)
dv.y = 0.01f;
to_ltemp.x = (
(height - Program.camera_game_main.transform.position.y) * (dv.x) / dv.y
+ Program.camera_game_main.transform.position.x
);
to_ltemp.y = (
(height - Program.camera_game_main.transform.position.y) * (dv.y) / dv.y
+ Program.camera_game_main.transform.position.y
);
to_ltemp.z = (
(height - Program.camera_game_main.transform.position.y) * (dv.z) / dv.y
+ Program.camera_game_main.transform.position.z
);
return to_ltemp;
}
bool isDraging = false;
public void beginDrag()
{
physicalOFF();
physicalHalfON();
isDraging = true;
Program.go(1, () => { iTween.RotateTo(gameObject, new Vector3(90, 0, 0), 0.6f); });
Program.go(
1,
() =>
{
iTween.RotateTo(gameObject, new Vector3(90, 0, 0), 0.6f);
}
);
}
public void endDrag()
{
physicalON();
isDraging = false;
if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl) || getIfAlive() == false)
stopDragThisFrame = true;
if (
Input.GetKey(KeyCode.LeftControl)
|| Input.GetKey(KeyCode.RightControl)
|| getIfAlive() == false
)
{
Vector3 form_position = getGoodPosition(4);
Vector3 from_position = getGoodPosition(4);
Vector3 to_position = getGoodPosition(0);
Vector3 delta_position = to_position - form_position;
Vector3 delta_position = to_position - from_position;
GetComponent<Rigidbody>().AddForce(delta_position * 1000);
dying = true;
}
}
public void tweenToVectorAndFall(Vector3 position,Vector3 rotation,float delay=0)
public void tweenToVectorAndFall(Vector3 position, Vector3 rotation, float delay = 0)
{
Rigidbody rigidbody = GetComponent<Rigidbody>();
if (rigidbody != null)
{
rigidbody.Sleep();
rigidbody.isKinematic = true; // fix for Unity 2017
}
iTween.MoveTo(gameObject, iTween.Hash(
"delay", delay,
"x", position.x,
"y", position.y,
"z", position.z,
"time", 0.2f,
"oncomplete", (Action)physicalON
));
iTween.RotateTo(gameObject, iTween.Hash(
"delay", delay,
"x", rotation.x,
"y", rotation.y,
"z", rotation.z,
"time", 0.15f
));
iTween.MoveTo(
gameObject,
iTween.Hash(
"delay",
delay,
"x",
position.x,
"y",
position.y,
"z",
position.z,
"time",
0.2f,
"oncomplete",
(Action)physicalON
)
);
iTween.RotateTo(
gameObject,
iTween.Hash(
"delay",
delay,
"x",
rotation.x,
"y",
rotation.y,
"z",
rotation.z,
"time",
0.15f
)
);
physicalOFF();
}
......@@ -141,9 +183,8 @@ public class MonoCardInDeckManager : MonoBehaviour {
GetComponent<BoxCollider>().enabled = true;
Rigidbody rigidbody = GetComponent<Rigidbody>();
if (rigidbody == null)
{
rigidbody = gameObject.AddComponent<Rigidbody>();
}
rigidbody.isKinematic = false;
rigidbody.Sleep();
rigidbody.useGravity = true;
rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
......@@ -155,10 +196,9 @@ public class MonoCardInDeckManager : MonoBehaviour {
GetComponent<BoxCollider>().enabled = true;
Rigidbody rigidbody = GetComponent<Rigidbody>();
if (rigidbody == null)
{
rigidbody = gameObject.AddComponent<Rigidbody>();
}
rigidbody.useGravity = false;
rigidbody.isKinematic = false;
rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
}
......@@ -168,44 +208,37 @@ public class MonoCardInDeckManager : MonoBehaviour {
GetComponent<BoxCollider>().enabled = false;
Rigidbody rigidbody = GetComponent<Rigidbody>();
if (rigidbody != null)
{
rigidbody.useGravity = false;
}
}
public bool getIfAlive()
{
bool ret = true;
if (died == true)
{
ret = false;
}
if (gameObject.transform.position.y < -0.5f)
{
ret = false;
}
if (died || gameObject.transform.position.y < -0.5f)
return false;
Vector3 to_ltemp = refLectPosition(gameObject.transform.position);
if (to_ltemp.x < -15.2f) ret = false;
if (to_ltemp.x > 15.2f) ret = false;
if (Program.I().deckManager.condition == DeckManager.Condition.changeSide)
{
ret = true;
}
return ret;
if (to_ltemp.x < -15.2f || to_ltemp.x > 15.2f)
return false;
return Program.I().deckManager.condition == DeckManager.Condition.changeSide || true;
}
public static Vector3 refLectPosition(Vector3 pos)
{
Vector3 to_ltemp = pos;
Vector3 dv = to_ltemp - Program.camera_game_main.transform.position;
if (dv.y == 0) dv.y = 0.01f;
to_ltemp.x = ((0 - Program.camera_game_main.transform.position.y)
* (dv.x) / dv.y + Program.camera_game_main.transform.position.x);
to_ltemp.y = ((0 - Program.camera_game_main.transform.position.y)
* (dv.y) / dv.y + Program.camera_game_main.transform.position.y);
to_ltemp.z = ((0 - Program.camera_game_main.transform.position.y)
* (dv.z) / dv.y + Program.camera_game_main.transform.position.z);
if (dv.y == 0)
dv.y = 0.01f;
to_ltemp.x = (
(0 - Program.camera_game_main.transform.position.y) * (dv.x) / dv.y
+ Program.camera_game_main.transform.position.x
);
to_ltemp.y = (
(0 - Program.camera_game_main.transform.position.y) * (dv.y) / dv.y
+ Program.camera_game_main.transform.position.y
);
to_ltemp.z = (
(0 - Program.camera_game_main.transform.position.y) * (dv.z) / dv.y
+ Program.camera_game_main.transform.position.z
);
return to_ltemp;
}
}
using UnityEngine;
using System.Collections;
using System.Collections;
using UnityEngine;
public class cardPicLoader : MonoBehaviour
{
public int loaded_code = -1;
public int code = 0;
......@@ -45,7 +44,12 @@ public class cardPicLoader : MonoBehaviour
{
if (Program.pointedCollider == coli)
{
((CardDescription)(Program.I().cardDescription)).setData(YGOSharp.CardsManager.Get(code), GameTextureManager.myBack,"",true);
((CardDescription)(Program.I().cardDescription)).setData(
YGOSharp.CardsManager.Get(code),
GameTextureManager.myBack,
"",
true
);
}
}
}
......
using UnityEngine;
using System.Collections;
using System.Collections;
using UnityEngine;
public class descKeeper : MonoBehaviour {
public class descKeeper : MonoBehaviour
{
public UITexture card;
public UITexture back;
// Use this for initialization
void Start()
{
}
// Use this for initialization
void Start() { }
// Update is called once per frame
void Update () {
void Update()
{
if (back.width < card.width)
{
back.width = card.width + 2;
}
back.transform.localPosition = new Vector3(back.width / 2f, 0);
Vector3 leftTop = new Vector3(-back.width / 2 + 2 + back.transform.localPosition.x, +back.height / 2 - 2 + back.transform.localPosition.y);
card.transform.localPosition = new Vector3(leftTop.x + card.width / 2, leftTop.y - card.height / 2);
Program.I().cardDescription.width = back.width-2;
Vector3 leftTop = new Vector3(
-back.width / 2 + 2 + back.transform.localPosition.x,
+back.height / 2 - 2 + back.transform.localPosition.y
);
card.transform.localPosition = new Vector3(
leftTop.x + card.width / 2,
leftTop.y - card.height / 2
);
Program.I().cardDescription.width = back.width - 2;
Program.I().cardDescription.cHeight = card.height;
}
}
......@@ -301,11 +301,11 @@ Camera:
m_TargetEye: 3
m_HDR: 0
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!26 &2655262
ParticleRenderer:
m_ObjectHideFlags: 1
......@@ -315,6 +315,7 @@ ParticleRenderer:
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
......@@ -330,6 +331,7 @@ ParticleRenderer:
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
......@@ -357,6 +359,7 @@ ParticleRenderer:
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
......@@ -372,6 +375,7 @@ ParticleRenderer:
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
......@@ -503,8 +507,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
camera: {fileID: 2091536}
e1: {fileID: 1598580}
e2: {fileID: 1537834}
trans: {fileID: 497540}
--- !u!114 &11491940
MonoBehaviour:
......
using UnityEngine;
using System.Collections;
using System.Collections;
using UnityEngine;
public class mouseParticle : MonoBehaviour {
public class mouseParticle : MonoBehaviour
{
public Camera camera;
public EllipsoidParticleEmitter e1;
public EllipsoidParticleEmitter e2;
public Transform trans;
// Use this for initialization
void Start () {
void Start()
{
camera.depth = 99999;
}
float time = 0;
// Update is called once per frame
void Update () {
// Update is called once per frame
void Update()
{
Vector3 screenPoint = Input.mousePosition;
screenPoint.z = 10;
trans.position = camera.ScreenToWorldPoint(screenPoint);
if (Input.GetMouseButton(0))
if (Input.GetMouseButton(0))
{
if (Input.GetMouseButtonDown(0))
{
......@@ -28,17 +33,9 @@ public class mouseParticle : MonoBehaviour {
{
time = 0.49f;
}
e1.maxEmission = (0.5f - time) * 60f;
e1.minEmission = (0.5f - time) * 60f;
e2.maxEmission = e1.maxEmission / 3f;
e2.minEmission = e1.minEmission / 3f;
e1.emit = true;
e2.emit = true;
}
else
{
e1.emit = false;
e2.emit = false;
}
}
}
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System;
using System.Linq;
using System.Threading;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;
using System.Threading;
using UnityEngine;
public class Program : MonoBehaviour
{
#region Resources
public Camera main_camera;
public facer face;
......@@ -175,7 +175,6 @@ public class Program : MonoBehaviour
void loadResources()
{
loadResource(mod_audio_effect);
loadResource(mod_ocgcore_card);
loadResource(mod_ocgcore_card_cloude);
......@@ -207,7 +206,6 @@ public class Program : MonoBehaviour
loadResource(mod_ocgcore_blood);
loadResource(mod_ocgcore_blood_screen);
loadResource(mod_ocgcore_bs_atk_decoration);
loadResource(mod_ocgcore_bs_atk_line_earth);
loadResource(mod_ocgcore_bs_atk_line_water);
......@@ -278,8 +276,7 @@ public class Program : MonoBehaviour
public static float verticleScale = 5f;
//YGOPro2 Path (https://github.com/Unicorn369/YGOPro2_Droid/tree/Test) //Multi-language support
public static string ANDROID_GAME_PATH = "/storage/emulated/0/ygocore/";//YGOMobile Path
public static string ANDROID_GAME_PATH = "/storage/emulated/0/ygocore/"; //YGOMobile Path
#if UNITY_EDITOR || UNITY_STANDALONE_WIN //编译器、Windows
public static bool ANDROID_API_N = true;
#elif UNITY_ANDROID || UNITY_IPHONE //Mobile Platform
......@@ -291,10 +288,9 @@ public class Program : MonoBehaviour
#if !UNITY_EDITOR && UNITY_ANDROID
AndroidJavaObject jo = new AndroidJavaObject("cn.unicorn369.library.API");
#endif
#if UNITY_EDITOR || UNITY_STANDALONE_WIN //编译器、Windows
//Environment.CurrentDirectory = System.Windows.Forms.Application.StartupPath;
//System.IO.Directory.SetCurrentDirectory(System.Windows.Forms.Application.StartupPath);
// // Environment.CurrentDirectory = System.Windows.Forms.Application.StartupPath;
// System.IO.Directory.SetCurrentDirectory(System.Windows.Forms.Application.StartupPath);
#elif UNITY_ANDROID //Android
/**
* public String GamePath(String path) {
......@@ -314,8 +310,11 @@ public class Program : MonoBehaviour
//File.Create(ANDROID_GAME_PATH + ".nomedia");
}
if (!File.Exists(ANDROID_GAME_PATH + "updates/ui.txt") || !File.Exists(ANDROID_GAME_PATH + "textures/ui/bg_of_right_game_buttons.png")
|| !File.Exists(ANDROID_GAME_PATH + "textures/ui/bg_of_right_card_searcher2.png"))
if (
!File.Exists(ANDROID_GAME_PATH + "updates/ui.txt")
|| !File.Exists(ANDROID_GAME_PATH + "textures/ui/bg_of_right_game_buttons.png")
|| !File.Exists(ANDROID_GAME_PATH + "textures/ui/bg_of_right_card_searcher2.png")
)
{
string filePath = Application.streamingAssetsPath + "/ui.zip";
var www = new WWW(filePath);
......@@ -323,17 +322,17 @@ public class Program : MonoBehaviour
byte[] bytes = www.bytes;
ExtractZipFile(bytes, ANDROID_GAME_PATH);
}
/* //选择性更新(用于额外打补丁)
if (!File.Exists(ANDROID_GAME_PATH + "updates/ver_1.034.9-fix1.txt"))
{
string filePath = Application.streamingAssetsPath + "/update.zip";
var www = new WWW(filePath);
while (!www.isDone) { }
byte[] bytes = www.bytes;
ExtractZipFile(bytes, ANDROID_GAME_PATH);
//File.Create(ANDROID_GAME_PATH + ".nomedia");
}
*/
/* //选择性更新(用于额外打补丁)
if (!File.Exists(ANDROID_GAME_PATH + "updates/ver_1.034.9-fix1.txt"))
{
string filePath = Application.streamingAssetsPath + "/update.zip";
var www = new WWW(filePath);
while (!www.isDone) { }
byte[] bytes = www.bytes;
ExtractZipFile(bytes, ANDROID_GAME_PATH);
//File.Create(ANDROID_GAME_PATH + ".nomedia");
}
*/
Environment.CurrentDirectory = ANDROID_GAME_PATH;
System.IO.Directory.SetCurrentDirectory(ANDROID_GAME_PATH);
......@@ -347,135 +346,123 @@ public class Program : MonoBehaviour
Environment.CurrentDirectory = GamePaths;
System.IO.Directory.SetCurrentDirectory(GamePaths);
#endif
go(1, () =>
{
UIHelper.iniFaces();
initializeALLcameras();
fixALLcamerasPreFrame();
backGroundPic = new BackGroundPic();
servants.Add(backGroundPic);
backGroundPic.fixScreenProblem();
});
go(300, () =>
{
InterString.initialize("config/translation.conf");
GameTextureManager.initialize();
Config.initialize("config/config.conf");
bool database_ok = false;
bool string_ok = false;
bool lflist_ok = false;
if (!database_ok && File.Exists("cdb/cards.cdb"))
{
database_ok = YGOSharp.CardsManager.initialize("cdb/cards.cdb");
}
if (!database_ok && File.Exists("cards.cdb"))
{
database_ok = YGOSharp.CardsManager.initialize("cards.cdb");
}
if (!string_ok && File.Exists("cdb/strings.conf"))
{
string_ok = GameStringManager.initialize("cdb/strings.conf");
}
if (!string_ok && File.Exists("strings.conf"))
{
string_ok = GameStringManager.initialize("strings.conf");
}
if (File.Exists("expansions/lflist.conf")) // expansions lflist first
{
YGOSharp.BanlistManager.initialize("expansions/lflist.conf");
}
if (!lflist_ok && File.Exists("cdb/lflist.conf"))
{
lflist_ok = YGOSharp.BanlistManager.initialize("cdb/lflist.conf");
}
if (!lflist_ok && File.Exists("lflist.conf"))
go(
1,
() =>
{
lflist_ok = YGOSharp.BanlistManager.initialize("lflist.conf");
UIHelper.iniFaces();
initializeALLcameras();
fixALLcamerasPreFrame();
backGroundPic = new BackGroundPic();
servants.Add(backGroundPic);
backGroundPic.fixScreenProblem();
}
YGOSharp.BanlistManager.initializeComplete();
if (File.Exists("expansions/strings.conf"))
);
go(
10,
() =>
{
GameStringManager.initialize("expansions/strings.conf");
}
if (Directory.Exists("expansions"))
{
FileInfo[] fileInfos = (new DirectoryInfo("expansions")).GetFiles().OrderByDescending(x => x.Name).ToArray();
for (int i = 0; i < fileInfos.Length; i++)
InterString.initialize("config/translation.conf");
// 显示一个简单的加载提示
PrintToChat(InterString.Get("正在加载本地数据..."));
GameTextureManager.initialize();
Config.initialize("config/config.conf");
// [新增] 封装文件加载逻辑,避免重复检查
LoadDatabaseFile("cards.cdb", (path) => YGOSharp.CardsManager.initialize(path));
LoadDatabaseFile("strings.conf", (path) => GameStringManager.initialize(path));
// lflist的加载顺序有特殊性,单独处理
if (File.Exists("expansions/lflist.conf"))
{
YGOSharp.BanlistManager.initialize("expansions/lflist.conf");
}
else
{
LoadDatabaseFile(
"lflist.conf",
(path) => YGOSharp.BanlistManager.initialize(path)
);
}
YGOSharp.BanlistManager.initializeComplete();
// 加载 expansions
if (File.Exists("expansions/strings.conf"))
{
GameStringManager.initialize("expansions/strings.conf");
}
if (Directory.Exists("expansions"))
{
if (fileInfos[i].Name.Length > 4)
FileInfo[] fileInfos = (new DirectoryInfo("expansions"))
.GetFiles("*.cdb")
.OrderByDescending(x => x.Name)
.ToArray();
foreach (var fileInfo in fileInfos)
{
if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".cdb")
{
YGOSharp.CardsManager.initialize("expansions/" + fileInfos[i].Name, false, true);
}
YGOSharp.CardsManager.initialize(fileInfo.FullName, false, true);
}
}
}
YGOSharp.CardsManager.updateSetNames();
YGOSharp.CardsManager.updateSetNames();
if (Directory.Exists("pack"))
{
FileInfo[] fileInfos = (new DirectoryInfo("pack")).GetFiles();
for (int i = 0; i < fileInfos.Length; i++)
// 加载卡包
if (Directory.Exists("pack"))
{
if (fileInfos[i].Name.Length > 3)
FileInfo[] fileInfos = (new DirectoryInfo("pack")).GetFiles("*.db");
foreach (var fileInfo in fileInfos)
{
if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 3, 3) == ".db")
{
YGOSharp.PacksManager.initialize("pack/" + fileInfos[i].Name);
}
YGOSharp.PacksManager.initialize(fileInfo.FullName);
}
YGOSharp.PacksManager.initializeSec();
}
YGOSharp.PacksManager.initializeSec();
}
initializeALLservants();
if(UIHelper.fromStringToBool(Config.Get("*AutoPicDownload", "1")))
(new Thread(()=>{UpdateClient();})).Start();
loadResources();
initializeALLservants();
loadResources();
#if !UNITY_EDITOR && UNITY_ANDROID //Android Java Test
if (!File.Exists("updates/image_0.1.txt"))//用于检查更新
{
if (File.Exists("pics.zip")) {
jo.Call("doExtractZipFile", "pics.zip", ANDROID_GAME_PATH);
File.Copy("updates/ver_1.034.9.txt", "updates/image_0.1.txt", true);
} else {
jo.Call("doDownloadZipFile", "https://github.com/Unicorn369/closeup_mobile/releases/download/0.1/pics.zip");
if (!File.Exists("updates/image_0.1.txt")) //用于检查更新
{
if (File.Exists("pics.zip"))
{
jo.Call("doExtractZipFile", "pics.zip", ANDROID_GAME_PATH);
File.Copy("updates/ver_1.034.9.txt", "updates/image_0.1.txt", true);
}
else
{
jo.Call(
"doDownloadZipFile",
"https://github.com/Unicorn369/closeup_mobile/releases/download/0.1/pics.zip"
);
}
}
}
/**
* 使用Termux编译生成的:libgdiplus.so (https://github.com/Unicorn369/libgdiplus-Android)
* 经测试,只有Android 6.0以上才能正常使用。为了让Android 6.0以下的也能凑合使用立绘效果,需做判断
* 由于部分国产手机系统不够原生,就算是Android 6.0也用不起,只好抛弃能正常使用的手机,改为只支持:Android 7.+
*
* public boolean APIVersion() {
* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
* return true;
* } else {
* return false;
* }
* }
*/
bool API_SUPPORT = jo.Call<bool>("APIVersion");
if (API_SUPPORT == true) {
ANDROID_API_N = true;
} else {
ANDROID_API_N = false;
}
/**
* 使用Termux编译生成的:libgdiplus.so (https://github.com/Unicorn369/libgdiplus-Android)
* 经测试,只有Android 6.0以上才能正常使用。为了让Android 6.0以下的也能凑合使用立绘效果,需做判断
* 由于部分国产手机系统不够原生,就算是Android 6.0也用不起,只好抛弃能正常使用的手机,改为只支持:Android 7.+
*
* public boolean APIVersion() {
* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
* return true;
* } else {
* return false;
* }
* }
*/
bool API_SUPPORT = jo.Call<bool>("APIVersion");
if (API_SUPPORT == true)
{
ANDROID_API_N = true;
}
else
{
ANDROID_API_N = false;
}
#endif
});
}
);
}
public void ExtractZipFile(byte[] data, string outFolder)
{
ZipFile zf = null;
try
{
......@@ -492,7 +479,7 @@ public class Program : MonoBehaviour
}
String entryFileName = zipEntry.Name;
byte[] buffer = new byte[4096]; // 4K is optimum
byte[] buffer = new byte[4096]; // 4K is optimum
Stream zipStream = zf.GetInputStream(zipEntry);
String fullZipToPath = Path.Combine(outFolder, entryFileName);
......@@ -519,58 +506,117 @@ public class Program : MonoBehaviour
}
}
}
private void UpdateClient()
// [新增] 一个辅助方法,用于查找并加载数据库文件,减少重复代码
private bool LoadDatabaseFile(string fileName, Func<string, bool> loadAction)
{
try
string[] pathsToCkeck = { "cdb/" + fileName, fileName };
foreach (var path in pathsToCkeck)
{
PrintToChat(InterString.Get("开始更新卡片数据。"));
if(!Directory.Exists("cdb")) {
Directory.CreateDirectory("cdb");
}
/*if(File.Exists("cdb/cards.cdb"))
File.Delete("cdb/cards.cdb");
if(File.Exists("cdb/lflist.conf"))
File.Delete("cdb/lflist.conf");
if(File.Exists("cdb/strings.conf"))
File.Delete("cdb/strings.conf");*/
HttpDldFile httpDldFile = new HttpDldFile();
httpDldFile.Download("http://cdn01.moestart.com/koishipro/ygopro-database/zh-CN/cards.cdb", "cdb/_cards.cdb");
if(YGOSharp.CardsManager.initialize("cdb/_cards.cdb", true)) {
ReplaceFile("cdb/cards.cdb", "cdb/_cards.cdb");
}
else
{
PrintToChat(InterString.Get("卡片数据库更新失败。"));
}
httpDldFile.Download("http://cdn01.moestart.com/koishipro/ygopro-database/zh-CN/lflist.conf", "cdb/_lflist.conf");
if(YGOSharp.BanlistManager.initialize("cdb/_lflist.conf", true)) {
ReplaceFile("cdb/lflist.conf","cdb/_lflist.conf");
}
else
{
PrintToChat(InterString.Get("禁止/限制卡表文件更新失败。"));
}
httpDldFile.Download("http://cdn01.moestart.com/koishipro/ygopro-database/zh-CN/strings.conf", "cdb/_strings.conf");
if(GameStringManager.initialize("cdb/_strings.conf", true)) {
ReplaceFile("cdb/strings.conf","cdb/_strings.conf");
}
else
if (File.Exists(path))
{
PrintToChat(InterString.Get("字段信息文件更新失败。"));
if (loadAction(path))
{
Debug.Log("Successfully loaded: " + path);
return true;
}
}
PrintToChat(InterString.Get("卡片数据更新完毕,重启游戏生效。"));
}
catch (Exception e)
Debug.LogError("Failed to load file: " + fileName);
return false;
}
// [修改] 使用 UnityFileDownloader 完全重写后台更新协程
private IEnumerator UpdateClientCoroutine()
{
PrintToChat(InterString.Get("开始在后台检查卡片数据更新..."));
string dbDir = "cdb";
if (!Directory.Exists(dbDir))
{
Directory.CreateDirectory(dbDir);
}
bool anyFileUpdated = false;
bool cardsDbUpdated = false;
bool lflistUpdated = false;
bool stringsUpdated = false;
// 1. 下载 cards.cdb
string cardsUrl = "http://cdn01.moestart.com/koishipro/ygopro-database/zh-CN/cards.cdb";
string cardsPath = Path.Combine(dbDir, "cards.cdb");
yield return StartCoroutine(
UnityFileDownloader.DownloadFileAsync(
cardsUrl,
cardsPath,
(success) =>
{
if (success)
{
anyFileUpdated = true;
cardsDbUpdated = true;
}
}
)
);
// 2. 下载 lflist.conf
string lflistUrl = "http://cdn01.moestart.com/koishipro/ygopro-database/zh-CN/lflist.conf";
string lflistPath = Path.Combine(dbDir, "lflist.conf");
yield return StartCoroutine(
UnityFileDownloader.DownloadFileAsync(
lflistUrl,
lflistPath,
(success) =>
{
if (success)
{
anyFileUpdated = true;
lflistUpdated = true;
}
}
)
);
// 3. 下载 strings.conf
string stringsUrl =
"http://cdn01.moestart.com/koishipro/ygopro-database/zh-CN/strings.conf";
string stringsPath = Path.Combine(dbDir, "strings.conf");
yield return StartCoroutine(
UnityFileDownloader.DownloadFileAsync(
stringsUrl,
stringsPath,
(success) =>
{
if (success)
{
anyFileUpdated = true;
stringsUpdated = true;
}
}
)
);
// 4. 根据下载结果显示最终提示
if (anyFileUpdated)
{
string updatedFiles = "";
if (cardsDbUpdated)
updatedFiles += "卡片库 ";
if (lflistUpdated)
updatedFiles += "禁卡表 ";
if (stringsUpdated)
updatedFiles += "文本 ";
PrintToChat(
InterString.Get("数据更新完毕([?]),重启游戏后生效。", updatedFiles.Trim())
);
}
else
{
PrintToChat("UPDATE ERROR: " + e.ToString());
Debug.Log("UPDATE ERROR: " + e.ToString());
PrintToChat(InterString.Get("后台更新检查完成,未发现新数据或更新失败。"));
}
}
private void ReplaceFile(string oldfile, string newfile) {
if(File.Exists(oldfile)) {
private void ReplaceFile(string oldfile, string newfile)
{
if (File.Exists(oldfile))
{
File.Delete(oldfile);
}
File.Move(newfile, oldfile);
......@@ -579,6 +625,7 @@ public class Program : MonoBehaviour
public GameObject mouseParticle;
static int lastChargeTime = 0;
public static void charge()
{
if (Program.TimePassed() - lastChargeTime > 5 * 60 * 1000)
......@@ -629,11 +676,9 @@ public class Program : MonoBehaviour
public static void go(int delay_, Action act_)
{
delayedTasks.Add(new delayedTask
{
act = act_,
timeToBeDone = delay_ + Program.TimePassed(),
});
delayedTasks.Add(
new delayedTask { act = act_, timeToBeDone = delay_ + Program.TimePassed() }
);
}
public static void notGo(Action act_)
......@@ -681,7 +726,9 @@ public class Program : MonoBehaviour
if (ui_back_ground_2d == null)
{
ui_back_ground_2d = create(mod_ui_2d);
camera_back_ground_2d = ui_back_ground_2d.transform.Find("Camera").GetComponent<Camera>();
camera_back_ground_2d = ui_back_ground_2d
.transform.Find("Camera")
.GetComponent<Camera>();
}
camera_back_ground_2d.depth = -2;
ui_back_ground_2d.layer = 8;
......@@ -706,8 +753,6 @@ public class Program : MonoBehaviour
camera_container_3d.rect = new Rect(0, 0, 1, 1);
camera_container_3d.clearFlags = CameraClearFlags.Depth;
if (ui_main_2d == null)
{
ui_main_2d = create(mod_ui_2d);
......@@ -719,7 +764,6 @@ public class Program : MonoBehaviour
camera_main_2d.cullingMask = (int)Mathf.Pow(2, 11);
camera_main_2d.clearFlags = CameraClearFlags.Depth;
if (ui_windows_2d == null)
{
ui_windows_2d = create(mod_ui_2d);
......@@ -731,7 +775,6 @@ public class Program : MonoBehaviour
camera_windows_2d.cullingMask = (int)Mathf.Pow(2, 19);
camera_windows_2d.clearFlags = CameraClearFlags.Depth;
if (ui_main_3d == null)
{
ui_main_3d = create(mod_ui_3d);
......@@ -748,14 +791,13 @@ public class Program : MonoBehaviour
camera_main_3d.transform.localScale = new Vector3(1, 1, 1);
camera_main_3d.clearFlags = CameraClearFlags.Depth;
camera_main_3d.transform.localPosition = camera_game_main.transform.position;
camera_container_3d.transform.localPosition = camera_game_main.transform.position;
camera_main_3d.transform.localEulerAngles = camera_game_main.transform.localEulerAngles;
camera_container_3d.transform.localEulerAngles = camera_game_main.transform.localEulerAngles;
camera_container_3d.transform.localEulerAngles = camera_game_main
.transform
.localEulerAngles;
camera_main_3d.fieldOfView = camera_game_main.fieldOfView;
camera_container_3d.fieldOfView = camera_game_main.fieldOfView;
......@@ -775,17 +817,23 @@ public class Program : MonoBehaviour
}
if (camera_game_main != null)
{
camera_game_main.transform.position += (cameraPosition - camera_game_main.transform.position) * deltaTime * 3.5f;
camera_game_main.transform.position +=
(cameraPosition - camera_game_main.transform.position) * deltaTime * 3.5f;
camera_container_3d.transform.localPosition = camera_game_main.transform.position;
if (cameraFacing == false)
{
camera_game_main.transform.localEulerAngles += (cameraRotation - camera_game_main.transform.localEulerAngles) * deltaTime * 3.5f;
camera_game_main.transform.localEulerAngles +=
(cameraRotation - camera_game_main.transform.localEulerAngles)
* deltaTime
* 3.5f;
}
else
{
camera_game_main.transform.LookAt(Vector3.zero);
}
camera_container_3d.transform.localEulerAngles = camera_game_main.transform.localEulerAngles;
camera_container_3d.transform.localEulerAngles = camera_game_main
.transform
.localEulerAngles;
camera_container_3d.fieldOfView = camera_game_main.fieldOfView;
camera_container_3d.rect = camera_game_main.rect;
}
......@@ -807,7 +855,7 @@ public class Program : MonoBehaviour
GameObject father = null,
bool allParamsInWorld = true,
Vector3 wantScale = default(Vector3)
)
)
{
Vector3 scale = mod.transform.localScale;
if (wantScale != default(Vector3))
......@@ -878,8 +926,10 @@ public class Program : MonoBehaviour
}
else
{
if (time != 0) MonoBehaviour.Destroy(obj, time);
else MonoBehaviour.Destroy(obj);
if (time != 0)
MonoBehaviour.Destroy(obj, time);
else
MonoBehaviour.Destroy(obj);
}
if (instantNull)
{
......@@ -1044,25 +1094,37 @@ public class Program : MonoBehaviour
{
aiRoom.hide();
}
if(to != roomList && to != selectServer && roomList.isShowed)
if (to != roomList && to != selectServer && roomList.isShowed)
{
roomList.hide();
}
if (to == backGroundPic && backGroundPic.isShowed == false) backGroundPic.show();
if (to == menu && menu.isShowed == false) menu.show();
if (to == setting && setting.isShowed == false) setting.show();
if (to == selectDeck && selectDeck.isShowed == false) selectDeck.show();
if (to == room && room.isShowed == false) room.show();
if (to == deckManager && deckManager.isShowed == false) deckManager.show();
if (to == ocgcore && ocgcore.isShowed == false) ocgcore.show();
if (to == selectServer && selectServer.isShowed == false) selectServer.show();
if (to == mycard && mycard.isShowed == false) mycard.show();
if (to == selectReplay && selectReplay.isShowed == false) selectReplay.show();
if (to == puzzleMode && puzzleMode.isShowed == false) puzzleMode.show();
if (to == aiRoom && aiRoom.isShowed == false) aiRoom.show();
if (to == roomList && !roomList.isShowed) roomList.show();
if (to == backGroundPic && backGroundPic.isShowed == false)
backGroundPic.show();
if (to == menu && menu.isShowed == false)
menu.show();
if (to == setting && setting.isShowed == false)
setting.show();
if (to == selectDeck && selectDeck.isShowed == false)
selectDeck.show();
if (to == room && room.isShowed == false)
room.show();
if (to == deckManager && deckManager.isShowed == false)
deckManager.show();
if (to == ocgcore && ocgcore.isShowed == false)
ocgcore.show();
if (to == selectServer && selectServer.isShowed == false)
selectServer.show();
if (to == mycard && mycard.isShowed == false)
mycard.show();
if (to == selectReplay && selectReplay.isShowed == false)
selectReplay.show();
if (to == puzzleMode && puzzleMode.isShowed == false)
puzzleMode.show();
if (to == aiRoom && aiRoom.isShowed == false)
aiRoom.show();
if (to == roomList && !roomList.isShowed)
roomList.show();
}
#endregion
......@@ -1071,7 +1133,7 @@ public class Program : MonoBehaviour
private float LastUpdateShowTime = 0f;
private float UpdateShowDeltaTime = 1f; //更新帧率
private float UpdateShowDeltaTime = 1f; //更新帧率
private int FrameUpdate = 0;
......@@ -1079,26 +1141,33 @@ public class Program : MonoBehaviour
void Start()
{
#if UNITY_EDITOR || UNITY_STANDALONE_WIN //编译器、Windows
#if UNITY_EDITOR || UNITY_STANDALONE_WIN //编译器、Windows
if (Screen.width < 100 || Screen.height < 100)
{
Screen.SetResolution(1300, 700, false);
}
QualitySettings.vSyncCount = 0;
#elif UNITY_ANDROID || UNITY_IPHONE //Android、iPhone
Screen.SetResolution(1280, 720, true);
#elif UNITY_ANDROID || UNITY_IPHONE //Android、iPhone
// Screen.SetResolution(1280, 720, true);
Screen.sleepTimeout = SleepTimeout.NeverSleep;
Screen.orientation = ScreenOrientation.AutoRotation;
Screen.autorotateToLandscapeLeft = true;
Screen.autorotateToLandscapeRight = true;
Screen.autorotateToPortrait = false;
Screen.autorotateToPortraitUpsideDown = false;
#endif
#endif
mouseParticle = Instantiate(new_mouse);
instance = this;
initialize();
go(500, () => { gameStart(); });
go(
1,
() =>
{
gameStart();
}
);
LastUpdateShowTime = Time.realtimeSinceStartup;
}
......@@ -1111,21 +1180,28 @@ public class Program : MonoBehaviour
void OnGUI()
{
if (Event.current.type == EventType.ScrollWheel) {
if (Event.current.type == EventType.ScrollWheel)
{
_padScroll = -Event.current.delta.y / 100;
} else {
}
else
{
_padScroll = 0;
}
string FPS = m_FPS.ToString();
try { FPS = FPS.Substring(0, 5); } catch{}
try
{
FPS = FPS.Substring(0, 5);
}
catch { }
GUI.Label(new Rect(10, 5, 200, 200), "[Ver 1.036.1-Otokaze] " + "FPS: " + FPS);
}
void Update()
{
FrameUpdate++;
if(Time.realtimeSinceStartup - LastUpdateShowTime >= UpdateShowDeltaTime)
if (Time.realtimeSinceStartup - LastUpdateShowTime >= UpdateShowDeltaTime)
{
m_FPS = FrameUpdate / (Time.realtimeSinceStartup - LastUpdateShowTime);
FrameUpdate = 0;
......@@ -1148,7 +1224,9 @@ public class Program : MonoBehaviour
pointedGameObject = hit.collider.gameObject;
pointedCollider = hit.collider;
}
GameObject hoverobject = UICamera.Raycast(Input.mousePosition) ? UICamera.lastHit.collider.gameObject : null;
GameObject hoverobject = UICamera.Raycast(Input.mousePosition)
? UICamera.lastHit.collider.gameObject
: null;
if (hoverobject != null)
{
if (hoverobject.layer == 11 || pointedGameObject == null)
......@@ -1197,7 +1275,6 @@ public class Program : MonoBehaviour
break;
}
}
}
private void onRESIZED()
......@@ -1237,6 +1314,13 @@ public class Program : MonoBehaviour
}
backGroundPic.show();
shiftToServant(menu);
// 游戏主菜单显示后,才开始在后台检查更新
// 调用新的、非阻塞的后台更新协程
if (UIHelper.fromStringToBool(Config.Get("*AutoPicDownload", "1")))
{
StartCoroutine(UpdateClientCoroutine());
}
}
public static bool Running = true;
......@@ -1282,7 +1366,10 @@ public class Program : MonoBehaviour
public static void gugugu()
{
PrintToChat(InterString.Get("非常抱歉,因为技术原因,此功能暂时无法使用。请关注官方网站获取更多消息。"));
PrintToChat(
InterString.Get(
"非常抱歉,因为技术原因,此功能暂时无法使用。请关注官方网站获取更多消息。"
)
);
}
}
using System;
using System.Collections.Generic;
using UnityEngine;
public static class GameStringManager
{
public class hashedString
......@@ -28,9 +29,7 @@ public static class GameStringManager
return_value = Int32.Parse(str);
}
}
catch (Exception)
{
}
catch (Exception) { }
return return_value;
}
......@@ -45,7 +44,8 @@ public static class GameStringManager
{
if (line.Length > 1 && line.Substring(0, 1) == "!")
{
string[] mats = line.Substring(1, line.Length - 1).Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
string[] mats = line.Substring(1, line.Length - 1)
.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
if (mats.Length > 2)
{
found = true;
......@@ -66,7 +66,8 @@ public static class GameStringManager
a.content += mats[i] + " ";
}
a.content = a.content.Substring(0, a.content.Length - 1);
if(!test) {
if (!test)
{
hashedStrings.Add(a);
if (a.region == "setname")
{
......@@ -150,6 +151,7 @@ public static class GameStringManager
else
return "???";
}
internal static string formatLocation(GPS gps)
{
return formatLocation(gps.location, gps.sequence);
......
using System;
using System.Collections;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
/// <summary>
/// 使用Unity官方推荐的UnityWebRequest来异步下载文件。
/// </summary>
public class UnityFileDownloader
{
public static IEnumerator DownloadFileAsync(
string url,
string filePath,
Action<bool> onComplete,
Action<float> onProgress = null
)
{
string directoryPath = Path.GetDirectoryName(filePath);
if (!Directory.Exists(directoryPath))
{
Directory.CreateDirectory(directoryPath);
}
string tempFilePath = filePath + ".tmp";
if (File.Exists(tempFilePath))
{
File.Delete(tempFilePath);
}
using (UnityWebRequest uwr = new UnityWebRequest(url, UnityWebRequest.kHttpVerbGET))
{
uwr.downloadHandler = new DownloadHandlerFile(tempFilePath);
uwr.timeout = GetTimeoutForFile(filePath);
var asyncOperation = uwr.SendWebRequest();
while (!asyncOperation.isDone)
{
if (onProgress != null)
{
onProgress.Invoke(asyncOperation.progress);
}
yield return null;
}
if (!uwr.isNetworkError && !uwr.isHttpError)
{
if (File.Exists(filePath))
{
File.Delete(filePath);
}
File.Move(tempFilePath, filePath);
// 使用 string.Format 替换了插值字符串
Debug.Log(string.Format("下载成功: {0} -> {1}", url, filePath));
if (onComplete != null)
{
onComplete.Invoke(true);
}
}
else
{
// 使用 string.Format 替换了插值字符串
Debug.LogError(string.Format("下载失败: {0}\n错误信息: {1}", url, uwr.error));
if (File.Exists(tempFilePath))
{
File.Delete(tempFilePath);
}
if (onComplete != null)
{
onComplete.Invoke(false);
}
}
}
}
private static int GetTimeoutForFile(string filename)
{
string extension = Path.GetExtension(filename).ToLower();
switch (extension)
{
case ".png":
return 7;
case ".jpg":
return 4;
case ".cdb":
return 30;
case ".conf":
return 3;
default:
return 10;
}
}
}
fileFormatVersion: 2
guid: 25fa5ec13b1e84a41b335ddc22a05481
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using YGOSharp.OCGWrapper.Enums;
public class Servant
......@@ -16,17 +16,13 @@ public class Servant
List<Action> updateActions_s = new List<Action>();
public Servant()
{
initialize();
AddUpdateAction(preFrameFunction);
}
public virtual void initialize()
{
}
public virtual void initialize() { }
public virtual void show()
{
......@@ -42,6 +38,11 @@ public class Servant
{
RMSshow_clear();
RMSshow_clearYNF();
// 取消屏幕修复任务
Program.notGo(fixScreenProblem);
Program.go(50, fixScreenProblem);
if (isShowed == true)
{
isShowed = false;
......@@ -78,60 +79,45 @@ public class Servant
allGameObjects.Add(o);
}
public virtual void preFrameFunction()
{
}
public virtual void ES_mouseDownEmpty()
{
}
public virtual void ES_mouseDownGameObject(GameObject gameObject)
{
}
public virtual void ES_mouseUp()
{
}
public virtual void ES_mouseDownRight()
{
public virtual void preFrameFunction() { }
}
public virtual void ES_mouseDownEmpty() { }
public virtual void ES_mouseUpRight()
{
public virtual void ES_mouseDownGameObject(GameObject gameObject) { }
}
public virtual void ES_mouseUp() { }
public virtual void ES_mouseUpEmpty()
{
public virtual void ES_mouseDownRight() { }
}
public virtual void ES_mouseUpRight() { }
public virtual void ES_mouseUpGameObject(GameObject gameObject)
{
public virtual void ES_mouseUpEmpty() { }
}
public virtual void ES_mouseUpGameObject(GameObject gameObject) { }
public virtual void ES_HoverOverGameObject(GameObject gameObject)
{
}
public virtual void ES_HoverOverGameObject(GameObject gameObject) { }
public void showBarOnly()
{
if (toolBar != null)
{
Vector3 vectorOfShowedBar_Screen = new Vector3(Screen.width - RightToScreen, buttomToScreen, 0);
iTween.MoveTo(toolBar, Program.camera_back_ground_2d.ScreenToWorldPoint(vectorOfShowedBar_Screen), 0.6f);
toolBar.transform.localScale = new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f);
Vector3 vectorOfShowedBar_Screen = new Vector3(
Screen.width - RightToScreen,
buttomToScreen,
0
);
iTween.MoveTo(
toolBar,
Program.camera_back_ground_2d.ScreenToWorldPoint(vectorOfShowedBar_Screen),
0.6f
);
toolBar.transform.localScale = new Vector3(
((float)Screen.height) / 700f,
((float)Screen.height) / 700f,
((float)Screen.height) / 700f
);
var items = toolBar.GetComponentsInChildren<toolShift>();
for (int i = 0; i < items.Length; i++)
for (int i = 0; i < items.Length; i++)
{
items[i].enabled = true;
}
......@@ -143,8 +129,16 @@ public class Servant
if (toolBar != null)
{
Vector3 vectorOfHidedBar_Screen = new Vector3(Screen.width - RightToScreen, -100, 0);
iTween.MoveTo(toolBar, Program.camera_back_ground_2d.ScreenToWorldPoint(vectorOfHidedBar_Screen), 0.6f);
toolBar.transform.localScale = new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f);
iTween.MoveTo(
toolBar,
Program.camera_back_ground_2d.ScreenToWorldPoint(vectorOfHidedBar_Screen),
0.6f
);
toolBar.transform.localScale = new Vector3(
((float)Screen.height) / 700f,
((float)Screen.height) / 700f,
((float)Screen.height) / 700f
);
var items = toolBar.GetComponentsInChildren<toolShift>();
for (int i = 0; i < items.Length; i++)
{
......@@ -163,10 +157,7 @@ public class Servant
hideBarOnly();
}
public virtual void ES_quit()
{
}
public virtual void ES_quit() { }
GameObject preHover = null;
......@@ -216,7 +207,7 @@ public class Servant
if (preHover != Program.pointedGameObject)
{
preHover = Program.pointedGameObject;
if (preHover!=null)
if (preHover != null)
ES_HoverOverGameObject(preHover);
}
}
......@@ -235,9 +226,11 @@ public class Servant
GameObject father = null,
bool allParamsInWorld = true,
Vector3 wantScale = default(Vector3)
)
)
{
var re = Program.I().create(mod, position, rotation, fade, father, allParamsInWorld, wantScale);
var re = Program
.I()
.create(mod, position, rotation, fade, father, allParamsInWorld, wantScale);
return re;
}
......@@ -249,9 +242,11 @@ public class Servant
GameObject father = null,
bool allParamsInWorld = true,
Vector3 wantScale = default(Vector3)
)
)
{
var re = Program.I().create(mod, position, rotation, fade, father, allParamsInWorld, wantScale);
var re = Program
.I()
.create(mod, position, rotation, fade, father, allParamsInWorld, wantScale);
allGameObjects.Add(re);
return re;
}
......@@ -288,22 +283,23 @@ public class Servant
float RightToScreen;
public void SetBar(GameObject mod,float buttomToScreen,float RightToScreen)
public void SetBar(GameObject mod, float buttomToScreen, float RightToScreen)
{
this.buttomToScreen = buttomToScreen;
this.RightToScreen = RightToScreen;
if (toolBar!=null)
if (toolBar != null)
{
MonoBehaviour.DestroyImmediate(toolBar);
}
toolBar = create
(
toolBar = create(
mod,
Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width - RightToScreen, -100, 0)),
Program.camera_main_2d.ScreenToWorldPoint(
new Vector3(Screen.width - RightToScreen, -100, 0)
),
new Vector3(0, 0, 0),
false,
Program.ui_main_2d
);
);
UIHelper.InterGameObject(toolBar);
fixScreenProblem();
}
......@@ -311,27 +307,26 @@ public class Servant
public void reShowBar(float buttomToScreen, float RightToScreen)
{
this.buttomToScreen = buttomToScreen;
this.RightToScreen = RightToScreen;
if (isShowed)
this.RightToScreen = RightToScreen;
if (isShowed)
{
showBarOnly();
}
}
List<Program.delayedTask> delayedTasks = new List<Program.delayedTask>();
public void safeGogo(int delay_, Action act_)
{
Program.go(delay_, act_);
delayedTasks.Add(new Program.delayedTask
{
act = act_,
timeToBeDone = delay_ + Program.TimePassed(),
});
delayedTasks.Add(
new Program.delayedTask { act = act_, timeToBeDone = delay_ + Program.TimePassed() }
);
}
#region remasterMessageSystem
public Vector3 centre(bool fix=false)
public Vector3 centre(bool fix = false)
{
if (Program.I().ocgcore.isShowed || Program.I().deckManager.isShowed)
{
......@@ -352,7 +347,9 @@ public class Servant
}
else
{
return Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2, 0));
return Program.camera_main_2d.ScreenToWorldPoint(
new Vector3(Screen.width / 2, Screen.height / 2, 0)
);
}
}
......@@ -361,7 +358,9 @@ public class Servant
if (Program.I().ocgcore.isShowed)
{
float real = (Program.fieldSize - 1) * 0.9f + 1f;
Vector3 screenP = Program.camera_game_main.WorldToScreenPoint(new Vector3(0, 0, -5.65f * real));
Vector3 screenP = Program.camera_game_main.WorldToScreenPoint(
new Vector3(0, 0, -5.65f * real)
);
screenP.z = 0;
return Program.camera_main_2d.ScreenToWorldPoint(screenP);
}
......@@ -371,7 +370,9 @@ public class Servant
screenP.z = 0;
return Program.camera_main_2d.ScreenToWorldPoint(screenP);
}
return Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2, 0));
return Program.camera_main_2d.ScreenToWorldPoint(
new Vector3(Screen.width / 2, Screen.height / 2, 0)
);
}
private enum messageSystemType
......@@ -408,7 +409,7 @@ public class Servant
void ES_RMSpremono(GameObject gameObjectClicked, messageSystemValue value)
{
List<messageSystemValue> re;
switch (currentMStype)
switch (currentMStype)
{
case messageSystemType.onlyYes:
case messageSystemType.yesOrNo:
......@@ -490,36 +491,47 @@ public class Servant
RMSshow_clear();
currentMShash = hashCode;
currentMStype = messageSystemType.onlyYes;
currentMSwindow = create
(
currentMSwindow = create(
Program.I().ES_1,
MSentre(),
Vector3.zero,
true,
Program.ui_main_2d,
true,
new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f)
);
new Vector3(
((float)Screen.height) / 700f,
((float)Screen.height) / 700f,
((float)Screen.height) / 700f
)
);
UIHelper.InterGameObject(currentMSwindow);
UIHelper.trySetLableText(currentMSwindow, "hint_", hint);
UIHelper.registEvent(currentMSwindow, "yes_", ES_RMSpremono, yes);
}
public void RMSshow_yesOrNo(string hashCode, string hint, messageSystemValue yes, messageSystemValue no)
public void RMSshow_yesOrNo(
string hashCode,
string hint,
messageSystemValue yes,
messageSystemValue no
)
{
RMSshow_clear();
currentMShash = hashCode;
currentMStype = messageSystemType.yesOrNo;
currentMSwindow = create
(
currentMSwindow = create(
Program.I().ES_2,
MSentre(),
Vector3.zero,
true,
Program.ui_main_2d,
true,
new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f)
);
new Vector3(
((float)Screen.height) / 700f,
((float)Screen.height) / 700f,
((float)Screen.height) / 700f
)
);
UIHelper.InterGameObject(currentMSwindow);
UIHelper.trySetLableText(currentMSwindow, "hint_", hint);
UIHelper.registEvent(currentMSwindow, "yes_", ES_RMSpremono, yes);
......@@ -531,16 +543,19 @@ public class Servant
public void RMSshow_yesOrNoForce(string hint, messageSystemValue yes, messageSystemValue no)
{
RMSshow_clearYNF();
yesOrNoForce = create
(
yesOrNoForce = create(
Program.I().ES_2Force,
MSentre(),
Vector3.zero,
true,
Program.ui_main_2d,
true,
new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f)
);
new Vector3(
((float)Screen.height) / 700f,
((float)Screen.height) / 700f,
((float)Screen.height) / 700f
)
);
UIHelper.InterGameObject(yesOrNoForce);
UIHelper.trySetLableText(yesOrNoForce, "hint_", hint);
UIHelper.registEvent(yesOrNoForce, "yes_", ES_RMSpremonoForceYesNo, yes);
......@@ -562,36 +577,48 @@ public class Servant
RMSshow_clear();
currentMShash = hashCode;
currentMStype = messageSystemType.yesOrNo;
currentMSwindow = create
(
currentMSwindow = create(
Program.I().ES_FS,
MSentre(),
Vector3.zero,
true,
Program.ui_main_2d,
true,
new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f)
);
new Vector3(
((float)Screen.height) / 700f,
((float)Screen.height) / 700f,
((float)Screen.height) / 700f
)
);
UIHelper.InterGameObject(currentMSwindow);
UIHelper.registEvent(currentMSwindow, "yes_", ES_RMSpremono, first);
UIHelper.registEvent(currentMSwindow, "no_", ES_RMSpremono, second);
}
public void RMSshow_yesOrNoOrCancle(string hashCode, string hint, messageSystemValue yes, messageSystemValue no, messageSystemValue cancle)
public void RMSshow_yesOrNoOrCancle(
string hashCode,
string hint,
messageSystemValue yes,
messageSystemValue no,
messageSystemValue cancle
)
{
RMSshow_clear();
currentMShash = hashCode;
currentMStype = messageSystemType.yesOrNoOrCancle;
currentMSwindow = create
(
currentMSwindow = create(
Program.I().ES_3cancle,
MSentre(),
Vector3.zero,
true,
Program.ui_main_2d,
true,
new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f)
);
new Vector3(
((float)Screen.height) / 700f,
((float)Screen.height) / 700f,
((float)Screen.height) / 700f
)
);
UIHelper.InterGameObject(currentMSwindow);
UIHelper.trySetLableText(currentMSwindow, "hint_", hint);
UIHelper.registEvent(currentMSwindow, "yes_", ES_RMSpremono, yes);
......@@ -604,30 +631,32 @@ public class Servant
RMSshow_clear();
currentMShash = hashCode;
currentMStype = messageSystemType.singleChoice;
currentMSwindow = create
(
currentMSwindow = create(
Program.I().ES_Single_multiple_window,
MSentre(),
Vector3.zero,
true,
Program.ui_main_2d,
true,
new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f)
);
new Vector3(
((float)Screen.height) / 700f,
((float)Screen.height) / 700f,
((float)Screen.height) / 700f
)
);
UISprite sp = UIHelper.getByName<UISprite>(currentMSwindow, "under");
sp.height = 70 + options.Count * 48;
for (int i = 0; i < options.Count; i++)
{
GameObject btn = create
(
Program.I().ES_Single_option,
new Vector3(-2, sp.height / 2 - 59 - 48 * i, 0),
Vector3.zero,
false,
sp.gameObject,
false
);
UIHelper.trySetLableText(btn, "[u]"+options[i].hint);
GameObject btn = create(
Program.I().ES_Single_option,
new Vector3(-2, sp.height / 2 - 59 - 48 * i, 0),
Vector3.zero,
false,
sp.gameObject,
false
);
UIHelper.trySetLableText(btn, "[u]" + options[i].hint);
UIHelper.registEvent(btn, btn.name, ES_RMSpremono, options[i]);
}
UIHelper.InterGameObject(currentMSwindow);
......@@ -637,23 +666,30 @@ public class Servant
List<messageSystemValue> RMSshow_multipleChoice_selected = new List<messageSystemValue>();
public void RMSshow_multipleChoice(string hashCode, int selectCount, List<messageSystemValue> options)
public void RMSshow_multipleChoice(
string hashCode,
int selectCount,
List<messageSystemValue> options
)
{
RMSshow_multipleChoice_count = selectCount;
RMSshow_multipleChoice_selected.Clear();
RMSshow_clear();
currentMShash = hashCode;
currentMStype = messageSystemType.multipleChoice;
currentMSwindow = create
(
currentMSwindow = create(
Program.I().ES_Single_multiple_window,
MSentre(),
Vector3.zero,
true,
Program.ui_main_2d,
true,
new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f)
);
new Vector3(
((float)Screen.height) / 700f,
((float)Screen.height) / 700f,
((float)Screen.height) / 700f
)
);
UISprite sp = UIHelper.getByName<UISprite>(currentMSwindow, "under");
sp.height = 70 + UIHelper.get_zonghangshu(options.Count, 5) * 40;
sp.width = 470;
......@@ -662,36 +698,43 @@ public class Servant
Vector2 v = UIHelper.get_hang_lie(i, 5);
float hang = v.x;
float lie = v.y;
GameObject btn = create
(
Program.I().ES_multiple_option,
new Vector3(-162 + lie * 80, sp.height / 2 - 55 - 40 * hang, 0),
Vector3.zero,
false,
sp.gameObject,
false
);
GameObject btn = create(
Program.I().ES_multiple_option,
new Vector3(-162 + lie * 80, sp.height / 2 - 55 - 40 * hang, 0),
Vector3.zero,
false,
sp.gameObject,
false
);
UIHelper.trySetLableText(btn, "[u]" + options[i].hint);
UIHelper.registEvent(btn, btn.name, ES_RMSpremono, options[i]);
}
UIHelper.InterGameObject(currentMSwindow);
}
public void RMSshow_position(string hashCode, int code, messageSystemValue atk, messageSystemValue def)
public void RMSshow_position(
string hashCode,
int code,
messageSystemValue atk,
messageSystemValue def
)
{
RMSshow_clear();
currentMShash = hashCode;
currentMStype = messageSystemType.position;
currentMSwindow = create
(
currentMSwindow = create(
Program.I().ES_position,
MSentre(),
Vector3.zero,
true,
Program.ui_main_2d,
true,
new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f)
);
new Vector3(
((float)Screen.height) / 700f,
((float)Screen.height) / 700f,
((float)Screen.height) / 700f
)
);
UIHelper.InterGameObject(currentMSwindow);
UIHelper.registEvent(currentMSwindow, "atk_", ES_RMSpremono, atk);
UIHelper.registEvent(currentMSwindow, "def_", ES_RMSpremono, def);
......@@ -713,28 +756,48 @@ public class Servant
cardPicLoader_.code = code;
cardPicLoader_.uiTexture = atkpic;
cardPicLoader_ = currentMSwindow.AddComponent<cardPicLoader>();
cardPicLoader_.code = (Int32.Parse(def.value) == (int)CardPosition.FaceDownDefence) ? 0 : code;
cardPicLoader_.code =
(Int32.Parse(def.value) == (int)CardPosition.FaceDownDefence) ? 0 : code;
cardPicLoader_.uiTexture = UIHelper.getByName<UITexture>(currentMSwindow, "defPic_");
}
public void RMSshow_position3(string hashCode, int code)
{
RMSshow_clear();
currentMShash = hashCode;
currentMStype = messageSystemType.position;
currentMSwindow = create
(
currentMSwindow = create(
Program.I().ES_position3,
MSentre(),
Vector3.zero,
true,
Program.ui_main_2d,
true,
new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f)
);
new Vector3(
((float)Screen.height) / 700f,
((float)Screen.height) / 700f,
((float)Screen.height) / 700f
)
);
UIHelper.InterGameObject(currentMSwindow);
UIHelper.registEvent(currentMSwindow, "upAtk_", ES_RMSpremono, new messageSystemValue { value = "1", hint = "Face-Up Attack" });
UIHelper.registEvent(currentMSwindow, "upDef_", ES_RMSpremono, new messageSystemValue { value = "4", hint = "Face-Up Defense" });
UIHelper.registEvent(currentMSwindow, "downDef_", ES_RMSpremono, new messageSystemValue { value = "8", hint = "Face-Down Defense" });
UIHelper.registEvent(
currentMSwindow,
"upAtk_",
ES_RMSpremono,
new messageSystemValue { value = "1", hint = "Face-Up Attack" }
);
UIHelper.registEvent(
currentMSwindow,
"upDef_",
ES_RMSpremono,
new messageSystemValue { value = "4", hint = "Face-Up Defense" }
);
UIHelper.registEvent(
currentMSwindow,
"downDef_",
ES_RMSpremono,
new messageSystemValue { value = "8", hint = "Face-Down Defense" }
);
UITexture upatkpic = UIHelper.getByName<UITexture>(currentMSwindow, "upAtkPic_");
UITexture updefpic = UIHelper.getByName<UITexture>(currentMSwindow, "upDefPic_");
......@@ -751,48 +814,65 @@ public class Servant
cardPicLoader_.uiTexture = downdefpic;
}
public void RMSshow_tp(string hashCode, messageSystemValue jiandao, messageSystemValue shitou, messageSystemValue bu)
public void RMSshow_tp(
string hashCode,
messageSystemValue jiandao,
messageSystemValue shitou,
messageSystemValue bu
)
{
RMSshow_clear();
currentMShash = hashCode;
currentMStype = messageSystemType.tp;
currentMSwindow = create
(
currentMSwindow = create(
Program.I().ES_Tp,
MSentre(),
Vector3.zero,
true,
Program.ui_main_2d,
true,
new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f)
);
new Vector3(
((float)Screen.height) / 700f,
((float)Screen.height) / 700f,
((float)Screen.height) / 700f
)
);
UIHelper.InterGameObject(currentMSwindow);
UIHelper.registEvent(currentMSwindow, "jiandao_", ES_RMSpremono, jiandao);
UIHelper.registEvent(currentMSwindow, "shitou_", ES_RMSpremono, shitou);
UIHelper.registEvent(currentMSwindow, "bu_", ES_RMSpremono, bu);
}
public void RMSshow_input(string hashCode, string hint,string default_)
public void RMSshow_input(string hashCode, string hint, string default_)
{
RMSshow_clear();
currentMShash = hashCode;
currentMStype = messageSystemType.input;
currentMSwindow = create
(
currentMSwindow = create(
Program.I().ES_input,
MSentre(),
Vector3.zero,
true,
Program.ui_main_2d,
true,
new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f)
);
new Vector3(
((float)Screen.height) / 700f,
((float)Screen.height) / 700f,
((float)Screen.height) / 700f
)
);
UIHelper.InterGameObject(currentMSwindow);
UIHelper.trySetLableText(currentMSwindow, "hint_", hint);
UIHelper.registEvent(currentMSwindow, "input_", ES_RMSpremono, null, "yes_");
UIHelper.registEvent(currentMSwindow, "exit_", ES_RMSpremono, new messageSystemValue());
UIHelper.getByName<UIInput>(currentMSwindow, "input_").value = default_;
Program.go(100, () => { UIHelper.getByName<UIInput>(currentMSwindow, "input_").isSelected = true; });
Program.go(
100,
() =>
{
UIHelper.getByName<UIInput>(currentMSwindow, "input_").isSelected = true;
}
);
}
public void RMSshow_none(string hint)
......@@ -806,26 +886,31 @@ public class Servant
private GameObject currentMSwindow_Face = null;
public void RMSshow_face(string hashCode, string name)
public void RMSshow_face(string hashCode, string name)
{
RMSshow_clear();
currentMShash = hashCode;
currentMStype = messageSystemType.onlyYes;
currentMSwindow = create
(
currentMSwindow = create(
Program.I().ES_Face,
MSentre(),
Vector3.zero,
true,
Program.ui_main_2d,
true,
new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f)
);
new Vector3(
((float)Screen.height) / 700f,
((float)Screen.height) / 700f,
((float)Screen.height) / 700f
)
);
nameFace = name;
currentMSwindow_Face = currentMSwindow;
UIHelper.InterGameObject(currentMSwindow);
inputUrl = UIHelper.getByName<UIInput>(currentMSwindow, "input_");
UIHelper.getByName<UITexture>(currentMSwindow, "face_").mainTexture = UIHelper.getFace(name);
UIHelper.getByName<UITexture>(currentMSwindow, "face_").mainTexture = UIHelper.getFace(
name
);
UIHelper.registEvent(currentMSwindow, "exit_", ES_RMSpremono, new messageSystemValue());
UIHelper.registEvent(currentMSwindow, "yes_", DownloadFace);
}
......@@ -833,26 +918,53 @@ public class Servant
public void DownloadFace()
{
string url = "http://q1.qlogo.cn/headimg_dl?dst_uin=" + inputUrl.value + "&spec=100";
string face = "textures/face/" + nameFace + ".jpg";
//开始下载
HttpDldFile df = new HttpDldFile();
if (inputUrl.value.Length >= 4 && inputUrl.value.Substring(0, 4) == "http")
string facePath = "textures/face/" + nameFace + ".jpg";
// 如果输入的是一个完整的URL,则使用它
if (inputUrl.value.Length >= 4 && inputUrl.value.StartsWith("http"))
{
url = inputUrl.value;
df.Download(url, face); //使用自定义Url
}
else
{
df.Download(url, face); //使用QQ头像
}
//刷新头像
if (File.Exists(face))
{
Texture2D Face = UIHelper.getTexture2D(face);
UIHelper.faces.Remove(nameFace);//防止bug,先删除再添加
UIHelper.faces.Add(nameFace, Face);
UIHelper.getByName<UITexture>(currentMSwindow_Face, "face_").mainTexture = Face;
}
Debug.Log("开始异步下载头像: " + url);
// [核心修改] 使用我们新的、异步的 UnityFileDownloader
// 启动一个协程来执行异步下载任务
Program
.I()
.StartCoroutine(
UnityFileDownloader.DownloadFileAsync(
url,
facePath,
(success) =>
{
// 这个部分是回调函数,只会在下载完成后执行
if (success)
{
Debug.Log("头像下载成功,路径: " + facePath);
// 将原来同步执行的刷新逻辑移动到这里
// 确保文件确实存在并且已经被下载完毕
if (File.Exists(facePath))
{
Texture2D faceTexture = UIHelper.getTexture2D(facePath);
if (UIHelper.faces.ContainsKey(nameFace))
{
UIHelper.faces.Remove(nameFace); // 防止bug,先删除再添加
}
UIHelper.faces.Add(nameFace, faceTexture);
// 检查UI窗口是否还存在,防止因用户关闭窗口而报错
if (currentMSwindow_Face != null)
{
UIHelper
.getByName<UITexture>(currentMSwindow_Face, "face_")
.mainTexture = faceTexture;
}
}
}
else
{
Debug.LogError("头像下载失败: " + url);
}
}
)
);
}
#endregion
}
using UnityEngine;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using UnityEngine;
public class SelectServer : WindowServantSP
{
......@@ -26,10 +26,16 @@ public class SelectServer : WindowServantSP
UIHelper.registEvent(gameObject, "clearPsw_", onClearPsw);
serversList = UIHelper.getByName<UIPopupList>(gameObject, "server");
//serversList.fontSize = 30;
if (Application.systemLanguage == SystemLanguage.Chinese || Application.systemLanguage == SystemLanguage.ChineseSimplified || Application.systemLanguage == SystemLanguage.ChineseTraditional)
if (
Application.systemLanguage == SystemLanguage.Chinese
|| Application.systemLanguage == SystemLanguage.ChineseSimplified
|| Application.systemLanguage == SystemLanguage.ChineseTraditional
)
{
serversList.value = Config.Get("serversPicker", "[自定义]");
} else {
}
else
{
serversList.value = Config.Get("serversPicker", "[Custom]");
}
UIHelper.registEvent(gameObject, "server", pickServer);
......@@ -47,25 +53,23 @@ public class SelectServer : WindowServantSP
set_version("0x" + String.Format("{0:X}", Config.ClientVersion));
//方便免修改 [selectServerWithRoomlist.prefab]
serversList.items.Add("[OCG]Koishi");
//serversList.items.Add("[OCG]Koishi备用节点");
serversList.items.Add("[OCG]EXP");
serversList.items.Add("[OCG]MYGO");
serversList.items.Add("[OCG]233 1");
serversList.items.Add("[OCG]233 2");
serversList.items.Add("[OCG]233 约战");
serversList.items.Add("[OCG]23333 Pre");
serversList.items.Add("[AI]233 AI");
serversList.items.Add("[TCG]Koishi TCG");
serversList.items.Add("[CCG]Koishi 简中");
serversList.items.Add("[OCG]透视服");
serversList.items.Add("[OCG]自走棋");
serversList.items.Add("[轮抽服]2Pick");
serversList.items.Add("[随机卡组]决斗编年史");
serversList.items.Add("[DIY]YGOPro 222DIY");
serversList.items.Add("[AI]Doom Bots of Doom");
if (Application.systemLanguage == SystemLanguage.Chinese || Application.systemLanguage == SystemLanguage.ChineseSimplified || Application.systemLanguage == SystemLanguage.ChineseTraditional)
serversList.items.Add("[OCG]Koishi");
if (
Application.systemLanguage == SystemLanguage.Chinese
|| Application.systemLanguage == SystemLanguage.ChineseSimplified
|| Application.systemLanguage == SystemLanguage.ChineseTraditional
)
{
serversList.items.Add("[自定义]");
} else {
}
else
{
serversList.items.Add("[Custom]");
}
......@@ -77,152 +81,88 @@ public class SelectServer : WindowServantSP
string server = serversList.value;
switch (server)
{
case "[OCG]EXP":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "exp.baldlee.top";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "23333";
Config.Set("serversPicker", "[OCG]EXP");
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
case "[OCG]MYGO":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "mygo.suprepre.pro";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "888";
Config.Set("serversPicker", "[OCG]MYGO");
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
case "[OCG]Koishi":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.momobako.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "7210";
Config.Set("serversPicker", "[OCG]Koishi");
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.momobako.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "7210";
Config.Set("serversPicker", "[OCG]Koishi");
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
case "[OCG]233 1":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s1.ygo233.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "233";
Config.Set("serversPicker", "[OCG]233 1");
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s1.ygo233.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "233";
Config.Set("serversPicker", "[OCG]233 1");
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
case "[OCG]233 2":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s2.ygo233.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "233";
Config.Set("serversPicker", "[OCG]233 2");
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s2.ygo233.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "233";
Config.Set("serversPicker", "[OCG]233 2");
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
case "[OCG]233 约战":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s1.ygo233.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "2333";
Config.Set("serversPicker", "[OCG]233 约战");
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s1.ygo233.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "2333";
Config.Set("serversPicker", "[OCG]233 约战");
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
case "[OCG]23333 Pre":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s1.ygo233.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "23333";
Config.Set("serversPicker", "[OCG]23333 Pre");
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
case "[AI]233 AI":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s1.ygo233.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "9999";
Config.Set("serversPicker", "[AI]233 AI");
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
case "[TCG]Koishi TCG":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.momobako.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "1311";
Config.Set("serversPicker", "[TCG]Koishi TCG");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
}
case "[CCG]Koishi 简中":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.momobako.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "2500";
Config.Set("serversPicker", "[CCG]Koishi 简中");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
}
case "[OCG]透视服":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.momobako.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "3800";
Config.Set("serversPicker", "[OCG]透视服");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
}
case "[OCG]自走棋":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.momobako.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "3400";
Config.Set("serversPicker", "[OCG]自走棋");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
}
case "[轮抽服]2Pick":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "2pick.mycard.moe";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "765";
Config.Set("serversPicker", "[轮抽服]2Pick");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
}
case "[随机卡组]决斗编年史":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "dc.momobako.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "23331";
Config.Set("serversPicker", "[随机卡组]决斗编年史");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
}
case "[AI]Doom Bots of Doom":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.momobako.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "573";
Config.Set("serversPicker", "[AI]Doom Bots of Doom");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
}
case "[DIY]YGOPro 222DIY":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "222diy.momobako.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "222";
Config.Set("serversPicker", "[DIY]YGOPro 222DIY");
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s1.ygo233.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "23333";
Config.Set("serversPicker", "[OCG]23333 Pre");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
}
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
default:
{
if (Application.systemLanguage == SystemLanguage.Chinese || Application.systemLanguage == SystemLanguage.ChineseSimplified || Application.systemLanguage == SystemLanguage.ChineseTraditional)
if (
Application.systemLanguage == SystemLanguage.Chinese
|| Application.systemLanguage == SystemLanguage.ChineseSimplified
|| Application.systemLanguage == SystemLanguage.ChineseTraditional
)
{
Config.Set("serversPicker", "[自定义]");
} else {
}
else
{
Config.Set("serversPicker", "[Custom]");
}
......@@ -231,7 +171,6 @@ public class SelectServer : WindowServantSP
break;
}
}
}
void onSelected()
......@@ -244,46 +183,46 @@ public class SelectServer : WindowServantSP
private void readString(string str)
{
/*
str = str.Substring(1, str.Length - 1);
string version = "", remain = "";
string[] splited;
splited = str.Split(")");
try
{
version = splited[0];
remain = splited[1];
}
catch (Exception)
{
}
splited = remain.Split(":");
string ip = "";
try
{
ip = splited[0];
remain = splited[1];
}
catch (Exception)
{
}
splited = remain.Split(" ");
string psw = "", port = "";
try
{
port = splited[0];
psw = splited[1];
}
catch (Exception)
{
}
if (EditIpAndPort)
{
inputIP.value = ip;
inputPort.value = port;
}
inputPsw.value = psw;
*/
/*
str = str.Substring(1, str.Length - 1);
string version = "", remain = "";
string[] splited;
splited = str.Split(")");
try
{
version = splited[0];
remain = splited[1];
}
catch (Exception)
{
}
splited = remain.Split(":");
string ip = "";
try
{
ip = splited[0];
remain = splited[1];
}
catch (Exception)
{
}
splited = remain.Split(" ");
string psw = "", port = "";
try
{
port = splited[0];
psw = splited[1];
}
catch (Exception)
{
}
if (EditIpAndPort)
{
inputIP.value = ip;
inputPort.value = port;
}
inputPsw.value = psw;
*/
//确保密码为空时,退出后密码依旧保持为空
str = str.Substring(5, str.Length - 5);
inputPsw.value = str;
......@@ -296,9 +235,13 @@ public class SelectServer : WindowServantSP
string[] lines = PswString.Replace("\r", "").Split("\n");
for (int i = 0; i < lines.Length; i++)
{
list.RemoveItem(lines[i]);//清空list
list.RemoveItem(lines[i]); //清空list
}
FileStream stream = new FileStream("config/passwords.conf", FileMode.Truncate, FileAccess.ReadWrite);//清空文件内容
FileStream stream = new FileStream(
"config/passwords.conf",
FileMode.Truncate,
FileAccess.ReadWrite
); //清空文件内容
stream.Close();
inputPsw.value = "";
Program.PrintToChat(InterString.Get("房间密码已清空"));
......@@ -390,7 +333,13 @@ public class SelectServer : WindowServantSP
gameObject.SetActive(!Bool);
}
public void KF_onlineGame(string Name, string ipString, string portString, string versionString, string pswString = "")
public void KF_onlineGame(
string Name,
string ipString,
string portString,
string versionString,
string pswString = ""
)
{
name = Name;
Config.Set("name", name);
......@@ -418,8 +367,13 @@ public class SelectServer : WindowServantSP
}
File.WriteAllText("config/passwords.conf", all);
printFile(false);
Program.I().mycard.isMatching = false;
(new Thread(() => { TcpHelper.join(ipString, name, portString, pswString, versionString); })).Start();
Program.I().mycard.isMatching = false;
(
new Thread(() =>
{
TcpHelper.join(ipString, name, portString, pswString, versionString);
})
).Start();
}
else
{
......@@ -438,5 +392,4 @@ public class SelectServer : WindowServantSP
RMSshow_face("showFace", name);
Config.Set("name", name);
}
}
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Data;
using Mono.Data.Sqlite;
using System;
using System.IO;
using System.Text.RegularExpressions;
using Mono.Data.Sqlite;
using YGOSharp.OCGWrapper.Enums;
namespace YGOSharp
......@@ -16,12 +16,18 @@ namespace YGOSharp
public static string nullString = "";
internal static bool initialize(string databaseFullPath, bool test = false, bool replace = false)
internal static bool initialize(
string databaseFullPath,
bool test = false,
bool replace = false
)
{
if(!test) {
if (!test)
{
nullName = InterString.Get("未知卡片");
nullString = "";
nullString += "欢迎使用 KoishiPro2 iOS,本软件免责声明:[url=https://koishi.pro/koishipro2ios-note/][u]https://koishi.pro/koishipro2ios-note/[/u][/url]";
nullString +=
"欢迎使用 KoishiPro2 iOS,本软件免责声明:[url=https://koishi.pro/koishipro2ios-note/][u]https://koishi.pro/koishipro2ios-note/[/u][/url]";
nullString += "\r\n\r\n";
nullString += "KoishiPro2 iOS的用户QQ群627975038,游戏中遇到任何bug欢迎提交";
nullString += "\r\n\r\n";
......@@ -30,12 +36,22 @@ namespace YGOSharp
nullString += "喜欢游戏王DIY的朋友欢迎来222服QQ群642043095";
}
bool success = true;
try {
using (SqliteConnection connection = new SqliteConnection("Data Source=" + databaseFullPath))
try
{
using (
SqliteConnection connection = new SqliteConnection(
"Data Source=" + databaseFullPath
)
)
{
connection.Open();
using (IDbCommand command = new SqliteCommand("SELECT datas.*, texts.* FROM datas,texts WHERE datas.id=texts.id;", connection))
using (
IDbCommand command = new SqliteCommand(
"SELECT datas.*, texts.* FROM datas,texts WHERE datas.id=texts.id;",
connection
)
)
{
using (IDataReader reader = command.ExecuteReader())
{
......@@ -47,7 +63,8 @@ namespace YGOSharp
}
}
}
catch (System.Exception e) {
catch (System.Exception e)
{
success = false;
}
return success;
......@@ -98,7 +115,7 @@ namespace YGOSharp
if (!_cards.ContainsKey(card.Id))
{
_cards.Add(card.Id, card);
}
}
else if (replace)
{
_cards.Remove(card.Id);
......@@ -136,7 +153,7 @@ namespace YGOSharp
uint getRaceFilter,
uint getAttributeFilter,
uint getCatagoryFilter
)
)
{
List<Card> returnValue = new List<Card>();
foreach (var item in _cards)
......@@ -144,23 +161,44 @@ namespace YGOSharp
Card card = item.Value;
if ((card.Type & (uint)CardType.Token) == 0)
{
if (getName == ""
|| Regex.Replace(card.Name, getName,"miaowu", RegexOptions.IgnoreCase) != card.Name
|| Regex.Replace(card.Desc, getName, "miaowu", RegexOptions.IgnoreCase) != card.Desc
|| Regex.Replace(card.strSetName, getName, "miaowu", RegexOptions.IgnoreCase) != card.strSetName
if (
getName == ""
|| Regex.Replace(card.Name, getName, "miaowu", RegexOptions.IgnoreCase)
!= card.Name
|| Regex.Replace(card.Desc, getName, "miaowu", RegexOptions.IgnoreCase)
!= card.Desc
|| Regex.Replace(
card.strSetName,
getName,
"miaowu",
RegexOptions.IgnoreCase
) != card.strSetName
|| card.Id.ToString() == getName
)
)
{
if (((card.Type & getTypeFilter) == getTypeFilter || getTypeFilter == 0)
&& ((card.Type == getTypeFilter2
|| getTypeFilter == (UInt32)CardType.Monster) && (card.Type & getTypeFilter2) == getTypeFilter2
|| getTypeFilter2 == 0))
if (
((card.Type & getTypeFilter) == getTypeFilter || getTypeFilter == 0)
&& (
(
card.Type == getTypeFilter2
|| getTypeFilter == (UInt32)CardType.Monster
)
&& (card.Type & getTypeFilter2) == getTypeFilter2
|| getTypeFilter2 == 0
)
)
{
if ((card.Race & getRaceFilter) > 0 || getRaceFilter == 0)
{
if ((card.Attribute & getAttributeFilter) > 0 || getAttributeFilter == 0)
if (
(card.Attribute & getAttributeFilter) > 0
|| getAttributeFilter == 0
)
{
if (((card.Category & getCatagoryFilter))== getCatagoryFilter || getCatagoryFilter == 0)
if (
((card.Category & getCatagoryFilter)) == getCatagoryFilter
|| getCatagoryFilter == 0
)
{
if (judgeint(getAttack, getAttack_UP, card.Attack))
{
......@@ -170,13 +208,27 @@ namespace YGOSharp
{
if (judgeint(getP, getP_UP, card.LScale))
{
if (judgeint(getYear, getYear_UP, card.year))
if (
judgeint(getYear, getYear_UP, card.year)
)
{
if (getBAN == -233 || banlist == null || banlist.GetQuantity(card.Id) == getBAN)
if (
getBAN == -233
|| banlist == null
|| banlist.GetQuantity(card.Id)
== getBAN
)
{
if (getOT == -233 || (getOT & card.Ot) == getOT)
if (
getOT == -233
|| (getOT & card.Ot) == getOT
)
{
if (getPack == "" || card.packFullName == getPack)
if (
getPack == ""
|| card.packFullName
== getPack
)
{
returnValue.Add(card);
}
......@@ -224,23 +276,23 @@ namespace YGOSharp
return re;
}
internal static List<Card> search(
string getName,
List<int> getsearchCode
)
internal static List<Card> search(string getName, List<int> getsearchCode)
{
List<Card> returnValue = new List<Card>();
foreach (var item in _cards)
{
Card card = item.Value;
if (getName == ""
|| Regex.Replace(card.Name, getName, "miaowu", RegexOptions.IgnoreCase) != card.Name
//|| Regex.Replace(card.Desc, getName, "miaowu", RegexOptions.IgnoreCase) != card.Desc
|| Regex.Replace(card.strSetName, getName, "miaowu", RegexOptions.IgnoreCase) != card.strSetName
|| card.Id.ToString() == getName
)
if (
getName == ""
|| Regex.Replace(card.Name, getName, "miaowu", RegexOptions.IgnoreCase)
!= card.Name
//|| Regex.Replace(card.Desc, getName, "miaowu", RegexOptions.IgnoreCase) != card.Desc
|| Regex.Replace(card.strSetName, getName, "miaowu", RegexOptions.IgnoreCase)
!= card.strSetName
|| card.Id.ToString() == getName
)
{
if (getsearchCode.Count == 0|| is_declarable(card, getsearchCode))
if (getsearchCode.Count == 0 || is_declarable(card, getsearchCode))
{
returnValue.Add(card);
}
......@@ -421,14 +473,13 @@ namespace YGOSharp
}
if (stack.Count != 1 || stack.Pop() == 0)
return false;
return
card.Id == (int)TwoNameCards.CARD_MARINE_DOLPHIN
||
card.Id == (int)TwoNameCards.CARD_TWINKLE_MOSS
||
(!(card.Alias != 0)
&& ((card.Type & ((int)CardType.Monster + (int)CardType.Token)))
!= ((int)CardType.Monster + (int)CardType.Token));
return card.Id == (int)TwoNameCards.CARD_MARINE_DOLPHIN
|| card.Id == (int)TwoNameCards.CARD_TWINKLE_MOSS
|| (
!(card.Alias != 0)
&& ((card.Type & ((int)CardType.Monster + (int)CardType.Token)))
!= ((int)CardType.Monster + (int)CardType.Token)
);
}
public static bool IfSetCard(int setCodeToAnalyse, long setCodeFromCard)
......@@ -551,14 +602,13 @@ namespace YGOSharp
return a;
};
}
}
internal static class PacksManager
{
public class packName
{
public string fullName;
public string fullName;
public string shortName;
public int year;
public int month;
......@@ -571,10 +621,16 @@ namespace YGOSharp
internal static void initialize(string databaseFullPath)
{
using (SqliteConnection connection = new SqliteConnection("Data Source=" + databaseFullPath))
using (
SqliteConnection connection = new SqliteConnection(
"Data Source=" + databaseFullPath
)
)
{
connection.Open();
using (IDbCommand command = new SqliteCommand("SELECT pack.* FROM pack;", connection))
using (
IDbCommand command = new SqliteCommand("SELECT pack.* FROM pack;", connection)
)
{
using (IDataReader reader = command.ExecuteReader())
{
......@@ -592,7 +648,10 @@ namespace YGOSharp
if (mats.Length > 1)
c.packShortNam = mats[0];
else
c.packShortNam = c.packFullName.Length > 10 ? c.packFullName.Substring(0, 10) + "..." : c.packFullName;
c.packShortNam =
c.packFullName.Length > 10
? c.packFullName.Substring(0, 10) + "..."
: c.packFullName;
c.reality = reader.GetString(3);
temp = reader.GetString(4);
mats = temp.Split("/");
......@@ -609,8 +668,15 @@ namespace YGOSharp
c.month = int.Parse(mats[1]);
c.day = int.Parse(mats[2]);
}
c.packFullName = c.year + "-" + c.month.ToString().PadLeft(2, '0') + "-" + c.day.ToString().PadLeft(2, '0') + " " + c.packShortNam;
if (!pacDic.ContainsKey(c.packFullName))
c.packFullName =
c.year
+ "-"
+ c.month.ToString().PadLeft(2, '0')
+ "-"
+ c.day.ToString().PadLeft(2, '0')
+ " "
+ c.packShortNam;
if (!pacDic.ContainsKey(c.packFullName))
{
pacDic.Add(c.packFullName, c.packShortNam);
packName p = new packName();
......@@ -623,10 +689,7 @@ namespace YGOSharp
}
}
}
catch (Exception)
{
}
catch (Exception) { }
}
}
}
......@@ -635,34 +698,36 @@ namespace YGOSharp
internal static void initializeSec()
{
packs.Sort((left, right) => {
if (left.year > right.year)
{
return -1;
}
if (left.year < right.year)
{
return 1;
}
if (left.month > right.month)
{
return -1;
}
if (left.month < right.month)
{
return 1;
}
if (left.day > right.day)
{
return -1;
}
if (left.day < right.day)
packs.Sort(
(left, right) =>
{
if (left.year > right.year)
{
return -1;
}
if (left.year < right.year)
{
return 1;
}
if (left.month > right.month)
{
return -1;
}
if (left.month < right.month)
{
return 1;
}
if (left.day > right.day)
{
return -1;
}
if (left.day < right.day)
{
return 1;
}
return 1;
}
return 1;
});
);
}
}
}
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