Exemplo 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();
            }
        }
Exemplo n.º 2
0
        public static Type GetAnimationType(OutTurnOperationType operation)
        {
            switch (operation)
            {
            case OutTurnOperationType.Chow:
                return(Type.Chow);

            case OutTurnOperationType.Pong:
                return(Type.Pong);

            case OutTurnOperationType.Kong:
                return(Type.Kong);

            case OutTurnOperationType.Rong:
                return(Type.Rong);

            default:
                throw new NotSupportedException($"This kind of operation {operation} does not have an animation");
            }
        }