/// <summary> /// 初始化分兵状态 /// </summary> private void InitFightProgressOption() { percentGo.SetActive(false); newProgressGo.SetActive(false); int option = LocalSettingStorage.Get().fightOption; if (option == 1) { // 长按 ShowNewProgress1(false); } else { // 普通进度条 // 进度条滑块绑定事件 UIEventListener listener = percetPic.gameObject.GetComponent <UIEventListener> (); listener.onDrag = OnProgressDrag; listener.onDragStart = OnProgressDragStart; //listener.onDragEnd = OnProgressDragEnd; // line total Length lineTotalLength = 1200; percentZeroPos = new Vector3(percetPic.transform.localPosition.x - (lineTotalLength / 2), percetPic.transform.localPosition.y, 0); percentGo.SetActive(true); } }
/// <summary> /// 播放音效 /// </summary> /// <param name="audio">Audio.</param> /// <param name="loop">If set to <c>true</c> loop.</param> /// <param name="volume">Volume.</param> /// <param name="pan">Pan.</param> void PlayAudioEffect(string audioName, float volume = 1.0f, float pan = 0.0f) { if (!LocalSettingStorage.Get().sound) { return; } if (BattleSystem.Instance.battleData.silent) { return; } AudioSource audio = GetFreeEffectAudioSource(); if (audio == null) { return; } AudioClip clip = AssetManager.Get().GetResources(audioName) as AudioClip; if (clip == null) { return; } //audio.Stop (); audio.volume = volume; audio.panStereo = pan; audio.loop = false; audio.PlayOneShot(clip); }
/// <summary> /// 播放音效 /// </summary> /// <param name="clip">Clip.</param> /// <param name="volume">Volume.</param> /// <param name="pitch">Pitch.</param> private void PlayAudioEffect(AudioClip clip, float volume) { if (!LocalSettingStorage.Get().sound) { return; } if (clip == null) { return; } AudioSource audio = GetFreeEffectAudioSource(); if (audio == null) { return; } //Debug.Log ("Audio Play:" + clip.name); //audio.Stop (); audio.volume = volume; audio.panStereo = 0; audio.loop = false; audio.PlayOneShot(clip); }
public void OnFightToggleValueChanged() { for (int i = 0; i < fightOptionToggles.Length; ++i) { if (fightOptionToggles [i].value) { LocalSettingStorage.Get().fightOption = i; } SetToggleColor(fightOptionToggles [i].gameObject, fightOptionToggles [i].value); } }
public void OnToggleValueChanged() { for (int i = 0; i < effectToggles.Length; ++i) { if (effectToggles [i].value) { LocalSettingStorage.Get().effectLevel = i; } SetToggleColor(effectToggles [i].gameObject, effectToggles [i].value); } }
public void OnCloseClick() { UISystem.Get().ShowWindow("LobbyWindowView"); UISystem.Get().HideWindow("SettingWindow"); if (LocalSettingStorage.Get().lobbyWindowType == 0) { EventSystem.Instance.FireEvent(EventId.UpdateChaptersWindow); } else if (LocalSettingStorage.Get().lobbyWindowType == 1) { EventSystem.Instance.FireEvent(EventId.UpdateChapterWindow, 3); } }
public void OnSoundClick(GameObject go) { LocalSettingStorage.Get().sound = !LocalSettingStorage.Get().sound; SetPage(); // 播放/停止音效 if (LocalSettingStorage.Get().sound) { AudioManger.Get().PlayEffect("click_down"); AudioManger.Get().MuteEffectAudio(false); } else { AudioManger.Get().MuteEffectAudio(true); } }
public void OnMusicClick(GameObject go) { LocalSettingStorage.Get().music = !LocalSettingStorage.Get().music; SetPage(); AudioManger.Get().PlayEffect("click_down"); // 播放/停止背景音 if (LocalSettingStorage.Get().music) { AudioManger.Get().MuteBGAudio(false); AudioManger.Get().PlayAudioBG("Empty"); } else { AudioManger.Get().MuteBGAudio(true); } }
/// <summary> /// 初始化 /// </summary> public bool Init() { LoggerSystem.Instance.Debug("LocalStorageSystem init begin"); // 注册管理器 RegisterLocalStorage(LocalAccountStorage.Get()); RegisterLocalStorage(LocalSettingStorage.Get()); RegisterLocalStorage(LocalLevelStorage.Get()); // 获取客户端版本 appVersion = UpdateSystem.Get().GetAppVersion(); // 加载存储信息 LoadStorage(); LoggerSystem.Instance.Debug("LocalStorageSystem init end"); return(true); }
//private void PauseNewProgress1 (Node node) //{ // if (LocalSettingStorage.Get ().fightOption != 1) // return; // if (newProgressTag.Equals (node.tag) && IsInvoking ("UpdateNewProgress1")) { // CancelInvoke ("UpdateNewProgress1"); // } //} private void UpdateNewProgress1() { if (LocalSettingStorage.Get().fightOption != 1) { return; } if (newProgressCount >= 40) { newProgressCount = 0; } percent = 1 - newProgressCount * 0.025f; SetPercent(); newProgressCount++; }
/// <summary> /// 播放背景音乐 /// </summary> /// <param name="audio">Audio.</param> public void PlayAudioBG(string audio, float volume = 0.5f) { if (!LocalSettingStorage.Get().music) { return; } if (bgAudio.isPlaying && !bgAudio.mute) { if (nowPlayAudioBG.Equals(audio)) { bgAudio.volume = volume; return; } } nowPlayAudioBG = audio; CoroutineMono.Start(PlayAudioBGA(audio, volume)); }
/// <summary> /// 新的分兵方式,长按 /// </summary> private void ShowNewProgress1(bool show /*, Node node = null*/) { if (LocalSettingStorage.Get().fightOption != 1) { return; } if (newProgressGo == null) { return; } if (show) { //newProgressGo.gameObject.SetActive (true); //Vector3 pos = Camera.main.WorldToScreenPoint (node.GetPosition ()); //pos.x -= Screen.width / 2; //pos.y -= Screen.height / 2; //newProgressGo.transform.localPosition = pos; //newProgressPic.transform.localScale = Vector3.one * node.GetScale (); // SetPercent (); //if (!IsInvoking ("UpdateNewProgress1")) { // InvokeRepeating ("UpdateNewProgress1", 0.1f, 0.05f); //} //newProgressTag = node.tag; } else { newProgressGo.SetActive(false); CancelInvoke("UpdateNewProgress1"); newProgressTag = string.Empty; newProgressCount = 0; percent = 1.0f; } }
private void SetPercent() { if (LocalSettingStorage.Get().fightOption == 1) { newProgressPic.fillAmount = percent; newProgressLabel.text = string.Format("{0}%", Mathf.RoundToInt(percent * 100)); } else { float length = lineTotalLength * percent; Vector3 pos = percentZeroPos; pos.x += length; int width = (int)((lineTotalLength * percent) + 2 - percentPicWidth / 2); percentleft.width = width; width = (int)((lineTotalLength * (1 - percent)) + 2 - percentPicWidth / 2); percentright.width = width; percentleft.gameObject.SetActive(true); percentright.gameObject.SetActive(true); if (percent == 0) { percentleft.gameObject.SetActive(false); } else if (percent == 1) { percentright.gameObject.SetActive(false); } //percentleft.fillAmount = percent - 0.06f; //percetright.fillAmount = 1f - percent - 0.06f; percetPic.transform.localPosition = pos; // 设置百分比数字 percentLabel.text = string.Format("{0}%", Mathf.RoundToInt(percent * 100)); } // 设置游戏内飞船移动百分比 BattleSystem.Instance.battleData.sliderRate = percent; }
public void SetPage() { Vector3 onPos = Vector3.zero; Vector3 valuePos = Vector3.zero; // 背景音 onPos = musicBg.transform.localPosition; valuePos = musicBg.transform.localPosition; if (LocalSettingStorage.Get().music) { onPos.x += 65.0f / 2; // musicOn.bg / 2; valuePos.x -= 65.0f / 2; musicOn.color = musicBg.color = musicValue.color = btn_on_color; musicValue.text = LanguageDataProvider.GetValue(401); } else { onPos.x -= 65.0f / 2; valuePos.x += 65.0f / 2; musicOn.color = musicBg.color = musicValue.color = btn_off_color; musicValue.text = LanguageDataProvider.GetValue(402); } musicOn.transform.localPosition = onPos; musicValue.transform.localPosition = valuePos; // 音效 onPos = soundBg.transform.localPosition; valuePos = soundBg.transform.localPosition; if (LocalSettingStorage.Get().sound) { onPos.x += 65.0f / 2; valuePos.x -= 65.0f / 2; soundOn.color = soundBg.color = soundValue.color = btn_on_color; soundValue.text = LanguageDataProvider.GetValue(401); } else { onPos.x -= 65.0f / 2; valuePos.x += 65.0f / 2; soundOn.color = soundBg.color = soundValue.color = btn_off_color; soundValue.text = LanguageDataProvider.GetValue(402); } soundOn.transform.localPosition = onPos; soundValue.transform.localPosition = valuePos; /// 语言 if (LocalAccountStorage.Get().localLanguage == (int)SystemLanguage.Chinese) { //chineseValue.text = LanguageDataProvider.GetValue(401); chineseOn.gameObject.SetActive(true); } else { //chineseValue.text = LanguageDataProvider.GetValue(402); chineseOn.gameObject.SetActive(false); } if (LocalAccountStorage.Get().localLanguage != (int)SystemLanguage.Chinese) { //englishValue.text = LanguageDataProvider.GetValue(401); englishOn.gameObject.SetActive(true); } else { //englishValue.text = LanguageDataProvider.GetValue(402); englishOn.gameObject.SetActive(false); } // 效果 for (int i = 0; i < effectToggles.Length; ++i) { if (i == LocalSettingStorage.Get().effectLevel) { effectToggles [i].Set(true, false); SetToggleColor(effectToggles [i].gameObject, true); } else { effectToggles [i].Set(false, false); SetToggleColor(effectToggles [i].gameObject, false); } } // 分兵方式 for (int i = 0; i < fightOptionToggles.Length; ++i) { if (i == LocalSettingStorage.Get().fightOption) { fightOptionToggles [i].Set(true, false); SetToggleColor(fightOptionToggles [i].gameObject, true); } else { fightOptionToggles [i].Set(false, false); SetToggleColor(fightOptionToggles [i].gameObject, false); } } // version string appVersion = string.Empty; //ConfigSystem.Instance.TryGetConfig ("version", out appVersion); version.text = Application.version; //ip and bundle ipLabel.text = NetSystem.Instance.GetConnector().GetHost().ToString(); //bundleLabel.text = Application.bundleIdentifier; }