コード例 #1
0
    //##### BGM #####

    //購入可能BGMリスト表示
    private void DispStoreMusicList()
    {
        DispListClear();
        MusicGetList.gameObject.SetActive(true);

        Transform storeMusicContent = MusicGetList.FindChild("View/Content");

        ////再生中BGM名
        //string playingBgmName = "";
        //if (PlayingText != null) playingBgmName = PlayingText.text;

        //リストクリア
        foreach (Transform child in storeMusicContent)
        {
            Destroy(child.gameObject);
        }

        //音楽リスト
        List <BgmManager> battleBgmList = SoundManager.Instance.GetBattleBgmList();

        for (int i = 0; i < battleBgmList.Count; i++)
        {
            int        musicIndex = i;
            BgmManager battleBgm  = battleBgmList[musicIndex];

            //OPENチェック
            bool isOpen = false;
            if (UserManager.userOpenMusics.IndexOf(musicIndex) >= 0)
            {
                isOpen = true;
            }

            GameObject row       = (GameObject)Instantiate(storeMusicObj);
            Transform  rowTran   = row.transform;
            string     musicName = battleBgm.GetAudioClipName();
            Text       musicText = rowTran.FindChild("Name").GetComponent <Text>();
            musicText.text = musicName;
            BgmManager bgmMgr = battleBgm;
            if (isOpen)
            {
                //再生
                musicText.color = (PlayingMusicIndex == musicIndex) ? playFontColor : normalFontColor;
                rowTran.GetComponent <Button>().onClick.AddListener(() => PlayMusic(musicIndex, bgmMgr));
            }
            else
            {
                //購入
                musicText.color = closeFontColor;
                rowTran.GetComponent <Button>().onClick.AddListener(() => BuyMusic(musicIndex, battleBgm));
            }
            rowTran.SetParent(storeMusicContent, false);
        }
    }
コード例 #2
0
    //BGM購入
    private void BuyMusic(int musicIndex, BgmManager battleBgm)
    {
        string musicName = battleBgm.GetAudioClipName();

        UnityAction buy = () =>
        {
            DialogController.OpenMessage(DialogController.MESSAGE_LOADING, DialogController.MESSAGE_POSITION_RIGHT);

            //point消費
            Point.Use PointUse = new Point.Use();
            PointUse.SetApiFinishCallback(() => MusicBuyResult(musicIndex));
            PointUse.SetApiFinishErrorCallback(BuyMusicErrorProc);
            PointUse.Exe(NEED_MUSIC_POINT, Common.API.POINT_LOG_KIND_MUSIC, musicIndex);
        };

        //確認ダイアログ
        string text = "未開放のBGMです\n";

        text += "解放しますか?\n\n";
        text += "「" + musicName + "」\n";
        text += NEED_MUSIC_POINT + "pt消費";
        DialogController.OpenDialog(text, buy, true);
    }