Пример #1
0
 public void OnRichiButtonClicked(InTurnOperation operation)
 {
     if (operation.Type != InTurnOperationType.Richi)
     {
         Debug.LogError($"Cannot send a operation with type {operation.Type} within OnRichiButtonClicked method");
         return;
     }
     // show richi selection panel
     Debug.Log($"Showing richi selection panel, candidates: {string.Join(",", operation.RichiAvailableTiles)}");
     CurrentRoundStatus.SetRichiing(true);
     controller.HandPanelManager.SetCandidates(operation.RichiAvailableTiles);
 }
Пример #2
0
        public void OnDiscardTile(Tile tile, bool isLastDraw, int bonusTimeLeft)
        {
            Debug.Log($"Sending request of discarding tile {tile}");
            var info = new EventMessages.DiscardTileInfo
            {
                PlayerIndex        = CurrentRoundStatus.LocalPlayerIndex,
                IsRichiing         = CurrentRoundStatus.IsRichiing,
                DiscardingLastDraw = isLastDraw,
                Tile          = tile,
                BonusTurnTime = bonusTimeLeft
            };

            PhotonNetwork.RaiseEvent(
                EventMessages.DiscardTileEvent, info,
                EventMessages.ToMaster, EventMessages.SendReliable);
            controller.InTurnPanelManager.Close();
            CurrentRoundStatus.SetRichiing(false);
            controller.HandPanelManager.RemoveCandidates();
        }
Пример #3
0
        /// <summary>
        /// 显示玩家回合内的状态栏
        /// </summary>
        /// <param name="operations">当前玩家可用的操作</param>
        /// <param name="bonusTurnTime">玩家额外的时间</param>
        public void ShowInTurnPanels(InTurnOperation[] operations, int bonusTurnTime)
        {
            var settings = CurrentRoundStatus.LocalSettings;
            var richied  = CurrentRoundStatus.GetRichiStatus(0);
            var lastDraw = (Tile)CurrentRoundStatus.GetLastDraw(0);

            // auto discard when richied or set to qie
            if ((settings.Qie || richied) && operations.All(op => op.Type == InTurnOperationType.Discard))
            {
                if (richied)
                {
                    HandPanelManager.LockTiles();
                }
                Timing.RunCoroutine(CoAutoDiscard(lastDraw, bonusTurnTime));
                InTurnPanelManager.Close();
                return;
            }

            // check settings
            if (settings.He)
            {
                // handle auto-win
                int index = System.Array.FindIndex(operations, op => op.Type == InTurnOperationType.Tsumo);
                if (index >= 0)
                {
                    ClientBehaviour.Instance.OnTsumoButtonClicked(operations[index]);
                    return;
                }
            }

            // not richied, show timer and panels
            CurrentRoundStatus.CalculatePossibleWaitingTiles();
            CurrentRoundStatus.ClearWaitingTiles();
            InTurnPanelManager.SetOperations(operations);
            TurnTimeController.StartCountDown(CurrentRoundStatus.GameSetting.BaseTurnTime, bonusTurnTime, () =>
            {
                Debug.Log("Time out! Automatically discarding last drawn tile");
                CurrentRoundStatus.SetRichiing(false);
                ClientBehaviour.Instance.OnDiscardTile(lastDraw, true, 0);
                InTurnPanelManager.Close();
            });
        }