Ejemplo n.º 1
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();
    }