Commit 563e82f4 authored by Yuyang's avatar Yuyang

Merge remote-tracking branch 'origin/master' into YuYang

parents e536bebe 8b1786ea
This diff is collapsed.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SettingPanel : MonoBehaviour
{
public Button m_vibrationBtn;//震动按钮
public Button m_soundBtn;//音效按钮
public Button m_bgmBtn;//背景音乐按钮
public GameObject m_vibrationImageObj;//震动✔
public GameObject m_soundImageObj;//音效✔
public GameObject m_bgmImageObj;//背景音乐✔
private void Awake()
{
m_vibrationBtn.onClick.AddListener(OnVibrationClick);
m_soundBtn.onClick.AddListener(OnSoundClick);
m_bgmBtn.onClick.AddListener(OnBgmClick);
}
private void Start()
{
string varStr1 = GlobalConfig.VibrationKey;
if (LocalRecord.HasKey(varStr1))
{
m_vibrationImageObj.SetActive(LocalRecord.GetIntRecord(varStr1) > 0 ? true : false);
}
else
{
m_vibrationImageObj.SetActive(true);
}
string varStr2 = GlobalConfig.SoundKey;
if (LocalRecord.HasKey(varStr2))
{
m_soundImageObj.SetActive(LocalRecord.GetIntRecord(varStr2) > 0 ? true : false);
}
else
{
m_soundImageObj.SetActive(true);
}
string varStr3 = GlobalConfig.BgmKey;
if (LocalRecord.HasKey(varStr3))
{
m_bgmImageObj.SetActive(LocalRecord.GetIntRecord(varStr3) > 0 ? true : false);
}
else
{
m_bgmImageObj.SetActive(true);
}
}
//震动
void OnVibrationClick()
{
bool varBool = m_vibrationImageObj.activeSelf;
m_vibrationImageObj.SetActive(!varBool);
LocalRecord.SetIntRecord(GlobalConfig.VibrationKey, varBool ? 0 : 1);
}
//音效
void OnSoundClick()
{
bool varBool = m_soundImageObj.activeSelf;
m_soundImageObj.SetActive(!varBool);
LocalRecord.SetIntRecord(GlobalConfig.SoundKey, varBool ? 0 : 1);
}
//背景音乐
void OnBgmClick()
{
bool varBool = m_bgmImageObj.activeSelf;
m_bgmImageObj.SetActive(!varBool);
LocalRecord.SetIntRecord(GlobalConfig.BgmKey, varBool ? 0 : 1);
if(varBool)
{
GameServices.audioServices.RecycleBgm();
}
else
{
GameServices.audioServices.PlayBgm(GameServices.configService.audioConfig.GameBgm);
}
}
public void OnCloseClick()
{
gameObject.SetActive(false);
BattleCtrl.instance.battleUI.SetBattleObjState(true);
}
}
fileFormatVersion: 2
guid: 86d1c03e5362d0d44ab2d6e6ca6418f5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -71,7 +71,6 @@ public class ChainRopeView : MonoBehaviour
private Outlinable m_outlinable;//插件脚本
private bool m_bIsClawUp = false;//是否爪子在上升
private AudioSource m_clawDownOrUpAudioSource;//下降上升音乐,需要循环播放
private bool m_bControlClawDownOrUpAudio = true;//控制音效
void Awake()
{
......@@ -228,7 +227,6 @@ public class ChainRopeView : MonoBehaviour
{
return;
}
m_bControlClawDownOrUpAudio = true;
m_clawDownOrUpAudioSource = GameServices.audioServices.GetPlayAudioSource(GameServices.configService.audioConfig.clawDownOrUp);
//第五关特殊处理
//if (BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelFiveIndex)
......@@ -560,9 +558,8 @@ public class ChainRopeView : MonoBehaviour
}
else
{
if (m_bControlClawDownOrUpAudio)
if (m_clawDownOrUpAudioSource)
{
m_bControlClawDownOrUpAudio = false;
GameServices.audioServices.AudioPlayFinished(m_clawDownOrUpAudioSource);
m_clawDownOrUpAudioSource = null;
}
......@@ -590,9 +587,8 @@ public class ChainRopeView : MonoBehaviour
else
{
SetJoyStickDirectTrans(m_topCollider.transform);
if (m_bControlClawDownOrUpAudio)
if (m_clawDownOrUpAudioSource)
{
m_bControlClawDownOrUpAudio = false;
GameServices.audioServices.AudioPlayFinished(m_clawDownOrUpAudioSource);
m_clawDownOrUpAudioSource = null;
}
......@@ -634,9 +630,8 @@ public class ChainRopeView : MonoBehaviour
}
else
{
if (m_bControlClawDownOrUpAudio)
if (m_clawDownOrUpAudioSource)
{
m_bControlClawDownOrUpAudio = false;
GameServices.audioServices.AudioPlayFinished(m_clawDownOrUpAudioSource);
m_clawDownOrUpAudioSource = null;
}
......
......@@ -63,6 +63,10 @@ public class AudioServices : MonoBehaviour
public void PlayBgm(AudioClip clip)
{
if(LocalRecord.HasKey(GlobalConfig.BgmKey) && LocalRecord.GetIntRecord(GlobalConfig.BgmKey) == 0)
{
return;
}
if (bgmSource == null)
{
bgmSource = GetSource();
......@@ -75,9 +79,22 @@ public class AudioServices : MonoBehaviour
bgmSource.Play();
}
//释放背景音乐
public void RecycleBgm()
{
if(bgmSource)
{
RecycleSource(bgmSource);
bgmSource = null;
}
}
public void PlayAudio(AudioClip clip, bool isLoop = false, Action onPlayEnd = null)
{
if (LocalRecord.HasKey(GlobalConfig.SoundKey) && LocalRecord.GetIntRecord(GlobalConfig.SoundKey) == 0)
{
return;
}
AudioSource source = GetSource();
source.clip = clip;
source.loop = isLoop;
......@@ -91,6 +108,10 @@ public class AudioServices : MonoBehaviour
}
public AudioSource GetPlayAudioSource(AudioClip clip)
{
if (LocalRecord.HasKey(GlobalConfig.SoundKey) && LocalRecord.GetIntRecord(GlobalConfig.SoundKey) == 0)
{
return null;
}
AudioSource source = GetSource();
source.clip = clip;
source.loop = true;
......@@ -101,6 +122,10 @@ public class AudioServices : MonoBehaviour
public void AudioPlayFinished(AudioSource source)
{
if (LocalRecord.HasKey(GlobalConfig.SoundKey) && LocalRecord.GetIntRecord(GlobalConfig.SoundKey) == 0)
{
return;
}
RecycleSource(source);
}
......
......@@ -22,6 +22,9 @@ public class GlobalConfig
/// 语言类型
/// </summary>
public static LangeType langType;
public static string VibrationKey = "VibrationKey";//震动Key
public static string SoundKey = "SoundKey";//音效Key
public static string BgmKey = "BgmKey";//音乐Key
}
public enum LangeType
......
This diff is collapsed.
......@@ -36,14 +36,9 @@ MonoBehaviour:
fifthLevelGoalName3: SM_Primitive_Sphere_02
sixthLevelGoalName: SM_Primitive_Pyramid_01
audioConfig:
pienDeads: []
win: {fileID: 0}
fail: {fileID: 0}
shoot: {fileID: 0}
ElevatorOpen: {fileID: 0}
keyPick: {fileID: 0}
GameBgm: {fileID: 0}
npcRescue: {fileID: 0}
npc2pien: {fileID: 0}
gunPick: {fileID: 0}
girlScream: {fileID: 0}
failList:
- {fileID: 8300000, guid: 03522ac8d99167f45ac598927093c79e, type: 3}
- {fileID: 8300000, guid: 18755c9489da3654db451b917f8ecd81, type: 3}
GameBgm: {fileID: 8300000, guid: 75b73601c36cb92418c2f0e6a18de5e2, type: 3}
Success: {fileID: 8300000, guid: a4fa2dc9fd619ef4a965de465f1586dc, type: 3}
clawDownOrUp: {fileID: 8300000, guid: f582290ca8df575409f8f5868dbeb6c6, type: 3}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment