Beispiel #1
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, ""));
            }
        }
Beispiel #2
0
        public void ReceiveCalendar(string json)
        {
            try
            {
                _num          = 0;
                alarmCursor   = 0;
                alarmList     = new List <AlarmEvent>();
                calanderEvent = new CalanderEvent();
                CalendarList calendarList = JsonUtility.FromJson <CalendarList>(json);
                Debug.Log(json);
                for (int i = 0; i < calendarList.data.Count; i++)
                {
                    Debug.LogError(calendarList.data.Count);
                    long time = new System.DateTime(int.Parse(calendarList.data[i].year),
                                                    int.Parse(calendarList.data[i].month),
                                                    int.Parse(calendarList.data[i].day),
                                                    int.Parse(calendarList.data[i].hour),
                                                    int.Parse(calendarList.data[i].minute),
                                                    int.Parse(calendarList.data[i].second), DateTime.Now.Kind).Ticks;


                    AlarmEvent alarmEvent = new AlarmEvent();
                    alarmEvent.title = calendarList.data[i].title;
                    alarmEvent.tick  = time;


                    alarmList.Add(alarmEvent);
                }

                IComparer <AlarmEvent> sort = new Sorting();
                alarmList.Sort(sort);

                calanderEvent.alarmEvents = alarmList.ToArray();
                string temp = JsonUtility.ToJson(calanderEvent);
                //Android.AndroidTrasferMgr.Instance.ShowToast("처음 : " + temp);

                calendarModel.AlarmEvents.Clear();
                for (int i = 0; i < alarmList.Count; i++)
                {
                    calendarModel.AlarmEvents.Add(alarmList[i]);
                }


                if (alarmList.Count > 0)
                {
                    //기존
                    //Android.AndroidTrasferMgr.Instance.BluetoothSendMsg(temp, Constants.SENDMSGTYPE.CALENDAR);

                    //테스트
                    Android.AndroidTrasferMgr.Instance.BluetoothSendMsg("start", Constants.SENDMSGTYPE.CALENDAR);

                    for (int i = 0; i < alarmList.Count; i++)
                    {
                        string evt = JsonUtility.ToJson(alarmList[i]);
                        Debug.Log("이벤트 : " + evt);
                        Android.AndroidTrasferMgr.Instance.BluetoothSendMsg(evt, Constants.SENDMSGTYPE.CALENDAR);
                    }

                    Android.AndroidTrasferMgr.Instance.BluetoothSendMsg("end", Constants.SENDMSGTYPE.CALENDAR);
                }

                Message.Send <CreateJosnFileMsg>(new CreateJosnFileMsg("calander", temp));
            }

            catch
            {
                Debug.LogError("Json Catch");
            }
        }