Ejemplo n.º 1
0
        public void StopPlayingVoice()
        {
            MahjongCommonMethod    mc   = MahjongCommonMethod.Instance;//开静音
            PlayerPlayingPanelData pppd = GameData.Instance.PlayerPlayingPanelData;

            if (VoiceFlag == 1)
            {
                int err = m_voiceengine.StopPlayFile();
                if (err != 0)
                {
                    ErroOccur(err, null);
                }
            }
            else
            {
                YunVaImSDK.instance.RecordStopPlayRequest();
            }
            UIMainView.Instance.PlayerPlayingPanel._playingHead[pppd.GetOtherPlayerShowPos(pppd.GetOtherPlayerPos(voices[0].iUserId)) - 1].GetChild(4).GetComponent <Animator>().SetBool("isPlayOthers", false);
            isPlayingState = false; //关闭播放状态
                                    // mc.isMusicShut = false;
            if (voices.Count > 0)
            {
                voices.RemoveAt(0);
            }
            // SystemMgr.Instance.BgmSystem.UpdateVolume();
        }
Ejemplo n.º 2
0
        public void PlayVoice(string urlLocal)
        {
            AudioListener.volume = 0f;
            //找到对应位置的语音动画播放
            PlayerPlayingPanelData pppd = GameData.Instance.PlayerPlayingPanelData;
            //  Debug.LogWarning("玩家index:" + (pppd.GetOtherPlayerShowPos(pppd.GetOtherPlayerPos(voices[0].iUserId)) - 1));
            int index = pppd.GetOtherPlayerShowPos(pppd.GetOtherPlayerPos(voices[0].iUserId)) - 1;

            UIMainView.Instance.PlayerPlayingPanel._playingHead[index].GetChild(4).GetComponent <Animator>().SetBool("isPlayOthers", true);
            //Debug.LogWarning("动画没问题");
            string ext = DateTime.Now.ToFileTime().ToString();

            if (VoiceFlag == 1)
            {
                string[]      pathSplit     = voices[0].szRecordUrlPath.Split('/');
                string        localFilePath = isExistGvoiceFile(MahjongLobby_AH.SDKManager.DataPath) + pathSplit[pathSplit.Length - 1];
                int           downLoadErr   = m_voiceengine.DownloadRecordedFile(ByteArrayToHexString(voices[0].id), localFilePath, 6000);
                ShortTalkData std           = GameData.Instance.ShortTalkData;
                if (!std._DownLoadFilePath.ContainsKey(voices[0].szRecordUrlPath))
                {
                    std._DownLoadFilePath.Add(voices[0].szRecordUrlPath, localFilePath);
                    Debug.LogWarning("下载地址1:" + voices[0].szRecordUrlPath);
                }
                Debug.LogWarning("下载地址2:" + localFilePath);

                m_voiceengine.OnPlayRecordFilComplete += (code, filePath) =>
                {
                    if (code != IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_PLAYFILE_DONE)
                    {
                        Debug.Log("OnPlayRecordFilComplete error" + code);
                    }
                    else
                    {
                        Chenggong = true;
                        StartCoroutine(CompeletPlay());
                    }
                };
                ErroOccur(downLoadErr, () => { StartCoroutine(CompeletPlay()); });
            }
            else
            {
                YunVaImSDK.instance.RecordStartPlayRequest(urlLocal, voices[0].szRecordUrlPath, ext, (data2) =>
                {
                    Debug.LogWarning("data2.result:" + data2.result + "Chenggong:" + Chenggong);
                    if (data2.result == 0)
                    {
                        Chenggong = true;
                        StartCoroutine(CompeletPlay());
                    }
                    else
                    {
                        VoiceInit();
                        // StartCoroutine(CompeletPlay());
                        //Debug.LogWarning("播放失败");//关静音
                        Debug.LogWarning(voices[0].szRecordUrlPath);
                        MahjongCommonMethod.Instance.ShowRemindFrame("语音播放失败", true);
                    }
                });
            }
        }
Ejemplo n.º 3
0
        IEnumerator CompeletPlay(float time = -1)
        {
            yield return(new WaitForSeconds(0));

            if (voices.Count > 0)
            {
                PlayerPlayingPanelData pppd = GameData.Instance.PlayerPlayingPanelData;
                int index_pH = pppd.GetOtherPlayerShowPos(pppd.GetOtherPlayerPos(voices[0].iUserId)) - 1;
                Debug.LogWarning("播放完成" + voices[0].iUserId + "index_pH:" + index_pH);

                if (index_pH >= 0 && index_pH <= 3)
                {
                    UIMainView.Instance.PlayerPlayingPanel._playingHead[index_pH].GetChild(4).GetComponent <Animator>().SetBool("isPlayOthers", false);
                }
                isPlayingState = false;//关闭播放状态
                voices.RemoveAt(0);
            }
            AudioListener.volume = 1;
            if (time > 0)
            {
                StopCoroutine(DealNoReasult(time));
            }
        }
