IEnumerator NowPlayingMusic() { WindowBluetooth.GetInstance().SendBluetoothMsg(holostarSettingModel.MusicIndex.ToString(), SENDMSGTYPE.MUSIC, MUSICINFO.MUSIC_PLAY); yield return(new WaitForSeconds(0.5f)); corMusicCheck = StartCoroutine(CheckMusic()); }
IEnumerator CheckMusic() { while (holostarSettingModel.IsMusicPlay) { yield return(new WaitForSeconds(1.0f)); int num = 0; for (int i = 0; i < playlist.data.Count; i++) { if (musicIndex == playlist.data[i].index) { num = i; break; } } if (audioSource.time >= playlist.data[num].duration - 1f) { holostarSettingModel.IsMusicPlay = false; Message.Send <SetMusicPlayButtonMsg>(new SetMusicPlayButtonMsg(holostarSettingModel.IsMusicPlay)); MusicRequest(new MusicRequestMsg(MUSICINFO.MUSIC_NEXT, 0.ToString())); } WindowBluetooth.GetInstance().SendBluetoothMsg(audioSource.time.ToString(), SENDMSGTYPE.MUSIC, MUSICINFO.MUSIC_TIME); } }
void SetAniMation(int num) { Message.Send <SetCharacterAnimationMsg>(new SetCharacterAnimationMsg((AnimationType)num, false)); if (settingModel.IsBluetoothConnet) { WindowBluetooth.GetInstance().SendBluetoothMsg(num.ToString(), SENDMSGTYPE.ANIMATION); } }
//public bool IsSendPossible = true; //public List<string> ListMsg = new List<string>(); public static WindowBluetooth GetInstance() { if (!instance) { contain = new GameObject(); contain.name = "WindowBluetooth"; instance = contain.AddComponent(typeof(WindowBluetooth)) as WindowBluetooth; } return(instance); }
private void SetCharacterAnimation(SetCharacterAnimationMsg msg) { int tempAniNum = (int)msg.animationType; nowCharacter_Controller.SetAniMation(tempAniNum, msg.isBluetoothCommand); if (settingModel.IsBluetoothConnet && !msg.isBluetoothCommand) { WindowBluetooth.GetInstance().SendBluetoothMsg(msg.animationType.ToString(), SENDMSGTYPE.ANIMATION); } }
protected override void OnEnter() { AddMessage(); SetAudioVisualizer(); //LeapModule.transform.position = new Vector3(0, 0, 5.4f); playlist = WindowMusic.GetInstance().GetPlaylist(); holostarSettingModel.HoloStarSetting.musicSetting.musicNowTime = audioSource.time; string tempJsonMsg = JsonUtility.ToJson(holostarSettingModel.HoloStarSetting); WindowBluetooth.GetInstance().SendBluetoothMsg(tempJsonMsg, SENDMSGTYPE.SETTING); if (holostarSettingModel.IsMusicPlay) { int motionNum = UnityEngine.Random.Range((int)AnimationType.Motion1, (int)AnimationType.Motion7 + 1); SetAniMation(motionNum); StartCoroutine(NowPlayingMusic()); } }
IEnumerator GetAudio(int index) { musicIndex = index; //Music music = playlist.data[index]; Music music = null; for (int i = 0; i < playlist.data.Count; i++) { if (playlist.data[i].index == musicIndex) { //musicIndex = i; music = playlist.data[i]; break; } } Debug.Log("file://" + music.path); WWW www = new WWW("file://" + music.path); yield return(www); if (www.error != null) { Debug.Log(www.error); } else { Message.Send <InfoMsg>(new InfoMsg(music.title + " / " + music.artist)); //test audioSource.clip = NAudioPlayer.FromMp3Data(www.bytes); audioSource.Play(); audioSource.time = 0; WindowBluetooth.GetInstance().SendBluetoothMsg(musicIndex.ToString(), SENDMSGTYPE.MUSIC, MUSICINFO.MUSIC_SELECT); } }
//립모션으로 메뉴 이동시 private void TabletMotion(TabletMotionMsg msg) { BluetoothData data = JsonUtility.FromJson <BluetoothData>(msg.msg); SENDMSGTYPE tempMsgType = data.dataType; IContent.RequestContentExit <TabletHolostarContent>(); IContent.RequestContentExit <TabletWatchContent>(); IContent.RequestContentExit <TabletMusicContent>(); IContent.RequestContentExit <TabletRhythmContent>(); if (tempMsgType == SENDMSGTYPE.MENU) { try { Menu tempMenu = data.menu; if (tempMenu == Menu.Main) { Debug.Log("메인 메뉴"); settingModel.NowMenu = Menu.Main; } else if (tempMenu == Menu.Watch) { Debug.Log("시계"); settingModel.NowMenu = Menu.Watch; IContent.RequestContentEnter <TabletWatchContent>(); } else if (tempMenu == Menu.Music) { Debug.Log("음악"); settingModel.NowMenu = Menu.Music; IContent.RequestContentEnter <TabletMusicContent>(); } else if (tempMenu == Menu.Game) { Debug.Log("게임"); settingModel.NowMenu = Menu.Game; } else if (tempMenu == Menu.HoloStar) { Debug.Log("홀로스타"); settingModel.NowMenu = Menu.HoloStar; IContent.RequestContentEnter <TabletHolostarContent>(); } else if (tempMenu == Menu.Option) { Debug.Log("옵션"); settingModel.NowMenu = Menu.Option; } WindowBluetooth.GetInstance().SendBluetoothMsg("", SENDMSGTYPE.MENU, MUSICINFO.None, tempMenu); Message.Send <RunMenuMsg>(new RunMenuMsg(tempMenu)); } catch (Exception e) { Debug.Log(e.ToString()); } } else if (tempMsgType == SENDMSGTYPE.GAME) { settingModel.NowMenu = Menu.Game; GameType gameType = (GameType)Enum.Parse(typeof(GameType), data.msg); if (gameType == GameType.AlongGame) { Debug.Log("방치형"); IContent.RequestContentEnter <TabletAloneContent>(); } else if (gameType == GameType.RhythmGame) { Debug.Log("리듬"); IContent.RequestContentEnter <TabletRhythmContent>(); Message.Send <RunMenuMsg>(new RunMenuMsg(Menu.Game)); Message.Send <RhythmGameStartMsg>(new RhythmGameStartMsg()); } } }
protected override void OnEnter() { WindowBluetooth.GetInstance().OpenPort(settingModel.Port, settingModel.Baud, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One); AddMessage(); }
void ReceiveMsg(string msg) { if (msg == "DisConnect") { settingModel.IsBluetoothConnet = false; Message.Send <InfoMsg>(new InfoMsg("Bluetooth 연결이 끊어졌습니다.")); return; } BluetoothData data = JsonUtility.FromJson <BluetoothData>(msg); SENDMSGTYPE tempMsgType = data.dataType; WindowBluetooth.GetInstance().SendBluetoothMsg("", SENDMSGTYPE.RECEIVE); if (tempMsgType == SENDMSGTYPE.MENU) { try { Menu tempMenu = data.menu; IContent.RequestContentExit <TabletHolostarContent>(); IContent.RequestContentExit <TabletWatchContent>(); IContent.RequestContentExit <TabletMusicContent>(); IContent.RequestContentExit <TabletRhythmContent>(); if (tempMenu == Menu.Main) { Debug.Log("메인 메뉴"); settingModel.NowMenu = Menu.Main; } else if (tempMenu == Menu.Watch) { Debug.Log("시계"); settingModel.NowMenu = Menu.Watch; IContent.RequestContentEnter <TabletWatchContent>(); } else if (tempMenu == Menu.Music) { Debug.Log("음악"); settingModel.NowMenu = Menu.Music; IContent.RequestContentEnter <TabletMusicContent>(); } else if (tempMenu == Menu.Game) { Debug.Log("게임"); settingModel.NowMenu = Menu.Game; } else if (tempMenu == Menu.HoloStar) { Debug.Log("홀로스타"); settingModel.NowMenu = Menu.HoloStar; IContent.RequestContentEnter <TabletHolostarContent>(); } else if (tempMenu == Menu.Option) { Debug.Log("옵션"); settingModel.NowMenu = Menu.Option; } Message.Send <RunMenuMsg>(new RunMenuMsg(tempMenu)); if (holostarSettingModel.IsMusicPlay && tempMenu == Menu.Music) { } else { Message.Send <SetCharacterAnimationMsg>(new SetCharacterAnimationMsg(AnimationType.Idel1, false)); } } catch (Exception e) { Debug.Log(e.ToString()); } } else if (tempMsgType == SENDMSGTYPE.GAME) { IContent.RequestContentExit <TabletAloneContent>(); IContent.RequestContentExit <TabletRhythmContent>(); settingModel.NowMenu = Menu.Game; GameType gameType = (GameType)Enum.Parse(typeof(GameType), data.msg); if (gameType == GameType.AlongGame) { Debug.Log("방치형"); IContent.RequestContentEnter <TabletAloneContent>(); } else if (gameType == GameType.RhythmGame) { Debug.Log("리듬"); IContent.RequestContentEnter <TabletRhythmContent>(); } } else if (tempMsgType == SENDMSGTYPE.MSG) { if (holostarSettingModel.IsMMSReceive) { Message.Send <InfoMsg>(new InfoMsg(data.msg)); } if (holostarSettingModel.IsTTSReceive) { Message.Send <TTSSendMsg>(new TTSSendMsg(null, data.msg, playerInventoryModel.NowCharacter)); } } else if (tempMsgType == SENDMSGTYPE.MUSIC) { Message.Send <MusicRequestMsg>(new MusicRequestMsg(data.musicInfo, data.msg)); } else if (tempMsgType == SENDMSGTYPE.CHARINFO) { //블루트스 커넥터가 false인 상태에서 최초 정보 수신 연결 확인 알림 //모바일에 인벤토리 정보를 저장 PlayerInventory tempInven = JsonUtility.FromJson <PlayerInventory>(data.msg); playerInventoryModel.PlayerInventory = tempInven; //모델 정보로 케릭터 셋팅 Message.Send <SetCharacterDressMsg>(new SetCharacterDressMsg(playerInventoryModel.PlayerInventory.nowCharacter, playerInventoryModel.PlayerInventory.nowSkin)); string tempSetting = JsonUtility.ToJson(holostarSettingModel.HoloStarSetting); WindowBluetooth.GetInstance().SendBluetoothMsg(tempSetting, SENDMSGTYPE.SETTING); } else if (tempMsgType == SENDMSGTYPE.LOCATION) { string[] location = data.msg.Split('&'); Message.Send <LocationMsg>(new LocationMsg(location[0], location[1])); //위치 정보 저장 } else if (tempMsgType == SENDMSGTYPE.CALENDAR) { if (data.msg == "start") { calendarModel.AlarmEvents.Clear(); } else if (data.msg == "end") { } else { AlarmEvent alarmEvent = JsonUtility.FromJson <AlarmEvent>(data.msg); calendarModel.AlarmEvents.Add(alarmEvent); } //WindowBluetooth.GetInstance().SendBluetoothMsg("", SENDMSGTYPE.RECEIVE); // CalanderEvent alarmEvent = JsonUtility.FromJson<CalanderEvent>(data.msg); //calendarModel.AlarmEvents = alarmEvent.alarmEvents.ToList(); //calendarModel.AlarmEvents.Add //일정 저장 } else if (tempMsgType == SENDMSGTYPE.SETTING) { settingModel.NowMenu = Menu.Option; Message.Send <RunMenuMsg>(new RunMenuMsg(Menu.Option)); HoloStarSetting tempSetting = JsonUtility.FromJson <HoloStarSetting>(data.msg); holostarSettingModel.HoloStarSetting = tempSetting; } else if (tempMsgType == SENDMSGTYPE.ANIMATION) { //애니메이션 AnimationType aniType = (AnimationType)Enum.Parse(typeof(AnimationType), data.msg); Message.Send <SetCharacterAnimationMsg>(new SetCharacterAnimationMsg(aniType, true)); } else if (tempMsgType == SENDMSGTYPE.CONNECTION) { if (Convert.ToBoolean(data.msg)) { Debug.Log("접속 완료"); Message.Send <InfoMsg>(new InfoMsg("Bluetooth 연결되었습니다.")); settingModel.IsBluetoothConnet = true; //Debug.Log("메인"); BluetoothData bluetoothData = new BluetoothData(); bluetoothData.msg = ""; bluetoothData.dataType = SENDMSGTYPE.MENU; bluetoothData.musicInfo = MUSICINFO.None; bluetoothData.menu = Menu.Main; string dataMsg = JsonUtility.ToJson(bluetoothData); Message.Send <TabletMotionMsg>(new TabletMotionMsg(dataMsg)); Message.Send <RunMenuMsg>(new RunMenuMsg(Menu.Main)); WindowBluetooth.GetInstance().SendBluetoothMsg("", SENDMSGTYPE.CHARINFO); } else { Debug.Log("접속 종료"); Message.Send <InfoMsg>(new InfoMsg("Bluetooth 연결이 끊어졌습니다.")); settingModel.IsBluetoothConnet = false; } } else if (tempMsgType == SENDMSGTYPE.INTENT) { Message.Send <STTReceiveMsg>(new STTReceiveMsg(data.msg, "")); } }
private void RhythmGameStart(RhythmGameStartMsg msg) { Message.Send <InfoMsg>(new InfoMsg("잠시후에 게임이 시작됩니다.")); WindowBluetooth.GetInstance().SendBluetoothMsg("rhythm", SENDMSGTYPE.MENU, MUSICINFO.None, Menu.Game); StartCoroutine(StartGaemDelay()); }
private void OnDestroy() { WindowBluetooth.GetInstance().SendBluetoothMsg("false", SENDMSGTYPE.CONNECTION); }
private void MusicRequest(MusicRequestMsg msg) { if (msg.musicInfo == MUSICINFO.MUSIC_LIST) { //처음 //string temp = JsonUtility.ToJson(playlist); //WindowBluetooth.GetInstance().SendBluetoothMsg(temp, SENDMSGTYPE.MUSIC, MUSICINFO.MUSIC_LIST); WindowBluetooth.GetInstance().SendBluetoothMsg("start", SENDMSGTYPE.MUSIC, MUSICINFO.MUSIC_LIST); for (int i = 0; i < playlist.data.Count; i++) { string abc = JsonUtility.ToJson(playlist.data[i]); Debug.Log(abc); WindowBluetooth.GetInstance().SendBluetoothMsg(abc, SENDMSGTYPE.MUSIC, MUSICINFO.MUSIC_LIST); } WindowBluetooth.GetInstance().SendBluetoothMsg("end", SENDMSGTYPE.MUSIC, MUSICINFO.MUSIC_LIST); } else if (msg.musicInfo == MUSICINFO.MUSIC_PLAY) { if (isPause && audioSource.clip != null) { audioSource.UnPause(); } else { holostarSettingModel.MusicIndex = 0; StartCoroutine(GetAudio(0)); } int motionNum = UnityEngine.Random.Range((int)AnimationType.Motion1, (int)AnimationType.Motion7 + 1); SetAniMation(motionNum); holostarSettingModel.IsMusicPlay = true; Message.Send <SetMusicPlayButtonMsg>(new SetMusicPlayButtonMsg(holostarSettingModel.IsMusicPlay)); corMusicCheck = StartCoroutine(CheckMusic()); } else if (msg.musicInfo == MUSICINFO.MUSIC_SELECT) { StartCoroutine(GetAudio((int.Parse(msg.msg)))); holostarSettingModel.MusicIndex = int.Parse(msg.msg); holostarSettingModel.IsMusicPlay = true; Message.Send <SetMusicPlayButtonMsg>(new SetMusicPlayButtonMsg(holostarSettingModel.IsMusicPlay)); int motionNum = UnityEngine.Random.Range((int)AnimationType.Motion1, (int)AnimationType.Motion7 + 1); SetAniMation(motionNum); corMusicCheck = StartCoroutine(CheckMusic()); } else if (msg.musicInfo == MUSICINFO.MUSIC_PAUSE) { isPause = true; audioSource.Pause(); holostarSettingModel.IsMusicPlay = false; Message.Send <SetMusicPlayButtonMsg>(new SetMusicPlayButtonMsg(holostarSettingModel.IsMusicPlay)); int motionNum = UnityEngine.Random.Range((int)AnimationType.Idel1, (int)AnimationType.Idel2 + 1); SetAniMation(motionNum); if (corMusicCheck != null) { StopCoroutine(corMusicCheck); } } else if (msg.musicInfo == MUSICINFO.MUSIC_NEXT) { int tempIndex; audioSource.Stop(); if (isRandomPlay) { int listNum = 0; for (int i = 0; i < playlist.data.Count; i++) { if (playlist.data[i].index == musicIndex) { listNum = i; break; } } if (listNum + 1 > playlist.data.Count - 1) { listNum = 0; } else { listNum = listNum + 1; } musicIndex = playlist.data[listNum].index; } else { int musicNum; do { tempIndex = UnityEngine.Random.Range(0, playlist.data.Count); musicNum = playlist.data[tempIndex].index; } while (playlist.data[tempIndex].index == musicIndex); musicIndex = musicNum; } holostarSettingModel.MusicIndex = musicIndex; holostarSettingModel.IsMusicPlay = true; Message.Send <SetMusicPlayButtonMsg>(new SetMusicPlayButtonMsg(holostarSettingModel.IsMusicPlay)); int motionNum = UnityEngine.Random.Range((int)AnimationType.Motion1, (int)AnimationType.Motion7 + 1); SetAniMation(motionNum); StartCoroutine(GetAudio(musicIndex)); } else if (msg.musicInfo == MUSICINFO.MUSIC_PREV) { int tempIndex; audioSource.Stop(); if (isRandomPlay) { int listNum = 0; for (int i = 0; i < playlist.data.Count; i++) { if (playlist.data[i].index == musicIndex) { listNum = i; break; } } if (listNum - 1 < 0) { listNum = playlist.data.Count - 1; } else { listNum = listNum - 1; } musicIndex = playlist.data[listNum].index; } else { int musicNum; do { tempIndex = UnityEngine.Random.Range(0, playlist.data.Count); musicNum = playlist.data[tempIndex].index; } while (playlist.data[tempIndex].index == musicIndex); musicIndex = musicNum; } holostarSettingModel.MusicIndex = musicIndex; holostarSettingModel.IsMusicPlay = true; Message.Send <SetMusicPlayButtonMsg>(new SetMusicPlayButtonMsg(holostarSettingModel.IsMusicPlay)); int motionNum = UnityEngine.Random.Range((int)AnimationType.Motion1, (int)AnimationType.Motion7 + 1); SetAniMation(motionNum); StartCoroutine(GetAudio(musicIndex)); } else if (msg.musicInfo == MUSICINFO.MUSIC_VOLUME) { holostarSettingModel.MusicVolume = float.Parse(msg.msg); audioSource.volume = holostarSettingModel.MusicVolume; } else if (msg.musicInfo == MUSICINFO.MUSIC_MODE_REPEIT) { isRandomPlay = false; holostarSettingModel.IsRepeat = true; } else if (msg.musicInfo == MUSICINFO.MUSIC_MODE_SHUFFLE) { isRandomPlay = true; holostarSettingModel.IsRepeat = false; } holostarSettingModel.HoloStarSetting.musicSetting.musicNowTime = audioSource.time; string tempJsonMsg = JsonUtility.ToJson(holostarSettingModel.HoloStarSetting); WindowBluetooth.GetInstance().SendBluetoothMsg(tempJsonMsg, SENDMSGTYPE.SETTING); }