Esempio n. 1
0
        public override void OnServerStateEnter()
        {
            if (CurrentRoundStatus.CurrentPlayerIndex != CurrentPlayerIndex)
            {
                Debug.LogError("CurrentPlayerIndex does not match, this should not happen");
                CurrentRoundStatus.CurrentPlayerIndex = CurrentPlayerIndex;
            }

            firstTime = Time.time;
            // determines the operation to take when turn ends
            operationChosen = ChooseOperations();
            Debug.Log(
                $"The operation chosen by this round is {operationChosen}, operation after choosing: {string.Join(",", Operations)}");
            // if operation is not rong or round-draw, perform richi and test zhenting
            if (operationChosen != OutTurnOperationType.Rong && operationChosen != OutTurnOperationType.RoundDraw)
            {
                CurrentRoundStatus.TryRichi(CurrentPlayerIndex, IsRichiing);
                CurrentRoundStatus.UpdateTempZhenting(CurrentPlayerIndex, DiscardingTile);
                CurrentRoundStatus.UpdateDiscardZhenting();
                CurrentRoundStatus.UpdateRichiZhenting(DiscardingTile);
            }

            // Send messages to clients
            for (int i = 0; i < players.Count; i++)
            {
                var info = new EventMessages.TurnEndInfo
                {
                    PlayerIndex         = i,
                    ChosenOperationType = operationChosen,
                    Operations          = Operations,
                    Points         = CurrentRoundStatus.Points.ToArray(),
                    RichiStatus    = CurrentRoundStatus.RichiStatusArray,
                    RichiSticks    = CurrentRoundStatus.RichiSticks,
                    Zhenting       = CurrentRoundStatus.IsZhenting(i),
                    MahjongSetData = MahjongSet.Data
                };
                var player = CurrentRoundStatus.GetPlayer(i);
                ClientBehaviour.Instance.photonView.RPC("RpcTurnEnd", player, info);
            }

            serverTurnEndTimeOut =
                operationChosen == OutTurnOperationType.Rong || operationChosen == OutTurnOperationType.RoundDraw
                                        ? ServerConstants.ServerTurnEndTimeOutExtra
                                        : ServerConstants.ServerTurnEndTimeOut;
            if (operationChosen == OutTurnOperationType.Chow ||
                operationChosen == OutTurnOperationType.Pong ||
                operationChosen == OutTurnOperationType.Kong)
            {
                CurrentRoundStatus.BreakOneShotsAndFirstTurn();
            }
        }
Esempio n. 2
0
        public void RpcTurnEnd(EventMessages.TurnEndInfo info)
        {
            var turnEndState = new PlayerTurnEndState
            {
                CurrentRoundStatus  = CurrentRoundStatus,
                PlayerIndex         = info.PlayerIndex,
                ChosenOperationType = info.ChosenOperationType,
                Operations          = info.Operations,
                Points         = info.Points,
                RichiStatus    = info.RichiStatus,
                RichiSticks    = info.RichiSticks,
                Zhenting       = info.Zhenting,
                MahjongSetData = info.MahjongSetData
            };

            StateMachine.ChangeState(turnEndState);
        }