public override void OnStateUpdate() { // check operations: if all operations are skip, let the current player to draw his lingshang // if some one claimed rong, transfer to TurnEndState handling rong operations if (Time.time - firstTime > serverTimeOut) { for (int i = 0; i < responds.Length; i++) { if (responds[i]) { continue; } // players[i].BonusTurnTime = 0; outTurnOperations[i] = new OutTurnOperation { Type = OutTurnOperationType.Skip }; NextState(); return; } } if (responds.All(r => r)) { Debug.Log("[Server] Server received all operation response, handling results."); NextState(); } }
public override void OnStateUpdate() { // Send messages again until get enough responds or time out if (Time.time - firstSendTime > serverTimeOut) { // Time out, entering next state for (int i = 0; i < responds.Length; i++) { if (responds[i]) { continue; } CurrentRoundStatus.SetBonusTurnTime(i, 0); operations[i] = new OutTurnOperation { Type = OutTurnOperationType.Skip }; } TurnEnd(); return; } if (responds.All(r => r)) { Debug.Log("[Server] Server received all operation response, ending this turn."); TurnEnd(); } }
public void OnOutTurnButtonClicked(OutTurnOperation operation) { int bonusTimeLeft = controller.TurnTimeController.StopCountDown(); Debug.Log($"Sending request of operation {operation} with bonus turn time {bonusTimeLeft}"); OnOutTurnOperationTaken(operation, bonusTimeLeft); controller.OutTurnPanelManager.Close(); }
/// <summary> /// 显示回合外的玩家动作响应UI /// </summary> /// <param name="operations">当前玩家可用的操作</param> /// <param name="bonusTurnTime">可用的额外时间</param> /// <returns>显示UI则返回true,否则返回false</returns> public bool ShowOutTurnPanels(OutTurnOperation[] operations, int bonusTurnTime) { if (operations == null || operations.Length == 0) { Debug.LogError("Received with no operations, this should not happen"); ClientBehaviour.Instance.OnSkipOutTurnOperation(bonusTurnTime); return(false); } var settings = CurrentRoundStatus.LocalSettings; if (settings.He) { // handle auto-win int index = System.Array.FindIndex(operations, op => op.Type == OutTurnOperationType.Rong); if (index >= 0) { ClientBehaviour.Instance.OnOutTurnButtonClicked(operations[index]); return(false); } } if (settings.Ming) { // handle dont-open 关闭鸣牌 for (int i = 0; i < operations.Length; i++) { var operation = operations[i]; if (operation.Type == OutTurnOperationType.Chow || operation.Type == OutTurnOperationType.Pong || operation.Type == OutTurnOperationType.Kong) { operations[i] = new OutTurnOperation { Type = OutTurnOperationType.Skip }; } } } // if all the operations are skip, automatically skip this turn. if (operations.All(op => op.Type == OutTurnOperationType.Skip)) { Debug.Log("Only operation is skip, skipping turn"); ClientBehaviour.Instance.OnSkipOutTurnOperation(bonusTurnTime); OutTurnPanelManager.Close(); return(false); } // Time out OutTurnPanelManager.SetOperations(operations); TurnTimeController.StartCountDown(CurrentRoundStatus.GameSetting.BaseTurnTime, bonusTurnTime, () => { Debug.Log("Time out! Automatically skip this turn"); ClientBehaviour.Instance.OnSkipOutTurnOperation(0); OutTurnPanelManager.Close(); }); return(true); }
public void PerformOutTurnOperation(int newPlayerIndex, OutTurnOperation operation) { var operationPerformState = new OperationPerformState { CurrentRoundStatus = CurrentRoundStatus, CurrentPlayerIndex = newPlayerIndex, DiscardPlayerIndex = CurrentRoundStatus.CurrentPlayerIndex, Operation = operation, MahjongSet = mahjongSet }; StateMachine.ChangeState(operationPerformState); }
public void OnOutTurnOperationTaken(OutTurnOperation operation, int bonusTurnTime) { var info = new EventMessages.OutTurnOperationInfo { PlayerIndex = CurrentRoundStatus.LocalPlayerIndex, Operation = operation, BonusTurnTime = bonusTurnTime }; PhotonNetwork.RaiseEvent( EventMessages.OutTurnOperationEvent, info, EventMessages.ToMaster, EventMessages.SendReliable); }
private OutTurnOperationType ChooseOperations() { Debug.Log($"[Server] Operation before choosing: {string.Join(",", Operations)}"); // test every circumstances by priority // test for rong if (Operations.Any(op => op.Type == OutTurnOperationType.Rong)) { // check if 3 rong if (CurrentRoundStatus.CheckThreeRongs(Operations)) { for (int i = 0; i < Operations.Length; i++) { Operations[i] = new OutTurnOperation { Type = OutTurnOperationType.RoundDraw, RoundDrawType = RoundDrawType.ThreeRong }; } return(OutTurnOperationType.RoundDraw); } for (int i = 0; i < Operations.Length; i++) { if (Operations[i].Type != OutTurnOperationType.Rong) { Operations[i] = new OutTurnOperation { Type = OutTurnOperationType.Skip } } ; } return(OutTurnOperationType.Rong); } // check if 4 winds if (CurrentRoundStatus.CheckFourWinds()) { Debug.Log($"[Server] Round draw -- Four winds"); for (int i = 0; i < Operations.Length; i++) { Operations[i] = new OutTurnOperation { Type = OutTurnOperationType.RoundDraw, RoundDrawType = RoundDrawType.FourWinds }; } return(OutTurnOperationType.RoundDraw); } // check if 4 richis if (CurrentRoundStatus.CheckFourRichis()) { Debug.Log($"[Server] Round draw -- Four richis"); for (int i = 0; i < Operations.Length; i++) { Operations[i] = new OutTurnOperation { Type = OutTurnOperationType.RoundDraw, RoundDrawType = RoundDrawType.FourRichis }; } return(OutTurnOperationType.RoundDraw); } // check if 4 kongs if (CurrentRoundStatus.CheckFourKongs()) { Debug.Log($"[Server] Round draw -- Four kongs"); for (int i = 0; i < Operations.Length; i++) { Operations[i] = new OutTurnOperation { Type = OutTurnOperationType.RoundDraw, RoundDrawType = RoundDrawType.FourKongs }; } return(OutTurnOperationType.RoundDraw); } // check if run out of tiles -- leads to a normal round draw if (MahjongSet.TilesRemain == gameSettings.MountainReservedTiles) { // no more tiles to draw and no one choose a rong operation. Debug.Log("No more tiles to draw and nobody claims a rong, the round has drawn."); for (int i = 0; i < Operations.Length; i++) { Operations[i] = new OutTurnOperation { Type = OutTurnOperationType.RoundDraw, RoundDrawType = RoundDrawType.RoundDraw } } ; return(OutTurnOperationType.RoundDraw); } // check if some one claimed kong if (Operations.Any(op => op.Type == OutTurnOperationType.Kong)) { for (int i = 0; i < Operations.Length; i++) { if (Operations[i].Type != OutTurnOperationType.Kong) { Operations[i] = new OutTurnOperation { Type = OutTurnOperationType.Skip } } ; } return(OutTurnOperationType.Kong); } // check if some one claimed pong if (Operations.Any(op => op.Type == OutTurnOperationType.Pong)) { for (int i = 0; i < Operations.Length; i++) { if (Operations[i].Type != OutTurnOperationType.Pong) { Operations[i] = new OutTurnOperation { Type = OutTurnOperationType.Skip } } ; } return(OutTurnOperationType.Pong); } // check if some one claimed chow if (Operations.Any(op => op.Type == OutTurnOperationType.Chow)) { for (int i = 0; i < Operations.Length; i++) { if (Operations[i].Type != OutTurnOperationType.Chow) { Operations[i] = new OutTurnOperation { Type = OutTurnOperationType.Skip } } ; } return(OutTurnOperationType.Chow); } // no particular operations -- skip return(OutTurnOperationType.Skip); }
private void HandleRoundDraw(OutTurnOperation operation) { // controller.RoundDrawManager.SetDrawType(operation.RoundDrawType); controller.StartCoroutine(ShowRoundDrawEffect(operation.RoundDrawType)); }
private void HandleRong(int placeIndex, OutTurnOperation operation) { controller.ShowEffect(placeIndex, PlayerEffectManager.GetAnimationType(operation.Type)); controller.StartCoroutine(controller.RevealHandTiles(placeIndex, operation.HandData)); }
private void HandleOpen(int placeIndex, OutTurnOperation operation) { Debug.Log($"Operation: {operation}"); // show effect controller.ShowEffect(placeIndex, PlayerEffectManager.GetAnimationType(operation.Type)); }