Ejemplo n.º 4
0
    /// <summary>
    /// 打出牌之后的操作
    /// </summary>
    /// <param name="status">1表示正常打出牌,2表示碰杠的处理</param>
    public void PutCard(int status)
    {
        #region 关闭提示
        showM[] show = transform.parent.parent.parent.GetComponentsInChildren <showM>();
        //Debug.LogError("down" + show.Length);
        for (int i = 0; i < show.Length; i++)
        {
            if (show[i].isOpen)
            {
                show[i].Stop();
                for (int j = 0; j < show[i].m.Length; j++)
                {
                    show[i].m[j].enabled = false;
                }
                show[i].isOpen = false;
            }
        }
        #endregion 关闭提示
        Vector3 firstPos            = Vector3.zero; //第一张麻将的位置
        PlayerPlayingPanelData pppd = GameData.Instance.PlayerPlayingPanelData;
        pppd.isCanHandCard = false;
        if (status == 1 && pppd.iPlayerHostStatus == 0)
        {
            //发送出牌请求
            byte value = Convert.ToByte(bMahjongValue.ToString("x8"));
            NetMsg.ClientDiscardTileReq msg = new NetMsg.ClientDiscardTileReq();
            msg.iUserId         = GameData.Instance.PlayerNodeDef.iUserId;
            msg.byDrawSeaBottom = bMahjongValue;
            MahjongManger.Instance.TingFirstValue = msg.byDrawSeaBottom;
            NetworkMgr.Instance.GameServer.SendDiscardTileReq(msg);
            MahjongManger.Instance.isEndPutAnimation = false;
            UIMainView.Instance.PlayerPlayingPanel.TingShow.SetActive(false);
            MahjongManger.Instance.HideTingLogo();
        }


        //隐藏该麻将
        //transform.localScale = Vector3.one * 0.001f;
        iState = 0;
        //获取第一张麻将的位置
        //firstPos = MahjongManger.Instance.GetFirstMahjongPos(0);
        firstPos = MahjongManger.Instance.FirstPos;
        //获取打出牌的下标
        for (int i = 0; i < pppd.usersCardsInfo[0].listCurrentCards.Count; i++)
        {
            if (bMahjongValue == pppd.usersCardsInfo[0].listCurrentCards[i].cardNum && iMahId == pppd.usersCardsInfo[0].listCurrentCards[i].MahId)
            {
                pppd.usersCardsInfo[0].listCurrentCards.RemoveAt(i);
                MahjongManger.Instance.iputCardIndex = i;
                break;
            }
        }


        int deadcardValue = -1;
        int mahid         = -1;
        if (MahjongManger.Instance.PlayerDealHandCrad != null)
        {
            deadcardValue = MahjongManger.Instance.PlayerDealHandCrad.bMahjongValue;
            mahid         = MahjongManger.Instance.PlayerDealHandCrad.iMahId;
        }
        //判断打出的牌是不是摸到的手牌
        if (isDealCard)
        {
            isDealCard = false;
        }
        else
        {
            //对list进行排序,获取手牌的下标
            pppd.CurrentCradSort(0);
            pppd.CurrentCradSort(0);
            //处理玩家吃碰之后的打牌操作
            if (deadcardValue == -1 && mahid == -1)
            {
                if (pppd.isSpwanSpecialCard)
                {
                    pppd.isSpwanSpecialCard = false;
                    MahjongManger.Instance.insertCardIndex = pppd.usersCardsInfo[0].listCurrentCards.Count;
                }
                else
                {
                    MahjongManger.Instance.insertCardIndex = -1;
                    MahjongManger.Instance.iputCardIndex  -= 1;
                }
            }
            else
            {
                for (int i = 0; i < pppd.usersCardsInfo[0].listCurrentCards.Count; i++)
                {
                    if (deadcardValue == pppd.usersCardsInfo[0].listCurrentCards[i].cardNum && mahid == pppd.usersCardsInfo[0].listCurrentCards[i].MahId)
                    {
                        MahjongManger.Instance.insertCardIndex = i;
                        break;
                    }
                }
            }

            Mahjong[] mah = new Mahjong[Mathf.Abs(MahjongManger.Instance.insertCardIndex - MahjongManger.Instance.iputCardIndex)];


            if (Mathf.Abs(MahjongManger.Instance.insertCardIndex - MahjongManger.Instance.iputCardIndex) > 0)
            {
                mah = MahjongManger.Instance.GetWillMoveCard();
            }

            //调用移动方法插入手牌
            if (mah.Length > 0)
            {
                for (int i = 0; i < mah.Length; i++)
                {
                    mah[i].MoveSelf(MahjongManger.Instance.MoveStatus, 1);
                }
            }

            //Debug.LogError("这张麻将的信息,deadcardValue:" + deadcardValue + ",mahid:" + mahid);

            if (deadcardValue != -1 && mahid != -1)
            {
                MahjongManger.Instance.flyMahjongIndexPos(firstPos);
            }
            else
            {
                MahjongManger.Instance.GetFirstMahjongPos(0);
            }
        }

        int index = pppd.GetOtherPlayerShowPos(pppd.bySeatNum + 1) - 1;
        if (status == 1)
        {
            byte value = bMahjongValue;
            //if (PlayerPrefs.HasKey("TingOneCard"))
            //{
            //    if (PlayerPrefs.GetInt("TingOneCard") == 1 && pppd.playingMethodConf.byDiscardSeeReadHandTile == 0)
            //    {
            //        value = 255;
            //    }
            //}
            pppd.iSpwanCardNum--;
            //先在同一个位置产生一个对应的预置体,然后移动
            transform.localScale = Vector3.zero;
            GameObject go = Instantiate(Resources.Load <GameObject>("Game/Ma/TabelBigCard"));
            go.transform.SetParent(UIMainView.Instance.PlayerPlayingPanel._Cards[0].transform.Find("currentGroup"));
            go.name = "TabelBigCard";
            go.transform.localPosition    = transform.localPosition;
            go.transform.localScale       = Vector3.one * 1.2f;
            go.transform.localEulerAngles = Vector3.zero;
            UIMainView.Instance.PlayerPlayingPanel.ChangeCardNum(go.transform.Find("Image/num").GetComponent <Image>(), value, index);
            go.GetComponent <Mahjong>().bMahjongValue = value;
            go.GetComponent <Mahjong>().PutCardAnimator(pppd.bySeatNum, value, 1);
            PoolManager.Unspawn(gameObject);
        }
        else
        {
        }
        isDealCard = false;
    }
