コード例 #1
0
ファイル: WSClient.cs プロジェクト: gguan/VAClient
    // Update is called once per frame
    void Update()
    {
        FSMSystem.Instance().CurrentState.Act(gameObject, gameObject);

        while (ExecuteOnMainThread.Count > 0)
        {
            ExecuteOnMainThread.Dequeue().Invoke();
        }
    }
コード例 #2
0
 public override void Act(GameObject gameObject, GameObject npc)
 {
     client = gameObject.GetComponent <WSClient>();
     base.Act(gameObject, npc);
     if (isStartMusic && !_audioSource.isPlaying)
     {
         if (!_musicAudioSource.isPlaying)
         {
             isStartMusic = false;
             Debug.Log("结束唱歌");
             FSMSystem.Instance().PerformTransition(PersonState.Idle, "idle");
         }
     }
 }
コード例 #3
0
ファイル: PersonDanceState.cs プロジェクト: gguan/VAClient
    public override void Act(GameObject gameObject, GameObject npc)
    {
        base.Act(gameObject, npc);
        if (isPlayDance && !_audioSource.isPlaying)
        {
            AnimatorStateInfo animatorStateInfo = _animator.GetCurrentAnimatorStateInfo(0);

            if ((animatorStateInfo.normalizedTime > 1.0f) && (animatorStateInfo.IsName(danceResId)) && !_danceAudioSource.isPlaying)
            {
                isPlayDance = false;
                Debug.Log("结束舞蹈");
                FSMSystem.Instance().PerformTransition(PersonState.Idle, "idle");
            }
        }
    }
コード例 #4
0
ファイル: WSClient.cs プロジェクト: gguan/VAClient
    void ProcessRequest(string data)
    {
        ExecuteOnMainThread.Enqueue(() =>
        {
            var reqType = JSON.Parse(data)["type"].Value;

            checkOptions(data);

            if ("server_state".Equals(reqType))
            {
                RequestData <ServerStateData> mSerStateData = JsonUtility.FromJson <RequestData <ServerStateData> >(data);
                if (ServerStateData.Order_Listening.Equals(mSerStateData.data.state))
                {
                    ControlAnim.Instance().ShowMicrophone();
                }
                else
                {
                    ControlAnim.Instance().DismissMicrophone();
                }
            }
            else if ("stt".Equals(reqType))
            {
                RequestData <STTData> mStt = JsonUtility.FromJson <RequestData <STTData> >(data);
                ControlAnim.Instance().ShowTips(mStt.data.text);
            }
            else if (FSMSystem.Instance().CurrentStateID == StateID.SleepStateId && reqType != "awake")
            {
                var response     = new ResponseData();
                response.message = "can not do " + reqType + " when unity sleep";
                response.type    = "sleep";
                ws.Send(JsonUtility.ToJson(response));
                return;
            }
            else               //状态改变
            {
                switch (reqType)
                {
                case "weather":
                    FSMSystem.Instance().PerformTransition(PersonState.ShowWeather, data);
                    break;

                case "horoscope":
                    FSMSystem.Instance().PerformTransition(PersonState.ShowConstellation, data);
                    break;

                case "awake":
                    FSMSystem.Instance().PerformTransition(PersonState.Awake, data);
                    break;

                case "chat":
                    FSMSystem.Instance().PerformTransition(PersonState.Chat, data);
                    break;

                case "music":
                    FSMSystem.Instance().PerformTransition(PersonState.Music, data);
                    break;

                case "stop":
                    FSMSystem.Instance().PerformTransition(PersonState.Stop, data);
                    break;

                case "sleep":
                    FSMSystem.Instance().PerformTransition(PersonState.Sleep, data);
                    break;

                case "dance":
                    FSMSystem.Instance().PerformTransition(PersonState.Dance, data);
                    break;

                default:
                    FSMSystem.Instance().PerformTransition(PersonState.Idle, data);
                    var response     = new ResponseData();
                    response.message = "can not parse state";
                    response.type    = "error";
                    ws.Send(JsonUtility.ToJson(response));
                    break;
                }
            }
        });
    }
コード例 #5
0
ファイル: WSClient.cs プロジェクト: gguan/VAClient
 private void MakeFSM()
 {
     fsm = FSMSystem.Instance();
 }
コード例 #6
0
 protected virtual void AfterVoiceEnd()
 {
     FSMSystem.Instance().PerformTransition(PersonState.Idle, "idle");
 }