/// <summary> /// Check if the conditions are met to proceed to the next turn. /// If they are it will make the appropriate updates. Otherwise /// it will return false. /// </summary> private bool NextTurn() { // log.Debug ("Next Turn Check: Current Turn - " + LockStepTurnID); // log.Debug (" priorConfirmedCount - " + confirmedActions.playersConfirmedPriorAction.Count); // log.Debug (" currentConfirmedCount - " + confirmedActions.playersConfirmedCurrentAction.Count); // log.Debug (" allPlayerCurrentActionsCount - " + pendingActions.CurrentActions.Count); // log.Debug (" allPlayerNextActionsCount - " + pendingActions.NextActions.Count); // log.Debug (" allPlayerNextNextActionsCount - " + pendingActions.NextNextActions.Count); // log.Debug (" allPlayerNextNextNextActionsCount - " + pendingActions.NextNextNextActions.Count); if (confirmedActions.ReadyForNextTurn()) { if (pendingActions.ReadyForNextTurn()) { //increment the turn ID LockStepTurnID++; //move the confirmed actions to next turn confirmedActions.NextTurn(); //move the pending actions to this turn pendingActions.NextTurn(); return(true); } else { StringBuilder sb = new StringBuilder(); sb.Append("Have not recieved player(s) actions: "); foreach (int i in pendingActions.WhosNotReady()) { sb.Append(i + ", "); } log.Debug(sb.ToString()); } } else { StringBuilder sb = new StringBuilder(); sb.Append("Have not recieved confirmation from player(s): "); foreach (int i in pendingActions.WhosNotReady()) { sb.Append(i + ", "); } log.Debug(sb.ToString()); } // if(confirmedActions.ReadyForNextTurn() && pendingActions.ReadyForNextTurn()) { // //increment the turn ID // LockStepTurnID++; // //move the confirmed actions to next turn // confirmedActions.NextTurn(); // //move the pending actions to this turn // pendingActions.NextTurn(); // // return true; // } return(false); }
private bool NextTurn() { if (confirmedActions.ReadyForNextTurn() && pendingActions.ReadyForNextTurn()) { //increment the turn ID TurnID++; //move the confirmed actions to next turn confirmedActions.NextTurn(); //move the pending actions to this turn pendingActions.NextTurn(); return(true); } return(false); }
/// <summary> /// Check if the conditions are met to proceed to the next turn. /// If they are it will make the appropriate updates. Otherwise /// it will return false. /// </summary> private bool NextTurn() { // log.Debug ("Next Turn Check: Current Turn - " + LockStepTurnID); // log.Debug (" priorConfirmedCount - " + confirmedActions.playersConfirmedPriorAction.Count); // log.Debug (" currentConfirmedCount - " + confirmedActions.playersConfirmedCurrentAction.Count); // log.Debug (" allPlayerCurrentActionsCount - " + pendingActions.CurrentActions.Count); // log.Debug (" allPlayerNextActionsCount - " + pendingActions.NextActions.Count); // log.Debug (" allPlayerNextNextActionsCount - " + pendingActions.NextNextActions.Count); // log.Debug (" allPlayerNextNextNextActionsCount - " + pendingActions.NextNextNextActions.Count); if (confirmedActions.ReadyForNextTurn() && pendingActions.ReadyForNextTurn()) { //increment the turn ID LockStepTurnID++; //move the confirmed actions to next turn confirmedActions.NextTurn(); //move the pending actions to this turn pendingActions.NextTurn(); return(true); } return(false); }
/// <summary> /// Check if the conditions are met to proceed to the next turn. /// If they are it will make the appropriate updates. Otherwise /// it will return false. /// </summary> private bool NextTurn() { // Debug.Log("Next Turn Check: Current Turn - " + LockStepTurnID); // Debug.Log(" priorConfirmedCount - " + confirmedActions.playersConfirmedPriorAction.Count); // Debug.Log(" currentConfirmedCount - " + confirmedActions.playersConfirmedCurrentAction.Count); // Debug.Log(" allPlayerCurrentActionsCount - " + pendingActions.CurrentActions.Count); // Debug.Log(" allPlayerNextActionsCount - " + pendingActions.NextActions.Count); // Debug.Log(" allPlayerNextNextActionsCount - " + pendingActions.NextNextActions.Count); // Debug.Log(" allPlayerNextNextNextActionsCount - " + pendingActions.NextNextNextActions.Count); //fzy begin //检查两点 //1.我们已经收到了所有客户端的下一轮动作了吗? //2.每个客户端都确认得到我们的动作了吗? //fzy end if (confirmedActions.ReadyForNextTurn()) { if (pendingActions.ReadyForNextTurn()) { //fzy begin //LockStepTurnID是回合次数记次,只增加不减少 //fzy end //increment the turn ID LockStepTurnID++; //move the confirmed actions to next turn confirmedActions.NextTurn(); //move the pending actions to this turn pendingActions.NextTurn(); return(true); } else { StringBuilder sb = new StringBuilder(); sb.Append("Have not recieved player(s) actions: "); foreach (int i in pendingActions.WhosNotReady()) { sb.Append(i + ", "); } Debug.Log(sb.ToString()); } } else { StringBuilder sb = new StringBuilder(); sb.Append("Have not recieved confirmation from player(s): "); foreach (int i in pendingActions.WhosNotReady()) { sb.Append(i + ", "); } Debug.Log(sb.ToString()); } // if(confirmedActions.ReadyForNextTurn() && pendingActions.ReadyForNextTurn()) { // //increment the turn ID // LockStepTurnID++; // //move the confirmed actions to next turn // confirmedActions.NextTurn(); // //move the pending actions to this turn // pendingActions.NextTurn(); // // return true; // } return(false); }