public override IEnumerator SendMessageInsistently <T>(TCPMessageType tcpMessageType, TCPData <T> message, float waitingTerm = 2f) { global::Debug.LogFormat("Send tcpMessageType:{0}", new object[] { tcpMessageType }); float sendWaitTime = waitingTerm; float sendTotalWaitTime = 0f; for (;;) { while (this.isSendEvent || this.isDisconnected || this.isEnemyFailedAction) { yield return(null); } if (sendWaitTime >= waitingTerm) { sendWaitTime = 0f; base.SendMessageForSync(tcpMessageType, message); } if (sendTotalWaitTime >= 45f) { sendTotalWaitTime = 0f; IEnumerator enemyFailedAction = this.EnemyFailedAction(); while (enemyFailedAction.MoveNext()) { yield return(null); } } if (this.confirmationChecks[tcpMessageType].Count == base.otherUserCount) { break; } sendWaitTime += Time.unscaledDeltaTime; sendTotalWaitTime += Time.unscaledDeltaTime; yield return(null); } LastConfirmationData message2 = new LastConfirmationData { playerUserId = ClassSingleton <MultiBattleData> .Instance.MyPlayerUserId, hashValue = Singleton <TCPUtil> .Instance.CreateHash(TCPMessageType.LastConfirmation, ClassSingleton <MultiBattleData> .Instance.MyPlayerUserId, tcpMessageType), tcpMessageType = tcpMessageType.ToInteger() }; base.SendMessageForSync(TCPMessageType.LastConfirmation, message2); this.confirmationChecks[tcpMessageType].Clear(); yield break; yield break; }
protected void RecieveLastConfirmation(TCPMessageType tcpMessageType, object messageObj) { global::Debug.Log("LastConfirmation: 受信"); LastConfirmationData lastConfirmationData = TCPData <LastConfirmationData> .Convert(messageObj); if (this.CheckRecieveData(lastConfirmationData.playerUserId, lastConfirmationData.hashValue)) { return; } this.confirmationChecks[TCPMessageType.Confirmation].Add(lastConfirmationData.playerUserId); this.RunLastAction((TCPMessageType)lastConfirmationData.tcpMessageType); global::Debug.LogFormat("tcpMessageType:{0}", new object[] { (TCPMessageType)lastConfirmationData.tcpMessageType }); }
private IEnumerator BattleEndActionSync() { if (base.IsOwner) { EnemyTurnSyncData message = new EnemyTurnSyncData { playerUserId = ClassSingleton <MultiBattleData> .Instance.MyPlayerUserId, hashValue = Singleton <TCPUtil> .Instance.CreateHash(TCPMessageType.EnemyTurnSync, ClassSingleton <MultiBattleData> .Instance.MyPlayerUserId, TCPMessageType.None) }; float sendWaitTime = 2f; float waitingCount = 0f; for (;;) { if (sendWaitTime >= 2f) { sendWaitTime = 0f; base.SendMessageForSyncDisconnected(TCPMessageType.EnemyTurnSync, message); } if (waitingCount >= 45f || this.confirmationChecks[TCPMessageType.EnemyTurnSync].Count == base.otherUserCount) { break; } sendWaitTime += Time.unscaledDeltaTime; waitingCount += Time.unscaledDeltaTime; yield return(null); } LastConfirmationData message2 = new LastConfirmationData { playerUserId = ClassSingleton <MultiBattleData> .Instance.MyPlayerUserId, hashValue = Singleton <TCPUtil> .Instance.CreateHash(TCPMessageType.LastConfirmation, ClassSingleton <MultiBattleData> .Instance.MyPlayerUserId, TCPMessageType.EnemyTurnSync), tcpMessageType = TCPMessageType.EnemyTurnSync.ToInteger() }; base.SendMessageForSync(TCPMessageType.LastConfirmation, message2); this.confirmationChecks[TCPMessageType.EnemyTurnSync].Clear(); } else { float waitingCount2 = 0f; while (waitingCount2 < 45f && !this.recieveChecks[TCPMessageType.EnemyTurnSync]) { waitingCount2 += Time.unscaledDeltaTime; yield return(null); } this.recieveChecks[TCPMessageType.EnemyTurnSync] = false; } yield break; }