Commit 68130274 authored by hex's avatar hex

fix and optimized

parent 7be44462
Pipeline #39619 failed
...@@ -15,11 +15,11 @@ public class OpenCardOnClick : MonoBehaviour ...@@ -15,11 +15,11 @@ public class OpenCardOnClick : MonoBehaviour
return; return;
} }
int code = int.Parse(s); 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) catch (System.Exception e)
{ {
Debug.Log(e); // Debug.Log(e);
} }
} }
} }
......
using UnityEngine; using System.Collections;
using System.Collections;
using System.IO; using System.IO;
using UnityEngine;
public class barPngLoader : MonoBehaviour { public class barPngLoader : MonoBehaviour
{
public UITexture under; public UITexture under;
public UIPanel healthBarCC; public UIPanel healthBarCC;
public UIPanel timeBarCC; public UIPanel timeBarCC;
...@@ -14,7 +15,8 @@ public class barPngLoader : MonoBehaviour { ...@@ -14,7 +15,8 @@ public class barPngLoader : MonoBehaviour {
public UILabel api_timeHint; public UILabel api_timeHint;
public UILabel api_healthHint; public UILabel api_healthHint;
// Use this for initialization // Use this for initialization
void Start () { void Start()
{
under.mainTexture = GameTextureManager.bar; under.mainTexture = GameTextureManager.bar;
api_healthBar.mainTexture = GameTextureManager.lp; api_healthBar.mainTexture = GameTextureManager.lp;
api_timeBar.mainTexture = GameTextureManager.time; api_timeBar.mainTexture = GameTextureManager.time;
...@@ -62,7 +64,7 @@ public class barPngLoader : MonoBehaviour { ...@@ -62,7 +64,7 @@ public class barPngLoader : MonoBehaviour {
api_name.height = int.Parse(mats[1]); api_name.height = int.Parse(mats[1]);
break; break;
case "playerNameLable.color": case "playerNameLable.color":
ColorUtility.TryParseHtmlString(mats[1],out c); ColorUtility.TryParseHtmlString(mats[1], out c);
api_name.color = c; api_name.color = c;
api_name.gradientTop = api_name.color; api_name.gradientTop = api_name.color;
break; break;
...@@ -245,12 +247,13 @@ public class barPngLoader : MonoBehaviour { ...@@ -245,12 +247,13 @@ public class barPngLoader : MonoBehaviour {
} }
catch (System.Exception e) catch (System.Exception e)
{ {
Debug.LogError(e); // Debug.LogError(e);
} }
} }
// Update is called once per frame // Update is called once per frame
void Update () { void Update()
{
} }
} }
// using System; using System;
// using System.Collections.Generic;
// using DG.Tweening;
// using UnityEngine;
// public class gameUIbutton
// {
// public string hashString;
// public GameObject gameObject;
// public int response;
// public bool dying;
// public bool dead;
// }
// public class gameInfo : MonoBehaviour
// {
// public UITexture instance_btnPan;
// public UITextList instance_lab;
// public UIToggle toggle_ignore;
// public UIToggle toggle_all;
// public UIToggle toggle_smart;
// public GameObject line;
// public void on_toggle_ignore()
// {
// toggle_all.value = false;
// toggle_smart.value = false;
// }
// public void on_toggle_all()
// {
// toggle_ignore.value = false;
// toggle_smart.value = false;
// }
// public void on_toggle_smart()
// {
// toggle_ignore.value = false;
// toggle_all.value = false;
// }
// //public UITextList hinter;
// barPngLoader me;
// barPngLoader opponent;
// public GameObject mod_healthBar;
// public float width = 0;
// int lastTickTime = 0;
// // Use this for initialization
// void Start()
// {
// ini();
// }
// public void ini()
// {
// Update();
// }
// public bool swaped = false;
// void Update()
// {
// if (me == null || opponent == null)
// {
// me = ((GameObject)MonoBehaviour.Instantiate(mod_healthBar, new Vector3(1000, 0, 0), Quaternion.identity)).GetComponent<barPngLoader>();
// me.transform.SetParent(gameObject.transform);
// opponent = ((GameObject)MonoBehaviour.Instantiate(mod_healthBar, new Vector3(1000, 0, 0), Quaternion.identity)).GetComponent<barPngLoader>();
// opponent.transform.SetParent(gameObject.transform);
// Transform[] Transforms = me.GetComponentsInChildren<Transform>();
// foreach (Transform child in Transforms)
// {
// child.gameObject.layer = gameObject.layer;
// }
// Transforms = opponent.GetComponentsInChildren<Transform>();
// foreach (Transform child in Transforms)
// {
// child.gameObject.layer = gameObject.layer;
// }
// Color c;
// ColorUtility.TryParseHtmlString(Config.Getui("gameChainCheckArea.color"), out c);
// UIHelper.getByName<UISprite>(UIHelper.getByName<UIToggle>(gameObject, "ignore_").gameObject, "Background").color = c;
// UIHelper.getByName<UISprite>(UIHelper.getByName<UIToggle>(gameObject, "watch_").gameObject, "Background").color = c;
// UIHelper.getByName<UISprite>(UIHelper.getByName<UIToggle>(gameObject, "use_").gameObject, "Background").color = c;
// }
// // float k = ((float)(Screen.width - Program.I().cardDescription.width)) / 1200f;
// // if (k > 1.2f)
// // {
// // k = 1.2f;
// // }
// // if (k < 0.8f)
// // {
// // k = 0.8f;
// // }
// float k = (global::System.Object)Screen.width switch
// {
// 1366 => 0.8f,
// 1600 => 0.9f,
// 1920 => 1.2f,
// 2560 => 1.5f,
// _ => 1,
// };
// Vector3 ks = new Vector3(k, k, k);
// // float kb = ((float)(Screen.width - Program.I().cardDescription.width)) / 1200f;
// // Debug.Log("kb:" + kb);
// // if (kb > 1.2f)
// // {
// // kb = 1.2f;
// // }
// // if (kb < 0.73f)
// // {
// // kb = 0.73f;
// // }
// float kb = (global::System.Object)Screen.width switch
// {
// 1366 => 0.8f,
// 1600 => 0.9f,
// 1920 => 1.1f,
// 2560 => 1.4f,
// _ => 1,
// };
// Vector3 ksb = new Vector3(kb, kb, kb);
// instance_btnPan.gameObject.transform.localScale = ksb;
// opponent.transform.localScale = ks;
// me.transform.localScale = ks;
// if (!swaped)
// {
// opponent.transform.localPosition = new Vector3(Screen.width / 2 - 14, Screen.height / 2 - 14);
// me.transform.localPosition = new Vector3(Screen.width / 2 - 14, Screen.height / 2 - 14 - k * (float)(opponent.under.height));
// }
// else
// {
// me.transform.localPosition = new Vector3(Screen.width / 2 - 14, Screen.height / 2 - 14);
// opponent.transform.localPosition = new Vector3(Screen.width / 2 - 14, Screen.height / 2 - 14 - k * (float)(opponent.under.height));
// }
// width = (225 * kb) + 15f;
// float localPositionPanX = (((float)Screen.width - 225 * kb) / 2) - 15f;
// instance_btnPan.transform.localPosition = new Vector3(localPositionPanX, 120, 0);
// instance_lab.transform.localPosition = new Vector3(Screen.width / 2 - 315, -Screen.height / 2 + 90 + Screen.safeArea.y, 0);
// int j = 0;
// for (int i = 0; i < HashedButtons.Count; i++)
// {
// if (HashedButtons[i].gameObject != null)
// {
// if (HashedButtons[i].dying)
// {
// HashedButtons[i].gameObject.transform.localPosition += (new Vector3(0, -120, 0) - HashedButtons[i].gameObject.transform.localPosition) * Program.deltaTime * 20f;
// if (Math.Abs(HashedButtons[i].gameObject.transform.localPosition.y - -120) < 1)
// HashedButtons[i].dead = true;
// }
// else
// {
// HashedButtons[i].gameObject.transform.localPosition += (new Vector3(0, -220 - j * 75, 0) - HashedButtons[i].gameObject.transform.localPosition) * Program.deltaTime * 10f;
// j++;
// }
// }
// else
// HashedButtons[i].dead = true;
// }
// for (int i = HashedButtons.Count - 1; i >= 0; i--)
// {
// if (HashedButtons[i].dead)
// HashedButtons.RemoveAt(i);
// }
// float height = 198 + 75 * j;
// if (j == 0)
// {
// height = 174;
// }
// instance_btnPan.height += (int)(((float)height - (float)instance_btnPan.height) * 0.2f);
// if (Program.TimePassed() - lastTickTime > 1000)
// {
// lastTickTime = Program.TimePassed();
// tick();
// }
// }
// List<gameUIbutton> HashedButtons = new List<gameUIbutton>();
// public void addHashedButton(string hashString_, int hashInt, superButtonType type, string hint)
// {
// gameUIbutton hashedButton = new gameUIbutton();
// string hashString = hashString_;
// if (hashString == "")
// {
// hashString = hashInt.ToString();
// }
// hashedButton.hashString = hashString;
// hashedButton.response = hashInt;
// hashedButton.gameObject = Program.I().create(Program.I().new_ui_superButtonTransparent);
// UIHelper.trySetLableText(hashedButton.gameObject, "hint_", hint);
// UIHelper.getRealEventGameObject(hashedButton.gameObject).name = hashString + "----" + hashInt.ToString();
// UIHelper.registUIEventTriggerForClick(hashedButton.gameObject, listenerForClicked);
// hashedButton.gameObject.GetComponent<iconSetForButton>().setTexture(type);
// hashedButton.gameObject.GetComponent<iconSetForButton>().setText(hint);
// Transform[] Transforms = hashedButton.gameObject.GetComponentsInChildren<Transform>();
// foreach (Transform child in Transforms)
// {
// child.gameObject.layer = instance_btnPan.gameObject.layer;
// }
// hashedButton.gameObject.transform.SetParent(instance_btnPan.transform, false);
// hashedButton.gameObject.transform.localScale = Vector3.zero;
// hashedButton.gameObject.transform.localPosition = new Vector3(0, -120, 0);
// hashedButton.gameObject.transform.localEulerAngles = Vector3.zero;
// hashedButton.gameObject.transform.DOScale(new Vector3(0.9f, 0.9f, 0.9f), 0.3f);
// hashedButton.dying = false;
// HashedButtons.Add(hashedButton);
// refreshLine();
// }
// void listenerForClicked(GameObject obj)
// {
// string[] mats = obj.name.Split("----");
// if (mats.Length == 2)
// {
// for (int i = 0; i < HashedButtons.Count; i++)
// {
// if (HashedButtons[i].hashString == mats[0])
// {
// if (HashedButtons[i].response.ToString() == mats[1])
// {
// Program.I().ocgcore.ES_gameUIbuttonClicked(HashedButtons[i]);
// }
// }
// }
// }
// }
// public bool queryHashedButton(string hashString)
// {
// for (int i = 0; i < HashedButtons.Count; i++)
// {
// if (HashedButtons[i].hashString == hashString && !HashedButtons[i].dying)
// {
// return true;
// }
// }
// return false;
// }
// public void removeHashedButton(string hashString)
// {
// gameUIbutton remove = null;
// for (int i = 0; i < HashedButtons.Count; i++)
// {
// if (HashedButtons[i].hashString == hashString)
// {
// remove = HashedButtons[i];
// }
// }
// if (remove != null)
// {
// if (remove.gameObject != null)
// {
// Program.I().destroy(remove.gameObject, 0.3f, true);
// }
// remove.dying = true;
// }
// refreshLine();
// }
// public void removeAll()
// {
// if (HashedButtons.Count == 1)
// {
// if (HashedButtons[0].hashString == "swap")
// {
// return;
// }
// }
// for (int i = 0; i < HashedButtons.Count; i++)
// {
// if (HashedButtons[i].gameObject != null)
// {
// Program.I().destroy(HashedButtons[i].gameObject, 0.3f, true);
// }
// HashedButtons[i].dying = true;
// }
// refreshLine();
// }
// void refreshLine()
// {
// int j = 0;
// for (int i = 0; i < HashedButtons.Count; i++)
// {
// if (!HashedButtons[i].dying)
// {
// j++;
// }
// }
// line.SetActive(j > 0);
// }
// int[] time = new int[2];
// bool[] isTicking = new bool[2];
// public void setTime(int player, int t)
// {
// if (player < 2)
// {
// time[player] = t;
// setTimeAbsolutely(player, t);
// isTicking[player] = true;
// isTicking[1 - player] = false;
// }
// }
// public void setExcited(int player)
// {
// if (player == 0)
// {
// me.under.mainTexture = GameTextureManager.exBar;
// opponent.under.mainTexture = GameTextureManager.bar;
// }
// else
// {
// opponent.under.mainTexture = GameTextureManager.exBar;
// me.under.mainTexture = GameTextureManager.bar;
// }
// }
// public void setTimeStill(int player)
// {
// time[0] = Program.I().ocgcore.timeLimit;
// time[1] = Program.I().ocgcore.timeLimit;
// setTimeAbsolutely(0, Program.I().ocgcore.timeLimit);
// setTimeAbsolutely(1, Program.I().ocgcore.timeLimit);
// isTicking[0] = false;
// isTicking[1] = false;
// if (player == 0)
// {
// me.under.mainTexture = GameTextureManager.exBar;
// opponent.under.mainTexture = GameTextureManager.bar;
// }
// else
// {
// opponent.under.mainTexture = GameTextureManager.exBar;
// me.under.mainTexture = GameTextureManager.bar;
// }
// if (Program.I().ocgcore.timeLimit == 0)
// {
// me.api_timeHint.text = "infinite";
// opponent.api_timeHint.text = "infinite";
// }
// else
// {
// me.api_timeHint.text = "paused";
// opponent.api_timeHint.text = "paused";
// }
// }
// public bool amIdanger()
// {
// return time[0] < Program.I().ocgcore.timeLimit / 3;
// }
// void setTimeAbsolutely(int player, int t)
// {
// if (Program.I().ocgcore.timeLimit == 0)
// {
// return;
// }
// if (player == 0)
// {
// me.api_timeHint.text = t.ToString() + "/" + Program.I().ocgcore.timeLimit.ToString();
// opponent.api_timeHint.text = "waiting";
// me.api_timeBar.transform.DOKill();
// me.api_timeBar.transform.DOLocalMoveX((float)(me.api_timeBar.width) - (float)t / (float)Program.I().ocgcore.timeLimit * (float)(me.api_timeBar.width), 1f);
// }
// if (player == 1)
// {
// opponent.api_timeHint.text = t.ToString() + "/" + Program.I().ocgcore.timeLimit.ToString();
// me.api_timeHint.text = "waiting";
// opponent.api_timeBar.transform.DOKill();
// opponent.api_timeBar.transform.DOLocalMoveX((float)(opponent.api_timeBar.width) - (float)t / (float)Program.I().ocgcore.timeLimit * (float)(opponent.api_timeBar.width), 1f);
// }
// }
// public void realize()
// {
// me.api_healthHint.text = ((float)Program.I().ocgcore.life_0 > 0 ? Program.I().ocgcore.life_0 : 0).ToString();
// opponent.api_healthHint.text = ((float)Program.I().ocgcore.life_1 > 0 ? Program.I().ocgcore.life_1 : 0).ToString();
// me.api_name.text = Program.I().ocgcore.name_0_c;
// opponent.api_name.text = Program.I().ocgcore.name_1_c;
// me.api_face.mainTexture = UIHelper.getFace(Program.I().ocgcore.name_0_c);
// opponent.api_face.mainTexture = UIHelper.getFace(Program.I().ocgcore.name_1_c);
// // 玩家自己
// // me.api_healthBar.transform.DOKill();
// float myLpTargetX = (float)(me.api_healthBar.width) - getRealLife(Program.I().ocgcore.life_0) / ((float)Program.I().ocgcore.lpLimit) * (float)(me.api_healthBar.width);
// me.api_healthBar.transform.DOLocalMoveX(myLpTargetX, 1f);
// // 对手
// // opponent.api_healthBar.transform.DOKill();
// float opLpTargetX = (float)(opponent.api_healthBar.width) - getRealLife(Program.I().ocgcore.life_1) / ((float)Program.I().ocgcore.lpLimit) * (float)(opponent.api_healthBar.width);
// opponent.api_healthBar.transform.DOLocalMoveX(opLpTargetX, 1f);
// instance_lab.Clear();
// if (Program.I().ocgcore.confirmedCards.Count > 0)
// {
// instance_lab.Add(GameStringHelper.yijingqueren);
// }
// foreach (var item in Program.I().ocgcore.confirmedCards)
// {
// instance_lab.Add(item);
// }
// }
// static float getRealLife(float in_)
// {
// if (in_ < 0)
// {
// return 0;
// }
// if (in_ > Program.I().ocgcore.lpLimit)
// {
// return Program.I().ocgcore.lpLimit;
// }
// return in_;
// }
// void tick()
// {
// if (isTicking[0])
// {
// if (time[0] > 0)
// {
// time[0]--;
// }
// if (amIdanger())
// {
// if (Program.I().ocgcore != null)
// {
// Program.I().ocgcore.dangerTicking();
// }
// }
// setTimeAbsolutely(0, time[0]);
// }
// if (isTicking[1])
// {
// if (time[1] > 0)
// {
// time[1]--;
// }
// setTimeAbsolutely(1, time[1]);
// }
// }
// public enum chainCondition
// {
// standard, no, all, smart
// }
// public void set_condition(chainCondition c)
// {
// switch (c)
// {
// case chainCondition.standard:
// toggle_all.value = false;
// toggle_smart.value = false;
// toggle_ignore.value = false;
// break;
// case chainCondition.no:
// toggle_all.value = false;
// toggle_smart.value = false;
// toggle_ignore.value = true;
// break;
// case chainCondition.all:
// toggle_all.value = true;
// toggle_smart.value = false;
// toggle_ignore.value = false;
// break;
// case chainCondition.smart:
// toggle_all.value = false;
// toggle_smart.value = true;
// toggle_ignore.value = false;
// break;
// }
// }
// public chainCondition get_condition()
// {
// chainCondition res = chainCondition.standard;
// if (toggle_ignore.value)
// {
// res = chainCondition.no;
// }
// if (toggle_smart.value)
// {
// res = chainCondition.smart;
// }
// if (toggle_all.value)
// {
// res = chainCondition.all;
// }
// return res;
// }
// }
using System;
using System.Collections.Generic; using System.Collections.Generic;
using DG.Tweening; using DG.Tweening;
using UnityEngine; using UnityEngine;
...@@ -1202,7 +688,6 @@ public class gameInfo : MonoBehaviour ...@@ -1202,7 +688,6 @@ public class gameInfo : MonoBehaviour
public void set_condition(chainCondition condition) public void set_condition(chainCondition condition)
{ {
ResetAllToggles(); ResetAllToggles();
switch (condition) switch (condition)
{ {
case chainCondition.no: case chainCondition.no:
......
...@@ -65,9 +65,9 @@ public class Menu : WindowServantSP ...@@ -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 ...@@ -231,9 +231,9 @@ public class Menu : WindowServantSP
File.Create("commamd.shell").Close(); File.Create("commamd.shell").Close();
} }
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // UnityEngine.Debug.Log(e);
} }
string all = ""; string all = "";
try try
...@@ -291,9 +291,9 @@ public class Menu : WindowServantSP ...@@ -291,9 +291,9 @@ public class Menu : WindowServantSP
} }
} }
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
try try
{ {
...@@ -305,9 +305,9 @@ public class Menu : WindowServantSP ...@@ -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 ...@@ -96,7 +96,7 @@ public static class TcpHelper
} }
catch (System.Exception e) catch (System.Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
Monitor.Exit(datas); Monitor.Exit(datas);
} }
...@@ -224,7 +224,7 @@ public static class TcpHelper ...@@ -224,7 +224,7 @@ public static class TcpHelper
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogWarning("Socket cleanup failed: " + e.Message); // Debug.LogWarning("Socket cleanup failed: " + e.Message);
} }
tcpClient = null; tcpClient = null;
...@@ -475,16 +475,16 @@ public static class TcpHelper ...@@ -475,16 +475,16 @@ public static class TcpHelper
public static List<Package> readPackagesInRecord(string path) public static List<Package> readPackagesInRecord(string path)
{ {
UnityEngine.Debug.Log(path); // UnityEngine.Debug.Log(path);
List<Package> re = null; List<Package> re = null;
try try
{ {
re = getPackages(File.ReadAllBytes(path)); re = getPackages(File.ReadAllBytes(path));
} }
catch (System.Exception e) catch (Exception e)
{ {
re = new List<Package>(); re = new List<Package>();
UnityEngine.Debug.Log(e); // UnityEngine.Debug.Log(e);
} }
return re; return re;
} }
...@@ -506,9 +506,9 @@ public static class TcpHelper ...@@ -506,9 +506,9 @@ public static class TcpHelper
} }
} }
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
return re; return re;
} }
...@@ -542,7 +542,7 @@ public static class TcpHelper ...@@ -542,7 +542,7 @@ public static class TcpHelper
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Log(e); // Debug.Log(e);
} }
} }
if (write) if (write)
...@@ -570,7 +570,7 @@ public static class TcpHelper ...@@ -570,7 +570,7 @@ public static class TcpHelper
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Log(e); // Debug.Log(e);
} }
} }
...@@ -665,9 +665,9 @@ public static class BinaryExtensions ...@@ -665,9 +665,9 @@ public static class BinaryExtensions
result[unicode.Length + 1] = 0; result[unicode.Length + 1] = 0;
writer.Write(result); writer.Write(result);
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
} }
...@@ -898,80 +898,6 @@ public class SocketMaster ...@@ -898,80 +898,6 @@ 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 public class TcpClientWithTimeout
{ {
protected string _hostname; protected string _hostname;
...@@ -1028,11 +954,6 @@ public class TcpClientWithTimeout ...@@ -1028,11 +954,6 @@ public class TcpClientWithTimeout
_isCancelled = true; _isCancelled = true;
// 2. The background thread still exists and is trying to connect. // 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); string message = string.Format("TcpClient connection to {0}:{1} timed out", _hostname, _port);
throw new TimeoutException(message); throw new TimeoutException(message);
} }
...@@ -1076,9 +997,6 @@ public class TcpClientWithTimeout ...@@ -1076,9 +997,6 @@ public class TcpClientWithTimeout
} }
else 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(); client.Close();
if (!_isCancelled) // If it wasn't the main thread that timed out if (!_isCancelled) // If it wasn't the main thread that timed out
{ {
...@@ -1088,8 +1006,6 @@ public class TcpClientWithTimeout ...@@ -1088,8 +1006,6 @@ public class TcpClientWithTimeout
} }
catch (Exception ex) 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; exception = ex;
} }
} }
......
...@@ -805,7 +805,7 @@ public static class UIHelper ...@@ -805,7 +805,7 @@ public static class UIHelper
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Log(e); // Debug.Log(e);
} }
} }
} }
...@@ -814,7 +814,7 @@ public static class UIHelper ...@@ -814,7 +814,7 @@ public static class UIHelper
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Log(e); // Debug.Log(e);
} }
} }
...@@ -859,7 +859,7 @@ public static class UIHelper ...@@ -859,7 +859,7 @@ public static class UIHelper
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Log(e); // Debug.Log(e);
} }
return pic; return pic;
} }
......
...@@ -178,7 +178,7 @@ public class gameCard : OCGobject ...@@ -178,7 +178,7 @@ public class gameCard : OCGobject
} }
catch (System.Exception e) catch (System.Exception e)
{ {
UnityEngine.Debug.Log(e); // UnityEngine.Debug.Log(e);
} }
gameObject.SetActive(false); gameObject.SetActive(false);
} }
...@@ -226,7 +226,7 @@ public class gameCard : OCGobject ...@@ -226,7 +226,7 @@ public class gameCard : OCGobject
} }
catch (System.Exception e) catch (System.Exception e)
{ {
UnityEngine.Debug.Log(e); // UnityEngine.Debug.Log(e);
} }
} }
} }
...@@ -969,7 +969,7 @@ public class gameCard : OCGobject ...@@ -969,7 +969,7 @@ public class gameCard : OCGobject
} }
catch (System.Exception e) catch (System.Exception e)
{ {
UnityEngine.Debug.Log(e); // UnityEngine.Debug.Log(e);
} }
destroy(game_object_monster_cloude); destroy(game_object_monster_cloude);
destroy(game_object_verticle_drawing); destroy(game_object_verticle_drawing);
...@@ -996,7 +996,7 @@ public class gameCard : OCGobject ...@@ -996,7 +996,7 @@ public class gameCard : OCGobject
} }
catch (System.Exception e) catch (System.Exception e)
{ {
UnityEngine.Debug.Log(e); // UnityEngine.Debug.Log(e);
} }
destroy(game_object_monster_cloude); destroy(game_object_monster_cloude);
destroy(game_object_verticle_drawing); destroy(game_object_verticle_drawing);
...@@ -1022,7 +1022,7 @@ public class gameCard : OCGobject ...@@ -1022,7 +1022,7 @@ public class gameCard : OCGobject
} }
catch (System.Exception e) catch (System.Exception e)
{ {
UnityEngine.Debug.Log(e); // UnityEngine.Debug.Log(e);
} }
loaded_verticalDrawingCode = 0; loaded_verticalDrawingCode = 0;
loaded_verticalDrawingNumber = -1; loaded_verticalDrawingNumber = -1;
...@@ -1719,7 +1719,7 @@ public class gameCard : OCGobject ...@@ -1719,7 +1719,7 @@ public class gameCard : OCGobject
} }
catch (System.Exception e) catch (System.Exception e)
{ {
UnityEngine.Debug.Log(e); // UnityEngine.Debug.Log(e);
} }
} }
int special_hint = 0; int special_hint = 0;
......
...@@ -587,9 +587,9 @@ public class Ocgcore : ServantWithCardDescription ...@@ -587,9 +587,9 @@ public class Ocgcore : ServantWithCardDescription
{ {
logicalizeMessage(Packages_ALL[i]); logicalizeMessage(Packages_ALL[i]);
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
if (needSwap) if (needSwap)
{ {
...@@ -599,9 +599,9 @@ public class Ocgcore : ServantWithCardDescription ...@@ -599,9 +599,9 @@ public class Ocgcore : ServantWithCardDescription
{ {
practicalizeMessage(Packages_ALL[i]); practicalizeMessage(Packages_ALL[i]);
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
clearResponse(); clearResponse();
} }
...@@ -612,9 +612,9 @@ public class Ocgcore : ServantWithCardDescription ...@@ -612,9 +612,9 @@ public class Ocgcore : ServantWithCardDescription
{ {
logicalizeMessage(Packages_ALL[i]); 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 ...@@ -652,7 +652,7 @@ public class Ocgcore : ServantWithCardDescription
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Log(e); // Debug.Log(e);
} }
} }
...@@ -672,17 +672,17 @@ public class Ocgcore : ServantWithCardDescription ...@@ -672,17 +672,17 @@ public class Ocgcore : ServantWithCardDescription
{ {
logicalizeMessage(currentPackage); logicalizeMessage(currentPackage);
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
try try
{ {
practicalizeMessage(currentPackage); practicalizeMessage(currentPackage);
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
Packages.Dequeue(); Packages.Dequeue();
} }
...@@ -702,9 +702,9 @@ public class Ocgcore : ServantWithCardDescription ...@@ -702,9 +702,9 @@ public class Ocgcore : ServantWithCardDescription
{ {
logicalizeMessage(currentPackage); logicalizeMessage(currentPackage);
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
if (Packages.Count == 1) if (Packages.Count == 1)
{ {
...@@ -714,9 +714,9 @@ public class Ocgcore : ServantWithCardDescription ...@@ -714,9 +714,9 @@ public class Ocgcore : ServantWithCardDescription
realize(); realize();
toNearest(); toNearest();
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
} }
Packages.Dequeue(); Packages.Dequeue();
...@@ -1070,17 +1070,17 @@ public class Ocgcore : ServantWithCardDescription ...@@ -1070,17 +1070,17 @@ public class Ocgcore : ServantWithCardDescription
{ {
logicalizeMessage(currentPackage); logicalizeMessage(currentPackage);
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
try try
{ {
practicalizeMessage(currentPackage); practicalizeMessage(currentPackage);
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
Packages.Dequeue(); Packages.Dequeue();
} }
...@@ -1099,9 +1099,9 @@ public class Ocgcore : ServantWithCardDescription ...@@ -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 ...@@ -1655,9 +1655,9 @@ public class Ocgcore : ServantWithCardDescription
r.BaseStream.Position = pos + len - 4; r.BaseStream.Position = pos + len - 4;
} }
} }
catch (System.Exception e) catch (Exception e)
{ {
// UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
break; break;
case GameMessage.UpdateCard: case GameMessage.UpdateCard:
...@@ -3010,7 +3010,7 @@ public class Ocgcore : ServantWithCardDescription ...@@ -3010,7 +3010,7 @@ public class Ocgcore : ServantWithCardDescription
showCaculator(); showCaculator();
break; break;
case GameMessage.Retry: case GameMessage.Retry:
Debug.Log("Retry"); // Debug.Log("Retry");
break; break;
//case GameMessage.sibyl_delay: //case GameMessage.sibyl_delay:
// if (inIgnoranceReplay()) // if (inIgnoranceReplay())
...@@ -6252,9 +6252,9 @@ public class Ocgcore : ServantWithCardDescription ...@@ -6252,9 +6252,9 @@ public class Ocgcore : ServantWithCardDescription
cardsInSelectAnimation[i].del_all_decoration_by_string("selected"); cardsInSelectAnimation[i].del_all_decoration_by_string("selected");
cardsInSelectAnimation[i].currentKuang = gameCard.kuangType.none; cardsInSelectAnimation[i].currentKuang = gameCard.kuangType.none;
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
} }
cardsInSelectAnimation.Clear(); cardsInSelectAnimation.Clear();
...@@ -7975,7 +7975,6 @@ public class Ocgcore : ServantWithCardDescription ...@@ -7975,7 +7975,6 @@ public class Ocgcore : ServantWithCardDescription
{ {
if (my_p_cards.Count == 2) if (my_p_cards.Count == 2)
{ {
Debug.Log("oh");
gameField gameField
.me_left_p_num.GetComponent<number_loader>() .me_left_p_num.GetComponent<number_loader>()
.set_number((int)my_p_cards[0].get_data().LScale, 3); .set_number((int)my_p_cards[0].get_data().LScale, 3);
...@@ -8296,7 +8295,6 @@ public class Ocgcore : ServantWithCardDescription ...@@ -8296,7 +8295,6 @@ public class Ocgcore : ServantWithCardDescription
{ {
gameInfo.removeHashedButton("swap"); gameInfo.removeHashedButton("swap");
} }
animation_count(gameField.LOCATION_DECK_0, CardLocation.Deck, 0); animation_count(gameField.LOCATION_DECK_0, CardLocation.Deck, 0);
animation_count(gameField.LOCATION_EXTRA_0, CardLocation.Extra, 0); animation_count(gameField.LOCATION_EXTRA_0, CardLocation.Extra, 0);
animation_count(gameField.LOCATION_GRAVE_0, CardLocation.Grave, 0); animation_count(gameField.LOCATION_GRAVE_0, CardLocation.Grave, 0);
...@@ -8751,9 +8749,9 @@ public class Ocgcore : ServantWithCardDescription ...@@ -8751,9 +8749,9 @@ public class Ocgcore : ServantWithCardDescription
} }
} }
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
//to card //to card
...@@ -9778,9 +9776,9 @@ public class Ocgcore : ServantWithCardDescription ...@@ -9778,9 +9776,9 @@ public class Ocgcore : ServantWithCardDescription
binaryMaster.writer.Write(Int32.Parse(result[0].value)); binaryMaster.writer.Write(Int32.Parse(result[0].value));
sendReturn(binaryMaster.get()); sendReturn(binaryMaster.get());
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
} }
break; break;
...@@ -9811,9 +9809,9 @@ public class Ocgcore : ServantWithCardDescription ...@@ -9811,9 +9809,9 @@ public class Ocgcore : ServantWithCardDescription
binaryMaster.writer.Write(answer >= 0 ? answer : 0); binaryMaster.writer.Write(answer >= 0 ? answer : 0);
sendReturn(binaryMaster.get()); sendReturn(binaryMaster.get());
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
} }
if (result[0].value == "no") if (result[0].value == "no")
...@@ -9831,9 +9829,9 @@ public class Ocgcore : ServantWithCardDescription ...@@ -9831,9 +9829,9 @@ public class Ocgcore : ServantWithCardDescription
{ {
res |= UInt32.Parse(item.value); res |= UInt32.Parse(item.value);
} }
catch (System.Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // Debug.Log(e);
} }
} }
binaryMaster.writer.Write(res); binaryMaster.writer.Write(res);
...@@ -9922,7 +9920,7 @@ public class Ocgcore : ServantWithCardDescription ...@@ -9922,7 +9920,7 @@ public class Ocgcore : ServantWithCardDescription
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Log(e); // Debug.Log(e);
} }
} }
break; break;
......
...@@ -169,9 +169,9 @@ public class Program : MonoBehaviour ...@@ -169,9 +169,9 @@ public class Program : MonoBehaviour
obj.SetActive(false); obj.SetActive(false);
allObjects.Add(obj); 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 ...@@ -672,9 +672,9 @@ public class Program : MonoBehaviour
Resources.UnloadUnusedAssets(); Resources.UnloadUnusedAssets();
GC.Collect(); 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 ...@@ -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 ...@@ -1413,7 +1413,7 @@ public class Program : MonoBehaviour
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Log(e); // Debug.Log(e);
} }
processedTasks++; processedTasks++;
break; break;
...@@ -1521,9 +1521,9 @@ public class Program : MonoBehaviour ...@@ -1521,9 +1521,9 @@ public class Program : MonoBehaviour
{ {
TcpHelper.tcpClient.Close(); TcpHelper.tcpClient.Close();
} }
catch (System.Exception e) catch (Exception e)
{ {
//adeUnityEngine.Debug.Log(e); // Debug.Log(e);
} }
Menu.deleteShell(); Menu.deleteShell();
} }
......
...@@ -214,7 +214,7 @@ public class GameTextureManager ...@@ -214,7 +214,7 @@ public class GameTextureManager
} }
catch (Exception e) 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); ProcessResourceRequest(resourceToProcess);
......
...@@ -962,7 +962,7 @@ public class Servant ...@@ -962,7 +962,7 @@ public class Servant
{ {
url = inputUrl.value; url = inputUrl.value;
} }
Debug.Log("开始异步下载头像: " + url); // Debug.Log("开始异步下载头像: " + url);
// [核心修改] 使用我们新的、异步的 UnityFileDownloader // [核心修改] 使用我们新的、异步的 UnityFileDownloader
// 启动一个协程来执行异步下载任务 // 启动一个协程来执行异步下载任务
Program Program
...@@ -976,7 +976,7 @@ public class Servant ...@@ -976,7 +976,7 @@ public class Servant
// 这个部分是回调函数,只会在下载完成后执行 // 这个部分是回调函数,只会在下载完成后执行
if (success) if (success)
{ {
Debug.Log("头像下载成功,路径: " + facePath); // Debug.Log("头像下载成功,路径: " + facePath);
Program.PrintToChat("头像下载成功!"); Program.PrintToChat("头像下载成功!");
// 将原来同步执行的刷新逻辑移动到这里 // 将原来同步执行的刷新逻辑移动到这里
// 确保文件确实存在并且已经被下载完毕 // 确保文件确实存在并且已经被下载完毕
......
...@@ -136,7 +136,7 @@ public class Setting : WindowServant2D ...@@ -136,7 +136,7 @@ public class Setting : WindowServant2D
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Log(e); // Debug.Log(e);
} }
} }
......
...@@ -444,7 +444,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -444,7 +444,7 @@ public class DeckManager : ServantWithCardDescription
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Log(e); // Debug.Log(e);
} }
} }
deckDirty = true; deckDirty = true;
...@@ -2087,7 +2087,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -2087,7 +2087,7 @@ public class DeckManager : ServantWithCardDescription
} }
catch (System.Exception e) catch (System.Exception e)
{ {
UnityEngine.Debug.Log(e); // UnityEngine.Debug.Log(e);
} }
} }
...@@ -2304,7 +2304,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -2304,7 +2304,7 @@ public class DeckManager : ServantWithCardDescription
} }
catch (System.Exception e) catch (System.Exception e)
{ {
UnityEngine.Debug.Log(e); // UnityEngine.Debug.Log(e);
} }
if (side) if (side)
{ {
...@@ -2338,7 +2338,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -2338,7 +2338,7 @@ public class DeckManager : ServantWithCardDescription
else else
{ {
UIInput_search.value = ""; UIInput_search.value = "";
UIInput_search.isSelected = true; UIInput_search.isSelected = false;
} }
} }
} }
...@@ -154,7 +154,7 @@ public class selectReplay : WindowServantSP ...@@ -154,7 +154,7 @@ public class selectReplay : WindowServantSP
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Log(e); // Debug.Log(e);
} }
// Debug.Log(returnValue); // Debug.Log(returnValue);
return returnValue; return returnValue;
...@@ -264,7 +264,7 @@ public class selectReplay : WindowServantSP ...@@ -264,7 +264,7 @@ public class selectReplay : WindowServantSP
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Log(e); // Debug.Log(e);
} }
return returnValue; return returnValue;
} }
...@@ -310,7 +310,7 @@ public class selectReplay : WindowServantSP ...@@ -310,7 +310,7 @@ public class selectReplay : WindowServantSP
} }
catch (Exception e) catch (Exception e)
{ {
UnityEngine.Debug.Log(e); // UnityEngine.Debug.Log(e);
RMSshow_none(InterString.Get("录像没有录制完整。")); RMSshow_none(InterString.Get("录像没有录制完整。"));
} }
} }
......
...@@ -41,16 +41,21 @@ namespace YGOSharp ...@@ -41,16 +41,21 @@ namespace YGOSharp
catch (System.Exception e) catch (System.Exception e)
{ {
success = false; success = false;
UnityEngine.Debug.Log(line); // UnityEngine.Debug.Log(line);
UnityEngine.Debug.Log(e); // UnityEngine.Debug.Log(e);
} }
} }
reader.Close(); reader.Close();
if(!test) { if (!test)
if (Banlists == null) { {
if (Banlists == null)
{
Banlists = new_list; Banlists = new_list;
} else { }
foreach (var item in new_list) { else
{
foreach (var item in new_list)
{
Banlists.Add(item); Banlists.Add(item);
} }
} }
...@@ -58,7 +63,8 @@ namespace YGOSharp ...@@ -58,7 +63,8 @@ namespace YGOSharp
return (success && new_list.Count > 1); return (success && new_list.Count > 1);
} }
public static void initializeComplete() { public static void initializeComplete()
{
Banlist blank = new Banlist(); Banlist blank = new Banlist();
blank.Name = "N/A"; blank.Name = "N/A";
Banlists.Add(blank); Banlists.Add(blank);
......
...@@ -109,7 +109,7 @@ namespace YGOSharp ...@@ -109,7 +109,7 @@ namespace YGOSharp
} }
catch (System.Exception e) catch (System.Exception e)
{ {
UnityEngine.Debug.Log(e); // UnityEngine.Debug.Log(e);
} }
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"com.unity.2d.tilemap": "1.0.0", "com.unity.2d.tilemap": "1.0.0",
"com.unity.analytics": "3.6.12", "com.unity.analytics": "3.6.12",
"com.unity.burst": "1.8.18", "com.unity.burst": "1.8.18",
"com.unity.ide.vscode": "1.2.5",
"com.unity.postprocessing": "3.4.0", "com.unity.postprocessing": "3.4.0",
"com.unity.test-framework": "1.1.33", "com.unity.test-framework": "1.1.33",
"com.unity.timeline": "1.6.5", "com.unity.timeline": "1.6.5",
......
...@@ -38,6 +38,13 @@ ...@@ -38,6 +38,13 @@
"dependencies": {}, "dependencies": {},
"url": "https://packages.unity.com" "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": { "com.unity.mathematics": {
"version": "1.2.6", "version": "1.2.6",
"depth": 1, "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