示例#1
0
        //>> 2018-06-07 최진호 블루투스 통신

        /********************************************
         * 2018-06-07 최진호
         * msg : 블루투스로 전송할 메세지
         * 블루투스를 통해 연결된 단말기로 msg 전송
         *******************************************/

        public void BluetoothSendMsg(string msg, SENDMSGTYPE type, MUSICINFO musicInfo = MUSICINFO.None, Menu menu = Menu.None)
        {
            BluetoothData tempData = new BluetoothData();

            tempData.dataType  = type;
            tempData.msg       = msg;
            tempData.musicInfo = musicInfo;
            tempData.menu      = menu;

            string sendMsg = JsonUtility.ToJson(tempData);

            //_instance.AJO.Call("SendMsg", sendMsg);

            ListMsg.Add(sendMsg);
        }
示例#2
0
    //Data송신
    public void SendBluetoothMsg(string msg, SENDMSGTYPE type, MUSICINFO musicInfo = MUSICINFO.None, Menu menu = Menu.None)
    {
        BluetoothData data = new BluetoothData
        {
            msg       = msg,
            dataType  = type,
            musicInfo = musicInfo,
            menu      = menu
        };

        string dataMsg = JsonUtility.ToJson(data);

        try
        {
            serialPort.Write(dataMsg);
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
        }
    }
示例#3
0
        //립모션으로 메뉴 이동시
        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());
                }
            }
        }
示例#4
0
        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, ""));
            }
        }
示例#5
0
        //>> 2018-06-07 최진호 블루투스 통신

        /********************************************
         * 2018-06-07 최진호
         * msg : 블루투스로 전송할 메세지
         * 블루투스를 통해 연결된 단말기로 msg 전송
         *******************************************/

        public void BluetoothSendMsg(string msg, SENDMSGTYPE type)
        {
            msg = (int)type + "|" + msg;
            _instance.AJO.Call("SendMsg", msg);
        }
示例#6
0
        void ReceiveMsg(string msg)
        {
            BluetoothData data        = JsonUtility.FromJson <BluetoothData>(msg);
            SENDMSGTYPE   tempMsgType = data.dataType;

            if (tempMsgType == SENDMSGTYPE.MENU)
            {
                try
                {
                    IContent.RequestContentExit <WatchContent>();
                    IContent.RequestContentExit <AloneGameContent>();
                    IContent.RequestContentExit <RhythmGameContent>();
                    IContent.RequestContentExit <HolostarContent>();
                    IContent.RequestContentExit <SettingContnet>();
                    IContent.RequestContentExit <StoreContent>();
                    IContent.RequestContentExit <MusicContent>();

                    Menu tempMenu = data.menu;

                    if (tempMenu == Menu.Watch)
                    {
                        IContent.RequestContentEnter <WatchContent>();
                        Message.Send <RunMenuMsg>(new RunMenuMsg(tempMenu));
                    }
                    else if (tempMenu == Menu.Music)
                    {
                        IContent.RequestContentEnter <MusicContent>();
                        Message.Send <RunMenuMsg>(new RunMenuMsg(tempMenu));
                    }
                    else if (tempMenu == Menu.Game)
                    {
                        if (data.msg == "rhythm")
                        {
                            IContent.RequestContentEnter <RhythmGameContent>();
                            Message.Send <RhythmGameBluetoothSelectMsg>(new RhythmGameBluetoothSelectMsg(true));
                            Message.Send <RunMenuMsg>(new RunMenuMsg(tempMenu));
                        }
                        else
                        {
                            UI.IDialog.RequestDialogEnter <UI.GameSelectDialog>();
                            Message.Send <RunMenuMsg>(new RunMenuMsg(tempMenu));
                        }
                    }
                    else if (tempMenu == Menu.Store)
                    {
                        IContent.RequestContentEnter <StoreContent>();
                        Message.Send <RunMenuMsg>(new RunMenuMsg(tempMenu));
                    }
                    else if (tempMenu == Menu.HoloStar)
                    {
                        IContent.RequestContentEnter <HolostarContent>();
                        Message.Send <RunMenuMsg>(new RunMenuMsg(tempMenu));
                    }
                    else if (tempMenu == Menu.Option)
                    {
                        IContent.RequestContentEnter <SettingContnet>();
                    }
                    else if (tempMenu == Menu.Main)
                    {
                        IContent.RequestContentEnter <MenuContent>();
                    }
                }
                catch (Exception e)
                {
                    Debug.Log(e.ToString());
                }
            }
            else if (tempMsgType == SENDMSGTYPE.MSG)
            {
            }
            else if (tempMsgType == SENDMSGTYPE.MUSIC)
            {
                if (data.musicInfo == MUSICINFO.MUSIC_PLAY)
                {
                    holostarSettingModel.MusicSetting.isMusicPlay = true;
                }
                else if (data.musicInfo == MUSICINFO.MUSIC_PAUSE)
                {
                    holostarSettingModel.MusicSetting.isMusicPlay = false;
                }

                Message.Send <BluetoothMusicCommandMsg>(new BluetoothMusicCommandMsg(data.musicInfo, data.msg));
            }
            else if (tempMsgType == SENDMSGTYPE.CHARINFO)
            {
                AndroidTrasferMgr.Instance.BluetoothSendMsg(JsonUtility.ToJson(playerInventoryModel.PlayerInventory), SENDMSGTYPE.CHARINFO);
            }
            else if (tempMsgType == SENDMSGTYPE.LOCATION)
            {
            }
            else if (tempMsgType == SENDMSGTYPE.CALENDAR)
            {
            }
            else if (tempMsgType == SENDMSGTYPE.SETTING)
            {
                HoloStarSetting holoStarSetting;
                holoStarSetting = JsonUtility.FromJson <HoloStarSetting>(data.msg);
                holostarSettingModel.HoloStarSetting = holoStarSetting;
                Message.Send <MusicPlaySettingMsg>(new MusicPlaySettingMsg(holostarSettingModel.HoloStarSetting.musicSetting));
            }
            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))
                {
                    Message.Send <MusicSettingResetMsg>(new MusicSettingResetMsg());
                    settingModel.IsBluetoothConnet = false;
                    holostarSettingModel.MusicSetting.isMusicPlay = false;
                    Message.Send <SetCharacterAnimationMsg>(new SetCharacterAnimationMsg(AnimationType.Idel1, false));
                    AndroidTrasferMgr.Instance.ShowToast("홀로스타 본체와 연결이 끊어졌습니다.");
                }
            }
            else if (tempMsgType == SENDMSGTYPE.RECEIVE)
            {
                if (AndroidTrasferMgr.Instance.corTimer != null)
                {
                    StopCoroutine(AndroidTrasferMgr.Instance.corTimer);
                    AndroidTrasferMgr.Instance.corTimer = null;
                }

                AndroidTrasferMgr.Instance.IsSendPossible = true;

                if (AndroidTrasferMgr.Instance.ListMsg.Count > 0)
                {
                    Debug.Log("지워지는 데인터 :" + AndroidTrasferMgr.Instance.ListMsg[0]);
                    AndroidTrasferMgr.Instance.ListMsg.RemoveAt(0);
                }
            }
        }