|
@@ -22,6 +22,7 @@ public class ERNIEBotManager : MonoBehaviour
|
|
|
private bool isCollect;
|
|
|
private float times;
|
|
|
private float times2;
|
|
|
+ private float times3;
|
|
|
private float backtTimes;
|
|
|
private string oldMyt;
|
|
|
private string oldback;
|
|
@@ -43,7 +44,7 @@ public class ERNIEBotManager : MonoBehaviour
|
|
|
private void OnEnable()
|
|
|
{
|
|
|
|
|
|
- StartCoroutine(PlayAnimator("Waving", 1f));
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|
|
@@ -64,7 +65,7 @@ public class ERNIEBotManager : MonoBehaviour
|
|
|
oldMyt = null;
|
|
|
oldback = null;
|
|
|
backtTimes = 0;
|
|
|
- interval = 1f;
|
|
|
+ interval = 0.2f;
|
|
|
irobotPos = new Vector3(0, -1, 6);
|
|
|
HttpTool.Instance.Get("https://fat1.qulivr.com/mr-navigator/v1/", "", (string getInterval) => {
|
|
|
Debug.Log(getInterval);
|
|
@@ -90,18 +91,9 @@ public class ERNIEBotManager : MonoBehaviour
|
|
|
YiYanBack _setAndrodCallback = new YiYanBack();
|
|
|
#if UNITY_ANDROID
|
|
|
UnityToJava.initSpeek(_setAndrodCallback);
|
|
|
-#endif
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- StartCoroutine(OpenSpeek(3f));
|
|
|
+ isInit = true;
|
|
|
+#endif
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -128,10 +120,11 @@ public class ERNIEBotManager : MonoBehaviour
|
|
|
{
|
|
|
|
|
|
YiYanBack.BackTextlist.Dequeue();
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -145,55 +138,124 @@ public class ERNIEBotManager : MonoBehaviour
|
|
|
{
|
|
|
myt.text = YiYanBack.MyTextlist.Dequeue();
|
|
|
oldMyt = myt.text;
|
|
|
- }
|
|
|
-
|
|
|
- if (oldback != null && oldback == backt.text)
|
|
|
- {
|
|
|
- times2 += Time.deltaTime;
|
|
|
- if (times2 > 3f)
|
|
|
+
|
|
|
+ if (myt.text.Contains("唤醒成功") && myt.text.Contains("小度小度"))
|
|
|
{
|
|
|
- oldback = null;
|
|
|
- times2 = 0;
|
|
|
- StartSpeek();
|
|
|
-
|
|
|
+ myt.text = "";
|
|
|
+
|
|
|
+ if (!Irobot.gameObject.activeSelf)
|
|
|
+ {
|
|
|
+ transform.position = player.position + player.forward * irobotPos.z;
|
|
|
+ transform.position = new Vector3(transform.position.x, irobotPos.y, transform.position.z);
|
|
|
+ transform.LookAt(player);
|
|
|
+ transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
|
|
|
+ Irobot.gameObject.SetActive(true);
|
|
|
+ isWakeup = true;
|
|
|
+ }
|
|
|
+ StartCoroutine(AudioIconSetting(0, true));
|
|
|
+ YiYanBack.BackText.Clear();
|
|
|
+ YiYanBack.BackText = new Queue<char>();
|
|
|
+ backt.text = "";
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
+ else
|
|
|
+ isWakeup = false;
|
|
|
+
|
|
|
times2 = 0;
|
|
|
+ times3 = 0;
|
|
|
+ backt.text = "";
|
|
|
+ HttpsSendLog.Instance.SendLog("MYT", oldMyt+" "+ myt.text);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- if (oldMyt!=null && myt.text == oldMyt)
|
|
|
+ if(oldback!=null &&oldback == backt.text)
|
|
|
{
|
|
|
-
|
|
|
- if(!isWakeup&&myt.text.Contains("小度小度"))
|
|
|
+ times2 += Time.deltaTime;
|
|
|
+ if (times2>5f)
|
|
|
{
|
|
|
- isWakeup = true;
|
|
|
- transform.position = player.position + player.forward * irobotPos.z;
|
|
|
- transform.position = new Vector3(transform.position.x, irobotPos.y, transform.position.z);
|
|
|
- transform.LookAt(player);
|
|
|
- transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
|
|
|
- Irobot.gameObject.SetActive(true);
|
|
|
- myt.text = "";
|
|
|
- backfinalt.text = "";
|
|
|
- backt.text = "";
|
|
|
-
|
|
|
- StartSpeek();
|
|
|
+ times2 = 0;
|
|
|
+ isWakeup = false;
|
|
|
+ Irobot.gameObject.SetActive(false);
|
|
|
+
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
+ if (oldMyt != null && myt.text == oldMyt)
|
|
|
+ {
|
|
|
+ HttpsSendLog.Instance.SendLog("MYT", " 计时开始 " + times);
|
|
|
times += Time.deltaTime;
|
|
|
- if(times>1f)
|
|
|
- StartCoroutine(AudioIconSetting(0, false));
|
|
|
if (times > 3f)
|
|
|
{
|
|
|
+ send(myt.text);
|
|
|
+
|
|
|
oldMyt = null;
|
|
|
times = 0;
|
|
|
- send(myt.text);
|
|
|
}
|
|
|
- }else
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isWakeup)
|
|
|
{
|
|
|
- times = 0;
|
|
|
+ times3 += Time.deltaTime;
|
|
|
+ if (times3 > 10f)
|
|
|
+ {
|
|
|
+ times3 = 0;
|
|
|
+ isWakeup = false;
|
|
|
+ Irobot.gameObject.SetActive(false);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ #region old
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ */
|
|
|
+ #endregion
|
|
|
}
|
|
|
|
|
|
private void OnApplicationPause(bool pause)
|
|
@@ -238,35 +300,40 @@ public class ERNIEBotManager : MonoBehaviour
|
|
|
public void StartSpeek()
|
|
|
{
|
|
|
|
|
|
- UnityToJava.yiYanClass.CallStatic("StartSpeek");
|
|
|
- Debug.Log("StartSpeek====");
|
|
|
- StartCoroutine(AudioIconSetting(0.7f, true));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public void send(string str)
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
StartCoroutine(AudioIconSetting(0, false));
|
|
|
- if (isWakeup)
|
|
|
- {
|
|
|
- if (myt.text.Contains("小度拜拜"))
|
|
|
- {
|
|
|
- isWakeup = false;
|
|
|
- Irobot.gameObject.SetActive(false);
|
|
|
- StartSpeek();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- UnityToJava.yiYanClass.CallStatic("SendText", str);
|
|
|
- Debug.Log("Send " + str);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- StartSpeek();
|
|
|
- }
|
|
|
+ HttpsSendLog.Instance.SendLog("SendText", myt.text);
|
|
|
+ UnityToJava.yiYanClass.CallStatic("SendText", str);
|
|
|
backt.text = "";
|
|
|
- myt.text = "";
|
|
|
+ oldMyt = null;
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -298,3 +365,52 @@ public class ERNIEBotManager : MonoBehaviour
|
|
|
|
|
|
|
|
|
}
|
|
|
+public class YiYanBack : AndroidJavaProxy
|
|
|
+{
|
|
|
+ public static Queue<string> BackTextlist = new Queue<string>();
|
|
|
+ public static Queue<string> BackFINALTextlist = new Queue<string>();
|
|
|
+ public static Queue<string> MyTextlist = new Queue<string>();
|
|
|
+
|
|
|
+ public static Queue<char> BackText = new Queue<char>();
|
|
|
+ public YiYanBack() : base("com.xiaodu.dueros.magictool.demo.YiYanBack")
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ public void onBackText(string msg)
|
|
|
+ {
|
|
|
+
|
|
|
+ Debug.Log("onBackText====>" + msg);
|
|
|
+ BackTextlist.Enqueue(msg);
|
|
|
+
|
|
|
+ HttpsSendLog.Instance.SendLog("F", msg);
|
|
|
+
|
|
|
+ for (int i = 0; i < msg.Length; i++)
|
|
|
+ {
|
|
|
+ BackText.Enqueue(msg[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void onMyFINALText(string msg)
|
|
|
+ {
|
|
|
+
|
|
|
+ Debug.Log("onBackFINALText====>" + msg);
|
|
|
+ BackFINALTextlist.Enqueue(msg);
|
|
|
+ }
|
|
|
+ public void onMyText(string msg)
|
|
|
+ {
|
|
|
+
|
|
|
+ Debug.Log("onMyText====>" + msg);
|
|
|
+ MyTextlist.Enqueue(msg);
|
|
|
+ }
|
|
|
+ public void onWakeupSucceed(string msg)
|
|
|
+ {
|
|
|
+
|
|
|
+ Debug.Log("onMyText====>" + msg);
|
|
|
+ MyTextlist.Enqueue(msg);
|
|
|
+ }
|
|
|
+ public void onWakeupFailed(string msg)
|
|
|
+ {
|
|
|
+
|
|
|
+ Debug.Log("onMyText====>" + msg);
|
|
|
+ MyTextlist.Enqueue(msg);
|
|
|
+ }
|
|
|
+}
|