Commit 373b4951 authored by SherryChaos's avatar SherryChaos

bug fix

parent 727cbd30
This diff is collapsed.
......@@ -134,7 +134,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
......
......@@ -186,7 +186,7 @@ namespace MDPro3.UI
if(cookieCard.p.controller == 0)
height = 250f;
else
height = -100;
height = -200;
}
}
}
......
......@@ -24,26 +24,29 @@ namespace MDPro3
public static string lastRecordName = "";
public static List<Package> packagesInRecord = new List<Package>();
private static readonly Queue<Package> messageQueue = new Queue<Package>();
public static void InitializeSender()
{
var senderThead = new Thread(Sender);
senderThead.IsBackground = true;
senderThead.Start();
}
public static void Join(string ipString, string name, string portString, string pswString, string version)
{
//Debug.Log("TcpHelper-Join-Start");
if (canJoin)
{
//Debug.Log("TcpHelper-Join-canJoin: true");
if (tcpClient == null || tcpClient.Connected == false)
{
//Debug.Log("TcpHelper-Join-mark1");
canJoin = false;
try
{
//Debug.Log("TcpHelper-Join-mark2");
tcpClient = new TcpClientWithTimeout(ipString, int.Parse(portString), 3000).Connect();
networkStream = tcpClient.GetStream();
var t = new Thread(Receiver);
t.Start();
messageQueue.Clear();
InitializeSender();
CtosMessage_PlayerInfo(name);
CtosMessage_JoinGame(pswString, version);
}
......@@ -56,16 +59,12 @@ namespace MDPro3
}
else
{
//Debug.Log("TcpHelper-Join-canJoin: false");
onDisConnected = true;
}
}
public static void Receiver()
{
//Debug.Log("TcpHelper-Receiver-Start");
try
{
while (tcpClient != null
......@@ -74,19 +73,13 @@ namespace MDPro3
&& Program.Running
&& !Program.I().room.duelEnded)
{
//Debug.Log("TcpHelper-Receiver-Mark1");
var data = SocketMaster.ReadPacket(networkStream);
AddDateJumoLine(data);
}
//Debug.Log("TcpHelper-Receiver-Mark2");
onDisConnected = true;
}
catch
{
//Debug.Log("TcpHelper-Receiver-Mark3");
onDisConnected = true;
}
}
......@@ -231,37 +224,56 @@ namespace MDPro3
public static void Send(Package message)
{
if (tcpClient != null && tcpClient.Connected)
lock (locker)
{
var t = new Thread(Sender);
t.Start(message);
messageQueue.Enqueue(message);
}
}
private static void Sender(object o)
private static void Sender()
{
try
while (tcpClient != null && tcpClient.Connected)
{
Package currentMessage;
lock (locker)
{
var message = (Package)o;
var data = message.Data.Get();
var memstream = new MemoryStream();
var b = new BinaryWriter(memstream);
b.Write(BitConverter.GetBytes((short)data.Length + 1), 0, 2);
b.Write(BitConverter.GetBytes((byte)message.Function), 0, 1);
b.Write(data, 0, data.Length);
var s = memstream.ToArray();
//Debug.Log(BitConverter.ToString(s));
tcpClient.Client.Send(s);
if (messageQueue.Count == 0)
continue;
currentMessage = messageQueue.Dequeue();
}
try
{
var data = currentMessage.Data.Get();
using (MemoryStream memstream = new MemoryStream())
{
using (BinaryWriter b = new BinaryWriter(memstream))
{
b.Write(BitConverter.GetBytes((short)(data.Length + 1)), 0, 2);
b.Write(BitConverter.GetBytes((byte)currentMessage.Function), 0, 1);
b.Write(data, 0, data.Length);
}
byte[] s = memstream.ToArray();
try
{
tcpClient.Client.Send(s);
}
catch (SocketException ex)
{
Debug.LogError($"Failed to send data: {ex.Message}");
onDisConnected = true;
break;
}
}
}
catch
{
onDisConnected = true;
break;
}
}
catch
{
onDisConnected = true;
}
}
#region CtosMessage
public static void CtosMessage_Response(byte[] response)
{
var message = new Package();
......@@ -408,7 +420,7 @@ namespace MDPro3
message.Function = (int)CtosMessage.HsStart;
Send(message);
}
#endregion
public static List<Package> ReadPackagesInRecord(string path)
{
List<Package> re = null;
......@@ -766,20 +778,15 @@ namespace MDPro3
{
private static byte[] ReadFull(NetworkStream stream, int length)
{
//Debug.Log("TcpHelper-ReadReadFull-Start");
var buf = new byte[length];
var rlen = 0;
while (rlen < buf.Length)
{
//Debug.Log("TcpHelper-ReadReadFull-Mark1");
var currentLength = stream.Read(buf, rlen, buf.Length - rlen);
rlen += currentLength;
if (currentLength == 0)
{
TcpHelper.onDisConnected = true;
//Debug.Log("TcpHelper-ReadReadFull-Set onDisConnected True");
break;
}
}
......@@ -788,8 +795,6 @@ namespace MDPro3
public static byte[] ReadPacket(NetworkStream stream)
{
//Debug.Log("TcpHelper-ReadPacket-Start");
var hdr = ReadFull(stream, 2);
var plen = BitConverter.ToUInt16(hdr, 0);
var buf = ReadFull(stream, plen);
......
......@@ -45,6 +45,10 @@ namespace MDPro3
public Room room;
public EditDeck editDeck;
#if UNITY_EDITOR
public float timeScaleFloat = 1;
#endif
#region Initializement
private static Program instance;
......@@ -165,11 +169,6 @@ namespace MDPro3
public static bool InputGetMouse1Up;
public static float pressingTime;
public float testFloat1;
public float testFloat2;
public float testFloat3;
public float testFloat4;
void Update()
{
InputGetMouse0 = Input.GetMouseButton(0);
......@@ -206,8 +205,9 @@ namespace MDPro3
foreach (Manager manager in managers) manager.PerFrameFunction();
foreach (Servant servant in servants) servant.PerFrameFunction();
if (Input.GetKey(KeyCode.P))
OcgCore.messagePass = true;
#if UNITY_EDITOR
timeScale = timeScaleFloat;
#endif
}
public void UnloadUnusedAssets()
......
......@@ -20,6 +20,7 @@ using MDPro3.YGOSharp.OCGWrapper.Enums;
using static YgomGame.Bg.BgEffectSettingInner;
using MDPro3.UI;
namespace MDPro3
{
public class OcgCore : Servant
......@@ -278,7 +279,7 @@ namespace MDPro3
}
}
public void OnDuelResultConfirmed()
public void OnDuelResultConfirmed(bool manual = false)
{
Program.I().room.joinWithReconnect = false;
......@@ -311,25 +312,42 @@ namespace MDPro3
if (condition == Condition.Watch)
{
if (duelEnded)
Hide(0);
if (manual)
{
surrended = false;
Program.I().room.duelEnded = false;
Program.I().room.needSide = false;
Program.I().room.sideWaitingObserver = false;
if (Program.I().currentSubServant != null)
{
Program.I().currentSubServant.Hide(-1);
Program.I().currentSubServant = null;
}
TcpHelper.CtosMessage_LeaveGame();
OnExit();
}
else
{
field0.SetActive(false);
field1.SetActive(false);
field0.SetActive(true);
field1.SetActive(true);
if (duelEnded)
Hide(0);
else
{
field0.SetActive(false);
field1.SetActive(false);
field0.SetActive(true);
field1.SetActive(true);
}
}
return;
}
var selections = new List<string>
{
InterString.Get("投降"),
InterString.Get("您确定要投降吗?"),
InterString.Get("是"),
InterString.Get("否")
};
{
InterString.Get("投降"),
InterString.Get("您确定要投降吗?"),
InterString.Get("是"),
InterString.Get("否")
};
Action yes = () =>
{
surrended = true;
......@@ -1276,8 +1294,8 @@ namespace MDPro3
public void SendReturn(byte[] buffer)
{
handler?.Invoke(buffer);
ClearResponse();
if (handler != null) handler(buffer);
}
public void Sleep(int framsIn100)
......@@ -1286,6 +1304,14 @@ namespace MDPro3
if (illustion > MessageBeginTime) MessageBeginTime = illustion;
}
public void OnResend()
{
var binaryMaster = new BinaryMaster();
binaryMaster = new BinaryMaster();
binaryMaster.writer.Write(-1);
SendReturn(binaryMaster.Get());
}
public void StocMessage_TimeLimit(BinaryReader r)
{
int player = LocalPlayer(r.ReadByte());
......@@ -4088,101 +4114,54 @@ namespace MDPro3
}
var handleFlag = 0;
//无强制发动的卡
if (forced == 0)
{
//无关键卡
if (spcount == 0)
{
//全时点
if (chainCondition == ChainCondition.All)
switch (chainCondition)
{
//无卡连锁
if (chainCards.Count == 0)
//无连锁提示
handleFlag = -1;
//有卡连锁
else
{
//一个效果需要处理
if (chainCards.Count == 1 && chainCards[0].effects.Count == 1)
handleFlag = 1;
//多个效果需要处理
case ChainCondition.All:
if (chainCards.Count == 0)
handleFlag = -1;
else
handleFlag = 2;
}
handleFlag = 1;
break;
default:
handleFlag = 0;
break;
}
else
handleFlag = 0;
}
//有关键卡
else
{
//无卡连锁
if (chainCards.Count == 0)
{
handleFlag = 0;
if (chainCondition == ChainCondition.All)
handleFlag = -1;
}
//有卡连锁
else
{
if (chainCondition == ChainCondition.No)
handleFlag = 0;
else
{
if (chainCards.Count == 1 && chainCards[0].effects.Count == 1)
handleFlag = 1;
else
handleFlag = 2;
}
handleFlag = 1;
}
}
}
//有强制发动的卡
else
handleFlag = 3;
switch (handleFlag)
{
//有一张强制发动的卡
if (chainCards.Count == 1 && chainCards[0].effects.Count == 1)
handleFlag = 4;
//有多张强制发动的卡
else
handleFlag = 3;
}
//响应
//无卡连锁提示
if (handleFlag == -1)
{
//TODO or not to
binaryMaster = new BinaryMaster();
binaryMaster.writer.Write(-1);
SendReturn(binaryMaster.Get());
}
//直接回复
else if (handleFlag == 0)
{
binaryMaster = new BinaryMaster();
binaryMaster.writer.Write(-1);
SendReturn(binaryMaster.Get());
}
//处理一张 废除
if (handleFlag == 1)
handleFlag = 2;
//处理多张
if (handleFlag == 2)
{
ShowPopupSelectCard(InterString.Get("选择效果发动。"), chainCards, 1, 1, true, false);
}
//处理多张强制发动的卡
else if (handleFlag == 3)
{
ShowPopupSelectCard(InterString.Get("选择必发效果发动。"), chainCards, 1, 1, false, false);
}
//处理一张强制发动的卡
else if (handleFlag == 4)
{
ShowPopupSelectCard(InterString.Get("选择必发效果发动。"), chainCards, 1, 1, false, false);
case 1:
ShowPopupSelectCard(InterString.Get("选择效果发动。"), chainCards, 1, 1, true, false);
break;
case 3:
ShowPopupSelectCard(InterString.Get("选择必发效果发动。"), chainCards, 1, 1, false, false);
break;
default:
OnResend();
break;
}
break;
case GameMessage.SelectCard:
......@@ -4438,7 +4417,7 @@ namespace MDPro3
}
else
if (ES_selectHint == "")
ES_selectHint = StringHelper.GetUnsafe(570);//请选择要变成不能使用的卡片区域
ES_selectHint = StringHelper.GetUnsafe(570);//请选择要变成不能使用的卡片区域
hintObj.SetActive(true);
hintText.text = ES_selectHint;
break;
......
......@@ -431,7 +431,7 @@ namespace MDPro3.UI
}
}
}
if ((passController & 0x1F00) > 0)
if ((passController & 0x3F00) > 0)
{
if ((p.location & (uint)CardLocation.SpellZone) > 0)
{
......
......@@ -57,10 +57,10 @@ namespace MDPro3.UI
textMode.text,
toggleNoCheck.switchOn ? "T" : "F",
toggleNoShuffle.switchOn ? "T" : "F",
inputTime.text,
inputLP.text,
inputHand.text,
inputDraw.text
inputTime.text == "" ? "0" : inputTime.text,
inputLP.text == "" ? "8000" : inputLP.text,
inputHand.text == "" ? "5" : inputHand.text,
inputDraw.text == "" ? "1" : inputDraw.text
};
}
......
......@@ -134,9 +134,8 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 0.5.2
preloadedAssets:
- {fileID: 11400000, guid: 5fb02d2098f52054b89ce4a9f63ba9ee, type: 2}
bundleVersion: 0.5.3
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 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