Commit 929de022 authored by hex's avatar hex

Changed card addition from double-click to long-press (good news for those with tenosynovitis)

parent 5cf5390a
Pipeline #37618 failed
using System; using System;
using System.Net.Sockets; using System.Collections.Generic;
using YGOSharp.Network.Enums;
using UnityEngine;
using System.IO; using System.IO;
using System.Threading; using System.Net.Sockets;
using System.Text; using System.Text;
using System.Collections.Generic; using System.Threading;
using UnityEngine;
using YGOSharp.Network.Enums;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
public static class TcpHelper public static class TcpHelper
{ {
public static TcpClient tcpClient = null; public static TcpClient tcpClient = null;
static NetworkStream networkStream = null; static NetworkStream networkStream = null;
static bool canjoin = true; static bool canjoin = true;
static bool roomListChecking = false; static bool roomListChecking = false;
public static void join(string ipString, string name, string portString, string pswString, string version) public static void join(
string ipString,
string name,
string portString,
string pswString,
string version
)
{ {
if (canjoin) if (canjoin)
{ {
...@@ -26,7 +32,11 @@ public static class TcpHelper ...@@ -26,7 +32,11 @@ public static class TcpHelper
canjoin = false; canjoin = false;
try try
{ {
tcpClient = new TcpClientWithTimeout(ipString, int.Parse(portString), 3000).Connect(); tcpClient = new TcpClientWithTimeout(
ipString,
int.Parse(portString),
3000
).Connect();
networkStream = tcpClient.GetStream(); networkStream = tcpClient.GetStream();
Thread t = new Thread(receiver); Thread t = new Thread(receiver);
t.Start(); t.Start();
...@@ -36,7 +46,7 @@ public static class TcpHelper ...@@ -36,7 +46,7 @@ public static class TcpHelper
roomListChecking = true; roomListChecking = true;
} }
else else
{ {
roomListChecking = false; roomListChecking = false;
} }
CtosMessage_JoinGame(pswString, version); CtosMessage_JoinGame(pswString, version);
...@@ -59,7 +69,9 @@ public static class TcpHelper ...@@ -59,7 +69,9 @@ public static class TcpHelper
{ {
try try
{ {
while (tcpClient != null && networkStream != null && tcpClient.Connected && Program.Running) while (
tcpClient != null && networkStream != null && tcpClient.Connected && Program.Running
)
{ {
byte[] data = SocketMaster.ReadPacket(networkStream); byte[] data = SocketMaster.ReadPacket(networkStream);
addDateJumoLine(data); addDateJumoLine(data);
...@@ -72,7 +84,6 @@ public static class TcpHelper ...@@ -72,7 +84,6 @@ public static class TcpHelper
onDisConnected = true; onDisConnected = true;
Program.DEBUGLOG("onDisConnected 3"); Program.DEBUGLOG("onDisConnected 3");
} }
} }
public static void addDateJumoLine(byte[] data) public static void addDateJumoLine(byte[] data)
...@@ -95,7 +106,7 @@ public static class TcpHelper ...@@ -95,7 +106,7 @@ public static class TcpHelper
public static void preFrameFunction() public static void preFrameFunction()
{ {
if (datas.Count>0) if (datas.Count > 0)
{ {
if (Monitor.TryEnter(datas)) if (Monitor.TryEnter(datas))
{ {
...@@ -187,7 +198,7 @@ public static class TcpHelper ...@@ -187,7 +198,7 @@ public static class TcpHelper
} }
catch (System.Exception e) catch (System.Exception e)
{ {
// Program.DEBUGLOG(e); // Program.DEBUGLOG(e);
} }
} }
datas.Clear(); datas.Clear();
...@@ -198,23 +209,34 @@ public static class TcpHelper ...@@ -198,23 +209,34 @@ public static class TcpHelper
{ {
onDisConnected = false; onDisConnected = false;
Program.I().ocgcore.setDefaultReturnServant(); Program.I().ocgcore.setDefaultReturnServant();
if (TcpHelper.tcpClient != null)
try
{ {
if (TcpHelper.tcpClient.Connected) if (tcpClient != null)
{ {
tcpClient.Client.Shutdown(0); if (tcpClient.Connected)
{
tcpClient.Client.Shutdown(SocketShutdown.Both);
}
tcpClient.Close(); tcpClient.Close();
} }
} }
catch (Exception e)
{
Debug.LogWarning("Socket cleanup failed: " + e.Message);
}
tcpClient = null; tcpClient = null;
if (Program.I().ocgcore.isShowed == false) if (Program.I().ocgcore.isShowed == false)
{ {
if (Program.I().menu.isShowed == false) if (Program.I().menu.isShowed == false)
{ {
if (Program.I().mycard.isMatching) { if (Program.I().mycard.isMatching)
{
Program.I().shiftToServant(Program.I().mycard); Program.I().shiftToServant(Program.I().mycard);
} else { }
else
{
Program.I().shiftToServant(Program.I().selectServer); Program.I().shiftToServant(Program.I().selectServer);
} }
} }
...@@ -225,10 +247,13 @@ public static class TcpHelper ...@@ -225,10 +247,13 @@ public static class TcpHelper
} }
else else
{ {
Program.I().cardDescription.RMSshow_none(InterString.Get("对方离开游戏,您现在可以截图。")); Program
.I()
.cardDescription.RMSshow_none(
InterString.Get("对方离开游戏,您现在可以截图。")
);
Program.I().ocgcore.forceMSquit(); Program.I().ocgcore.forceMSquit();
} }
} }
} }
...@@ -269,7 +294,6 @@ public static class TcpHelper ...@@ -269,7 +294,6 @@ public static class TcpHelper
public static void CtosMessage_Response(byte[] response) public static void CtosMessage_Response(byte[] response)
{ {
Package message = new Package(); Package message = new Package();
message.Fuction = (int)CtosMessage.Response; message.Fuction = (int)CtosMessage.Response;
message.Data.writer.Write(response); message.Data.writer.Write(response);
...@@ -277,6 +301,7 @@ public static class TcpHelper ...@@ -277,6 +301,7 @@ public static class TcpHelper
} }
public static YGOSharp.Deck deck; public static YGOSharp.Deck deck;
public static void CtosMessage_UpdateDeck(YGOSharp.Deck deckFor) public static void CtosMessage_UpdateDeck(YGOSharp.Deck deckFor)
{ {
if (deckFor.Main.Count == 0) if (deckFor.Main.Count == 0)
...@@ -335,12 +360,11 @@ public static class TcpHelper ...@@ -335,12 +360,11 @@ public static class TcpHelper
Send(message); Send(message);
} }
public static void CtosMessage_CreateGame() public static void CtosMessage_CreateGame() { }
{
}
public static List<string> deckStrings = new List<string>(); public static List<string> deckStrings = new List<string>();
public static void CtosMessage_JoinGame(string psw,string version)
public static void CtosMessage_JoinGame(string psw, string version)
{ {
deckStrings.Clear(); deckStrings.Clear();
Package message = new Package(); Package message = new Package();
...@@ -467,7 +491,7 @@ public static class TcpHelper ...@@ -467,7 +491,7 @@ public static class TcpHelper
return re; return re;
} }
public static string lastRecordName = ""; public static string lastRecordName = "";
public static void SaveRecord() public static void SaveRecord()
{ {
...@@ -541,6 +565,7 @@ public class Package ...@@ -541,6 +565,7 @@ public class Package
{ {
public int Fuction = 0; public int Fuction = 0;
public BinaryMaster Data = null; public BinaryMaster Data = null;
public Package() public Package()
{ {
Fuction = (int)CtosMessage.Response; Fuction = (int)CtosMessage.Response;
...@@ -553,6 +578,7 @@ public class BinaryMaster ...@@ -553,6 +578,7 @@ public class BinaryMaster
MemoryStream memstream = null; MemoryStream memstream = null;
public BinaryReader reader = null; public BinaryReader reader = null;
public BinaryWriter writer = null; public BinaryWriter writer = null;
public BinaryMaster(byte[] raw = null) public BinaryMaster(byte[] raw = null)
{ {
if (raw == null) if (raw == null)
...@@ -566,21 +592,25 @@ public class BinaryMaster ...@@ -566,21 +592,25 @@ public class BinaryMaster
reader = new BinaryReader(memstream); reader = new BinaryReader(memstream);
writer = new BinaryWriter(memstream); writer = new BinaryWriter(memstream);
} }
public void set(byte[] raw) public void set(byte[] raw)
{ {
memstream = new MemoryStream(raw); memstream = new MemoryStream(raw);
reader = new BinaryReader(memstream); reader = new BinaryReader(memstream);
writer = new BinaryWriter(memstream); writer = new BinaryWriter(memstream);
} }
public byte[] get() public byte[] get()
{ {
byte[] bytes = memstream.ToArray(); byte[] bytes = memstream.ToArray();
return bytes; return bytes;
} }
public int getLength() public int getLength()
{ {
return (int)memstream.Length; return (int)memstream.Length;
} }
public override string ToString() public override string ToString()
{ {
string return_value = ""; string return_value = "";
...@@ -588,11 +618,11 @@ public class BinaryMaster ...@@ -588,11 +618,11 @@ public class BinaryMaster
for (int i = 0; i < bytes.Length; i++) for (int i = 0; i < bytes.Length; i++)
{ {
return_value += ((int)bytes[i]).ToString(); return_value += ((int)bytes[i]).ToString();
if (i < bytes.Length - 1) return_value += ","; if (i < bytes.Length - 1)
return_value += ",";
} }
return return_value; return return_value;
} }
} }
public static class BinaryExtensions public static class BinaryExtensions
...@@ -617,7 +647,6 @@ public static class BinaryExtensions ...@@ -617,7 +647,6 @@ public static class BinaryExtensions
{ {
UnityEngine.Debug.Log(e); UnityEngine.Debug.Log(e);
} }
} }
public static string ReadUnicode(this BinaryReader reader, int len) public static string ReadUnicode(this BinaryReader reader, int len)
...@@ -661,7 +690,7 @@ public static class BinaryExtensions ...@@ -661,7 +690,7 @@ public static class BinaryExtensions
return a; return a;
} }
public static void readCardData(this BinaryReader r, gameCard cardTemp=null) public static void readCardData(this BinaryReader r, gameCard cardTemp = null)
{ {
gameCard cardToRefresh = cardTemp; gameCard cardToRefresh = cardTemp;
int flag = r.ReadInt32(); int flag = r.ReadInt32();
...@@ -670,13 +699,13 @@ public static class BinaryExtensions ...@@ -670,13 +699,13 @@ public static class BinaryExtensions
if ((flag & (int)Query.Code) != 0) if ((flag & (int)Query.Code) != 0)
{ {
code= r.ReadInt32(); code = r.ReadInt32();
} }
if ((flag & (int)Query.Position) != 0) if ((flag & (int)Query.Position) != 0)
{ {
gps = r.ReadGPS(); gps = r.ReadGPS();
cardToRefresh = null; cardToRefresh = null;
cardToRefresh = Program.I().ocgcore.GCS_cardGet(gps,false); cardToRefresh = Program.I().ocgcore.GCS_cardGet(gps, false);
} }
if (cardToRefresh == null) if (cardToRefresh == null)
...@@ -699,7 +728,6 @@ public static class BinaryExtensions ...@@ -699,7 +728,6 @@ public static class BinaryExtensions
cardToRefresh.p = gps; cardToRefresh.p = gps;
} }
if (data.Id > 0) if (data.Id > 0)
{ {
if ((cardToRefresh.p.location & (UInt32)CardLocation.Hand) > 0) if ((cardToRefresh.p.location & (UInt32)CardLocation.Hand) > 0)
...@@ -795,7 +823,11 @@ public static class BinaryExtensions ...@@ -795,7 +823,11 @@ public static class BinaryExtensions
l3 = r.ReadInt32(); //link value l3 = r.ReadInt32(); //link value
data.LinkMarker = r.ReadInt32(); data.LinkMarker = r.ReadInt32();
} }
if (((flag & (int)Query.Level) != 0) || ((flag & (int)Query.Rank) != 0) || ((flag & (int)Query.Link) != 0)) if (
((flag & (int)Query.Level) != 0)
|| ((flag & (int)Query.Rank) != 0)
|| ((flag & (int)Query.Link) != 0)
)
{ {
if (l1 > l2) if (l1 > l2)
{ {
...@@ -805,7 +837,7 @@ public static class BinaryExtensions ...@@ -805,7 +837,7 @@ public static class BinaryExtensions
{ {
data.Level = l2; data.Level = l2;
} }
if(l3 > data.Level) if (l3 > data.Level)
data.Level = l3; data.Level = l3;
} }
...@@ -842,7 +874,6 @@ public class SocketMaster ...@@ -842,7 +874,6 @@ public class SocketMaster
var buf = ReadFull(stream, plen); var buf = ReadFull(stream, plen);
return buf; return buf;
} }
} }
public class TcpClientWithTimeout public class TcpClientWithTimeout
...@@ -860,6 +891,7 @@ public class TcpClientWithTimeout ...@@ -860,6 +891,7 @@ public class TcpClientWithTimeout
_port = port; _port = port;
_timeout_milliseconds = timeout_milliseconds; _timeout_milliseconds = timeout_milliseconds;
} }
public TcpClient Connect() public TcpClient Connect()
{ {
// kick off the thread that tries to connect // kick off the thread that tries to connect
...@@ -867,7 +899,7 @@ public class TcpClientWithTimeout ...@@ -867,7 +899,7 @@ public class TcpClientWithTimeout
exception = null; exception = null;
Thread thread = new Thread(new ThreadStart(BeginConnect)); Thread thread = new Thread(new ThreadStart(BeginConnect));
thread.IsBackground = true; // 作为后台线程处理 thread.IsBackground = true; // 作为后台线程处理
// 不会占用机器太长的时间 // 不会占用机器太长的时间
thread.Start(); thread.Start();
// 等待如下的时间 // 等待如下的时间
...@@ -891,13 +923,17 @@ public class TcpClientWithTimeout ...@@ -891,13 +923,17 @@ public class TcpClientWithTimeout
{ {
// 同样地抛出错误 // 同样地抛出错误
thread.Abort(); thread.Abort();
string message = string.Format("TcpClient connection to {0}:{1} timed out", string message = string.Format(
_hostname, _port); "TcpClient connection to {0}:{1} timed out",
_hostname,
_port
);
TcpHelper.onDisConnected = true; TcpHelper.onDisConnected = true;
Program.DEBUGLOG("onDisConnected 8"); Program.DEBUGLOG("onDisConnected 8");
throw new TimeoutException(message); throw new TimeoutException(message);
} }
} }
protected void BeginConnect() protected void BeginConnect()
{ {
try try
......
...@@ -3,10 +3,22 @@ using System.Collections.Generic; ...@@ -3,10 +3,22 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using UnityEngine; using UnityEngine;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
public class DeckManager : ServantWithCardDescription public class DeckManager : ServantWithCardDescription
{ {
#region UI #region UI
// 优化长按检测的变量,以支持持续添加
private MonoCardInDeckManager cardForLongPress = null;
private float pressStartTime = 0f;
private Vector3 mouseDownPosition; // 记录鼠标按下时的屏幕位置,用于区分点击和拖拽
// 用于持续添加的常量和状态变量
private const float INITIAL_LONG_PRESS_DURATION = 0.5f; // 初始长按触发时间
private const float CONTINUOUS_ADD_INTERVAL = 0.15f; // 持续添加的间隔时间(秒)
private bool isContinuouslyAdding = false; // 是否已进入持续添加模式
private float nextAddCardTime = 0f; // 下一次可以添加卡片的时间点
public enum Condition public enum Condition
{ {
editDeck = 1, editDeck = 1,
...@@ -47,22 +59,24 @@ public class DeckManager : ServantWithCardDescription ...@@ -47,22 +59,24 @@ public class DeckManager : ServantWithCardDescription
public override void initialize() public override void initialize()
{ {
gameObjectSearch = create gameObjectSearch = create(
(
Program.I().new_ui_search, Program.I().new_ui_search,
Program.camera_back_ground_2d.ScreenToWorldPoint(new Vector3(Screen.width + 600, Screen.height / 2, 600)), Program.camera_back_ground_2d.ScreenToWorldPoint(
new Vector3(Screen.width + 600, Screen.height / 2, 600)
),
new Vector3(0, 0, 0), new Vector3(0, 0, 0),
false, false,
Program.ui_back_ground_2d Program.ui_back_ground_2d
); );
gameObjectDetailedSearch = create gameObjectDetailedSearch = create(
(
Program.I().new_ui_searchDetailed, Program.I().new_ui_searchDetailed,
Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height * 2f, 0)), Program.camera_main_2d.ScreenToWorldPoint(
new Vector3(Screen.width, Screen.height * 2f, 0)
),
new Vector3(0, 0, 0), new Vector3(0, 0, 0),
false, false,
Program.ui_main_2d Program.ui_main_2d
); );
UIHelper.InterGameObject(gameObjectSearch); UIHelper.InterGameObject(gameObjectSearch);
UIHelper.InterGameObject(gameObjectDetailedSearch); UIHelper.InterGameObject(gameObjectDetailedSearch);
shiftCondition(Condition.editDeck); shiftCondition(Condition.editDeck);
...@@ -72,7 +86,10 @@ public class DeckManager : ServantWithCardDescription ...@@ -72,7 +86,10 @@ public class DeckManager : ServantWithCardDescription
UIPopupList_ban = UIHelper.getByName<UIPopupList>(gameObjectDetailedSearch, "ban_"); UIPopupList_ban = UIHelper.getByName<UIPopupList>(gameObjectDetailedSearch, "ban_");
UIPopupList_second = UIHelper.getByName<UIPopupList>(gameObjectDetailedSearch, "second_"); UIPopupList_second = UIHelper.getByName<UIPopupList>(gameObjectDetailedSearch, "second_");
UIPopupList_race = UIHelper.getByName<UIPopupList>(gameObjectDetailedSearch, "race_"); UIPopupList_race = UIHelper.getByName<UIPopupList>(gameObjectDetailedSearch, "race_");
UIPopupList_attribute = UIHelper.getByName<UIPopupList>(gameObjectDetailedSearch, "attribute_"); UIPopupList_attribute = UIHelper.getByName<UIPopupList>(
gameObjectDetailedSearch,
"attribute_"
);
UIPopupList_pack = UIHelper.getByName<UIPopupList>(gameObjectDetailedSearch, "pack_"); UIPopupList_pack = UIHelper.getByName<UIPopupList>(gameObjectDetailedSearch, "pack_");
UIInput_search = UIHelper.getByName<UIInput>(gameObjectSearch, "input_"); UIInput_search = UIHelper.getByName<UIInput>(gameObjectSearch, "input_");
UIInput_search.value = ""; UIInput_search.value = "";
...@@ -81,9 +98,17 @@ public class DeckManager : ServantWithCardDescription ...@@ -81,9 +98,17 @@ public class DeckManager : ServantWithCardDescription
UIInput_def = UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "def_"); UIInput_def = UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "def_");
for (int i = 0; i < 32; i++) for (int i = 0; i < 32; i++)
{ {
UIToggle_effects[i] = UIHelper.getByName<UIToggle>(gameObjectDetailedSearch, "T (" + (i + 1).ToString() + ")"); UIToggle_effects[i] = UIHelper.getByName<UIToggle>(
UIHelper.trySetLableText(UIToggle_effects[i].gameObject, GameStringManager.get_unsafe(1100 + i)); gameObjectDetailedSearch,
UIToggle_effects[i].GetComponentInChildren<UILabel>().overflowMethod = UILabel.Overflow.ClampContent; "T (" + (i + 1).ToString() + ")"
);
UIHelper.trySetLableText(
UIToggle_effects[i].gameObject,
GameStringManager.get_unsafe(1100 + i)
);
UIToggle_effects[i].GetComponentInChildren<UILabel>().overflowMethod = UILabel
.Overflow
.ClampContent;
} }
UIPopupList_pack.Clear(); UIPopupList_pack.Clear();
UIPopupList_pack.AddItem(GameStringManager.get_unsafe(1310)); UIPopupList_pack.AddItem(GameStringManager.get_unsafe(1310));
...@@ -109,36 +134,44 @@ public class DeckManager : ServantWithCardDescription ...@@ -109,36 +134,44 @@ public class DeckManager : ServantWithCardDescription
clearAll(); clearAll();
UIHelper.registEvent(UIPopupList_main.gameObject, onUIPopupList_main); UIHelper.registEvent(UIPopupList_main.gameObject, onUIPopupList_main);
UIHelper.registEvent(UIPopupList_second.gameObject, onUIPopupList_second); UIHelper.registEvent(UIPopupList_second.gameObject, onUIPopupList_second);
superScrollView = new SuperScrollView superScrollView = new SuperScrollView(
( UIHelper.getByName<UIPanel>(gameObjectSearch, "panel_"),
UIHelper.getByName<UIPanel>(gameObjectSearch, "panel_"), UIHelper.getByName<UIScrollBar>(gameObjectSearch, "bar_"),
UIHelper.getByName<UIScrollBar>(gameObjectSearch, "bar_"), itemOnListProducer,
itemOnListProducer, 86
86 );
); Program.go(
Program.go(500, () => 500,
{ () =>
List<MonoCardInDeckManager> cs = new List<MonoCardInDeckManager>(); {
for (int i = 0; i < 300; i++) List<MonoCardInDeckManager> cs = new List<MonoCardInDeckManager>();
{ for (int i = 0; i < 300; i++)
cs.Add(createCard()); {
} cs.Add(createCard());
for (int i = 0; i < 300; i++) }
{ for (int i = 0; i < 300; i++)
destroyCard(cs[i]); {
destroyCard(cs[i]);
}
} }
}); );
} }
GameObject itemOnListProducer(string[] Args) GameObject itemOnListProducer(string[] Args)
{ {
GameObject returnValue = null; GameObject returnValue = null;
returnValue = create(Program.I().new_ui_cardOnSearchList, Vector3.zero, Vector3.zero, false, Program.ui_back_ground_2d); returnValue = create(
Program.I().new_ui_cardOnSearchList,
Vector3.zero,
Vector3.zero,
false,
Program.ui_back_ground_2d
);
UIHelper.getRealEventGameObject(returnValue).name = Args[0]; UIHelper.getRealEventGameObject(returnValue).name = Args[0];
UIHelper.trySetLableText(returnValue, Args[2]); UIHelper.trySetLableText(returnValue, Args[2]);
cardPicLoader cardPicLoader_ = UIHelper.getRealEventGameObject(returnValue).AddComponent<cardPicLoader>(); cardPicLoader cardPicLoader_ = UIHelper
.getRealEventGameObject(returnValue)
.AddComponent<cardPicLoader>();
cardPicLoader_.code = int.Parse(Args[0]); cardPicLoader_.code = int.Parse(Args[0]);
cardPicLoader_.data = YGOSharp.CardsManager.Get(int.Parse(Args[0])); cardPicLoader_.data = YGOSharp.CardsManager.Get(int.Parse(Args[0]));
cardPicLoader_.uiTexture = UIHelper.getByName<UITexture>(returnValue, "pic_"); cardPicLoader_.uiTexture = UIHelper.getByName<UITexture>(returnValue, "pic_");
...@@ -151,7 +184,13 @@ public class DeckManager : ServantWithCardDescription ...@@ -151,7 +184,13 @@ public class DeckManager : ServantWithCardDescription
{ {
base.applyHideArrangement(); base.applyHideArrangement();
Program.cameraFacing = false; Program.cameraFacing = false;
iTween.MoveTo(gameObjectSearch, Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width + 600, Screen.height / 2, 600)), 1.2f); iTween.MoveTo(
gameObjectSearch,
Program.camera_main_2d.ScreenToWorldPoint(
new Vector3(Screen.width + 600, Screen.height / 2, 600)
),
1.2f
);
refreshDetail(); refreshDetail();
} }
...@@ -161,7 +200,13 @@ public class DeckManager : ServantWithCardDescription ...@@ -161,7 +200,13 @@ public class DeckManager : ServantWithCardDescription
Program.cameraFacing = true; Program.cameraFacing = true;
UITexture tex = UIHelper.getByName<UITexture>(gameObjectSearch, "under_"); UITexture tex = UIHelper.getByName<UITexture>(gameObjectSearch, "under_");
tex.height = Screen.height; tex.height = Screen.height;
iTween.MoveTo(gameObjectSearch, Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width - tex.width / 2, Screen.height / 2, 0)), 1.2f); iTween.MoveTo(
gameObjectSearch,
Program.camera_main_2d.ScreenToWorldPoint(
new Vector3(Screen.width - MAIN_PANEL_MARGIN_RIGHT, Screen.height / 2, 0)
),
1.2f
);
refreshDetail(); refreshDetail();
} }
...@@ -187,7 +232,14 @@ public class DeckManager : ServantWithCardDescription ...@@ -187,7 +232,14 @@ public class DeckManager : ServantWithCardDescription
UIHelper.registEvent(toolBar, "sort_", sort); UIHelper.registEvent(toolBar, "sort_", sort);
UIHelper.registEvent(toolBar, "clear_", clear); UIHelper.registEvent(toolBar, "clear_", clear);
UIHelper.registEvent(toolBar, "home_", home); UIHelper.registEvent(toolBar, "home_", home);
UIHelper.registEvent(toolBar, "save_", () => { onSave(); }); UIHelper.registEvent(
toolBar,
"save_",
() =>
{
onSave();
}
);
UIHelper.registEvent(toolBar, "lfList_", onLF); UIHelper.registEvent(toolBar, "lfList_", onLF);
UIHelper.registEvent(toolBar, "copy_", onCopy); UIHelper.registEvent(toolBar, "copy_", onCopy);
break; break;
...@@ -243,13 +295,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -243,13 +295,7 @@ public class DeckManager : ServantWithCardDescription
{ {
try try
{ {
if ( if (deck.IMain.Count <= 60 && deck.IExtra.Count <= 15 && deck.ISide.Count <= 15)
deck.IMain.Count <= 60
&&
deck.IExtra.Count <= 15
&&
deck.ISide.Count <= 15
)
{ {
string deckInUse = Config.Get("deckInUse", "miaowu"); string deckInUse = Config.Get("deckInUse", "miaowu");
if (canSave) if (canSave)
...@@ -271,7 +317,11 @@ public class DeckManager : ServantWithCardDescription ...@@ -271,7 +317,11 @@ public class DeckManager : ServantWithCardDescription
{ {
value += deck.Side[i].ToString() + "\r\n"; value += deck.Side[i].ToString() + "\r\n";
} }
System.IO.File.WriteAllText("deck/" + deckInUse + ".ydk", value, System.Text.Encoding.UTF8); System.IO.File.WriteAllText(
"deck/" + deckInUse + ".ydk",
value,
System.Text.Encoding.UTF8
);
} }
else else
{ {
...@@ -290,7 +340,11 @@ public class DeckManager : ServantWithCardDescription ...@@ -290,7 +340,11 @@ public class DeckManager : ServantWithCardDescription
{ {
value += deck.Deck_O.Side[i].ToString() + "\r\n"; value += deck.Deck_O.Side[i].ToString() + "\r\n";
} }
System.IO.File.WriteAllText("deck/" + deckInUse + ".ydk", value, System.Text.Encoding.UTF8); System.IO.File.WriteAllText(
"deck/" + deckInUse + ".ydk",
value,
System.Text.Encoding.UTF8
);
} }
deckDirty = false; deckDirty = false;
RMSshow_none(InterString.Get("卡组[?]已经被保存。", deckInUse)); RMSshow_none(InterString.Get("卡组[?]已经被保存。", deckInUse));
...@@ -353,7 +407,18 @@ public class DeckManager : ServantWithCardDescription ...@@ -353,7 +407,18 @@ public class DeckManager : ServantWithCardDescription
{ {
rid = item.gameObject.AddComponent<Rigidbody>(); rid = item.gameObject.AddComponent<Rigidbody>();
} }
rid.AddForce(0.7f * (item.transform.position + new Vector3(0, 30 - Vector3.Distance(item.transform.position, Vector3.zero), 0)) / Program.deltaTime); rid.AddForce(
0.7f
* (
item.transform.position
+ new Vector3(
0,
30 - Vector3.Distance(item.transform.position, Vector3.zero),
0
)
)
/ Program.deltaTime
);
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -378,8 +443,8 @@ public class DeckManager : ServantWithCardDescription ...@@ -378,8 +443,8 @@ public class DeckManager : ServantWithCardDescription
refreshDetail(); refreshDetail();
} }
bool detailPanelShiftedTemp = false; bool detailPanelShiftedTemp = false;
void shiftDetailPanel(bool dragged) void shiftDetailPanel(bool dragged)
{ {
detailPanelShiftedTemp = dragged; detailPanelShiftedTemp = dragged;
...@@ -396,6 +461,41 @@ public class DeckManager : ServantWithCardDescription ...@@ -396,6 +461,41 @@ public class DeckManager : ServantWithCardDescription
} }
} }
// 用于控制右侧UI布局的常量,方便调整
// -----------------------------------------------------------------
/// <summary>
/// 主搜索面板的基础宽度
/// </summary>
private const float MAIN_SEARCH_PANEL_WIDTH = 280f;
/// <summary>
/// 详细搜索面板的基础宽度
/// </summary>
private const float DETAILED_SEARCH_PANEL_WIDTH = 230f;
/// <summary>
/// 主搜索面板距离屏幕右边缘的距离 (基于其中心点)
/// </summary>
private const float MAIN_PANEL_MARGIN_RIGHT = MAIN_SEARCH_PANEL_WIDTH / 2;
/// <summary>
/// 详细搜索面板滑出后,与主搜索面板组合的总宽度 (用于计算位置)
/// </summary>
private const float COMBINED_PANEL_WIDTH =
MAIN_SEARCH_PANEL_WIDTH + DETAILED_SEARCH_PANEL_WIDTH + 115f; // 115f 是原始代码中的一个偏移/间距值
/// <summary>
/// 摄像机右侧需要避让的边距 (当只有主搜索面板时)
/// </summary>
private const float CAMERA_MARGIN_RIGHT_NORMAL = MAIN_SEARCH_PANEL_WIDTH;
/// <summary>
/// 摄像机右侧需要避让的边距 (当详细搜索也展开时)
/// 这个值通常等于 detailed panel 的宽度乘以其缩放值
/// </summary>
private const float CAMERA_MARGIN_RIGHT_DETAILED = DETAILED_SEARCH_PANEL_WIDTH;
// -----------------------------------------------------------------
void refreshDetail() void refreshDetail()
{ {
...@@ -405,18 +505,52 @@ public class DeckManager : ServantWithCardDescription ...@@ -405,18 +505,52 @@ public class DeckManager : ServantWithCardDescription
{ {
if (Screen.height < 700) if (Screen.height < 700)
{ {
gameObjectDetailedSearch.transform.localScale = new Vector3(Screen.height / 700f, Screen.height / 700f, Screen.height / 700f); gameObjectDetailedSearch.transform.localScale = new Vector3(
Screen.height / 700f,
Screen.height / 700f,
Screen.height / 700f
);
if (detailShowed) if (detailShowed)
{ {
gameObjectDetailedSearch.GetComponent<UITexture>().height = 700; gameObjectDetailedSearch.GetComponent<UITexture>().height = 700;
iTween.MoveTo(gameObjectDetailedSearch, Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width - 460 - 115f * Screen.height / 700f, Screen.height * 0.5f, 0)), 0.6f); iTween.MoveTo(
reShowBar(0, 460 + 460 * Screen.height/ 700f); gameObjectDetailedSearch,
Program.camera_main_2d.ScreenToWorldPoint(
new Vector3(
Screen.width
- MAIN_SEARCH_PANEL_WIDTH
- DETAILED_SEARCH_PANEL_WIDTH
- 115f * Screen.height / 700f,
Screen.height * 0.5f,
0
)
),
0.6f
);
reShowBar(
0,
MAIN_SEARCH_PANEL_WIDTH
+ DETAILED_SEARCH_PANEL_WIDTH * Screen.height / 700f
);
} }
else else
{ {
gameObjectDetailedSearch.GetComponent<UITexture>().height = 700; gameObjectDetailedSearch.GetComponent<UITexture>().height = 700;
iTween.MoveTo(gameObjectDetailedSearch, Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width - 460 - 115f * Screen.height / 700f, Screen.height * 1.5f, 0)), 0.6f); iTween.MoveTo(
reShowBar(0, 230); gameObjectDetailedSearch,
Program.camera_main_2d.ScreenToWorldPoint(
new Vector3(
Screen.width
- MAIN_SEARCH_PANEL_WIDTH
- DETAILED_SEARCH_PANEL_WIDTH
- 115f * Screen.height / 700f,
Screen.height * 1.5f,
0
)
),
0.6f
);
reShowBar(0, CAMERA_MARGIN_RIGHT_NORMAL);
} }
} }
else else
...@@ -425,17 +559,40 @@ public class DeckManager : ServantWithCardDescription ...@@ -425,17 +559,40 @@ public class DeckManager : ServantWithCardDescription
if (detailShowed) if (detailShowed)
{ {
gameObjectDetailedSearch.GetComponent<UITexture>().height = Screen.height; gameObjectDetailedSearch.GetComponent<UITexture>().height = Screen.height;
iTween.MoveTo(gameObjectDetailedSearch, Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width - 575f, Screen.height * 0.5f, 0)), 0.6f); // [修改] 使用常量替换硬编码的 575f
reShowBar(0, 460 * 2); iTween.MoveTo(
gameObjectDetailedSearch,
Program.camera_main_2d.ScreenToWorldPoint(
new Vector3(
Screen.width - COMBINED_PANEL_WIDTH,
Screen.height * 0.5f,
0
)
),
0.6f
);
// 使用常量替换硬编码的 460*2
reShowBar(0, MAIN_SEARCH_PANEL_WIDTH + DETAILED_SEARCH_PANEL_WIDTH);
} }
else else
{ {
gameObjectDetailedSearch.GetComponent<UITexture>().height = Screen.height; gameObjectDetailedSearch.GetComponent<UITexture>().height = Screen.height;
iTween.MoveTo(gameObjectDetailedSearch, Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width - 575f, Screen.height * 1.5f, 0)), 0.6f); // 使用常量替换硬编码的 575f
reShowBar(0, 230); iTween.MoveTo(
gameObjectDetailedSearch,
Program.camera_main_2d.ScreenToWorldPoint(
new Vector3(
Screen.width - COMBINED_PANEL_WIDTH,
Screen.height * 1.5f,
0
)
),
0.6f
);
// 使用常量替换硬编码的 230
reShowBar(0, CAMERA_MARGIN_RIGHT_NORMAL);
} }
} }
} }
else else
{ {
...@@ -504,7 +661,6 @@ public class DeckManager : ServantWithCardDescription ...@@ -504,7 +661,6 @@ public class DeckManager : ServantWithCardDescription
UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "atk_UP").value = ""; UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "atk_UP").value = "";
UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "def_UP").value = ""; UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "def_UP").value = "";
UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "year_UP").value = ""; UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "year_UP").value = "";
} }
catch (System.Exception e) catch (System.Exception e)
{ {
...@@ -513,6 +669,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -513,6 +669,7 @@ public class DeckManager : ServantWithCardDescription
} }
List<string> seconds = new List<string>(); List<string> seconds = new List<string>();
void onUIPopupList_second() void onUIPopupList_second()
{ {
Program.notGo(printSecond); Program.notGo(printSecond);
...@@ -627,29 +784,28 @@ public class DeckManager : ServantWithCardDescription ...@@ -627,29 +784,28 @@ public class DeckManager : ServantWithCardDescription
private void process() private void process()
{ {
List<YGOSharp.Card> result = YGOSharp.CardsManager.searchAdvanced List<YGOSharp.Card> result = YGOSharp.CardsManager.searchAdvanced(
( getName(),
getName(), getLevel(),
getLevel(), getAttack(),
getAttack(), getDefence(),
getDefence(), getP(),
getP(), getYear(),
getYear(), getLevel_UP(),
getLevel_UP(), getAttack_UP(),
getAttack_UP(), getDefence_UP(),
getDefence_UP(), getP_UP(),
getP_UP(), getYear_UP(),
getYear_UP(), getOT(),
getOT(), getPack(),
getPack(), getBanFilter(),
getBanFilter(), currentBanlist,
currentBanlist, getTypeFilter(),
getTypeFilter(), getTypeFilter2(),
getTypeFilter2(), getRaceFilter(),
getRaceFilter(), getAttributeFilter(),
getAttributeFilter(), getCatagoryFilter()
getCatagoryFilter() );
);
print(result); print(result);
UIHelper.trySetLableText(gameObjectSearch, "title_", result.Count.ToString()); UIHelper.trySetLableText(gameObjectSearch, "title_", result.Count.ToString());
UIInput_search.isSelected = true; UIInput_search.isSelected = true;
...@@ -927,7 +1083,9 @@ public class DeckManager : ServantWithCardDescription ...@@ -927,7 +1083,9 @@ public class DeckManager : ServantWithCardDescription
int returnValue = 0; int returnValue = 0;
try try
{ {
returnValue = int.Parse(UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "atk_").value); returnValue = int.Parse(
UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "atk_").value
);
} }
catch (Exception) catch (Exception)
{ {
...@@ -945,7 +1103,9 @@ public class DeckManager : ServantWithCardDescription ...@@ -945,7 +1103,9 @@ public class DeckManager : ServantWithCardDescription
int returnValue = 0; int returnValue = 0;
try try
{ {
returnValue = int.Parse(UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "def_").value); returnValue = int.Parse(
UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "def_").value
);
} }
catch (Exception) catch (Exception)
{ {
...@@ -963,7 +1123,9 @@ public class DeckManager : ServantWithCardDescription ...@@ -963,7 +1123,9 @@ public class DeckManager : ServantWithCardDescription
int returnValue = 0; int returnValue = 0;
try try
{ {
returnValue = int.Parse(UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "stars_").value); returnValue = int.Parse(
UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "stars_").value
);
} }
catch (Exception) catch (Exception)
{ {
...@@ -981,7 +1143,9 @@ public class DeckManager : ServantWithCardDescription ...@@ -981,7 +1143,9 @@ public class DeckManager : ServantWithCardDescription
int returnValue = 0; int returnValue = 0;
try try
{ {
returnValue = int.Parse(UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "p_").value); returnValue = int.Parse(
UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "p_").value
);
} }
catch (Exception) catch (Exception)
{ {
...@@ -999,7 +1163,9 @@ public class DeckManager : ServantWithCardDescription ...@@ -999,7 +1163,9 @@ public class DeckManager : ServantWithCardDescription
int returnValue = 0; int returnValue = 0;
try try
{ {
returnValue = int.Parse(UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "year_").value); returnValue = int.Parse(
UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "year_").value
);
} }
catch (Exception) catch (Exception)
{ {
...@@ -1017,7 +1183,9 @@ public class DeckManager : ServantWithCardDescription ...@@ -1017,7 +1183,9 @@ public class DeckManager : ServantWithCardDescription
int returnValue = 0; int returnValue = 0;
try try
{ {
returnValue = int.Parse(UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "atk_UP").value); returnValue = int.Parse(
UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "atk_UP").value
);
} }
catch (Exception) catch (Exception)
{ {
...@@ -1035,7 +1203,9 @@ public class DeckManager : ServantWithCardDescription ...@@ -1035,7 +1203,9 @@ public class DeckManager : ServantWithCardDescription
int returnValue = 0; int returnValue = 0;
try try
{ {
returnValue = int.Parse(UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "def_UP").value); returnValue = int.Parse(
UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "def_UP").value
);
} }
catch (Exception) catch (Exception)
{ {
...@@ -1053,7 +1223,9 @@ public class DeckManager : ServantWithCardDescription ...@@ -1053,7 +1223,9 @@ public class DeckManager : ServantWithCardDescription
int returnValue = 0; int returnValue = 0;
try try
{ {
returnValue = int.Parse(UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "stars_UP").value); returnValue = int.Parse(
UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "stars_UP").value
);
} }
catch (Exception) catch (Exception)
{ {
...@@ -1071,7 +1243,9 @@ public class DeckManager : ServantWithCardDescription ...@@ -1071,7 +1243,9 @@ public class DeckManager : ServantWithCardDescription
int returnValue = 0; int returnValue = 0;
try try
{ {
returnValue = int.Parse(UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "p_UP").value); returnValue = int.Parse(
UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "p_UP").value
);
} }
catch (Exception) catch (Exception)
{ {
...@@ -1089,7 +1263,9 @@ public class DeckManager : ServantWithCardDescription ...@@ -1089,7 +1263,9 @@ public class DeckManager : ServantWithCardDescription
int returnValue = 0; int returnValue = 0;
try try
{ {
returnValue = int.Parse(UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "year_UP").value); returnValue = int.Parse(
UIHelper.getByName<UIInput>(gameObjectDetailedSearch, "year_UP").value
);
} }
catch (Exception) catch (Exception)
{ {
...@@ -1116,6 +1292,27 @@ public class DeckManager : ServantWithCardDescription ...@@ -1116,6 +1292,27 @@ public class DeckManager : ServantWithCardDescription
return UIPopupList_pack.value; return UIPopupList_pack.value;
} }
// [新增] 封装的添加卡片副本的逻辑,用于复用
private void AddCopyToDeck(MonoCardInDeckManager sourceCard)
{
// 安全检查:如果不在编辑模式,或卡片已满编,则不执行任何操作
if (condition != Condition.editDeck || !checkBanlistAvail(sourceCard.cardData.Id))
{
return;
}
MonoCardInDeckManager newCard = createCard();
// 将新卡片生成在原卡片稍上方,视觉效果更好
newCard.transform.position = sourceCard.transform.position + Vector3.up * 0.5f;
sourceCard.cardData.cloneTo(newCard.cardData);
newCard.gameObject.layer = 16;
// 统一添加到 IMain 中,后续的 ArrangeObjectDeck 会自动处理分类(主卡组或额外)
deck.IMain.Add(newCard);
deckDirty = true;
ArrangeObjectDeck(true); // 重新整理数据
ShowObjectDeck(); // 重新排列场上的卡片
}
#endregion #endregion
GameObject gameObjectDesk = null; GameObject gameObjectDesk = null;
...@@ -1147,19 +1344,57 @@ public class DeckManager : ServantWithCardDescription ...@@ -1147,19 +1344,57 @@ public class DeckManager : ServantWithCardDescription
gameObjectDesk.transform.position = new Vector3(0, 0, 0); gameObjectDesk.transform.position = new Vector3(0, 0, 0);
gameObjectDesk.transform.eulerAngles = new Vector3(90, 0, 0); gameObjectDesk.transform.eulerAngles = new Vector3(90, 0, 0);
gameObjectDesk.transform.localScale = new Vector3(30, 30, 1); gameObjectDesk.transform.localScale = new Vector3(30, 30, 1);
gameObjectDesk.GetComponent<Renderer>().material.mainTexture = Program.GetTextureViaPath("textures/duel/deckTable.png");//YGOMobile Paths gameObjectDesk.GetComponent<Renderer>().material.mainTexture = Program.GetTextureViaPath(
"textures/duel/deckTable.png"
); //YGOMobile Paths
//UIHelper.SetMaterialRenderingMode(gameObjectDesk.GetComponent<Renderer>().material, UIHelper.RenderingMode.Transparent); //UIHelper.SetMaterialRenderingMode(gameObjectDesk.GetComponent<Renderer>().material, UIHelper.RenderingMode.Transparent);
Rigidbody rigidbody = gameObjectDesk.AddComponent<Rigidbody>(); Rigidbody rigidbody = gameObjectDesk.AddComponent<Rigidbody>();
rigidbody.useGravity = false; rigidbody.useGravity = false;
rigidbody.isKinematic = true; rigidbody.isKinematic = true;
rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
BoxCollider boxCollider = gameObjectDesk.AddComponent<BoxCollider>(); BoxCollider boxCollider = gameObjectDesk.AddComponent<BoxCollider>();
main_unmber = create_s(Program.I().mod_ocgcore_number, new Vector3(-16.5f, 0, 13.6f), new Vector3(90, 0, 0), true).GetComponent<number_loader>(); main_unmber = create_s(
m_unmber = create_s(Program.I().mod_ocgcore_number, new Vector3(-16.5f, 0, 6.6f), new Vector3(90, 0, 0), true).GetComponent<number_loader>(); Program.I().mod_ocgcore_number,
s_number = create_s(Program.I().mod_ocgcore_number, new Vector3(-16.5f, 0, 4.6f), new Vector3(90, 0, 0), true).GetComponent<number_loader>(); new Vector3(-16.5f, 0, 13.6f),
t_unmber = create_s(Program.I().mod_ocgcore_number, new Vector3(-16.5f, 0, 2.6f), new Vector3(90, 0, 0), true).GetComponent<number_loader>(); new Vector3(90, 0, 0),
extra_unmber = create_s(Program.I().mod_ocgcore_number, new Vector3(-16.5f, 0, -5.3f), new Vector3(90, 0, 0), true).GetComponent<number_loader>(); true
side_number = create_s(Program.I().mod_ocgcore_number, new Vector3(-16.5f, 0, -11f), new Vector3(90, 0, 0), true).GetComponent<number_loader>(); )
.GetComponent<number_loader>();
m_unmber = create_s(
Program.I().mod_ocgcore_number,
new Vector3(-16.5f, 0, 6.6f),
new Vector3(90, 0, 0),
true
)
.GetComponent<number_loader>();
s_number = create_s(
Program.I().mod_ocgcore_number,
new Vector3(-16.5f, 0, 4.6f),
new Vector3(90, 0, 0),
true
)
.GetComponent<number_loader>();
t_unmber = create_s(
Program.I().mod_ocgcore_number,
new Vector3(-16.5f, 0, 2.6f),
new Vector3(90, 0, 0),
true
)
.GetComponent<number_loader>();
extra_unmber = create_s(
Program.I().mod_ocgcore_number,
new Vector3(-16.5f, 0, -5.3f),
new Vector3(90, 0, 0),
true
)
.GetComponent<number_loader>();
side_number = create_s(
Program.I().mod_ocgcore_number,
new Vector3(-16.5f, 0, -11f),
new Vector3(90, 0, 0),
true
)
.GetComponent<number_loader>();
switch (condition) switch (condition)
{ {
case Condition.editDeck: case Condition.editDeck:
...@@ -1209,6 +1444,38 @@ public class DeckManager : ServantWithCardDescription ...@@ -1209,6 +1444,38 @@ public class DeckManager : ServantWithCardDescription
public override void preFrameFunction() public override void preFrameFunction()
{ {
base.preFrameFunction(); base.preFrameFunction();
// [修改] 全新的长按与拖拽检测逻辑
if (cardForLongPress != null)
{
// 1. 检查是否为拖拽 (鼠标移动超过一定距离)
if (Vector3.Distance(Input.mousePosition, mouseDownPosition) > 15f) // 15像素的阈值
{
// 判定为拖拽,开始拖拽卡牌
cardInDragging = cardForLongPress;
cardInDragging.beginDrag();
cardForLongPress = null; // 清除长按检测状态
isContinuouslyAdding = false; // 确保连续添加状态也被重置
}
// 2. 检查是否满足长按条件
else if (Time.time - pressStartTime > INITIAL_LONG_PRESS_DURATION)
{
// 2a. 如果是首次触发长按,立即添加第一张并启动持续添加模式
if (!isContinuouslyAdding)
{
isContinuouslyAdding = true;
AddCopyToDeck(cardForLongPress); // 添加第一张卡
nextAddCardTime = Time.time + CONTINUOUS_ADD_INTERVAL; // 设定下一次添加的时间
}
// 2b. 如果已在持续添加模式,检查是否到达下一次添加的时间点
else if (Time.time >= nextAddCardTime)
{
AddCopyToDeck(cardForLongPress); // 添加后续卡片
nextAddCardTime = Time.time + CONTINUOUS_ADD_INTERVAL; // 再次设定下一次添加的时间
}
}
}
if (cardInDragging != null) if (cardInDragging != null)
{ {
if (detailPanelShiftedTemp == false) if (detailPanelShiftedTemp == false)
...@@ -1240,7 +1507,11 @@ public class DeckManager : ServantWithCardDescription ...@@ -1240,7 +1507,11 @@ public class DeckManager : ServantWithCardDescription
} }
} }
cameraDistance = 29 - 3.1415926f / 180f * (cameraAngle - 60f) * 13f; cameraDistance = 29 - 3.1415926f / 180f * (cameraAngle - 60f) * 13f;
Program.cameraPosition = new Vector3(0, cameraDistance * Mathf.Sin(3.1415926f / 180f * cameraAngle), -cameraDistance * Mathf.Cos(3.1415926f / 180f * cameraAngle)); Program.cameraPosition = new Vector3(
0,
cameraDistance * Mathf.Sin(3.1415926f / 180f * cameraAngle),
-cameraDistance * Mathf.Cos(3.1415926f / 180f * cameraAngle)
);
if (Program.TimePassed() - lastRefreshTime > 80) if (Program.TimePassed() - lastRefreshTime > 80)
{ {
lastRefreshTime = Program.TimePassed(); lastRefreshTime = Program.TimePassed();
...@@ -1248,12 +1519,17 @@ public class DeckManager : ServantWithCardDescription ...@@ -1248,12 +1519,17 @@ public class DeckManager : ServantWithCardDescription
main_unmber.set_number(deck.Main.Count, 3); main_unmber.set_number(deck.Main.Count, 3);
side_number.set_number(deck.Side.Count, 4); side_number.set_number(deck.Side.Count, 4);
extra_unmber.set_number(deck.Extra.Count, 0); extra_unmber.set_number(deck.Extra.Count, 0);
int m = 0, s = 0, t = 0; int m = 0,
s = 0,
t = 0;
foreach (var item in deck.IMain) foreach (var item in deck.IMain)
{ {
if ((item.cardData.Type & (int)CardType.Monster) > 0) m++; if ((item.cardData.Type & (int)CardType.Monster) > 0)
if ((item.cardData.Type & (int)CardType.Spell) > 0) s++; m++;
if ((item.cardData.Type & (int)CardType.Trap) > 0) t++; if ((item.cardData.Type & (int)CardType.Spell) > 0)
s++;
if ((item.cardData.Type & (int)CardType.Trap) > 0)
t++;
} }
m_unmber.set_number(m, 1); m_unmber.set_number(m, 1);
s_number.set_number(s, 2); s_number.set_number(s, 2);
...@@ -1280,7 +1556,8 @@ public class DeckManager : ServantWithCardDescription ...@@ -1280,7 +1556,8 @@ public class DeckManager : ServantWithCardDescription
{ {
if (gameObjectDetailedSearch != null) if (gameObjectDetailedSearch != null)
{ {
r -= 230 * gameObjectDetailedSearch.transform.localScale.x; // [修改] 使用常量替换硬编码的 230
r -= CAMERA_MARGIN_RIGHT_DETAILED * gameObjectDetailedSearch.transform.localScale.x;
} }
} }
Program.reMoveCam((l + r) / 2f); Program.reMoveCam((l + r) / 2f);
...@@ -1291,12 +1568,18 @@ public class DeckManager : ServantWithCardDescription ...@@ -1291,12 +1568,18 @@ public class DeckManager : ServantWithCardDescription
MonoCardInDeckManager cardInDeck = gameObject.GetComponent<MonoCardInDeckManager>(); MonoCardInDeckManager cardInDeck = gameObject.GetComponent<MonoCardInDeckManager>();
if (cardInDeck != null) if (cardInDeck != null)
{ {
((CardDescription)(Program.I().cardDescription)).setData(cardInDeck.cardData, GameTextureManager.myBack); ((CardDescription)(Program.I().cardDescription)).setData(
cardInDeck.cardData,
GameTextureManager.myBack
);
} }
cardPicLoader cardInSearchResult = gameObject.GetComponent<cardPicLoader>(); cardPicLoader cardInSearchResult = gameObject.GetComponent<cardPicLoader>();
if (cardInSearchResult != null) if (cardInSearchResult != null)
{ {
((CardDescription)(Program.I().cardDescription)).setData(cardInSearchResult.data, GameTextureManager.myBack); ((CardDescription)(Program.I().cardDescription)).setData(
cardInSearchResult.data,
GameTextureManager.myBack
);
} }
} }
...@@ -1306,36 +1589,15 @@ public class DeckManager : ServantWithCardDescription ...@@ -1306,36 +1589,15 @@ public class DeckManager : ServantWithCardDescription
public override void ES_mouseDownGameObject(GameObject gameObject) public override void ES_mouseDownGameObject(GameObject gameObject)
{ {
bool doubleClick = false;
if (goLast == gameObject)
{
if (Program.TimePassed() - timeLastDown < 300)
{
doubleClick = true;
}
}
goLast = gameObject;
timeLastDown = Program.TimePassed();
MonoCardInDeckManager cardInDeck = gameObject.GetComponent<MonoCardInDeckManager>(); MonoCardInDeckManager cardInDeck = gameObject.GetComponent<MonoCardInDeckManager>();
cardPicLoader cardInSearchResult = gameObject.GetComponent<cardPicLoader>(); cardPicLoader cardInSearchResult = gameObject.GetComponent<cardPicLoader>();
if (cardInDeck != null && !cardInDeck.dying) if (cardInDeck != null && !cardInDeck.dying)
{ {
if (doubleClick && condition == Condition.editDeck && checkBanlistAvail(cardInDeck.cardData.Id)) // [修改] 初始化长按/拖拽状态
{ cardForLongPress = cardInDeck;
MonoCardInDeckManager card = createCard(); pressStartTime = Time.time;
card.transform.position = cardInDeck.transform.position; isContinuouslyAdding = false; // 每次按下都重置持续添加状态
cardInDeck.cardData.cloneTo(card.cardData); mouseDownPosition = Input.mousePosition;
card.gameObject.layer = 16;
deck.IMain.Add(card);
deckDirty = true;
ArrangeObjectDeck(true);
ShowObjectDeck();
}
else
{
cardInDragging = cardInDeck;
cardInDeck.beginDrag();
}
} }
else if (cardInSearchResult != null) else if (cardInSearchResult != null)
{ {
...@@ -1362,20 +1624,26 @@ public class DeckManager : ServantWithCardDescription ...@@ -1362,20 +1624,26 @@ public class DeckManager : ServantWithCardDescription
{ {
if (cardInDragging != null) if (cardInDragging != null)
{ {
if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) // 第一步:终止拖拽,设置物理状态
{ cardInDragging.endDrag();
//
} // 第二步:逻辑判断是否仍应纳入卡组
else if (cardInDragging.getIfAlive())
{ {
if (cardInDragging.getIfAlive()) deckDirty = true;
deckDirty = true;
ArrangeObjectDeck(true);
ShowObjectDeck();
} }
cardInDragging.endDrag();
// 第三步:整理数据结构(IMain、ISide等)
ArrangeObjectDeck(true);
// 第四步:更新卡片在场景中的位置与角度(含Tween)
ShowObjectDeck();
// 第五步:清除引用
cardInDragging = null; cardInDragging = null;
} }
cardForLongPress = null;
isContinuouslyAdding = false;
} }
public override void ES_mouseUpRight() public override void ES_mouseUpRight()
...@@ -1384,14 +1652,16 @@ public class DeckManager : ServantWithCardDescription ...@@ -1384,14 +1652,16 @@ public class DeckManager : ServantWithCardDescription
{ {
if (condition == Condition.editDeck) if (condition == Condition.editDeck)
{ {
MonoCardInDeckManager cardInDeck = Program.pointedGameObject.GetComponent<MonoCardInDeckManager>(); MonoCardInDeckManager cardInDeck =
Program.pointedGameObject.GetComponent<MonoCardInDeckManager>();
if (cardInDeck != null) if (cardInDeck != null)
{ {
cardInDeck.killIt(); cardInDeck.killIt();
ArrangeObjectDeck(true); ArrangeObjectDeck(true);
ShowObjectDeck(); ShowObjectDeck();
} }
cardPicLoader cardInSearchResult = Program.pointedGameObject.GetComponent<cardPicLoader>(); cardPicLoader cardInSearchResult =
Program.pointedGameObject.GetComponent<cardPicLoader>();
if (cardInSearchResult != null) if (cardInSearchResult != null)
{ {
CreateMonoCard(cardInSearchResult.data); CreateMonoCard(cardInSearchResult.data);
...@@ -1400,13 +1670,14 @@ public class DeckManager : ServantWithCardDescription ...@@ -1400,13 +1670,14 @@ public class DeckManager : ServantWithCardDescription
} }
else else
{ {
MonoCardInDeckManager cardInDeck = Program.pointedGameObject.GetComponent<MonoCardInDeckManager>(); MonoCardInDeckManager cardInDeck =
Program.pointedGameObject.GetComponent<MonoCardInDeckManager>();
if (cardInDeck != null) if (cardInDeck != null)
{ {
bool isSide = false; bool isSide = false;
for (int i = 0; i < deck.ISide.Count; i++) for (int i = 0; i < deck.ISide.Count; i++)
{ {
if (cardInDeck== deck.ISide[i]) if (cardInDeck == deck.ISide[i])
{ {
isSide = true; isSide = true;
} }
...@@ -1498,10 +1769,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1498,10 +1769,7 @@ public class DeckManager : ServantWithCardDescription
{ {
code = Int32.Parse(line); code = Int32.Parse(line);
} }
catch (Exception) catch (Exception) { }
{
}
if (code > 100) if (code > 100)
{ {
YGOSharp.Card card = YGOSharp.CardsManager.Get(code); YGOSharp.Card card = YGOSharp.CardsManager.Get(code);
...@@ -1519,39 +1787,38 @@ public class DeckManager : ServantWithCardDescription ...@@ -1519,39 +1787,38 @@ public class DeckManager : ServantWithCardDescription
} }
} }
else else
switch (flag) switch (flag)
{ {
case 1: case 1:
{ {
deck.Main.Add(code); deck.Main.Add(code);
deck.Deck_O.Main.Add(code); deck.Deck_O.Main.Add(code);
} }
break; break;
case 2: case 2:
{ {
deck.Extra.Add(code); deck.Extra.Add(code);
deck.Deck_O.Extra.Add(code); deck.Deck_O.Extra.Add(code);
} }
break; break;
case 3: case 3:
{ {
deck.Side.Add(code); deck.Side.Add(code);
deck.Deck_O.Side.Add(code); deck.Deck_O.Side.Add(code);
} }
break; break;
default: default:
break; break;
} }
} }
} }
} }
} }
catch (Exception e) catch (Exception e) { }
{
}
} }
public static bool FromBase64toCodedDeck(string base64, out YGOSharp.Deck deck) { public static bool FromBase64toCodedDeck(string base64, out YGOSharp.Deck deck)
{
deck = new YGOSharp.Deck(); deck = new YGOSharp.Deck();
bool res = true; bool res = true;
try try
...@@ -1562,7 +1829,8 @@ public class DeckManager : ServantWithCardDescription ...@@ -1562,7 +1829,8 @@ public class DeckManager : ServantWithCardDescription
offset += 4; offset += 4;
int sidec = BitConverter.ToInt32(buffer, offset); int sidec = BitConverter.ToInt32(buffer, offset);
offset += 4; offset += 4;
for(int i = 0; i < mainc; ++i) { for (int i = 0; i < mainc; ++i)
{
int code = BitConverter.ToInt32(buffer, offset); int code = BitConverter.ToInt32(buffer, offset);
offset += 4; offset += 4;
if (code > 100) if (code > 100)
...@@ -1580,7 +1848,8 @@ public class DeckManager : ServantWithCardDescription ...@@ -1580,7 +1848,8 @@ public class DeckManager : ServantWithCardDescription
} }
} }
} }
for(int i = 0; i < sidec; ++i) { for (int i = 0; i < sidec; ++i)
{
int code = BitConverter.ToInt32(buffer, offset); int code = BitConverter.ToInt32(buffer, offset);
offset += 4; offset += 4;
if (code > 100) if (code > 100)
...@@ -1597,7 +1866,8 @@ public class DeckManager : ServantWithCardDescription ...@@ -1597,7 +1866,8 @@ public class DeckManager : ServantWithCardDescription
return res; return res;
} }
public static string convertDeckToBase64(YGOSharp.Deck deck) { public static string convertDeckToBase64(YGOSharp.Deck deck)
{
List<byte> array_list = new List<byte>(); List<byte> array_list = new List<byte>();
writeInt32ToList(array_list, deck.Main.Count + deck.Extra.Count); writeInt32ToList(array_list, deck.Main.Count + deck.Extra.Count);
writeInt32ToList(array_list, deck.Side.Count); writeInt32ToList(array_list, deck.Side.Count);
...@@ -1617,9 +1887,11 @@ public class DeckManager : ServantWithCardDescription ...@@ -1617,9 +1887,11 @@ public class DeckManager : ServantWithCardDescription
return Convert.ToBase64String(buffer); return Convert.ToBase64String(buffer);
} }
private static void writeInt32ToList(List<byte> array_list, int value) { private static void writeInt32ToList(List<byte> array_list, int value)
{
byte[] int_buffer = BitConverter.GetBytes(value); byte[] int_buffer = BitConverter.GetBytes(value);
for(int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i)
{
array_list.Add(int_buffer[i]); array_list.Add(int_buffer[i]);
} }
} }
...@@ -1657,53 +1929,55 @@ public class DeckManager : ServantWithCardDescription ...@@ -1657,53 +1929,55 @@ public class DeckManager : ServantWithCardDescription
var deckTemp = deck.getAllObjectCardAndDeload(); var deckTemp = deck.getAllObjectCardAndDeload();
if (order) if (order)
{ {
deckTemp.Sort((left, right) => deckTemp.Sort(
{ (left, right) =>
Vector3 leftPosition = left.gameObject.transform.position;
Vector3 rightPosition = right.gameObject.transform.position;
if (leftPosition.y > 3f)
{ {
leftPosition = MonoCardInDeckManager.refLectPosition(leftPosition); Vector3 leftPosition = left.gameObject.transform.position;
} Vector3 rightPosition = right.gameObject.transform.position;
if (rightPosition.y > 3f) if (leftPosition.y > 3f)
{
rightPosition = MonoCardInDeckManager.refLectPosition(rightPosition);
}
if (leftPosition.z > -3 && rightPosition.z > -3)
{
float l = leftPosition.x + 1000f * (int)((13f - leftPosition.z) / 3.7f);
float r = rightPosition.x + 1000f * (int)((13f - rightPosition.z) / 3.7f);
if (l < r)
{ {
return -1; leftPosition = MonoCardInDeckManager.refLectPosition(leftPosition);
} }
else if (rightPosition.y > 3f)
{
rightPosition = MonoCardInDeckManager.refLectPosition(rightPosition);
}
if (leftPosition.z > -3 && rightPosition.z > -3)
{
float l = leftPosition.x + 1000f * (int)((13f - leftPosition.z) / 3.7f);
float r = rightPosition.x + 1000f * (int)((13f - rightPosition.z) / 3.7f);
if (l < r)
{
return -1;
}
else
{
return 1;
}
}
else if (leftPosition.z > -3 && rightPosition.z < -3)
{ {
return 1; return 1;
} }
} else if (leftPosition.z < -3 && rightPosition.z > -3)
else if (leftPosition.z > -3 && rightPosition.z < -3)
{
return 1;
}
else if (leftPosition.z < -3 && rightPosition.z > -3)
{
return -1;
}
else
{
float l = leftPosition.x;
float r = rightPosition.x;
if (l < r)
{ {
return -1; return -1;
} }
else else
{ {
return 1; float l = leftPosition.x;
float r = rightPosition.x;
if (l < r)
{
return -1;
}
else
{
return 1;
}
} }
} }
}); );
} }
for (int i = 0; i < deckTemp.Count; i++) for (int i = 0; i < deckTemp.Count; i++)
{ {
...@@ -1747,8 +2021,6 @@ public class DeckManager : ServantWithCardDescription ...@@ -1747,8 +2021,6 @@ public class DeckManager : ServantWithCardDescription
deckDirty = true; deckDirty = true;
} }
List<GameObject> diedCards = new List<GameObject>(); List<GameObject> diedCards = new List<GameObject>();
MonoCardInDeckManager createCard() MonoCardInDeckManager createCard()
...@@ -1761,9 +2033,18 @@ public class DeckManager : ServantWithCardDescription ...@@ -1761,9 +2033,18 @@ public class DeckManager : ServantWithCardDescription
} }
if (r == null) if (r == null)
{ {
r = Program.I().create(Program.I().new_mod_cardInDeckManager).AddComponent<MonoCardInDeckManager>(); r = Program
r.gameObject.transform.Find("back").gameObject.GetComponent<Renderer>().material.mainTexture = GameTextureManager.myBack; .I()
r.gameObject.transform.Find("face").gameObject.GetComponent<Renderer>().material.mainTexture = GameTextureManager.myBack; .create(Program.I().new_mod_cardInDeckManager)
.AddComponent<MonoCardInDeckManager>();
r
.gameObject.transform.Find("back")
.gameObject.GetComponent<Renderer>()
.material.mainTexture = GameTextureManager.myBack;
r
.gameObject.transform.Find("face")
.gameObject.GetComponent<Renderer>()
.material.mainTexture = GameTextureManager.myBack;
} }
r.gameObject.transform.position = new Vector3(0, 5, 0); r.gameObject.transform.position = new Vector3(0, 5, 0);
r.gameObject.transform.eulerAngles = new Vector3(90, 0, 0); r.gameObject.transform.eulerAngles = new Vector3(90, 0, 0);
...@@ -1792,55 +2073,79 @@ public class DeckManager : ServantWithCardDescription ...@@ -1792,55 +2073,79 @@ public class DeckManager : ServantWithCardDescription
public void FormCodedDeckToObjectDeck() public void FormCodedDeckToObjectDeck()
{ {
canSave = false; canSave = false;
safeGogo(4000, () => safeGogo(
{ 4000,
canSave = true; () =>
}); {
canSave = true;
}
);
int indexOfLogic = 0; int indexOfLogic = 0;
int[] hangshu = UIHelper.get_decklieshuArray(deck.Main.Count); int[] hangshu = UIHelper.get_decklieshuArray(deck.Main.Count);
foreach (var item in deck.Main) foreach (var item in deck.Main)
{ {
Vector2 v = UIHelper.get_hang_lieArry(indexOfLogic, hangshu); Vector2 v = UIHelper.get_hang_lieArry(indexOfLogic, hangshu);
Vector3 toVector = new Vector3(UIHelper.get_left_right_index(-12.5f, 12.5f, (int)v.y, hangshu[(int)v.x]), 0.5f + v.y / 3f + v.x / 3f, 11.8f - v.x * 4f); Vector3 toVector = new Vector3(
UIHelper.get_left_right_index(-12.5f, 12.5f, (int)v.y, hangshu[(int)v.x]),
0.5f + v.y / 3f + v.x / 3f,
11.8f - v.x * 4f
);
YGOSharp.Card data = YGOSharp.CardsManager.Get(item); YGOSharp.Card data = YGOSharp.CardsManager.Get(item);
safeGogo(indexOfLogic * 25, () => safeGogo(
{ indexOfLogic * 25,
MonoCardInDeckManager card = createCard(); () =>
card.cardData = data; {
card.gameObject.layer = 16; MonoCardInDeckManager card = createCard();
deck.IMain.Add(card); card.cardData = data;
card.tweenToVectorAndFall(toVector, new Vector3(90, 0, 0)); card.gameObject.layer = 16;
}); deck.IMain.Add(card);
card.tweenToVectorAndFall(toVector, new Vector3(90, 0, 0));
}
);
indexOfLogic++; indexOfLogic++;
} }
indexOfLogic = 0; indexOfLogic = 0;
foreach (var item in deck.Extra) foreach (var item in deck.Extra)
{ {
Vector3 toVector = new Vector3(UIHelper.get_left_right_indexZuo(-12.5f, 12.5f, indexOfLogic, deck.Extra.Count, 10), 0.5f + (float)indexOfLogic / 3f, -6.2f); Vector3 toVector = new Vector3(
UIHelper.get_left_right_indexZuo(-12.5f, 12.5f, indexOfLogic, deck.Extra.Count, 10),
0.5f + (float)indexOfLogic / 3f,
-6.2f
);
YGOSharp.Card data = YGOSharp.CardsManager.Get(item); YGOSharp.Card data = YGOSharp.CardsManager.Get(item);
safeGogo(indexOfLogic * 90, () => safeGogo(
{ indexOfLogic * 90,
MonoCardInDeckManager card = createCard(); () =>
card.cardData = data; {
card.gameObject.layer = 16; MonoCardInDeckManager card = createCard();
deck.IExtra.Add(card); card.cardData = data;
card.tweenToVectorAndFall(toVector, new Vector3(90, 0, 0)); card.gameObject.layer = 16;
}); deck.IExtra.Add(card);
card.tweenToVectorAndFall(toVector, new Vector3(90, 0, 0));
}
);
indexOfLogic++; indexOfLogic++;
} }
indexOfLogic = 0; indexOfLogic = 0;
foreach (var item in deck.Side) foreach (var item in deck.Side)
{ {
Vector3 toVector = new Vector3(UIHelper.get_left_right_indexZuo(-12.5f, 12.5f, indexOfLogic, deck.Side.Count, 10), 0.5f + (float)indexOfLogic / 3f, -12f); Vector3 toVector = new Vector3(
UIHelper.get_left_right_indexZuo(-12.5f, 12.5f, indexOfLogic, deck.Side.Count, 10),
0.5f + (float)indexOfLogic / 3f,
-12f
);
YGOSharp.Card data = YGOSharp.CardsManager.Get(item); YGOSharp.Card data = YGOSharp.CardsManager.Get(item);
safeGogo(indexOfLogic * 90, () => safeGogo(
{ indexOfLogic * 90,
MonoCardInDeckManager card = createCard(); () =>
card.cardData = data; {
card.gameObject.layer = 16; MonoCardInDeckManager card = createCard();
deck.ISide.Add(card); card.cardData = data;
card.tweenToVectorAndFall(toVector, new Vector3(90, 0, 0)); card.gameObject.layer = 16;
}); deck.ISide.Add(card);
card.tweenToVectorAndFall(toVector, new Vector3(90, 0, 0));
}
);
indexOfLogic++; indexOfLogic++;
} }
} }
...@@ -1861,7 +2166,11 @@ public class DeckManager : ServantWithCardDescription ...@@ -1861,7 +2166,11 @@ public class DeckManager : ServantWithCardDescription
toAngle = new Vector3(87f - (hangshu[(int)v.x] - 10f) * 0.4f, -90, -90); toAngle = new Vector3(87f - (hangshu[(int)v.x] - 10f) * 0.4f, -90, -90);
} }
} }
Vector3 toVector = new Vector3(UIHelper.get_left_right_indexZuo(-12.5f, 12.5f, (int)v.y, hangshu[(int)v.x], 10), 0.6f + Mathf.Sin((90 - toAngle.x) / 180f * Mathf.PI) * k, 11.8f - v.x * 4f); Vector3 toVector = new Vector3(
UIHelper.get_left_right_indexZuo(-12.5f, 12.5f, (int)v.y, hangshu[(int)v.x], 10),
0.6f + Mathf.Sin((90 - toAngle.x) / 180f * Mathf.PI) * k,
11.8f - v.x * 4f
);
deck.IMain[i].tweenToVectorAndFall(toVector, toAngle); deck.IMain[i].tweenToVectorAndFall(toVector, toAngle);
} }
for (int i = 0; i < deck.IExtra.Count; i++) for (int i = 0; i < deck.IExtra.Count; i++)
...@@ -1875,7 +2184,11 @@ public class DeckManager : ServantWithCardDescription ...@@ -1875,7 +2184,11 @@ public class DeckManager : ServantWithCardDescription
toAngle = new Vector3(87f - (deck.IExtra.Count - 10f) * 0.4f, -90, -90); toAngle = new Vector3(87f - (deck.IExtra.Count - 10f) * 0.4f, -90, -90);
} }
} }
Vector3 toVector = new Vector3(UIHelper.get_left_right_indexZuo(-12.5f, 12.5f, i, deck.IExtra.Count, 10), 0.6f + Mathf.Sin((90 - toAngle.x) / 180f * Mathf.PI) * k, -6.2f); Vector3 toVector = new Vector3(
UIHelper.get_left_right_indexZuo(-12.5f, 12.5f, i, deck.IExtra.Count, 10),
0.6f + Mathf.Sin((90 - toAngle.x) / 180f * Mathf.PI) * k,
-6.2f
);
deck.IExtra[i].tweenToVectorAndFall(toVector, toAngle); deck.IExtra[i].tweenToVectorAndFall(toVector, toAngle);
} }
...@@ -1890,7 +2203,11 @@ public class DeckManager : ServantWithCardDescription ...@@ -1890,7 +2203,11 @@ public class DeckManager : ServantWithCardDescription
toAngle = new Vector3(87f - (deck.ISide.Count - 10f) * 0.4f, -90, -90); toAngle = new Vector3(87f - (deck.ISide.Count - 10f) * 0.4f, -90, -90);
} }
} }
Vector3 toVector = new Vector3(UIHelper.get_left_right_indexZuo(-12.5f, 12.5f, i, deck.ISide.Count, 10), 0.6f + Mathf.Sin((90 - toAngle.x) / 180f * Mathf.PI) * k, -12f); Vector3 toVector = new Vector3(
UIHelper.get_left_right_indexZuo(-12.5f, 12.5f, i, deck.ISide.Count, 10),
0.6f + Mathf.Sin((90 - toAngle.x) / 180f * Mathf.PI) * k,
-12f
);
deck.ISide[i].tweenToVectorAndFall(toVector, toAngle); deck.ISide[i].tweenToVectorAndFall(toVector, toAngle);
} }
} }
...@@ -1919,7 +2236,10 @@ public class DeckManager : ServantWithCardDescription ...@@ -1919,7 +2236,10 @@ public class DeckManager : ServantWithCardDescription
{ {
try try
{ {
((CardDescription)(Program.I().cardDescription)).setData(YGOSharp.CardsManager.Get(deck.Main[0]), GameTextureManager.myBack); ((CardDescription)(Program.I().cardDescription)).setData(
YGOSharp.CardsManager.Get(deck.Main[0]),
GameTextureManager.myBack
);
} }
catch (System.Exception e) catch (System.Exception e)
{ {
...@@ -1937,7 +2257,11 @@ public class DeckManager : ServantWithCardDescription ...@@ -1937,7 +2257,11 @@ public class DeckManager : ServantWithCardDescription
} }
else else
{ {
UIHelper.trySetLableText(gameObjectSearch, "title_", InterString.Get("在此搜索卡片,拖动加入卡组")); UIHelper.trySetLableText(
gameObjectSearch,
"title_",
InterString.Get("在此搜索卡片,拖动加入卡组")
);
} }
Program.go(50, superScrollView.toTop); Program.go(50, superScrollView.toTop);
Program.go(100, superScrollView.toTop); Program.go(100, superScrollView.toTop);
......
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