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;
using System.Collections; using UnityEngine;
using System;
public class MonoCardInDeckManager : MonoBehaviour { public class MonoCardInDeckManager : MonoBehaviour
{
int loadedPicCode = 0; int loadedPicCode = 0;
YGOSharp.Banlist loaded_banlist = null; YGOSharp.Banlist loaded_banlist = null;
public bool dying = false; public bool dying = false;
bool died = 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) 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) if (pic != null)
{ {
loadedPicCode = cardData.Id; 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) if (Program.I().deckManager.currentBanlist != loaded_banlist)
{ {
ban_icon ico = GetComponentInChildren<ban_icon>(); ban_icon ico = GetComponentInChildren<ban_icon>();
loaded_banlist = Program.I().deckManager.currentBanlist; loaded_banlist = Program.I().deckManager.currentBanlist;
if (loaded_banlist != null) ico.show(loaded_banlist != null ? loaded_banlist.GetQuantity(cardData.Id) : 3);
{ }
ico.show(loaded_banlist.GetQuantity(cardData.Id));
} if (stopDragThisFrame)
else {
{ isDraging = false;
ico.show(3); stopDragThisFrame = false;
}
} }
if (isDraging) 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) if (Vector3.Distance(Vector3.zero, gameObject.transform.position) > 50 && bool_physicalON)
{ {
killIt(); killIt();
...@@ -49,15 +56,13 @@ public class MonoCardInDeckManager : MonoBehaviour { ...@@ -49,15 +56,13 @@ public class MonoCardInDeckManager : MonoBehaviour {
{ {
gameObject.transform.position = new Vector3(0, 5, 0); gameObject.transform.position = new Vector3(0, 5, 0);
endDrag(); endDrag();
if (Program.I().deckManager.cardInDragging==this) if (Program.I().deckManager.cardInDragging == this)
{ {
Program.I().deckManager.cardInDragging = null; Program.I().deckManager.cardInDragging = null;
} }
Rigidbody rigidbody = GetComponent<Rigidbody>(); Rigidbody rigidbody = GetComponent<Rigidbody>();
if (rigidbody == null) if (rigidbody == null)
{
rigidbody = gameObject.AddComponent<Rigidbody>(); rigidbody = gameObject.AddComponent<Rigidbody>();
}
rigidbody.Sleep(); rigidbody.Sleep();
} }
else else
...@@ -74,62 +79,99 @@ public class MonoCardInDeckManager : MonoBehaviour { ...@@ -74,62 +79,99 @@ public class MonoCardInDeckManager : MonoBehaviour {
float y = Input.mousePosition.y; float y = Input.mousePosition.y;
Vector3 to_ltemp = Program.camera_game_main.ScreenToWorldPoint(new Vector3(x, y, 1)); Vector3 to_ltemp = Program.camera_game_main.ScreenToWorldPoint(new Vector3(x, y, 1));
Vector3 dv = to_ltemp - Program.camera_game_main.transform.position; Vector3 dv = to_ltemp - Program.camera_game_main.transform.position;
if (dv.y == 0) dv.y = 0.01f; if (dv.y == 0)
to_ltemp.x = ((height - Program.camera_game_main.transform.position.y) dv.y = 0.01f;
* (dv.x) / dv.y + Program.camera_game_main.transform.position.x); to_ltemp.x = (
to_ltemp.y = ((height - Program.camera_game_main.transform.position.y) (height - Program.camera_game_main.transform.position.y) * (dv.x) / dv.y
* (dv.y) / dv.y + Program.camera_game_main.transform.position.y); + Program.camera_game_main.transform.position.x
to_ltemp.z = ((height - Program.camera_game_main.transform.position.y) );
* (dv.z) / dv.y + Program.camera_game_main.transform.position.z); 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; return to_ltemp;
} }
bool isDraging = false;
public void beginDrag() public void beginDrag()
{ {
physicalOFF(); physicalOFF();
physicalHalfON(); physicalHalfON();
isDraging = true; 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() public void endDrag()
{ {
physicalON(); physicalON();
isDraging = false; stopDragThisFrame = true;
if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl) || getIfAlive() == false)
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 to_position = getGoodPosition(0);
Vector3 delta_position = to_position - form_position; Vector3 delta_position = to_position - from_position;
GetComponent<Rigidbody>().AddForce(delta_position * 1000); GetComponent<Rigidbody>().AddForce(delta_position * 1000);
dying = true; 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>(); Rigidbody rigidbody = GetComponent<Rigidbody>();
if (rigidbody != null) if (rigidbody != null)
{ {
rigidbody.Sleep(); rigidbody.Sleep();
rigidbody.isKinematic = true; // fix for Unity 2017
} }
iTween.MoveTo(gameObject, iTween.Hash(
"delay", delay, iTween.MoveTo(
"x", position.x, gameObject,
"y", position.y, iTween.Hash(
"z", position.z, "delay",
"time", 0.2f, delay,
"oncomplete", (Action)physicalON "x",
)); position.x,
iTween.RotateTo(gameObject, iTween.Hash( "y",
"delay", delay, position.y,
"x", rotation.x, "z",
"y", rotation.y, position.z,
"z", rotation.z, "time",
"time", 0.15f 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(); physicalOFF();
} }
...@@ -141,9 +183,8 @@ public class MonoCardInDeckManager : MonoBehaviour { ...@@ -141,9 +183,8 @@ public class MonoCardInDeckManager : MonoBehaviour {
GetComponent<BoxCollider>().enabled = true; GetComponent<BoxCollider>().enabled = true;
Rigidbody rigidbody = GetComponent<Rigidbody>(); Rigidbody rigidbody = GetComponent<Rigidbody>();
if (rigidbody == null) if (rigidbody == null)
{
rigidbody = gameObject.AddComponent<Rigidbody>(); rigidbody = gameObject.AddComponent<Rigidbody>();
} rigidbody.isKinematic = false;
rigidbody.Sleep(); rigidbody.Sleep();
rigidbody.useGravity = true; rigidbody.useGravity = true;
rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
...@@ -155,10 +196,9 @@ public class MonoCardInDeckManager : MonoBehaviour { ...@@ -155,10 +196,9 @@ public class MonoCardInDeckManager : MonoBehaviour {
GetComponent<BoxCollider>().enabled = true; GetComponent<BoxCollider>().enabled = true;
Rigidbody rigidbody = GetComponent<Rigidbody>(); Rigidbody rigidbody = GetComponent<Rigidbody>();
if (rigidbody == null) if (rigidbody == null)
{
rigidbody = gameObject.AddComponent<Rigidbody>(); rigidbody = gameObject.AddComponent<Rigidbody>();
}
rigidbody.useGravity = false; rigidbody.useGravity = false;
rigidbody.isKinematic = false;
rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
} }
...@@ -168,44 +208,37 @@ public class MonoCardInDeckManager : MonoBehaviour { ...@@ -168,44 +208,37 @@ public class MonoCardInDeckManager : MonoBehaviour {
GetComponent<BoxCollider>().enabled = false; GetComponent<BoxCollider>().enabled = false;
Rigidbody rigidbody = GetComponent<Rigidbody>(); Rigidbody rigidbody = GetComponent<Rigidbody>();
if (rigidbody != null) if (rigidbody != null)
{
rigidbody.useGravity = false; rigidbody.useGravity = false;
}
} }
public bool getIfAlive() public bool getIfAlive()
{ {
bool ret = true; if (died || gameObject.transform.position.y < -0.5f)
if (died == true) return false;
{
ret = false;
}
if (gameObject.transform.position.y < -0.5f)
{
ret = false;
}
Vector3 to_ltemp = refLectPosition(gameObject.transform.position); Vector3 to_ltemp = refLectPosition(gameObject.transform.position);
if (to_ltemp.x < -15.2f) ret = false; if (to_ltemp.x < -15.2f || to_ltemp.x > 15.2f)
if (to_ltemp.x > 15.2f) ret = false; return false;
return Program.I().deckManager.condition == DeckManager.Condition.changeSide || true;
if (Program.I().deckManager.condition == DeckManager.Condition.changeSide)
{
ret = true;
}
return ret;
} }
public static Vector3 refLectPosition(Vector3 pos) public static Vector3 refLectPosition(Vector3 pos)
{ {
Vector3 to_ltemp = pos; Vector3 to_ltemp = pos;
Vector3 dv = to_ltemp - Program.camera_game_main.transform.position; Vector3 dv = to_ltemp - Program.camera_game_main.transform.position;
if (dv.y == 0) dv.y = 0.01f; if (dv.y == 0)
to_ltemp.x = ((0 - Program.camera_game_main.transform.position.y) dv.y = 0.01f;
* (dv.x) / dv.y + Program.camera_game_main.transform.position.x); to_ltemp.x = (
to_ltemp.y = ((0 - Program.camera_game_main.transform.position.y) (0 - Program.camera_game_main.transform.position.y) * (dv.x) / dv.y
* (dv.y) / dv.y + Program.camera_game_main.transform.position.y); + Program.camera_game_main.transform.position.x
to_ltemp.z = ((0 - Program.camera_game_main.transform.position.y) );
* (dv.z) / dv.y + Program.camera_game_main.transform.position.z); 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; return to_ltemp;
} }
} }
using UnityEngine; using System.Collections;
using System.Collections; using UnityEngine;
public class cardPicLoader : MonoBehaviour public class cardPicLoader : MonoBehaviour
{ {
public int loaded_code = -1; public int loaded_code = -1;
public int code = 0; public int code = 0;
...@@ -45,7 +44,12 @@ public class cardPicLoader : MonoBehaviour ...@@ -45,7 +44,12 @@ public class cardPicLoader : MonoBehaviour
{ {
if (Program.pointedCollider == coli) 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 card;
public UITexture back; public UITexture back;
// Use this for initialization
void Start()
{
} // Use this for initialization
void Start() { }
// Update is called once per frame // Update is called once per frame
void Update () { void Update()
{
if (back.width < card.width) if (back.width < card.width)
{ {
back.width = card.width + 2; back.width = card.width + 2;
} }
back.transform.localPosition = new Vector3(back.width / 2f, 0); 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); Vector3 leftTop = new Vector3(
card.transform.localPosition = new Vector3(leftTop.x + card.width / 2, leftTop.y - card.height / 2); -back.width / 2 + 2 + back.transform.localPosition.x,
Program.I().cardDescription.width = back.width-2; +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; Program.I().cardDescription.cHeight = card.height;
} }
} }
...@@ -301,11 +301,11 @@ Camera: ...@@ -301,11 +301,11 @@ Camera:
m_TargetEye: 3 m_TargetEye: 3
m_HDR: 0 m_HDR: 0
m_AllowMSAA: 1 m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0 m_ForceIntoRT: 0
m_OcclusionCulling: 1 m_OcclusionCulling: 1
m_StereoConvergence: 10 m_StereoConvergence: 10
m_StereoSeparation: 0.022 m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!26 &2655262 --- !u!26 &2655262
ParticleRenderer: ParticleRenderer:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
...@@ -315,6 +315,7 @@ ParticleRenderer: ...@@ -315,6 +315,7 @@ ParticleRenderer:
m_Enabled: 1 m_Enabled: 1
m_CastShadows: 0 m_CastShadows: 0
m_ReceiveShadows: 0 m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1 m_MotionVectors: 1
m_LightProbeUsage: 1 m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1 m_ReflectionProbeUsage: 1
...@@ -330,6 +331,7 @@ ParticleRenderer: ...@@ -330,6 +331,7 @@ ParticleRenderer:
m_PreserveUVs: 0 m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0 m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0 m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3 m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4 m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5 m_AutoUVMaxDistance: 0.5
...@@ -357,6 +359,7 @@ ParticleRenderer: ...@@ -357,6 +359,7 @@ ParticleRenderer:
m_Enabled: 1 m_Enabled: 1
m_CastShadows: 0 m_CastShadows: 0
m_ReceiveShadows: 0 m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1 m_MotionVectors: 1
m_LightProbeUsage: 1 m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1 m_ReflectionProbeUsage: 1
...@@ -372,6 +375,7 @@ ParticleRenderer: ...@@ -372,6 +375,7 @@ ParticleRenderer:
m_PreserveUVs: 0 m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0 m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0 m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3 m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4 m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5 m_AutoUVMaxDistance: 0.5
...@@ -503,8 +507,6 @@ MonoBehaviour: ...@@ -503,8 +507,6 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
camera: {fileID: 2091536} camera: {fileID: 2091536}
e1: {fileID: 1598580}
e2: {fileID: 1537834}
trans: {fileID: 497540} trans: {fileID: 497540}
--- !u!114 &11491940 --- !u!114 &11491940
MonoBehaviour: MonoBehaviour:
......
using UnityEngine; using System.Collections;
using System.Collections; using UnityEngine;
public class mouseParticle : MonoBehaviour { public class mouseParticle : MonoBehaviour
{
public Camera camera; public Camera camera;
public EllipsoidParticleEmitter e1;
public EllipsoidParticleEmitter e2;
public Transform trans; public Transform trans;
// Use this for initialization // Use this for initialization
void Start () { void Start()
{
camera.depth = 99999; camera.depth = 99999;
} }
float time = 0; float time = 0;
// Update is called once per frame
void Update () { // Update is called once per frame
void Update()
{
Vector3 screenPoint = Input.mousePosition; Vector3 screenPoint = Input.mousePosition;
screenPoint.z = 10; screenPoint.z = 10;
trans.position = camera.ScreenToWorldPoint(screenPoint); trans.position = camera.ScreenToWorldPoint(screenPoint);
if (Input.GetMouseButton(0)) if (Input.GetMouseButton(0))
{ {
if (Input.GetMouseButtonDown(0)) if (Input.GetMouseButtonDown(0))
{ {
...@@ -28,17 +33,9 @@ public class mouseParticle : MonoBehaviour { ...@@ -28,17 +33,9 @@ public class mouseParticle : MonoBehaviour {
{ {
time = 0.49f; 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 else
{ {
e1.emit = false;
e2.emit = false;
} }
} }
} }
using UnityEngine; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System;
using System.Linq; using System.Linq;
using System.Threading;
using ICSharpCode.SharpZipLib.Core; using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.SharpZipLib.Zip;
using System.Threading; using UnityEngine;
public class Program : MonoBehaviour public class Program : MonoBehaviour
{ {
#region Resources #region Resources
public Camera main_camera; public Camera main_camera;
public facer face; public facer face;
...@@ -175,7 +175,6 @@ public class Program : MonoBehaviour ...@@ -175,7 +175,6 @@ public class Program : MonoBehaviour
void loadResources() void loadResources()
{ {
loadResource(mod_audio_effect); loadResource(mod_audio_effect);
loadResource(mod_ocgcore_card); loadResource(mod_ocgcore_card);
loadResource(mod_ocgcore_card_cloude); loadResource(mod_ocgcore_card_cloude);
...@@ -207,7 +206,6 @@ public class Program : MonoBehaviour ...@@ -207,7 +206,6 @@ public class Program : MonoBehaviour
loadResource(mod_ocgcore_blood); loadResource(mod_ocgcore_blood);
loadResource(mod_ocgcore_blood_screen); loadResource(mod_ocgcore_blood_screen);
loadResource(mod_ocgcore_bs_atk_decoration); loadResource(mod_ocgcore_bs_atk_decoration);
loadResource(mod_ocgcore_bs_atk_line_earth); loadResource(mod_ocgcore_bs_atk_line_earth);
loadResource(mod_ocgcore_bs_atk_line_water); loadResource(mod_ocgcore_bs_atk_line_water);
...@@ -278,8 +276,7 @@ public class Program : MonoBehaviour ...@@ -278,8 +276,7 @@ public class Program : MonoBehaviour
public static float verticleScale = 5f; public static float verticleScale = 5f;
//YGOPro2 Path (https://github.com/Unicorn369/YGOPro2_Droid/tree/Test) //Multi-language support //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 #if UNITY_EDITOR || UNITY_STANDALONE_WIN //编译器、Windows
public static bool ANDROID_API_N = true; public static bool ANDROID_API_N = true;
#elif UNITY_ANDROID || UNITY_IPHONE //Mobile Platform #elif UNITY_ANDROID || UNITY_IPHONE //Mobile Platform
...@@ -291,10 +288,9 @@ public class Program : MonoBehaviour ...@@ -291,10 +288,9 @@ public class Program : MonoBehaviour
#if !UNITY_EDITOR && UNITY_ANDROID #if !UNITY_EDITOR && UNITY_ANDROID
AndroidJavaObject jo = new AndroidJavaObject("cn.unicorn369.library.API"); AndroidJavaObject jo = new AndroidJavaObject("cn.unicorn369.library.API");
#endif #endif
#if UNITY_EDITOR || UNITY_STANDALONE_WIN //编译器、Windows #if UNITY_EDITOR || UNITY_STANDALONE_WIN //编译器、Windows
//Environment.CurrentDirectory = System.Windows.Forms.Application.StartupPath; // // Environment.CurrentDirectory = System.Windows.Forms.Application.StartupPath;
//System.IO.Directory.SetCurrentDirectory(System.Windows.Forms.Application.StartupPath); // System.IO.Directory.SetCurrentDirectory(System.Windows.Forms.Application.StartupPath);
#elif UNITY_ANDROID //Android #elif UNITY_ANDROID //Android
/** /**
* public String GamePath(String path) { * public String GamePath(String path) {
...@@ -314,8 +310,11 @@ public class Program : MonoBehaviour ...@@ -314,8 +310,11 @@ public class Program : MonoBehaviour
//File.Create(ANDROID_GAME_PATH + ".nomedia"); //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") if (
|| !File.Exists(ANDROID_GAME_PATH + "textures/ui/bg_of_right_card_searcher2.png")) !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"; string filePath = Application.streamingAssetsPath + "/ui.zip";
var www = new WWW(filePath); var www = new WWW(filePath);
...@@ -323,17 +322,17 @@ public class Program : MonoBehaviour ...@@ -323,17 +322,17 @@ public class Program : MonoBehaviour
byte[] bytes = www.bytes; byte[] bytes = www.bytes;
ExtractZipFile(bytes, ANDROID_GAME_PATH); ExtractZipFile(bytes, ANDROID_GAME_PATH);
} }
/* //选择性更新(用于额外打补丁) /* //选择性更新(用于额外打补丁)
if (!File.Exists(ANDROID_GAME_PATH + "updates/ver_1.034.9-fix1.txt")) if (!File.Exists(ANDROID_GAME_PATH + "updates/ver_1.034.9-fix1.txt"))
{ {
string filePath = Application.streamingAssetsPath + "/update.zip"; string filePath = Application.streamingAssetsPath + "/update.zip";
var www = new WWW(filePath); var www = new WWW(filePath);
while (!www.isDone) { } while (!www.isDone) { }
byte[] bytes = www.bytes; byte[] bytes = www.bytes;
ExtractZipFile(bytes, ANDROID_GAME_PATH); ExtractZipFile(bytes, ANDROID_GAME_PATH);
//File.Create(ANDROID_GAME_PATH + ".nomedia"); //File.Create(ANDROID_GAME_PATH + ".nomedia");
} }
*/ */
Environment.CurrentDirectory = ANDROID_GAME_PATH; Environment.CurrentDirectory = ANDROID_GAME_PATH;
System.IO.Directory.SetCurrentDirectory(ANDROID_GAME_PATH); System.IO.Directory.SetCurrentDirectory(ANDROID_GAME_PATH);
...@@ -347,135 +346,123 @@ public class Program : MonoBehaviour ...@@ -347,135 +346,123 @@ public class Program : MonoBehaviour
Environment.CurrentDirectory = GamePaths; Environment.CurrentDirectory = GamePaths;
System.IO.Directory.SetCurrentDirectory(GamePaths); System.IO.Directory.SetCurrentDirectory(GamePaths);
#endif #endif
go(1, () => 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"))
{ {
lflist_ok = YGOSharp.BanlistManager.initialize("lflist.conf"); UIHelper.iniFaces();
initializeALLcameras();
fixALLcamerasPreFrame();
backGroundPic = new BackGroundPic();
servants.Add(backGroundPic);
backGroundPic.fixScreenProblem();
} }
);
YGOSharp.BanlistManager.initializeComplete(); go(
10,
if (File.Exists("expansions/strings.conf")) () =>
{ {
GameStringManager.initialize("expansions/strings.conf"); InterString.initialize("config/translation.conf");
} // 显示一个简单的加载提示
PrintToChat(InterString.Get("正在加载本地数据..."));
if (Directory.Exists("expansions")) GameTextureManager.initialize();
{ Config.initialize("config/config.conf");
FileInfo[] fileInfos = (new DirectoryInfo("expansions")).GetFiles().OrderByDescending(x => x.Name).ToArray();
for (int i = 0; i < fileInfos.Length; i++) // [新增] 封装文件加载逻辑,避免重复检查
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(fileInfo.FullName, false, true);
{
YGOSharp.CardsManager.initialize("expansions/" + fileInfos[i].Name, false, true);
}
} }
} }
} YGOSharp.CardsManager.updateSetNames();
YGOSharp.CardsManager.updateSetNames(); // 加载卡包
if (Directory.Exists("pack"))
if (Directory.Exists("pack"))
{
FileInfo[] fileInfos = (new DirectoryInfo("pack")).GetFiles();
for (int i = 0; i < fileInfos.Length; i++)
{ {
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(fileInfo.FullName);
{
YGOSharp.PacksManager.initialize("pack/" + fileInfos[i].Name);
}
} }
YGOSharp.PacksManager.initializeSec();
} }
YGOSharp.PacksManager.initializeSec(); initializeALLservants();
} loadResources();
initializeALLservants();
if(UIHelper.fromStringToBool(Config.Get("*AutoPicDownload", "1")))
(new Thread(()=>{UpdateClient();})).Start();
loadResources();
#if !UNITY_EDITOR && UNITY_ANDROID //Android Java Test #if !UNITY_EDITOR && UNITY_ANDROID //Android Java Test
if (!File.Exists("updates/image_0.1.txt"))//用于检查更新 if (!File.Exists("updates/image_0.1.txt")) //用于检查更新
{ {
if (File.Exists("pics.zip")) { 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); jo.Call("doExtractZipFile", "pics.zip", ANDROID_GAME_PATH);
} else { File.Copy("updates/ver_1.034.9.txt", "updates/image_0.1.txt", true);
jo.Call("doDownloadZipFile", "https://github.com/Unicorn369/closeup_mobile/releases/download/0.1/pics.zip"); }
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) * 使用Termux编译生成的:libgdiplus.so (https://github.com/Unicorn369/libgdiplus-Android)
* 经测试,只有Android 6.0以上才能正常使用。为了让Android 6.0以下的也能凑合使用立绘效果,需做判断 * 经测试,只有Android 6.0以上才能正常使用。为了让Android 6.0以下的也能凑合使用立绘效果,需做判断
* 由于部分国产手机系统不够原生,就算是Android 6.0也用不起,只好抛弃能正常使用的手机,改为只支持:Android 7.+ * 由于部分国产手机系统不够原生,就算是Android 6.0也用不起,只好抛弃能正常使用的手机,改为只支持:Android 7.+
* *
* public boolean APIVersion() { * public boolean APIVersion() {
* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { * if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
* return true; * return true;
* } else { * } else {
* return false; * return false;
* } * }
* } * }
*/ */
bool API_SUPPORT = jo.Call<bool>("APIVersion"); bool API_SUPPORT = jo.Call<bool>("APIVersion");
if (API_SUPPORT == true) { if (API_SUPPORT == true)
ANDROID_API_N = true; {
} else { ANDROID_API_N = true;
ANDROID_API_N = false; }
} else
{
ANDROID_API_N = false;
}
#endif #endif
}); }
);
} }
public void ExtractZipFile(byte[] data, string outFolder) public void ExtractZipFile(byte[] data, string outFolder)
{ {
ZipFile zf = null; ZipFile zf = null;
try try
{ {
...@@ -492,7 +479,7 @@ public class Program : MonoBehaviour ...@@ -492,7 +479,7 @@ public class Program : MonoBehaviour
} }
String entryFileName = zipEntry.Name; 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); Stream zipStream = zf.GetInputStream(zipEntry);
String fullZipToPath = Path.Combine(outFolder, entryFileName); String fullZipToPath = Path.Combine(outFolder, entryFileName);
...@@ -519,58 +506,117 @@ public class Program : MonoBehaviour ...@@ -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 (File.Exists(path))
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
{ {
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()); PrintToChat(InterString.Get("后台更新检查完成,未发现新数据或更新失败。"));
Debug.Log("UPDATE ERROR: " + e.ToString());
} }
} }
private void ReplaceFile(string oldfile, string newfile) { private void ReplaceFile(string oldfile, string newfile)
if(File.Exists(oldfile)) { {
if (File.Exists(oldfile))
{
File.Delete(oldfile); File.Delete(oldfile);
} }
File.Move(newfile, oldfile); File.Move(newfile, oldfile);
...@@ -579,6 +625,7 @@ public class Program : MonoBehaviour ...@@ -579,6 +625,7 @@ public class Program : MonoBehaviour
public GameObject mouseParticle; public GameObject mouseParticle;
static int lastChargeTime = 0; static int lastChargeTime = 0;
public static void charge() public static void charge()
{ {
if (Program.TimePassed() - lastChargeTime > 5 * 60 * 1000) if (Program.TimePassed() - lastChargeTime > 5 * 60 * 1000)
...@@ -629,11 +676,9 @@ public class Program : MonoBehaviour ...@@ -629,11 +676,9 @@ public class Program : MonoBehaviour
public static void go(int delay_, Action act_) public static void go(int delay_, Action act_)
{ {
delayedTasks.Add(new delayedTask delayedTasks.Add(
{ new delayedTask { act = act_, timeToBeDone = delay_ + Program.TimePassed() }
act = act_, );
timeToBeDone = delay_ + Program.TimePassed(),
});
} }
public static void notGo(Action act_) public static void notGo(Action act_)
...@@ -681,7 +726,9 @@ public class Program : MonoBehaviour ...@@ -681,7 +726,9 @@ public class Program : MonoBehaviour
if (ui_back_ground_2d == null) if (ui_back_ground_2d == null)
{ {
ui_back_ground_2d = create(mod_ui_2d); 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; camera_back_ground_2d.depth = -2;
ui_back_ground_2d.layer = 8; ui_back_ground_2d.layer = 8;
...@@ -706,8 +753,6 @@ public class Program : MonoBehaviour ...@@ -706,8 +753,6 @@ public class Program : MonoBehaviour
camera_container_3d.rect = new Rect(0, 0, 1, 1); camera_container_3d.rect = new Rect(0, 0, 1, 1);
camera_container_3d.clearFlags = CameraClearFlags.Depth; camera_container_3d.clearFlags = CameraClearFlags.Depth;
if (ui_main_2d == null) if (ui_main_2d == null)
{ {
ui_main_2d = create(mod_ui_2d); ui_main_2d = create(mod_ui_2d);
...@@ -719,7 +764,6 @@ public class Program : MonoBehaviour ...@@ -719,7 +764,6 @@ public class Program : MonoBehaviour
camera_main_2d.cullingMask = (int)Mathf.Pow(2, 11); camera_main_2d.cullingMask = (int)Mathf.Pow(2, 11);
camera_main_2d.clearFlags = CameraClearFlags.Depth; camera_main_2d.clearFlags = CameraClearFlags.Depth;
if (ui_windows_2d == null) if (ui_windows_2d == null)
{ {
ui_windows_2d = create(mod_ui_2d); ui_windows_2d = create(mod_ui_2d);
...@@ -731,7 +775,6 @@ public class Program : MonoBehaviour ...@@ -731,7 +775,6 @@ public class Program : MonoBehaviour
camera_windows_2d.cullingMask = (int)Mathf.Pow(2, 19); camera_windows_2d.cullingMask = (int)Mathf.Pow(2, 19);
camera_windows_2d.clearFlags = CameraClearFlags.Depth; camera_windows_2d.clearFlags = CameraClearFlags.Depth;
if (ui_main_3d == null) if (ui_main_3d == null)
{ {
ui_main_3d = create(mod_ui_3d); ui_main_3d = create(mod_ui_3d);
...@@ -748,14 +791,13 @@ public class Program : MonoBehaviour ...@@ -748,14 +791,13 @@ public class Program : MonoBehaviour
camera_main_3d.transform.localScale = new Vector3(1, 1, 1); camera_main_3d.transform.localScale = new Vector3(1, 1, 1);
camera_main_3d.clearFlags = CameraClearFlags.Depth; camera_main_3d.clearFlags = CameraClearFlags.Depth;
camera_main_3d.transform.localPosition = camera_game_main.transform.position; camera_main_3d.transform.localPosition = camera_game_main.transform.position;
camera_container_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_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_main_3d.fieldOfView = camera_game_main.fieldOfView;
camera_container_3d.fieldOfView = camera_game_main.fieldOfView; camera_container_3d.fieldOfView = camera_game_main.fieldOfView;
...@@ -775,17 +817,23 @@ public class Program : MonoBehaviour ...@@ -775,17 +817,23 @@ public class Program : MonoBehaviour
} }
if (camera_game_main != null) 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; camera_container_3d.transform.localPosition = camera_game_main.transform.position;
if (cameraFacing == false) 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 else
{ {
camera_game_main.transform.LookAt(Vector3.zero); 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.fieldOfView = camera_game_main.fieldOfView;
camera_container_3d.rect = camera_game_main.rect; camera_container_3d.rect = camera_game_main.rect;
} }
...@@ -807,7 +855,7 @@ public class Program : MonoBehaviour ...@@ -807,7 +855,7 @@ public class Program : MonoBehaviour
GameObject father = null, GameObject father = null,
bool allParamsInWorld = true, bool allParamsInWorld = true,
Vector3 wantScale = default(Vector3) Vector3 wantScale = default(Vector3)
) )
{ {
Vector3 scale = mod.transform.localScale; Vector3 scale = mod.transform.localScale;
if (wantScale != default(Vector3)) if (wantScale != default(Vector3))
...@@ -878,8 +926,10 @@ public class Program : MonoBehaviour ...@@ -878,8 +926,10 @@ public class Program : MonoBehaviour
} }
else else
{ {
if (time != 0) MonoBehaviour.Destroy(obj, time); if (time != 0)
else MonoBehaviour.Destroy(obj); MonoBehaviour.Destroy(obj, time);
else
MonoBehaviour.Destroy(obj);
} }
if (instantNull) if (instantNull)
{ {
...@@ -1044,25 +1094,37 @@ public class Program : MonoBehaviour ...@@ -1044,25 +1094,37 @@ public class Program : MonoBehaviour
{ {
aiRoom.hide(); aiRoom.hide();
} }
if(to != roomList && to != selectServer && roomList.isShowed) if (to != roomList && to != selectServer && roomList.isShowed)
{ {
roomList.hide(); roomList.hide();
} }
if (to == backGroundPic && backGroundPic.isShowed == false) backGroundPic.show(); if (to == backGroundPic && backGroundPic.isShowed == false)
if (to == menu && menu.isShowed == false) menu.show(); backGroundPic.show();
if (to == setting && setting.isShowed == false) setting.show(); if (to == menu && menu.isShowed == false)
if (to == selectDeck && selectDeck.isShowed == false) selectDeck.show(); menu.show();
if (to == room && room.isShowed == false) room.show(); if (to == setting && setting.isShowed == false)
if (to == deckManager && deckManager.isShowed == false) deckManager.show(); setting.show();
if (to == ocgcore && ocgcore.isShowed == false) ocgcore.show(); if (to == selectDeck && selectDeck.isShowed == false)
if (to == selectServer && selectServer.isShowed == false) selectServer.show(); selectDeck.show();
if (to == mycard && mycard.isShowed == false) mycard.show(); if (to == room && room.isShowed == false)
if (to == selectReplay && selectReplay.isShowed == false) selectReplay.show(); room.show();
if (to == puzzleMode && puzzleMode.isShowed == false) puzzleMode.show(); if (to == deckManager && deckManager.isShowed == false)
if (to == aiRoom && aiRoom.isShowed == false) aiRoom.show(); deckManager.show();
if (to == roomList && !roomList.isShowed) roomList.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 #endregion
...@@ -1071,7 +1133,7 @@ public class Program : MonoBehaviour ...@@ -1071,7 +1133,7 @@ public class Program : MonoBehaviour
private float LastUpdateShowTime = 0f; private float LastUpdateShowTime = 0f;
private float UpdateShowDeltaTime = 1f; //更新帧率 private float UpdateShowDeltaTime = 1f; //更新帧率
private int FrameUpdate = 0; private int FrameUpdate = 0;
...@@ -1079,26 +1141,33 @@ public class Program : MonoBehaviour ...@@ -1079,26 +1141,33 @@ public class Program : MonoBehaviour
void Start() void Start()
{ {
#if UNITY_EDITOR || UNITY_STANDALONE_WIN //编译器、Windows #if UNITY_EDITOR || UNITY_STANDALONE_WIN //编译器、Windows
if (Screen.width < 100 || Screen.height < 100) if (Screen.width < 100 || Screen.height < 100)
{ {
Screen.SetResolution(1300, 700, false); Screen.SetResolution(1300, 700, false);
} }
QualitySettings.vSyncCount = 0; QualitySettings.vSyncCount = 0;
#elif UNITY_ANDROID || UNITY_IPHONE //Android、iPhone #elif UNITY_ANDROID || UNITY_IPHONE //Android、iPhone
Screen.SetResolution(1280, 720, true);
// Screen.SetResolution(1280, 720, true);
Screen.sleepTimeout = SleepTimeout.NeverSleep; Screen.sleepTimeout = SleepTimeout.NeverSleep;
Screen.orientation = ScreenOrientation.AutoRotation; Screen.orientation = ScreenOrientation.AutoRotation;
Screen.autorotateToLandscapeLeft = true; Screen.autorotateToLandscapeLeft = true;
Screen.autorotateToLandscapeRight = true; Screen.autorotateToLandscapeRight = true;
Screen.autorotateToPortrait = false; Screen.autorotateToPortrait = false;
Screen.autorotateToPortraitUpsideDown = false; Screen.autorotateToPortraitUpsideDown = false;
#endif #endif
mouseParticle = Instantiate(new_mouse); mouseParticle = Instantiate(new_mouse);
instance = this; instance = this;
initialize(); initialize();
go(500, () => { gameStart(); }); go(
1,
() =>
{
gameStart();
}
);
LastUpdateShowTime = Time.realtimeSinceStartup; LastUpdateShowTime = Time.realtimeSinceStartup;
} }
...@@ -1111,21 +1180,28 @@ public class Program : MonoBehaviour ...@@ -1111,21 +1180,28 @@ public class Program : MonoBehaviour
void OnGUI() void OnGUI()
{ {
if (Event.current.type == EventType.ScrollWheel) { if (Event.current.type == EventType.ScrollWheel)
{
_padScroll = -Event.current.delta.y / 100; _padScroll = -Event.current.delta.y / 100;
} else { }
else
{
_padScroll = 0; _padScroll = 0;
} }
string FPS = m_FPS.ToString(); 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); GUI.Label(new Rect(10, 5, 200, 200), "[Ver 1.036.1-Otokaze] " + "FPS: " + FPS);
} }
void Update() void Update()
{ {
FrameUpdate++; FrameUpdate++;
if(Time.realtimeSinceStartup - LastUpdateShowTime >= UpdateShowDeltaTime) if (Time.realtimeSinceStartup - LastUpdateShowTime >= UpdateShowDeltaTime)
{ {
m_FPS = FrameUpdate / (Time.realtimeSinceStartup - LastUpdateShowTime); m_FPS = FrameUpdate / (Time.realtimeSinceStartup - LastUpdateShowTime);
FrameUpdate = 0; FrameUpdate = 0;
...@@ -1148,7 +1224,9 @@ public class Program : MonoBehaviour ...@@ -1148,7 +1224,9 @@ public class Program : MonoBehaviour
pointedGameObject = hit.collider.gameObject; pointedGameObject = hit.collider.gameObject;
pointedCollider = hit.collider; 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 != null)
{ {
if (hoverobject.layer == 11 || pointedGameObject == null) if (hoverobject.layer == 11 || pointedGameObject == null)
...@@ -1197,7 +1275,6 @@ public class Program : MonoBehaviour ...@@ -1197,7 +1275,6 @@ public class Program : MonoBehaviour
break; break;
} }
} }
} }
private void onRESIZED() private void onRESIZED()
...@@ -1237,6 +1314,13 @@ public class Program : MonoBehaviour ...@@ -1237,6 +1314,13 @@ public class Program : MonoBehaviour
} }
backGroundPic.show(); backGroundPic.show();
shiftToServant(menu); shiftToServant(menu);
// 游戏主菜单显示后,才开始在后台检查更新
// 调用新的、非阻塞的后台更新协程
if (UIHelper.fromStringToBool(Config.Get("*AutoPicDownload", "1")))
{
StartCoroutine(UpdateClientCoroutine());
}
} }
public static bool Running = true; public static bool Running = true;
...@@ -1282,7 +1366,10 @@ public class Program : MonoBehaviour ...@@ -1282,7 +1366,10 @@ public class Program : MonoBehaviour
public static void gugugu() public static void gugugu()
{ {
PrintToChat(InterString.Get("非常抱歉,因为技术原因,此功能暂时无法使用。请关注官方网站获取更多消息。")); PrintToChat(
InterString.Get(
"非常抱歉,因为技术原因,此功能暂时无法使用。请关注官方网站获取更多消息。"
)
);
} }
} }
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public static class GameStringManager public static class GameStringManager
{ {
public class hashedString public class hashedString
...@@ -28,9 +29,7 @@ public static class GameStringManager ...@@ -28,9 +29,7 @@ public static class GameStringManager
return_value = Int32.Parse(str); return_value = Int32.Parse(str);
} }
} }
catch (Exception) catch (Exception) { }
{
}
return return_value; return return_value;
} }
...@@ -45,7 +44,8 @@ public static class GameStringManager ...@@ -45,7 +44,8 @@ public static class GameStringManager
{ {
if (line.Length > 1 && line.Substring(0, 1) == "!") 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) if (mats.Length > 2)
{ {
found = true; found = true;
...@@ -66,7 +66,8 @@ public static class GameStringManager ...@@ -66,7 +66,8 @@ public static class GameStringManager
a.content += mats[i] + " "; a.content += mats[i] + " ";
} }
a.content = a.content.Substring(0, a.content.Length - 1); a.content = a.content.Substring(0, a.content.Length - 1);
if(!test) { if (!test)
{
hashedStrings.Add(a); hashedStrings.Add(a);
if (a.region == "setname") if (a.region == "setname")
{ {
...@@ -150,6 +151,7 @@ public static class GameStringManager ...@@ -150,6 +151,7 @@ public static class GameStringManager
else else
return "???"; return "???";
} }
internal static string formatLocation(GPS gps) internal static string formatLocation(GPS gps)
{ {
return formatLocation(gps.location, gps.sequence); 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.Collections.Generic;
using System.IO; using System.IO;
using UnityEngine;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
public class Servant public class Servant
...@@ -16,17 +16,13 @@ public class Servant ...@@ -16,17 +16,13 @@ public class Servant
List<Action> updateActions_s = new List<Action>(); List<Action> updateActions_s = new List<Action>();
public Servant() public Servant()
{ {
initialize(); initialize();
AddUpdateAction(preFrameFunction); AddUpdateAction(preFrameFunction);
} }
public virtual void initialize() public virtual void initialize() { }
{
}
public virtual void show() public virtual void show()
{ {
...@@ -42,6 +38,11 @@ public class Servant ...@@ -42,6 +38,11 @@ public class Servant
{ {
RMSshow_clear(); RMSshow_clear();
RMSshow_clearYNF(); RMSshow_clearYNF();
// 取消屏幕修复任务
Program.notGo(fixScreenProblem);
Program.go(50, fixScreenProblem);
if (isShowed == true) if (isShowed == true)
{ {
isShowed = false; isShowed = false;
...@@ -78,60 +79,45 @@ public class Servant ...@@ -78,60 +79,45 @@ public class Servant
allGameObjects.Add(o); allGameObjects.Add(o);
} }
public virtual void preFrameFunction() 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 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() public void showBarOnly()
{ {
if (toolBar != null) if (toolBar != null)
{ {
Vector3 vectorOfShowedBar_Screen = new Vector3(Screen.width - RightToScreen, buttomToScreen, 0); Vector3 vectorOfShowedBar_Screen = new Vector3(
iTween.MoveTo(toolBar, Program.camera_back_ground_2d.ScreenToWorldPoint(vectorOfShowedBar_Screen), 0.6f); Screen.width - RightToScreen,
toolBar.transform.localScale = new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f); 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>(); 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; items[i].enabled = true;
} }
...@@ -143,8 +129,16 @@ public class Servant ...@@ -143,8 +129,16 @@ public class Servant
if (toolBar != null) if (toolBar != null)
{ {
Vector3 vectorOfHidedBar_Screen = new Vector3(Screen.width - RightToScreen, -100, 0); Vector3 vectorOfHidedBar_Screen = new Vector3(Screen.width - RightToScreen, -100, 0);
iTween.MoveTo(toolBar, Program.camera_back_ground_2d.ScreenToWorldPoint(vectorOfHidedBar_Screen), 0.6f); iTween.MoveTo(
toolBar.transform.localScale = new Vector3(((float)Screen.height) / 700f, ((float)Screen.height) / 700f, ((float)Screen.height) / 700f); 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>(); var items = toolBar.GetComponentsInChildren<toolShift>();
for (int i = 0; i < items.Length; i++) for (int i = 0; i < items.Length; i++)
{ {
...@@ -163,10 +157,7 @@ public class Servant ...@@ -163,10 +157,7 @@ public class Servant
hideBarOnly(); hideBarOnly();
} }
public virtual void ES_quit() public virtual void ES_quit() { }
{
}
GameObject preHover = null; GameObject preHover = null;
...@@ -216,7 +207,7 @@ public class Servant ...@@ -216,7 +207,7 @@ public class Servant
if (preHover != Program.pointedGameObject) if (preHover != Program.pointedGameObject)
{ {
preHover = Program.pointedGameObject; preHover = Program.pointedGameObject;
if (preHover!=null) if (preHover != null)
ES_HoverOverGameObject(preHover); ES_HoverOverGameObject(preHover);
} }
} }
...@@ -235,9 +226,11 @@ public class Servant ...@@ -235,9 +226,11 @@ public class Servant
GameObject father = null, GameObject father = null,
bool allParamsInWorld = true, bool allParamsInWorld = true,
Vector3 wantScale = default(Vector3) 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; return re;
} }
...@@ -249,9 +242,11 @@ public class Servant ...@@ -249,9 +242,11 @@ public class Servant
GameObject father = null, GameObject father = null,
bool allParamsInWorld = true, bool allParamsInWorld = true,
Vector3 wantScale = default(Vector3) 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); allGameObjects.Add(re);
return re; return re;
} }
...@@ -288,22 +283,23 @@ public class Servant ...@@ -288,22 +283,23 @@ public class Servant
float RightToScreen; float RightToScreen;
public void SetBar(GameObject mod,float buttomToScreen,float RightToScreen) public void SetBar(GameObject mod, float buttomToScreen, float RightToScreen)
{ {
this.buttomToScreen = buttomToScreen; this.buttomToScreen = buttomToScreen;
this.RightToScreen = RightToScreen; this.RightToScreen = RightToScreen;
if (toolBar!=null) if (toolBar != null)
{ {
MonoBehaviour.DestroyImmediate(toolBar); MonoBehaviour.DestroyImmediate(toolBar);
} }
toolBar = create toolBar = create(
(
mod, 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), new Vector3(0, 0, 0),
false, false,
Program.ui_main_2d Program.ui_main_2d
); );
UIHelper.InterGameObject(toolBar); UIHelper.InterGameObject(toolBar);
fixScreenProblem(); fixScreenProblem();
} }
...@@ -311,27 +307,26 @@ public class Servant ...@@ -311,27 +307,26 @@ public class Servant
public void reShowBar(float buttomToScreen, float RightToScreen) public void reShowBar(float buttomToScreen, float RightToScreen)
{ {
this.buttomToScreen = buttomToScreen; this.buttomToScreen = buttomToScreen;
this.RightToScreen = RightToScreen; this.RightToScreen = RightToScreen;
if (isShowed) if (isShowed)
{ {
showBarOnly(); showBarOnly();
} }
} }
List<Program.delayedTask> delayedTasks = new List<Program.delayedTask>(); List<Program.delayedTask> delayedTasks = new List<Program.delayedTask>();
public void safeGogo(int delay_, Action act_) public void safeGogo(int delay_, Action act_)
{ {
Program.go(delay_, act_); Program.go(delay_, act_);
delayedTasks.Add(new Program.delayedTask delayedTasks.Add(
{ new Program.delayedTask { act = act_, timeToBeDone = delay_ + Program.TimePassed() }
act = act_, );
timeToBeDone = delay_ + Program.TimePassed(),
});
} }
#region remasterMessageSystem #region remasterMessageSystem
public Vector3 centre(bool fix=false) public Vector3 centre(bool fix = false)
{ {
if (Program.I().ocgcore.isShowed || Program.I().deckManager.isShowed) if (Program.I().ocgcore.isShowed || Program.I().deckManager.isShowed)
{ {
...@@ -352,7 +347,9 @@ public class Servant ...@@ -352,7 +347,9 @@ public class Servant
} }
else 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 ...@@ -361,7 +358,9 @@ public class Servant
if (Program.I().ocgcore.isShowed) if (Program.I().ocgcore.isShowed)
{ {
float real = (Program.fieldSize - 1) * 0.9f + 1f; 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; screenP.z = 0;
return Program.camera_main_2d.ScreenToWorldPoint(screenP); return Program.camera_main_2d.ScreenToWorldPoint(screenP);
} }
...@@ -371,7 +370,9 @@ public class Servant ...@@ -371,7 +370,9 @@ public class Servant
screenP.z = 0; screenP.z = 0;
return Program.camera_main_2d.ScreenToWorldPoint(screenP); 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 private enum messageSystemType
...@@ -408,7 +409,7 @@ public class Servant ...@@ -408,7 +409,7 @@ public class Servant
void ES_RMSpremono(GameObject gameObjectClicked, messageSystemValue value) void ES_RMSpremono(GameObject gameObjectClicked, messageSystemValue value)
{ {
List<messageSystemValue> re; List<messageSystemValue> re;
switch (currentMStype) switch (currentMStype)
{ {
case messageSystemType.onlyYes: case messageSystemType.onlyYes:
case messageSystemType.yesOrNo: case messageSystemType.yesOrNo:
...@@ -490,36 +491,47 @@ public class Servant ...@@ -490,36 +491,47 @@ public class Servant
RMSshow_clear(); RMSshow_clear();
currentMShash = hashCode; currentMShash = hashCode;
currentMStype = messageSystemType.onlyYes; currentMStype = messageSystemType.onlyYes;
currentMSwindow = create currentMSwindow = create(
(
Program.I().ES_1, Program.I().ES_1,
MSentre(), MSentre(),
Vector3.zero, Vector3.zero,
true, true,
Program.ui_main_2d, Program.ui_main_2d,
true, 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.InterGameObject(currentMSwindow);
UIHelper.trySetLableText(currentMSwindow, "hint_", hint); UIHelper.trySetLableText(currentMSwindow, "hint_", hint);
UIHelper.registEvent(currentMSwindow, "yes_", ES_RMSpremono, yes); 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(); RMSshow_clear();
currentMShash = hashCode; currentMShash = hashCode;
currentMStype = messageSystemType.yesOrNo; currentMStype = messageSystemType.yesOrNo;
currentMSwindow = create currentMSwindow = create(
(
Program.I().ES_2, Program.I().ES_2,
MSentre(), MSentre(),
Vector3.zero, Vector3.zero,
true, true,
Program.ui_main_2d, Program.ui_main_2d,
true, 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.InterGameObject(currentMSwindow);
UIHelper.trySetLableText(currentMSwindow, "hint_", hint); UIHelper.trySetLableText(currentMSwindow, "hint_", hint);
UIHelper.registEvent(currentMSwindow, "yes_", ES_RMSpremono, yes); UIHelper.registEvent(currentMSwindow, "yes_", ES_RMSpremono, yes);
...@@ -531,16 +543,19 @@ public class Servant ...@@ -531,16 +543,19 @@ public class Servant
public void RMSshow_yesOrNoForce(string hint, messageSystemValue yes, messageSystemValue no) public void RMSshow_yesOrNoForce(string hint, messageSystemValue yes, messageSystemValue no)
{ {
RMSshow_clearYNF(); RMSshow_clearYNF();
yesOrNoForce = create yesOrNoForce = create(
(
Program.I().ES_2Force, Program.I().ES_2Force,
MSentre(), MSentre(),
Vector3.zero, Vector3.zero,
true, true,
Program.ui_main_2d, Program.ui_main_2d,
true, 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.InterGameObject(yesOrNoForce);
UIHelper.trySetLableText(yesOrNoForce, "hint_", hint); UIHelper.trySetLableText(yesOrNoForce, "hint_", hint);
UIHelper.registEvent(yesOrNoForce, "yes_", ES_RMSpremonoForceYesNo, yes); UIHelper.registEvent(yesOrNoForce, "yes_", ES_RMSpremonoForceYesNo, yes);
...@@ -562,36 +577,48 @@ public class Servant ...@@ -562,36 +577,48 @@ public class Servant
RMSshow_clear(); RMSshow_clear();
currentMShash = hashCode; currentMShash = hashCode;
currentMStype = messageSystemType.yesOrNo; currentMStype = messageSystemType.yesOrNo;
currentMSwindow = create currentMSwindow = create(
(
Program.I().ES_FS, Program.I().ES_FS,
MSentre(), MSentre(),
Vector3.zero, Vector3.zero,
true, true,
Program.ui_main_2d, Program.ui_main_2d,
true, 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.InterGameObject(currentMSwindow);
UIHelper.registEvent(currentMSwindow, "yes_", ES_RMSpremono, first); UIHelper.registEvent(currentMSwindow, "yes_", ES_RMSpremono, first);
UIHelper.registEvent(currentMSwindow, "no_", ES_RMSpremono, second); 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(); RMSshow_clear();
currentMShash = hashCode; currentMShash = hashCode;
currentMStype = messageSystemType.yesOrNoOrCancle; currentMStype = messageSystemType.yesOrNoOrCancle;
currentMSwindow = create currentMSwindow = create(
(
Program.I().ES_3cancle, Program.I().ES_3cancle,
MSentre(), MSentre(),
Vector3.zero, Vector3.zero,
true, true,
Program.ui_main_2d, Program.ui_main_2d,
true, 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.InterGameObject(currentMSwindow);
UIHelper.trySetLableText(currentMSwindow, "hint_", hint); UIHelper.trySetLableText(currentMSwindow, "hint_", hint);
UIHelper.registEvent(currentMSwindow, "yes_", ES_RMSpremono, yes); UIHelper.registEvent(currentMSwindow, "yes_", ES_RMSpremono, yes);
...@@ -604,30 +631,32 @@ public class Servant ...@@ -604,30 +631,32 @@ public class Servant
RMSshow_clear(); RMSshow_clear();
currentMShash = hashCode; currentMShash = hashCode;
currentMStype = messageSystemType.singleChoice; currentMStype = messageSystemType.singleChoice;
currentMSwindow = create currentMSwindow = create(
(
Program.I().ES_Single_multiple_window, Program.I().ES_Single_multiple_window,
MSentre(), MSentre(),
Vector3.zero, Vector3.zero,
true, true,
Program.ui_main_2d, Program.ui_main_2d,
true, 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"); UISprite sp = UIHelper.getByName<UISprite>(currentMSwindow, "under");
sp.height = 70 + options.Count * 48; sp.height = 70 + options.Count * 48;
for (int i = 0; i < options.Count; i++) for (int i = 0; i < options.Count; i++)
{ {
GameObject btn = create GameObject btn = create(
( Program.I().ES_Single_option,
Program.I().ES_Single_option, new Vector3(-2, sp.height / 2 - 59 - 48 * i, 0),
new Vector3(-2, sp.height / 2 - 59 - 48 * i, 0), Vector3.zero,
Vector3.zero, false,
false, sp.gameObject,
sp.gameObject, false
false );
); UIHelper.trySetLableText(btn, "[u]" + options[i].hint);
UIHelper.trySetLableText(btn, "[u]"+options[i].hint);
UIHelper.registEvent(btn, btn.name, ES_RMSpremono, options[i]); UIHelper.registEvent(btn, btn.name, ES_RMSpremono, options[i]);
} }
UIHelper.InterGameObject(currentMSwindow); UIHelper.InterGameObject(currentMSwindow);
...@@ -637,23 +666,30 @@ public class Servant ...@@ -637,23 +666,30 @@ public class Servant
List<messageSystemValue> RMSshow_multipleChoice_selected = new List<messageSystemValue>(); 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_count = selectCount;
RMSshow_multipleChoice_selected.Clear(); RMSshow_multipleChoice_selected.Clear();
RMSshow_clear(); RMSshow_clear();
currentMShash = hashCode; currentMShash = hashCode;
currentMStype = messageSystemType.multipleChoice; currentMStype = messageSystemType.multipleChoice;
currentMSwindow = create currentMSwindow = create(
(
Program.I().ES_Single_multiple_window, Program.I().ES_Single_multiple_window,
MSentre(), MSentre(),
Vector3.zero, Vector3.zero,
true, true,
Program.ui_main_2d, Program.ui_main_2d,
true, 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"); UISprite sp = UIHelper.getByName<UISprite>(currentMSwindow, "under");
sp.height = 70 + UIHelper.get_zonghangshu(options.Count, 5) * 40; sp.height = 70 + UIHelper.get_zonghangshu(options.Count, 5) * 40;
sp.width = 470; sp.width = 470;
...@@ -662,36 +698,43 @@ public class Servant ...@@ -662,36 +698,43 @@ public class Servant
Vector2 v = UIHelper.get_hang_lie(i, 5); Vector2 v = UIHelper.get_hang_lie(i, 5);
float hang = v.x; float hang = v.x;
float lie = v.y; float lie = v.y;
GameObject btn = create GameObject btn = create(
( Program.I().ES_multiple_option,
Program.I().ES_multiple_option, new Vector3(-162 + lie * 80, sp.height / 2 - 55 - 40 * hang, 0),
new Vector3(-162 + lie * 80, sp.height / 2 - 55 - 40 * hang, 0), Vector3.zero,
Vector3.zero, false,
false, sp.gameObject,
sp.gameObject, false
false );
);
UIHelper.trySetLableText(btn, "[u]" + options[i].hint); UIHelper.trySetLableText(btn, "[u]" + options[i].hint);
UIHelper.registEvent(btn, btn.name, ES_RMSpremono, options[i]); UIHelper.registEvent(btn, btn.name, ES_RMSpremono, options[i]);
} }
UIHelper.InterGameObject(currentMSwindow); 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(); RMSshow_clear();
currentMShash = hashCode; currentMShash = hashCode;
currentMStype = messageSystemType.position; currentMStype = messageSystemType.position;
currentMSwindow = create currentMSwindow = create(
(
Program.I().ES_position, Program.I().ES_position,
MSentre(), MSentre(),
Vector3.zero, Vector3.zero,
true, true,
Program.ui_main_2d, Program.ui_main_2d,
true, 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.InterGameObject(currentMSwindow);
UIHelper.registEvent(currentMSwindow, "atk_", ES_RMSpremono, atk); UIHelper.registEvent(currentMSwindow, "atk_", ES_RMSpremono, atk);
UIHelper.registEvent(currentMSwindow, "def_", ES_RMSpremono, def); UIHelper.registEvent(currentMSwindow, "def_", ES_RMSpremono, def);
...@@ -713,28 +756,48 @@ public class Servant ...@@ -713,28 +756,48 @@ public class Servant
cardPicLoader_.code = code; cardPicLoader_.code = code;
cardPicLoader_.uiTexture = atkpic; cardPicLoader_.uiTexture = atkpic;
cardPicLoader_ = currentMSwindow.AddComponent<cardPicLoader>(); 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_"); cardPicLoader_.uiTexture = UIHelper.getByName<UITexture>(currentMSwindow, "defPic_");
} }
public void RMSshow_position3(string hashCode, int code) public void RMSshow_position3(string hashCode, int code)
{ {
RMSshow_clear(); RMSshow_clear();
currentMShash = hashCode; currentMShash = hashCode;
currentMStype = messageSystemType.position; currentMStype = messageSystemType.position;
currentMSwindow = create currentMSwindow = create(
(
Program.I().ES_position3, Program.I().ES_position3,
MSentre(), MSentre(),
Vector3.zero, Vector3.zero,
true, true,
Program.ui_main_2d, Program.ui_main_2d,
true, 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.InterGameObject(currentMSwindow);
UIHelper.registEvent(currentMSwindow, "upAtk_", ES_RMSpremono, new messageSystemValue { value = "1", hint = "Face-Up Attack" }); UIHelper.registEvent(
UIHelper.registEvent(currentMSwindow, "upDef_", ES_RMSpremono, new messageSystemValue { value = "4", hint = "Face-Up Defense" }); currentMSwindow,
UIHelper.registEvent(currentMSwindow, "downDef_", ES_RMSpremono, new messageSystemValue { value = "8", hint = "Face-Down Defense" }); "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 upatkpic = UIHelper.getByName<UITexture>(currentMSwindow, "upAtkPic_");
UITexture updefpic = UIHelper.getByName<UITexture>(currentMSwindow, "upDefPic_"); UITexture updefpic = UIHelper.getByName<UITexture>(currentMSwindow, "upDefPic_");
...@@ -751,48 +814,65 @@ public class Servant ...@@ -751,48 +814,65 @@ public class Servant
cardPicLoader_.uiTexture = downdefpic; 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(); RMSshow_clear();
currentMShash = hashCode; currentMShash = hashCode;
currentMStype = messageSystemType.tp; currentMStype = messageSystemType.tp;
currentMSwindow = create currentMSwindow = create(
(
Program.I().ES_Tp, Program.I().ES_Tp,
MSentre(), MSentre(),
Vector3.zero, Vector3.zero,
true, true,
Program.ui_main_2d, Program.ui_main_2d,
true, 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.InterGameObject(currentMSwindow);
UIHelper.registEvent(currentMSwindow, "jiandao_", ES_RMSpremono, jiandao); UIHelper.registEvent(currentMSwindow, "jiandao_", ES_RMSpremono, jiandao);
UIHelper.registEvent(currentMSwindow, "shitou_", ES_RMSpremono, shitou); UIHelper.registEvent(currentMSwindow, "shitou_", ES_RMSpremono, shitou);
UIHelper.registEvent(currentMSwindow, "bu_", ES_RMSpremono, bu); 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(); RMSshow_clear();
currentMShash = hashCode; currentMShash = hashCode;
currentMStype = messageSystemType.input; currentMStype = messageSystemType.input;
currentMSwindow = create currentMSwindow = create(
(
Program.I().ES_input, Program.I().ES_input,
MSentre(), MSentre(),
Vector3.zero, Vector3.zero,
true, true,
Program.ui_main_2d, Program.ui_main_2d,
true, 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.InterGameObject(currentMSwindow);
UIHelper.trySetLableText(currentMSwindow, "hint_", hint); UIHelper.trySetLableText(currentMSwindow, "hint_", hint);
UIHelper.registEvent(currentMSwindow, "input_", ES_RMSpremono, null, "yes_"); UIHelper.registEvent(currentMSwindow, "input_", ES_RMSpremono, null, "yes_");
UIHelper.registEvent(currentMSwindow, "exit_", ES_RMSpremono, new messageSystemValue()); UIHelper.registEvent(currentMSwindow, "exit_", ES_RMSpremono, new messageSystemValue());
UIHelper.getByName<UIInput>(currentMSwindow, "input_").value = default_; 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) public void RMSshow_none(string hint)
...@@ -806,26 +886,31 @@ public class Servant ...@@ -806,26 +886,31 @@ public class Servant
private GameObject currentMSwindow_Face = null; private GameObject currentMSwindow_Face = null;
public void RMSshow_face(string hashCode, string name) public void RMSshow_face(string hashCode, string name)
{ {
RMSshow_clear(); RMSshow_clear();
currentMShash = hashCode; currentMShash = hashCode;
currentMStype = messageSystemType.onlyYes; currentMStype = messageSystemType.onlyYes;
currentMSwindow = create currentMSwindow = create(
(
Program.I().ES_Face, Program.I().ES_Face,
MSentre(), MSentre(),
Vector3.zero, Vector3.zero,
true, true,
Program.ui_main_2d, Program.ui_main_2d,
true, 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; nameFace = name;
currentMSwindow_Face = currentMSwindow; currentMSwindow_Face = currentMSwindow;
UIHelper.InterGameObject(currentMSwindow); UIHelper.InterGameObject(currentMSwindow);
inputUrl = UIHelper.getByName<UIInput>(currentMSwindow, "input_"); 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, "exit_", ES_RMSpremono, new messageSystemValue());
UIHelper.registEvent(currentMSwindow, "yes_", DownloadFace); UIHelper.registEvent(currentMSwindow, "yes_", DownloadFace);
} }
...@@ -833,26 +918,53 @@ public class Servant ...@@ -833,26 +918,53 @@ public class Servant
public void DownloadFace() public void DownloadFace()
{ {
string url = "http://q1.qlogo.cn/headimg_dl?dst_uin=" + inputUrl.value + "&spec=100"; string url = "http://q1.qlogo.cn/headimg_dl?dst_uin=" + inputUrl.value + "&spec=100";
string face = "textures/face/" + nameFace + ".jpg"; string facePath = "textures/face/" + nameFace + ".jpg";
//开始下载 // 如果输入的是一个完整的URL,则使用它
HttpDldFile df = new HttpDldFile(); if (inputUrl.value.Length >= 4 && inputUrl.value.StartsWith("http"))
if (inputUrl.value.Length >= 4 && inputUrl.value.Substring(0, 4) == "http")
{ {
url = inputUrl.value; 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 #endregion
} }
using UnityEngine; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using UnityEngine;
public class SelectServer : WindowServantSP public class SelectServer : WindowServantSP
{ {
...@@ -26,10 +26,16 @@ public class SelectServer : WindowServantSP ...@@ -26,10 +26,16 @@ public class SelectServer : WindowServantSP
UIHelper.registEvent(gameObject, "clearPsw_", onClearPsw); UIHelper.registEvent(gameObject, "clearPsw_", onClearPsw);
serversList = UIHelper.getByName<UIPopupList>(gameObject, "server"); serversList = UIHelper.getByName<UIPopupList>(gameObject, "server");
//serversList.fontSize = 30; //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", "[自定义]"); serversList.value = Config.Get("serversPicker", "[自定义]");
} else { }
else
{
serversList.value = Config.Get("serversPicker", "[Custom]"); serversList.value = Config.Get("serversPicker", "[Custom]");
} }
UIHelper.registEvent(gameObject, "server", pickServer); UIHelper.registEvent(gameObject, "server", pickServer);
...@@ -47,25 +53,23 @@ public class SelectServer : WindowServantSP ...@@ -47,25 +53,23 @@ public class SelectServer : WindowServantSP
set_version("0x" + String.Format("{0:X}", Config.ClientVersion)); set_version("0x" + String.Format("{0:X}", Config.ClientVersion));
//方便免修改 [selectServerWithRoomlist.prefab] //方便免修改 [selectServerWithRoomlist.prefab]
serversList.items.Add("[OCG]Koishi"); serversList.items.Add("[OCG]EXP");
//serversList.items.Add("[OCG]Koishi备用节点"); serversList.items.Add("[OCG]MYGO");
serversList.items.Add("[OCG]233 1"); serversList.items.Add("[OCG]233 1");
serversList.items.Add("[OCG]233 2"); serversList.items.Add("[OCG]233 2");
serversList.items.Add("[OCG]233 约战"); serversList.items.Add("[OCG]233 约战");
serversList.items.Add("[OCG]23333 Pre"); serversList.items.Add("[OCG]23333 Pre");
serversList.items.Add("[AI]233 AI"); serversList.items.Add("[OCG]Koishi");
serversList.items.Add("[TCG]Koishi TCG"); if (
serversList.items.Add("[CCG]Koishi 简中"); Application.systemLanguage == SystemLanguage.Chinese
serversList.items.Add("[OCG]透视服"); || Application.systemLanguage == SystemLanguage.ChineseSimplified
serversList.items.Add("[OCG]自走棋"); || Application.systemLanguage == SystemLanguage.ChineseTraditional
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("[自定义]"); serversList.items.Add("[自定义]");
} else { }
else
{
serversList.items.Add("[Custom]"); serversList.items.Add("[Custom]");
} }
...@@ -77,152 +81,88 @@ public class SelectServer : WindowServantSP ...@@ -77,152 +81,88 @@ public class SelectServer : WindowServantSP
string server = serversList.value; string server = serversList.value;
switch (server) 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": case "[OCG]Koishi":
{ {
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.momobako.com"; UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.momobako.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "7210"; UIHelper.getByName<UIInput>(gameObject, "port_").value = "7210";
Config.Set("serversPicker", "[OCG]Koishi"); Config.Set("serversPicker", "[OCG]Koishi");
inputIP_.enabled = false; inputIP_.enabled = false;
inputPort_.enabled = true; inputPort_.enabled = true;
break; break;
} }
case "[OCG]233 1": case "[OCG]233 1":
{ {
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s1.ygo233.com"; UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s1.ygo233.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "233"; UIHelper.getByName<UIInput>(gameObject, "port_").value = "233";
Config.Set("serversPicker", "[OCG]233 1"); Config.Set("serversPicker", "[OCG]233 1");
inputIP_.enabled = false; inputIP_.enabled = false;
inputPort_.enabled = true; inputPort_.enabled = true;
break; break;
} }
case "[OCG]233 2": case "[OCG]233 2":
{ {
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s2.ygo233.com"; UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s2.ygo233.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "233"; UIHelper.getByName<UIInput>(gameObject, "port_").value = "233";
Config.Set("serversPicker", "[OCG]233 2"); Config.Set("serversPicker", "[OCG]233 2");
inputIP_.enabled = false; inputIP_.enabled = false;
inputPort_.enabled = true; inputPort_.enabled = true;
break; break;
} }
case "[OCG]233 约战": case "[OCG]233 约战":
{ {
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s1.ygo233.com"; UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s1.ygo233.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "2333"; UIHelper.getByName<UIInput>(gameObject, "port_").value = "2333";
Config.Set("serversPicker", "[OCG]233 约战"); Config.Set("serversPicker", "[OCG]233 约战");
inputIP_.enabled = false; inputIP_.enabled = false;
inputPort_.enabled = true; inputPort_.enabled = true;
break; break;
} }
case "[OCG]23333 Pre": case "[OCG]23333 Pre":
{ {
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s1.ygo233.com"; UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s1.ygo233.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "23333"; UIHelper.getByName<UIInput>(gameObject, "port_").value = "23333";
Config.Set("serversPicker", "[OCG]23333 Pre"); 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");
inputIP_.enabled = false; inputIP_.enabled = false;
inputPort_.enabled = false; inputPort_.enabled = true;
break; break;
} }
default: 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", "[自定义]"); Config.Set("serversPicker", "[自定义]");
} else { }
else
{
Config.Set("serversPicker", "[Custom]"); Config.Set("serversPicker", "[Custom]");
} }
...@@ -231,7 +171,6 @@ public class SelectServer : WindowServantSP ...@@ -231,7 +171,6 @@ public class SelectServer : WindowServantSP
break; break;
} }
} }
} }
void onSelected() void onSelected()
...@@ -244,46 +183,46 @@ public class SelectServer : WindowServantSP ...@@ -244,46 +183,46 @@ public class SelectServer : WindowServantSP
private void readString(string str) private void readString(string str)
{ {
/* /*
str = str.Substring(1, str.Length - 1); str = str.Substring(1, str.Length - 1);
string version = "", remain = ""; string version = "", remain = "";
string[] splited; string[] splited;
splited = str.Split(")"); splited = str.Split(")");
try try
{ {
version = splited[0]; version = splited[0];
remain = splited[1]; remain = splited[1];
} }
catch (Exception) catch (Exception)
{ {
} }
splited = remain.Split(":"); splited = remain.Split(":");
string ip = ""; string ip = "";
try try
{ {
ip = splited[0]; ip = splited[0];
remain = splited[1]; remain = splited[1];
} }
catch (Exception) catch (Exception)
{ {
} }
splited = remain.Split(" "); splited = remain.Split(" ");
string psw = "", port = ""; string psw = "", port = "";
try try
{ {
port = splited[0]; port = splited[0];
psw = splited[1]; psw = splited[1];
} }
catch (Exception) catch (Exception)
{ {
} }
if (EditIpAndPort) if (EditIpAndPort)
{ {
inputIP.value = ip; inputIP.value = ip;
inputPort.value = port; inputPort.value = port;
} }
inputPsw.value = psw; inputPsw.value = psw;
*/ */
//确保密码为空时,退出后密码依旧保持为空 //确保密码为空时,退出后密码依旧保持为空
str = str.Substring(5, str.Length - 5); str = str.Substring(5, str.Length - 5);
inputPsw.value = str; inputPsw.value = str;
...@@ -296,9 +235,13 @@ public class SelectServer : WindowServantSP ...@@ -296,9 +235,13 @@ public class SelectServer : WindowServantSP
string[] lines = PswString.Replace("\r", "").Split("\n"); string[] lines = PswString.Replace("\r", "").Split("\n");
for (int i = 0; i < lines.Length; i++) 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(); stream.Close();
inputPsw.value = ""; inputPsw.value = "";
Program.PrintToChat(InterString.Get("房间密码已清空")); Program.PrintToChat(InterString.Get("房间密码已清空"));
...@@ -390,7 +333,13 @@ public class SelectServer : WindowServantSP ...@@ -390,7 +333,13 @@ public class SelectServer : WindowServantSP
gameObject.SetActive(!Bool); 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; name = Name;
Config.Set("name", name); Config.Set("name", name);
...@@ -418,8 +367,13 @@ public class SelectServer : WindowServantSP ...@@ -418,8 +367,13 @@ public class SelectServer : WindowServantSP
} }
File.WriteAllText("config/passwords.conf", all); File.WriteAllText("config/passwords.conf", all);
printFile(false); printFile(false);
Program.I().mycard.isMatching = false; Program.I().mycard.isMatching = false;
(new Thread(() => { TcpHelper.join(ipString, name, portString, pswString, versionString); })).Start(); (
new Thread(() =>
{
TcpHelper.join(ipString, name, portString, pswString, versionString);
})
).Start();
} }
else else
{ {
...@@ -438,5 +392,4 @@ public class SelectServer : WindowServantSP ...@@ -438,5 +392,4 @@ public class SelectServer : WindowServantSP
RMSshow_face("showFace", name); RMSshow_face("showFace", name);
Config.Set("name", name); Config.Set("name", name);
} }
} }
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Data; using System.Data;
using Mono.Data.Sqlite;
using System;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Mono.Data.Sqlite;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
namespace YGOSharp namespace YGOSharp
...@@ -16,12 +16,18 @@ namespace YGOSharp ...@@ -16,12 +16,18 @@ namespace YGOSharp
public static string nullString = ""; 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("未知卡片"); nullName = InterString.Get("未知卡片");
nullString = ""; 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 += "\r\n\r\n";
nullString += "KoishiPro2 iOS的用户QQ群627975038,游戏中遇到任何bug欢迎提交"; nullString += "KoishiPro2 iOS的用户QQ群627975038,游戏中遇到任何bug欢迎提交";
nullString += "\r\n\r\n"; nullString += "\r\n\r\n";
...@@ -30,12 +36,22 @@ namespace YGOSharp ...@@ -30,12 +36,22 @@ namespace YGOSharp
nullString += "喜欢游戏王DIY的朋友欢迎来222服QQ群642043095"; nullString += "喜欢游戏王DIY的朋友欢迎来222服QQ群642043095";
} }
bool success = true; bool success = true;
try { try
using (SqliteConnection connection = new SqliteConnection("Data Source=" + databaseFullPath)) {
using (
SqliteConnection connection = new SqliteConnection(
"Data Source=" + databaseFullPath
)
)
{ {
connection.Open(); 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()) using (IDataReader reader = command.ExecuteReader())
{ {
...@@ -47,7 +63,8 @@ namespace YGOSharp ...@@ -47,7 +63,8 @@ namespace YGOSharp
} }
} }
} }
catch (System.Exception e) { catch (System.Exception e)
{
success = false; success = false;
} }
return success; return success;
...@@ -98,7 +115,7 @@ namespace YGOSharp ...@@ -98,7 +115,7 @@ namespace YGOSharp
if (!_cards.ContainsKey(card.Id)) if (!_cards.ContainsKey(card.Id))
{ {
_cards.Add(card.Id, card); _cards.Add(card.Id, card);
} }
else if (replace) else if (replace)
{ {
_cards.Remove(card.Id); _cards.Remove(card.Id);
...@@ -136,7 +153,7 @@ namespace YGOSharp ...@@ -136,7 +153,7 @@ namespace YGOSharp
uint getRaceFilter, uint getRaceFilter,
uint getAttributeFilter, uint getAttributeFilter,
uint getCatagoryFilter uint getCatagoryFilter
) )
{ {
List<Card> returnValue = new List<Card>(); List<Card> returnValue = new List<Card>();
foreach (var item in _cards) foreach (var item in _cards)
...@@ -144,23 +161,44 @@ namespace YGOSharp ...@@ -144,23 +161,44 @@ namespace YGOSharp
Card card = item.Value; Card card = item.Value;
if ((card.Type & (uint)CardType.Token) == 0) if ((card.Type & (uint)CardType.Token) == 0)
{ {
if (getName == "" if (
|| Regex.Replace(card.Name, getName,"miaowu", RegexOptions.IgnoreCase) != card.Name getName == ""
|| Regex.Replace(card.Desc, getName, "miaowu", RegexOptions.IgnoreCase) != card.Desc || Regex.Replace(card.Name, getName, "miaowu", RegexOptions.IgnoreCase)
|| Regex.Replace(card.strSetName, getName, "miaowu", RegexOptions.IgnoreCase) != card.strSetName != 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 || card.Id.ToString() == getName
) )
{ {
if (((card.Type & getTypeFilter) == getTypeFilter || getTypeFilter == 0) if (
&& ((card.Type == getTypeFilter2 ((card.Type & getTypeFilter) == getTypeFilter || getTypeFilter == 0)
|| getTypeFilter == (UInt32)CardType.Monster) && (card.Type & getTypeFilter2) == getTypeFilter2 && (
|| getTypeFilter2 == 0)) (
card.Type == getTypeFilter2
|| getTypeFilter == (UInt32)CardType.Monster
)
&& (card.Type & getTypeFilter2) == getTypeFilter2
|| getTypeFilter2 == 0
)
)
{ {
if ((card.Race & getRaceFilter) > 0 || getRaceFilter == 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)) if (judgeint(getAttack, getAttack_UP, card.Attack))
{ {
...@@ -170,13 +208,27 @@ namespace YGOSharp ...@@ -170,13 +208,27 @@ namespace YGOSharp
{ {
if (judgeint(getP, getP_UP, card.LScale)) 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); returnValue.Add(card);
} }
...@@ -224,23 +276,23 @@ namespace YGOSharp ...@@ -224,23 +276,23 @@ namespace YGOSharp
return re; return re;
} }
internal static List<Card> search( internal static List<Card> search(string getName, List<int> getsearchCode)
string getName,
List<int> getsearchCode
)
{ {
List<Card> returnValue = new List<Card>(); List<Card> returnValue = new List<Card>();
foreach (var item in _cards) foreach (var item in _cards)
{ {
Card card = item.Value; Card card = item.Value;
if (getName == "" if (
|| Regex.Replace(card.Name, getName, "miaowu", RegexOptions.IgnoreCase) != card.Name getName == ""
//|| Regex.Replace(card.Desc, getName, "miaowu", RegexOptions.IgnoreCase) != card.Desc || Regex.Replace(card.Name, getName, "miaowu", RegexOptions.IgnoreCase)
|| Regex.Replace(card.strSetName, getName, "miaowu", RegexOptions.IgnoreCase) != card.strSetName != card.Name
|| card.Id.ToString() == getName //|| 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); returnValue.Add(card);
} }
...@@ -421,14 +473,13 @@ namespace YGOSharp ...@@ -421,14 +473,13 @@ namespace YGOSharp
} }
if (stack.Count != 1 || stack.Pop() == 0) if (stack.Count != 1 || stack.Pop() == 0)
return false; return false;
return return card.Id == (int)TwoNameCards.CARD_MARINE_DOLPHIN
card.Id == (int)TwoNameCards.CARD_MARINE_DOLPHIN || card.Id == (int)TwoNameCards.CARD_TWINKLE_MOSS
|| || (
card.Id == (int)TwoNameCards.CARD_TWINKLE_MOSS !(card.Alias != 0)
|| && ((card.Type & ((int)CardType.Monster + (int)CardType.Token)))
(!(card.Alias != 0) != ((int)CardType.Monster + (int)CardType.Token)
&& ((card.Type & ((int)CardType.Monster + (int)CardType.Token))) );
!= ((int)CardType.Monster + (int)CardType.Token));
} }
public static bool IfSetCard(int setCodeToAnalyse, long setCodeFromCard) public static bool IfSetCard(int setCodeToAnalyse, long setCodeFromCard)
...@@ -551,14 +602,13 @@ namespace YGOSharp ...@@ -551,14 +602,13 @@ namespace YGOSharp
return a; return a;
}; };
} }
} }
internal static class PacksManager internal static class PacksManager
{ {
public class packName public class packName
{ {
public string fullName; public string fullName;
public string shortName; public string shortName;
public int year; public int year;
public int month; public int month;
...@@ -571,10 +621,16 @@ namespace YGOSharp ...@@ -571,10 +621,16 @@ namespace YGOSharp
internal static void initialize(string databaseFullPath) internal static void initialize(string databaseFullPath)
{ {
using (SqliteConnection connection = new SqliteConnection("Data Source=" + databaseFullPath)) using (
SqliteConnection connection = new SqliteConnection(
"Data Source=" + databaseFullPath
)
)
{ {
connection.Open(); 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()) using (IDataReader reader = command.ExecuteReader())
{ {
...@@ -592,7 +648,10 @@ namespace YGOSharp ...@@ -592,7 +648,10 @@ namespace YGOSharp
if (mats.Length > 1) if (mats.Length > 1)
c.packShortNam = mats[0]; c.packShortNam = mats[0];
else 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); c.reality = reader.GetString(3);
temp = reader.GetString(4); temp = reader.GetString(4);
mats = temp.Split("/"); mats = temp.Split("/");
...@@ -609,8 +668,15 @@ namespace YGOSharp ...@@ -609,8 +668,15 @@ namespace YGOSharp
c.month = int.Parse(mats[1]); c.month = int.Parse(mats[1]);
c.day = int.Parse(mats[2]); c.day = int.Parse(mats[2]);
} }
c.packFullName = c.year + "-" + c.month.ToString().PadLeft(2, '0') + "-" + c.day.ToString().PadLeft(2, '0') + " " + c.packShortNam; c.packFullName =
if (!pacDic.ContainsKey(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); pacDic.Add(c.packFullName, c.packShortNam);
packName p = new packName(); packName p = new packName();
...@@ -623,10 +689,7 @@ namespace YGOSharp ...@@ -623,10 +689,7 @@ namespace YGOSharp
} }
} }
} }
catch (Exception) catch (Exception) { }
{
}
} }
} }
} }
...@@ -635,34 +698,36 @@ namespace YGOSharp ...@@ -635,34 +698,36 @@ namespace YGOSharp
internal static void initializeSec() internal static void initializeSec()
{ {
packs.Sort((left, right) => { packs.Sort(
if (left.year > right.year) (left, right) =>
{
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)
{ {
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;
} }
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