Commit 68130274 authored by hex's avatar hex

fix and optimized

parent 7be44462
Pipeline #39619 failed
......@@ -15,11 +15,11 @@ public class OpenCardOnClick : MonoBehaviour
return;
}
int code = int.Parse(s);
((CardDescription)(Program.I().cardDescription)).setData(YGOSharp.CardsManager.Get(code), GameTextureManager.myBack,"",true);
((CardDescription)(Program.I().cardDescription)).setData(YGOSharp.CardsManager.Get(code), GameTextureManager.myBack, "", true);
}
catch (System.Exception e)
{
Debug.Log(e);
// Debug.Log(e);
}
}
}
......
using UnityEngine;
using System.Collections;
using System.Collections;
using System.IO;
using UnityEngine;
public class barPngLoader : MonoBehaviour {
public class barPngLoader : MonoBehaviour
{
public UITexture under;
public UIPanel healthBarCC;
public UIPanel timeBarCC;
public UIPanel faceCC;
public UIPanel faceCC;
public UITexture api_healthBar;
public UITexture api_timeBar;
public UITexture api_face;
......@@ -14,7 +15,8 @@ public class barPngLoader : MonoBehaviour {
public UILabel api_timeHint;
public UILabel api_healthHint;
// Use this for initialization
void Start () {
void Start()
{
under.mainTexture = GameTextureManager.bar;
api_healthBar.mainTexture = GameTextureManager.lp;
api_timeBar.mainTexture = GameTextureManager.time;
......@@ -62,7 +64,7 @@ public class barPngLoader : MonoBehaviour {
api_name.height = int.Parse(mats[1]);
break;
case "playerNameLable.color":
ColorUtility.TryParseHtmlString(mats[1],out c);
ColorUtility.TryParseHtmlString(mats[1], out c);
api_name.color = c;
api_name.gradientTop = api_name.color;
break;
......@@ -243,14 +245,15 @@ public class barPngLoader : MonoBehaviour {
}
}
}
catch (System.Exception e)
catch (System.Exception e)
{
Debug.LogError(e);
// Debug.LogError(e);
}
}
// Update is called once per frame
void Update () {
}
// Update is called once per frame
void Update()
{
}
}
This diff is collapsed.
......@@ -65,9 +65,9 @@ public class Menu : WindowServantSP
}
}
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
}
}
......@@ -231,9 +231,9 @@ public class Menu : WindowServantSP
File.Create("commamd.shell").Close();
}
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
}
string all = "";
try
......@@ -291,9 +291,9 @@ public class Menu : WindowServantSP
}
}
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
try
{
......@@ -305,9 +305,9 @@ public class Menu : WindowServantSP
}
}
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
}
}
}
......
......@@ -96,7 +96,7 @@ public static class TcpHelper
}
catch (System.Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
Monitor.Exit(datas);
}
......@@ -224,7 +224,7 @@ public static class TcpHelper
}
catch (Exception e)
{
Debug.LogWarning("Socket cleanup failed: " + e.Message);
// Debug.LogWarning("Socket cleanup failed: " + e.Message);
}
tcpClient = null;
......@@ -475,16 +475,16 @@ public static class TcpHelper
public static List<Package> readPackagesInRecord(string path)
{
UnityEngine.Debug.Log(path);
// UnityEngine.Debug.Log(path);
List<Package> re = null;
try
{
re = getPackages(File.ReadAllBytes(path));
}
catch (System.Exception e)
catch (Exception e)
{
re = new List<Package>();
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
}
return re;
}
......@@ -506,9 +506,9 @@ public static class TcpHelper
}
}
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
return re;
}
......@@ -542,7 +542,7 @@ public static class TcpHelper
}
catch (Exception e)
{
Debug.Log(e);
// Debug.Log(e);
}
}
if (write)
......@@ -570,7 +570,7 @@ public static class TcpHelper
}
catch (Exception e)
{
Debug.Log(e);
// Debug.Log(e);
}
}
......@@ -665,9 +665,9 @@ public static class BinaryExtensions
result[unicode.Length + 1] = 0;
writer.Write(result);
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
}
......@@ -898,86 +898,12 @@ public class SocketMaster
}
}
// public class TcpClientWithTimeout
// {
// protected string _hostname;
// protected int _port;
// protected int _timeout_milliseconds;
// protected TcpClient connection;
// protected bool connected;
// protected Exception exception;
// public TcpClientWithTimeout(string hostname, int port, int timeout_milliseconds)
// {
// _hostname = hostname;
// _port = port;
// _timeout_milliseconds = timeout_milliseconds;
// }
// public TcpClient Connect()
// {
// // kick off the thread that tries to connect
// connected = false;
// exception = null;
// Thread thread = new Thread(new ThreadStart(BeginConnect));
// thread.IsBackground = true; // 作为后台线程处理
// // 不会占用机器太长的时间
// thread.Start();
// // 等待如下的时间
// thread.Join(_timeout_milliseconds);
// if (connected == true)
// {
// // 如果成功就返回TcpClient对象
// thread.Abort();
// return connection;
// }
// if (exception != null)
// {
// // 如果失败就抛出错误
// thread.Abort();
// TcpHelper.onDisConnected = true;
// Program.DEBUGLOG("onDisConnected 7");
// throw exception;
// }
// else
// {
// // 同样地抛出错误
// thread.Abort();
// string message = string.Format(
// "TcpClient connection to {0}:{1} timed out",
// _hostname,
// _port
// );
// TcpHelper.onDisConnected = true;
// Program.DEBUGLOG("onDisConnected 8");
// throw new TimeoutException(message);
// }
// }
// protected void BeginConnect()
// {
// try
// {
// connection = new TcpClient(_hostname, _port);
// // 标记成功,返回调用者
// connected = true;
// }
// catch (Exception ex)
// {
// // 标记失败
// exception = ex;
// }
// }
// }
public class TcpClientWithTimeout
{
protected string _hostname;
protected int _port;
protected int _timeout_milliseconds;
// --- State variables ---
protected TcpClient connection;
protected bool connected;
......@@ -986,7 +912,7 @@ public class TcpClientWithTimeout
// --- Cooperative Cancellation Flag ---
// Use 'volatile' to ensure the latest value is read across threads.
private volatile bool _isCancelled = false;
public TcpClientWithTimeout(string hostname, int port, int timeout_milliseconds)
{
_hostname = hostname;
......@@ -999,7 +925,7 @@ public class TcpClientWithTimeout
connected = false;
exception = null;
_isCancelled = false;
Thread thread = new Thread(new ThreadStart(BeginConnect));
thread.IsBackground = true;
thread.Start();
......@@ -1023,16 +949,11 @@ public class TcpClientWithTimeout
{
// The thread did NOT finish in time (timeout occurred).
// This is where we AVOID Thread.Abort()
// 1. Signal the thread to cancel itself.
_isCancelled = true;
// 2. The background thread still exists and is trying to connect.
// If we just throw a TimeoutException, the background thread
// might eventually connect and leave a lingering, unused socket.
// The best we can do is "let it go" and let the garbage collector
// clean it up eventually since it's a background thread.
string message = string.Format("TcpClient connection to {0}:{1} timed out", _hostname, _port);
throw new TimeoutException(message);
}
......@@ -1052,11 +973,11 @@ public class TcpClientWithTimeout
client.Close(); // Clean up the partially created client.
return; // Exit gracefully.
}
// Now, use the async pattern available even in older .NET to check for cancellation
// while connecting. This gives us a chance to abort more cleanly.
IAsyncResult result = client.BeginConnect(_hostname, _port, null, null);
// Wait for the connection to complete OR for the main thread to signal a timeout.
WaitHandle handle = result.AsyncWaitHandle;
if (handle.WaitOne(_timeout_milliseconds))
......@@ -1068,7 +989,7 @@ public class TcpClientWithTimeout
client.Close();
return;
}
// Finalize the connection. This will re-throw any connection exception.
client.EndConnect(result);
connection = client;
......@@ -1076,9 +997,6 @@ public class TcpClientWithTimeout
}
else
{
// This 'else' block inside BeginConnect will rarely be hit because the
// main thread's Join timeout is usually what triggers first. But it's
// good practice for robustness.
client.Close();
if (!_isCancelled) // If it wasn't the main thread that timed out
{
......@@ -1088,8 +1006,6 @@ public class TcpClientWithTimeout
}
catch (Exception ex)
{
// A real connection error occurred (e.g., host not found, connection refused).
// Store the exception so the main thread can throw it.
exception = ex;
}
}
......
......@@ -805,7 +805,7 @@ public static class UIHelper
}
catch (Exception e)
{
Debug.Log(e);
// Debug.Log(e);
}
}
}
......@@ -814,7 +814,7 @@ public static class UIHelper
}
catch (Exception e)
{
Debug.Log(e);
// Debug.Log(e);
}
}
......@@ -859,7 +859,7 @@ public static class UIHelper
}
catch (Exception e)
{
Debug.Log(e);
// Debug.Log(e);
}
return pic;
}
......
......@@ -178,7 +178,7 @@ public class gameCard : OCGobject
}
catch (System.Exception e)
{
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
}
gameObject.SetActive(false);
}
......@@ -226,7 +226,7 @@ public class gameCard : OCGobject
}
catch (System.Exception e)
{
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
}
}
}
......@@ -969,7 +969,7 @@ public class gameCard : OCGobject
}
catch (System.Exception e)
{
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
}
destroy(game_object_monster_cloude);
destroy(game_object_verticle_drawing);
......@@ -996,7 +996,7 @@ public class gameCard : OCGobject
}
catch (System.Exception e)
{
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
}
destroy(game_object_monster_cloude);
destroy(game_object_verticle_drawing);
......@@ -1022,7 +1022,7 @@ public class gameCard : OCGobject
}
catch (System.Exception e)
{
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
}
loaded_verticalDrawingCode = 0;
loaded_verticalDrawingNumber = -1;
......@@ -1719,7 +1719,7 @@ public class gameCard : OCGobject
}
catch (System.Exception e)
{
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
}
}
int special_hint = 0;
......@@ -2377,7 +2377,7 @@ public class gameCard : OCGobject
{
return;
}
show_off_disabled = disabled;
show_off_begin_time = Program.TimePassed();
show_off_shokewave = summon;
......
......@@ -587,9 +587,9 @@ public class Ocgcore : ServantWithCardDescription
{
logicalizeMessage(Packages_ALL[i]);
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
if (needSwap)
{
......@@ -599,9 +599,9 @@ public class Ocgcore : ServantWithCardDescription
{
practicalizeMessage(Packages_ALL[i]);
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
clearResponse();
}
......@@ -612,9 +612,9 @@ public class Ocgcore : ServantWithCardDescription
{
logicalizeMessage(Packages_ALL[i]);
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
}
}
......@@ -652,7 +652,7 @@ public class Ocgcore : ServantWithCardDescription
}
catch (Exception e)
{
Debug.Log(e);
// Debug.Log(e);
}
}
......@@ -672,17 +672,17 @@ public class Ocgcore : ServantWithCardDescription
{
logicalizeMessage(currentPackage);
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
try
{
practicalizeMessage(currentPackage);
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
Packages.Dequeue();
}
......@@ -702,9 +702,9 @@ public class Ocgcore : ServantWithCardDescription
{
logicalizeMessage(currentPackage);
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
if (Packages.Count == 1)
{
......@@ -714,9 +714,9 @@ public class Ocgcore : ServantWithCardDescription
realize();
toNearest();
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
}
Packages.Dequeue();
......@@ -1070,17 +1070,17 @@ public class Ocgcore : ServantWithCardDescription
{
logicalizeMessage(currentPackage);
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
try
{
practicalizeMessage(currentPackage);
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
Packages.Dequeue();
}
......@@ -1099,9 +1099,9 @@ public class Ocgcore : ServantWithCardDescription
}
}
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
}
......@@ -1655,9 +1655,9 @@ public class Ocgcore : ServantWithCardDescription
r.BaseStream.Position = pos + len - 4;
}
}
catch (System.Exception e)
catch (Exception e)
{
// UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
break;
case GameMessage.UpdateCard:
......@@ -3010,7 +3010,7 @@ public class Ocgcore : ServantWithCardDescription
showCaculator();
break;
case GameMessage.Retry:
Debug.Log("Retry");
// Debug.Log("Retry");
break;
//case GameMessage.sibyl_delay:
// if (inIgnoranceReplay())
......@@ -6252,9 +6252,9 @@ public class Ocgcore : ServantWithCardDescription
cardsInSelectAnimation[i].del_all_decoration_by_string("selected");
cardsInSelectAnimation[i].currentKuang = gameCard.kuangType.none;
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
}
cardsInSelectAnimation.Clear();
......@@ -7975,7 +7975,6 @@ public class Ocgcore : ServantWithCardDescription
{
if (my_p_cards.Count == 2)
{
Debug.Log("oh");
gameField
.me_left_p_num.GetComponent<number_loader>()
.set_number((int)my_p_cards[0].get_data().LScale, 3);
......@@ -8296,7 +8295,6 @@ public class Ocgcore : ServantWithCardDescription
{
gameInfo.removeHashedButton("swap");
}
animation_count(gameField.LOCATION_DECK_0, CardLocation.Deck, 0);
animation_count(gameField.LOCATION_EXTRA_0, CardLocation.Extra, 0);
animation_count(gameField.LOCATION_GRAVE_0, CardLocation.Grave, 0);
......@@ -8751,9 +8749,9 @@ public class Ocgcore : ServantWithCardDescription
}
}
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
//to card
......@@ -9778,9 +9776,9 @@ public class Ocgcore : ServantWithCardDescription
binaryMaster.writer.Write(Int32.Parse(result[0].value));
sendReturn(binaryMaster.get());
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
}
break;
......@@ -9811,9 +9809,9 @@ public class Ocgcore : ServantWithCardDescription
binaryMaster.writer.Write(answer >= 0 ? answer : 0);
sendReturn(binaryMaster.get());
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
}
if (result[0].value == "no")
......@@ -9831,9 +9829,9 @@ public class Ocgcore : ServantWithCardDescription
{
res |= UInt32.Parse(item.value);
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
}
binaryMaster.writer.Write(res);
......@@ -9922,7 +9920,7 @@ public class Ocgcore : ServantWithCardDescription
}
catch (Exception e)
{
Debug.Log(e);
// Debug.Log(e);
}
}
break;
......
......@@ -169,9 +169,9 @@ public class Program : MonoBehaviour
obj.SetActive(false);
allObjects.Add(obj);
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
}
}
......@@ -672,9 +672,9 @@ public class Program : MonoBehaviour
Resources.UnloadUnusedAssets();
GC.Collect();
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
}
}
}
......@@ -977,9 +977,9 @@ public class Program : MonoBehaviour
}
}
}
catch (System.Exception e)
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// Debug.Log(e);
}
}
......@@ -1413,7 +1413,7 @@ public class Program : MonoBehaviour
}
catch (Exception e)
{
Debug.Log(e);
// Debug.Log(e);
}
processedTasks++;
break;
......@@ -1521,9 +1521,9 @@ public class Program : MonoBehaviour
{
TcpHelper.tcpClient.Close();
}
catch (System.Exception e)
catch (Exception e)
{
//adeUnityEngine.Debug.Log(e);
// Debug.Log(e);
}
Menu.deleteShell();
}
......
......@@ -214,7 +214,7 @@ public class GameTextureManager
}
catch (Exception e)
{
Debug.LogWarning("Get card type failed for code " + resourceToProcess.code + ": " + e.Message);
// Debug.LogWarning("Get card type failed for code " + resourceToProcess.code + ": " + e.Message);
}
ProcessResourceRequest(resourceToProcess);
......
......@@ -962,7 +962,7 @@ public class Servant
{
url = inputUrl.value;
}
Debug.Log("开始异步下载头像: " + url);
// Debug.Log("开始异步下载头像: " + url);
// [核心修改] 使用我们新的、异步的 UnityFileDownloader
// 启动一个协程来执行异步下载任务
Program
......@@ -976,7 +976,7 @@ public class Servant
// 这个部分是回调函数,只会在下载完成后执行
if (success)
{
Debug.Log("头像下载成功,路径: " + facePath);
// Debug.Log("头像下载成功,路径: " + facePath);
Program.PrintToChat("头像下载成功!");
// 将原来同步执行的刷新逻辑移动到这里
// 确保文件确实存在并且已经被下载完毕
......
......@@ -136,7 +136,7 @@ public class Setting : WindowServant2D
}
catch (Exception e)
{
Debug.Log(e);
// Debug.Log(e);
}
}
......
......@@ -444,7 +444,7 @@ public class DeckManager : ServantWithCardDescription
}
catch (Exception e)
{
Debug.Log(e);
// Debug.Log(e);
}
}
deckDirty = true;
......@@ -2087,7 +2087,7 @@ public class DeckManager : ServantWithCardDescription
}
catch (System.Exception e)
{
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
}
}
......@@ -2304,7 +2304,7 @@ public class DeckManager : ServantWithCardDescription
}
catch (System.Exception e)
{
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
}
if (side)
{
......@@ -2338,7 +2338,7 @@ public class DeckManager : ServantWithCardDescription
else
{
UIInput_search.value = "";
UIInput_search.isSelected = true;
UIInput_search.isSelected = false;
}
}
}
......@@ -154,7 +154,7 @@ public class selectReplay : WindowServantSP
}
catch (Exception e)
{
Debug.Log(e);
// Debug.Log(e);
}
// Debug.Log(returnValue);
return returnValue;
......@@ -264,7 +264,7 @@ public class selectReplay : WindowServantSP
}
catch (Exception e)
{
Debug.Log(e);
// Debug.Log(e);
}
return returnValue;
}
......@@ -310,7 +310,7 @@ public class selectReplay : WindowServantSP
}
catch (Exception e)
{
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
RMSshow_none(InterString.Get("录像没有录制完整。"));
}
}
......
......@@ -33,24 +33,29 @@ namespace YGOSharp
continue;
if (current == null)
continue;
string[] data = line.Split(new char[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
string[] data = line.Split(new char[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
int id = int.Parse(data[0]);
int count = int.Parse(data[1]);
current.Add(id, count);
}
catch (System.Exception e)
catch (System.Exception e)
{
success = false;
UnityEngine.Debug.Log(line);
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(line);
// UnityEngine.Debug.Log(e);
}
}
reader.Close();
if(!test) {
if (Banlists == null) {
if (!test)
{
if (Banlists == null)
{
Banlists = new_list;
} else {
foreach (var item in new_list) {
}
else
{
foreach (var item in new_list)
{
Banlists.Add(item);
}
}
......@@ -58,7 +63,8 @@ namespace YGOSharp
return (success && new_list.Count > 1);
}
public static void initializeComplete() {
public static void initializeComplete()
{
Banlist blank = new Banlist();
blank.Name = "N/A";
Banlists.Add(blank);
......@@ -71,7 +77,7 @@ namespace YGOSharp
return 0;
}
public static string GetName(uint hash)
public static string GetName(uint hash)
{
for (int i = 0; i < Banlists.Count; i++)
if (Banlists[i].Hash == hash)
......
......@@ -109,7 +109,7 @@ namespace YGOSharp
}
catch (System.Exception e)
{
UnityEngine.Debug.Log(e);
// UnityEngine.Debug.Log(e);
}
}
......
......@@ -4,6 +4,7 @@
"com.unity.2d.tilemap": "1.0.0",
"com.unity.analytics": "3.6.12",
"com.unity.burst": "1.8.18",
"com.unity.ide.vscode": "1.2.5",
"com.unity.postprocessing": "3.4.0",
"com.unity.test-framework": "1.1.33",
"com.unity.timeline": "1.6.5",
......
......@@ -38,6 +38,13 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.ide.vscode": {
"version": "1.2.5",
"depth": 0,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.mathematics": {
"version": "1.2.6",
"depth": 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