예제 #1
0
    /// <summary>
    /// 播放音效
    /// </summary>
    /// <param name="musicId">音效ID</param>
    /// <param name="alreadyPrepare">是否已经 Prepare 加载了 一般给 false</param>
    /// <param name="point">位置</param>
    /// <param name="playEndAction"> //非循环音效,播放完毕回调(需要的赋值就可以了)</param>
    /// <param name="userEndData"> 回调参数</param>
    public static void PlaySound(int musicId, bool alreadyPrepare, Vector3 point, Action <SystemObject> playEndAction = null, SystemObject userEndData = null)
    {
        //Debug.LogError("PlaySound2->musicId:" + musicId);
        //string traceStr = new System.Diagnostics.StackTrace().ToString();
        //Debug.LogError("StackTrace info:" + traceStr);
        MsgPlayMusicOrSound parame = new MsgPlayMusicOrSound();

        parame.musicId        = musicId;
        parame.alreadyPrepare = alreadyPrepare;
        parame.point          = point;
        parame.UseSoundParent = false;
        parame.endAction      = playEndAction;
        parame.userEndData    = userEndData;
        GameFacade.Instance.SendNotification(NotificationName.MSG_SOUND_PLAY, parame);
    }
예제 #2
0
    public override void Execute(INotification notification)
    {
        //特殊枚举类型标记
        MsgPlaySpecialTypeMusicOrSound specialparame = notification.Body as MsgPlaySpecialTypeMusicOrSound;

        if (specialparame != null)
        {
            if (specialparame.UseSoundParent)
            {
                WwiseManager.PlaySpecialTypeMusicOrSound(specialparame.ComboId, specialparame.type, specialparame.palce, specialparame.alreadyPrepare, specialparame.SoundParent, specialparame.endAction, specialparame.userEndData);
            }
            else
            {
                WwiseManager.PlaySpecialTypeMusicOrSound(specialparame.ComboId, specialparame.type, specialparame.palce, specialparame.alreadyPrepare, specialparame.point, specialparame.endAction, specialparame.userEndData);
            }
        }

        //普通的
        MsgPlayMusicOrSound playparame = notification.Body as MsgPlayMusicOrSound;

        if (playparame != null)
        {
            if (playparame.UseSoundParent)
            {
                WwiseManager.PlayMusicOrSound(playparame.musicId, playparame.alreadyPrepare, playparame.SoundParent, playparame.endAction, playparame.userEndData);
            }
            else
            {
                WwiseManager.PlayMusicOrSound(playparame.musicId, playparame.alreadyPrepare, playparame.point, playparame.endAction, playparame.userEndData);
            }
        }

        //toggle 越界声音
        MsgPlayMusicOrSound_outLine outLineparame = notification.Body as MsgPlayMusicOrSound_outLine;

        if (outLineparame != null && outLineparame.OldSelectionObj != null && outLineparame.OldSelectionObj.activeInHierarchy)
        {
            UnityEngine.UI.ButtonWithSound buttonSoundSprite = outLineparame.OldSelectionObj.GetComponent <UnityEngine.UI.ButtonWithSound>();
            if (buttonSoundSprite != null)
            {
                buttonSoundSprite.PlayOutLineSound();
            }
        }
    }