Beispiel #1
0
    /// <summary>
    /// 清除界面数据
    /// </summary>
    public void ClearDatas()
    {
        UnitTool.ToolStopAllCoroutines();
        //清除玩家相关数据
        for (int i = 0; i < players.Count; i++)
        {
            players[i].myCardInfo.Clear();
            players[i].myType = new DDZ_POKER_TYPE();
            players[i].myTerm = false;
        }

        lastType = DDZ_POKER_TYPE.DDZ_PASS;
        ClearLordDatas();
        //清除控制器相关数据
        this.tableCards.Clear();
        this.lastCards.Clear();
        this.lordTimes = 0;
        //销毁桌面上所有的扑克牌
        pokerTable.myUiCard.Clear();
        GameObject[] pokers = GameObject.FindGameObjectsWithTag("Poker");

        for (int i = 0; i < pokers.Length; i++)
        {
            GameObject.Destroy(pokers[i].gameObject);
        }

        startIndex = playerIndex % 3;
        SetLordImg(false);
        SetStartButton(false, true);
        //显示界面重置
        SetButton(false, false, false);
    }
Beispiel #2
0
    /// <summary>
    /// 不抢地主
    /// </summary>
    public virtual void NotLord()
    {
        //先关闭所有协程
        UnitTool.ToolStopAllCoroutines();

        loadLord = false;
        NotLordEvent();
    }
Beispiel #3
0
    /// <summary>
    /// 重新开始游戏
    /// </summary>
    private void _restartGame()
    {
        //关闭所有协程
        UnitTool.ToolStopAllCoroutines();

        //清除玩家和桌控制器的数据,重置UI的显示
        _clearDatas();

        //调用开始游戏
        _startGame();
    }
Beispiel #4
0
    /// <summary>
    /// 胡牌
    /// </summary>
    private void _huMajiang()
    {
        //停止所有协程
        UnitTool.ToolStopAllCoroutines();

        //玩家胡,显示赢家的麻将
        _sortCards(players[winIndex].myCards);
        _majiangTable.ShowHuMajiang(players[winIndex].myCards);

        //控制器显示胜利
        _gameOver();
    }
Beispiel #5
0
    /// <summary>
    /// 玩家不出牌
    /// </summary>
    public void NotPlayCards()
    {
        if (playerIndex % 3 == 0)
        {
            //玩家不出牌
            if (lastCards.Count != 0)
            {
                //上个玩家出牌了
                Debug.Log(players[0].ToString() + "不要");
                players[playerIndex % 3].myTerm = false;
                //lastType = players[playerIndex % 3].myType;

                //不出牌的时候,将选中出列的牌归位
                for (int i = 0; i < players[0].myCardInfo.Count; i++)
                {
                    if (players[0].myCardInfo[i].isSelected)
                    {
                        pokerTable.GetCardObject(players[0].myCardInfo[i]).SetSelectState();
                    }
                }

                UnitTool.ToolStopAllCoroutines();
                StartPlay();
            }
            else
            {
                //自己的出牌回合,时间结束,默认系统出玩家的第一张牌
                lastType = DDZ_POKER_TYPE.SINGLE;
                players[0].myCardInfo[players[0].myCardInfo.Count - 1].isSelected = true;

                CanPlayCards();
            }
        }
        else
        {
            //电脑不出牌
            Debug.Log(players[playerIndex % 3].ToString() + "不要");
            players[playerIndex % 3].myTerm = false;
            //先关闭所有协程
            UnitTool.ToolStopAllCoroutines();
            //回到开始出牌主函数
            StartPlay();
        }
    }
Beispiel #6
0
    /// <summary>
    /// 出牌协程
    /// </summary>
    /// <returns></returns>
    private IEnumerator StartPlayCoroutine()
    {
        SetButton(false, false, false);
        //这里等待一秒钟,是为了部分协程执行执行结束,不然就会同时对玩家索引进行操作
        yield return(new WaitForSeconds(1f));

        UnitTool.ToolStopAllCoroutines();

        if (isRestart)
        {
            isRestart   = false;
            playerIndex = startIndex;
        }
        else
        {
            playerIndex++;
        }
        players[playerIndex % 3].StartPlay();
    }