Ejemplo n.º 5
0
        /// <summary>
        /// 产生对应的手牌
        /// </summary>
        public void SpwanPlayerCard()
        {
            GameResultPanelData grpd      = GameData.Instance.GameResultPanelData;
            Vector3             initpos_0 = initPos.transform.localPosition; //普通麻将的初始位置

            PlayerPlayingPanelData pppd = GameData.Instance.PlayerPlayingPanelData;
            int index = pppd.GetOtherPlayerShowPos(iseatNum + 1) - 1;

            if (initpos_0.y > 80)
            {
                initpos_0 = new Vector3(initpos_0.x, 80, 0);
            }
            int  mahjongNum_0 = 0; //麻将产生数量
            byte bLastTile    = 0; //最后一张得到的牌
            int  winNum       = 0; //显示胡牌的数量
            //存储玩家的手牌
            List <byte> mahvalue = new List <byte>();

            for (int i = 0; i < 14; i++)
            {
                if (grpd.bHandleTiles[iseatNum - 1, i] != 0)
                {
                    mahvalue.Add(grpd.bHandleTiles[iseatNum - 1, i]);
                }
            }


            //添加玩家最后获取的一张牌,会添加一个胡牌的标志图片
            if (grpd.resultType[iseatNum - 1].lastTile.bySuit != 0 && grpd.byaWinSrat[iseatNum - 1] > 0)
            {
                bLastTile = (byte)(grpd.resultType[iseatNum - 1].lastTile.bySuit * 16 + grpd.resultType[iseatNum - 1].lastTile.byValue);

                if (!bSelfWin)
                {
                    mahvalue.Add(bLastTile);
                }
            }

            mahvalue.Sort(iCompareList);

            //产生手牌
            for (int i = 0; i < mahvalue.Count; i++)
            {
                if (mahvalue[i] != 0)
                {
                    GameObject go = null;
                    go = PoolManager.Spawn("Game/Ma/", PlayerPlayingPanelData.showVCardPre);
                    go.transform.SetParent(playerCard.transform);
                    go.transform.SetAsFirstSibling();
                    go.transform.localScale       = Vector3.one;
                    go.transform.localEulerAngles = Vector3.zero;
                    go.transform.Find("Image/num").transform.localEulerAngles = Vector3.zero;
                    go.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 0);
                    go.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0);
                    go.transform.localPosition = initpos_0 + new Vector3(mahjongNum_0 * 42f, 0, 0);
                    mahjongNum_0++;
                    if (bLastTile == mahvalue[i] && winNum == 0 && grpd.byaWinSrat[iseatNum - 1] > 0)
                    {
                        go.transform.Find("win").gameObject.SetActive(true);

                        winNum++;
                    }
                    go.transform.Find("point").gameObject.SetActive(false);
                    UIMainView.Instance.PlayerPlayingPanel.ChangeCardNum(go.transform.Find("Image/num").GetComponent <Image>(), mahvalue[i]);
                }
                else
                {
                    break;
                }
            }

            Vector3 initpos_1    = initPos_special.transform.localPosition; //特殊麻将的初始位置
            int     mahjongNum_1 = 0;

            //产生顺子牌
            //Debug.LogError("产生顺子牌:" + grpd.resultType[iseatNum - 1].bySequenceNum);
            for (int i = 0; i < grpd.resultType[iseatNum - 1].bySequenceNum; i++)
            {
                GameObject go    = null;
                byte       value = 0; //顺子的第一个值
                go = PoolManager.Spawn("Game/Ma/", PlayerPlayingPanelData.pegaUCardsPre);
                go.transform.SetParent(playerCard.transform);
                go.transform.SetAsFirstSibling();
                go.transform.localScale       = Vector3.one;
                go.transform.localEulerAngles = Vector3.zero;
                go.transform.localPosition    = initpos_1 + new Vector3(mahjongNum_0 * 42f + 20f + mahjongNum_1 * 145f, 0, 0);
                //更新牌面
                value = (byte)(grpd.resultType[iseatNum - 1].sequenceType[i].bySuit * 16 + grpd.resultType[iseatNum - 1].sequenceType[i].byFirstValue);
                UpdateCard(go, value, 0);
                mahjongNum_1++;
            }
            // Debug.LogError("grpd.resultType[iseatNum - 1].byTripletNum" + grpd.resultType[iseatNum - 1].byTripletNum);
            //产生刻子牌
            for (int i = 0; i < grpd.resultType[iseatNum - 1].byTripletNum; i++)
            {
                GameObject go    = null;
                byte       value = 0; //对应牌的花色值
                go = PoolManager.Spawn("Game/Ma/", PlayerPlayingPanelData.pegaUCardsPre);
                go.transform.SetParent(playerCard.transform);
                go.transform.SetAsFirstSibling();
                go.transform.localScale       = Vector3.one;
                go.transform.localEulerAngles = Vector3.zero;
                go.transform.localPosition    = initpos_1 + new Vector3(mahjongNum_0 * 42f + 20f + mahjongNum_1 * 145f, 0, 0);
                //更新牌面的花色值
                value = (byte)(grpd.resultType[iseatNum - 1].tripletType[i].bySuit * 16 + grpd.resultType[iseatNum - 1].tripletType[i].byValue);
                // Debug.LogError("刻子牌的花色值:" + value.ToString("X2"));
                UpdateCard(go, value, grpd.resultType[iseatNum - 1].tripletType[i].byPongKongType);
                mahjongNum_1++;
            }

            //Debug.LogError("吃抢的牌的数量:" + grpd.resultType[iseatNum - 1].byThirteenOrphansNum);
            //产生吃抢的牌
            for (int i = 0; i < grpd.resultType[iseatNum - 1].byThirteenOrphansNum; i++)
            {
                byte value = 0;  //对应牌的花色值
                                 //更新牌面的花色值
                value = (byte)(grpd.resultType[iseatNum - 1].thirteenOrphansType[i].bySuit * 16 + grpd.resultType[iseatNum - 1].thirteenOrphansType[i].byValue);
                GameObject go = null;
                go = PoolManager.Spawn("Game/Ma/", PlayerPlayingPanelData.showVCardPre);
                go.transform.SetParent(playerCard.transform);
                go.transform.SetAsFirstSibling();
                go.transform.localScale       = Vector3.one;
                go.transform.localEulerAngles = Vector3.zero;
                go.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 0);
                go.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0);
                go.transform.localPosition = initpos_0 + new Vector3(mahjongNum_0 * 42f + 20f, 0, 0);
                UIMainView.Instance.PlayerPlayingPanel.ChangeCardNum(go.transform.Find("Image/num").GetComponent <Image>(), value, index);
                mahjongNum_0++;
            }
        }