コード例 #1
0
    // 斗地主出牌音效
    public void playSound_DouDiZhu_ChuPai(List <TLJCommon.PokerInfo> list, string uid)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("playSound_DouDiZhu_ChuPai_hotfix", "playSound_DouDiZhu_ChuPai"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.playSound_DouDiZhu_ChuPai_hotfix", "playSound_DouDiZhu_ChuPai", null, list, uid);
            return;
        }

        CrazyLandlords.Helper.LandlordsCardsHelper.SetWeight(list);
        CrazyLandlords.Helper.CardsType cardsType;

        CrazyLandlords.Helper.LandlordsCardsHelper.GetCardsType(list.ToArray(), out cardsType);

        if (list.Count == 0)
        {
            playSound("guo");
            return;
        }

        switch (cardsType)
        {
        case CrazyLandlords.Helper.CardsType.JokerBoom:
        {
            playSound("huojian");

            {
                GameObject    obj           = CreateUGUI.createImageObj(GameObject.Find("Canvas_Middle").gameObject, CommonUtil.getImageSpriteByAssetBundle("animations.unity3d", "huojian1"));
                PlayAnimation playAnimation = obj.AddComponent <PlayAnimation>();
                playAnimation.start("animations.unity3d", "huojian", true, 0.07f);

                obj.transform.localPosition = new Vector3(0, -200, 0);
                obj.transform.DOMoveY(10, 3).OnComplete(() =>
                    {
                        GameObject.Destroy(obj);
                    });
            }
        }
        break;

        case CrazyLandlords.Helper.CardsType.Boom:
        {
            playSound("bomb");

            {
                GameObject    obj           = CreateUGUI.createImageObj(GameObject.Find("Canvas_Middle").gameObject, CommonUtil.getImageSpriteByAssetBundle("animations.unity3d", "zhadan1"));
                PlayAnimation playAnimation = obj.AddComponent <PlayAnimation>();
                playAnimation.start("animations.unity3d", "zhadan", false, 0.07f);
            }
        }
        break;

        case CrazyLandlords.Helper.CardsType.BoomAndOne:                    //四带一
        {
            playSound("four_one");
        }
        break;

        case CrazyLandlords.Helper.CardsType.BoomAndTwo:                    //四带二
        {
            playSound("four_two");
        }
        break;

        case CrazyLandlords.Helper.CardsType.OnlyThree:
        {
            playSound("three");
        }
        break;

        case CrazyLandlords.Helper.CardsType.ThreeAndOne:
        {
            playSound("three_one");
        }
        break;

        case CrazyLandlords.Helper.CardsType.ThreeAndTwo:
        {
            playSound("three_two");
        }
        break;

        case CrazyLandlords.Helper.CardsType.Straight:
        {
            playSound("shunzi");

            {
                GameObject    obj           = CreateUGUI.createImageObj(GameObject.Find("Canvas_Middle").gameObject, CommonUtil.getImageSpriteByAssetBundle("animations.unity3d", "shunzi1"));
                PlayAnimation playAnimation = obj.AddComponent <PlayAnimation>();
                playAnimation.start("animations.unity3d", "shunzi", false, 0.1f);
                obj.transform.localScale = new Vector3(2, 2, 2);

                int   middle = DDZ_GameData.getInstance().getPlayerDataByUid(uid).m_outPokerObjList.Count / 2;
                float y      = DDZ_GameData.getInstance().getPlayerDataByUid(uid).m_outPokerObjList[middle].transform.position.y + 80;
                obj.transform.localPosition = new Vector3(0, y, 0);
            }
        }
        break;

        case CrazyLandlords.Helper.CardsType.DoubleStraight:
        {
            playSound("liandui");

            {
                GameObject    obj           = CreateUGUI.createImageObj(GameObject.Find("Canvas_Middle").gameObject, CommonUtil.getImageSpriteByAssetBundle("animations.unity3d", "liandui1"));
                PlayAnimation playAnimation = obj.AddComponent <PlayAnimation>();
                playAnimation.start("animations.unity3d", "liandui", false, 0.1f);
                obj.transform.localScale = new Vector3(2, 2, 2);

                int   middle = DDZ_GameData.getInstance().getPlayerDataByUid(uid).m_outPokerObjList.Count / 2;
                float x      = DDZ_GameData.getInstance().getPlayerDataByUid(uid).m_outPokerObjList[middle].transform.position.x;
                float y      = DDZ_GameData.getInstance().getPlayerDataByUid(uid).m_outPokerObjList[middle].transform.position.y;
                obj.transform.position = new Vector3(x, y, 0);
            }
        }
        break;

        case CrazyLandlords.Helper.CardsType.TripleStraight:
        case CrazyLandlords.Helper.CardsType.TripleStraightAndOne:
        case CrazyLandlords.Helper.CardsType.TripleStraightAndTwo:
        {
            playSound("feiji");

            {
                GameObject    obj           = CreateUGUI.createImageObj(GameObject.Find("Canvas_Middle").gameObject, CommonUtil.getImageSpriteByAssetBundle("animations.unity3d", "feiji1"));
                PlayAnimation playAnimation = obj.AddComponent <PlayAnimation>();
                playAnimation.start("animations.unity3d", "feiji", true, 0.07f);

                obj.transform.localPosition = new Vector3(-500, 0, 0);
                obj.transform.DOMoveX(10, 3).OnComplete(() =>
                    {
                        GameObject.Destroy(obj);
                    });
            }
        }
        break;

        case CrazyLandlords.Helper.CardsType.Double:
        {
            int num = list[0].m_num;

            if ((num >= 2) && (num <= 10))
            {
                playSound("double_" + num.ToString());
            }
            else if (num == 11)
            {
                playSound("double_J");
            }
            else if (num == 12)
            {
                playSound("double_Q");
            }
            else if (num == 13)
            {
                playSound("double_K");
            }
            else if (num == 14)
            {
                playSound("double_A");
            }
        }
        break;

        case CrazyLandlords.Helper.CardsType.Single:
        {
            int num = list[0].m_num;

            if ((num >= 2) && (num <= 10))
            {
                playSound(num.ToString());
            }
            else if (num == 11)
            {
                playSound("J");
            }
            else if (num == 12)
            {
                playSound("Q");
            }
            else if (num == 13)
            {
                playSound("K");
            }
            else if (num == 14)
            {
                playSound("A");
            }
            else if (num == 15)
            {
                playSound("xiaowang");
            }
            else if (num == 16)
            {
                playSound("dawang");
            }
        }
        break;
        }
    }