Beispiel #7
0
    /// <summary>
    /// 开始叫地主
    /// </summary>
    public void StartForLord()
    {
        isLord = true;
        //判断谁是地主,如果没有出来那么就继续叫地主
        if (!JudgeLord())
        {
            return;
        }

        playerIndex++;
        playerIndex = playerIndex % 3;
        //Debug.Log(playerIndex);
        //抢地主前先关闭所有协程
        UnitTool.ToolStopAllCoroutines();
        //当前玩家开始叫地主
        players[playerIndex].ToLord();
        //显示叫地主图标
        ShowOption(true, false, players[playerIndex]);
    }
Beispiel #8
0
    /// <summary>
    /// 玩家摸牌
    /// </summary>
    private void _drawMajiang()
    {
        //该玩家摸牌
        if (tCards.Count == 0)
        {
            UnitTool.ToolStopAllCoroutines();
            Debug.Log("牌抓完了...平局");
            //打开平局面板
            UnitTool.ToolStopAllCoroutines();
            if (_gameOverEvent != null)
            {
                _gameOverEvent("平局");
            }
            return;
        }

        players[index].AddCard(tCards[0]);
        var moCard = tCards[0];

        _majiangTable.DrawMajiangAnimation(tCards[0], index);
        _sortCards(players[index].myCards);
        tCards.RemoveAt(0);
    }
Beispiel #9
0
 /// <summary>
 /// 杠按钮调用
 /// </summary>
 private void _buttonGang()
 {
     _setButton(false, false, false, false);
     UnitTool.ToolStopAllCoroutines();
     _gang(temp);
 }
Beispiel #10
0
 /// <summary>
 /// 玩家点击不叫地主
 /// </summary>
 public void PlayerNotClickLord()
 {
     UnitTool.ToolStopAllCoroutines();
     SetHintText("不抢", 0);
     StartForLord();
 }
Beispiel #11
0
    /// <summary>
    /// 玩家抢到地主
    /// </summary>
    public void ForLord()
    {
        //清除抢地主留下的信息,以免重开时未重置
        ClearLordDatas();
        Transform parent;

        //抢地主成功,当前playerIndex索引玩家为地主
        UnitTool.ToolStopAllCoroutines();
        SetButton(false, false, false);


        //拿到地主的位置
        parent = players[playerIndex % 3].GetPlayer();
        //重新排序地主的牌
        players[playerIndex % 3].myCardInfo = SortCards(players[playerIndex % 3].myCardInfo);

        if (playerIndex % 3 == 0)
        {
            //地主是玩家
            for (int i = 51; i < 54; i++)
            {
                players[0].AddCard(tableCards[i]);
                //玩家点击扑克牌市斤添加
                pokerTable.GetCardObject(tableCards[i]).AddSetSelectEvent(SetSelect);
            }

            //UI同步更新
            pokerTable.ClearCardParent(players[0].myCardInfo);
            InitPlayers();
            pokerTable.ShowCards(players[0].myCardInfo);
        }
        else
        {
            //地主是电脑
            for (int i = 51; i < 54; i++)
            {
                players[playerIndex % 3].AddCard(tableCards[i]);
                pokerTable.MoveCard(tableCards[i], 0.5f);
            }
        }

        tableCards.Clear();
        SetLordImg();

        //地主开始出牌
        //标志谁最先出牌
        startIndex = playerIndex;

        //由于下面的开始游戏前会自动增加玩家索引,所以这里玩家索引递减一个
        if (playerIndex != 0)
        {
            playerIndex--;
        }
        else
        {
            playerIndex += 2;
        }
        isLord = false;

        //开始出牌
        StartPlay();
    }
Beispiel #12
0
 /// <summary>
 /// 杠按钮调用
 /// </summary>
 private void ButtonGang()
 {
     SetButton(false, false, false, false);
     UnitTool.ToolStopAllCoroutines();
     Gang(temp);
 }