|
@@ -31,13 +31,14 @@ public class HomeController : MonoBehaviour
|
|
|
private bool isSleepChecked = false; // 用于检测第一次睡眠检测是否执行完成
|
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
|
private GameObject centerOfDogs;
|
|
|
+ private SceneMode sceneMode = SceneMode.NORMAL; // 当前场景处在的模式
|
|
|
|
|
|
- private bool isInteractMode = false; // 场景是否在交互状态
|
|
|
+ //private bool isInteractMode = false; // 场景是否在交互状态
|
|
|
private Vector2 previousPointerPosition = Vector2.zero; // 前一帧鼠标位置
|
|
|
private GameObject interactDog; // 交互的狗
|
|
|
float interactTime = 0f; // 交互时间
|
|
|
|
|
|
- private bool isTrainingMode = false; // 是否在训练状态
|
|
|
+ //private bool isTrainingMode = false; // 是否在训练状态
|
|
|
private string trainingContent = ""; // 训练内容
|
|
|
private int totalTrainingTimes = 2; // 训练总次数
|
|
|
private int currentTrainingTimes = 0; // 当前训练次数
|
|
@@ -123,7 +124,8 @@ public class HomeController : MonoBehaviour
|
|
|
{
|
|
|
if (dog.dogProperty.voiceCall == 0)
|
|
|
{
|
|
|
- isTrainingMode = true;
|
|
|
+ //isTrainingMode = true;
|
|
|
+ sceneMode = SceneMode.TRAINING;
|
|
|
|
|
|
trainingContent = "voiceCall";
|
|
|
trainingDogId = dog.dogProperty.d_id;
|
|
@@ -138,7 +140,7 @@ public class HomeController : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (isTrainingMode)
|
|
|
+ if (sceneMode == SceneMode.TRAINING)
|
|
|
{
|
|
|
foreach (var dog in dogsInScene)
|
|
|
{
|
|
@@ -170,9 +172,7 @@ public class HomeController : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
-
|
|
|
- if (isInteractMode)
|
|
|
+ else if (sceneMode == SceneMode.INACTIVE)
|
|
|
{
|
|
|
foreach (var dog in dogsInScene)
|
|
|
{
|
|
@@ -188,7 +188,8 @@ public class HomeController : MonoBehaviour
|
|
|
else if (dog.InteractTimeout()) // 如果交互时间结束,结束交互状态
|
|
|
{
|
|
|
dog.ExitInteract();
|
|
|
- isInteractMode = false; // 交互结束,退出交互状态
|
|
|
+ sceneMode = SceneMode.NORMAL; // 交互结束,退出交互状态
|
|
|
+ //isInteractMode = false; // 交互结束,退出交互状态
|
|
|
VoiceButtonOnlySwitch(false); // 交互结束,打开其他菜单
|
|
|
}
|
|
|
else
|
|
@@ -414,8 +415,9 @@ public class HomeController : MonoBehaviour
|
|
|
form.AddField("user_id", UserProperty.userId);
|
|
|
|
|
|
// TODO 待后台开发完成后,开启网络通讯功能,目前暂用临时直接赋值
|
|
|
- // StartCoroutine(WebController.PostRequest(url, form, filePath, callback: VoiceCallCallback));
|
|
|
- isInteractMode = true; // 场景进入交互模式
|
|
|
+ StartCoroutine(WebController.PostRequest(url, form, filePath, callback: VoiceCallCallback));
|
|
|
+ sceneMode = SceneMode.INACTIVE; // 场景进入交互模式
|
|
|
+ //isInteractMode = true; // 场景进入交互模式
|
|
|
dogsInScene[0].SetupInteract();
|
|
|
interactDog = dogsInScene[0].gameObject;
|
|
|
VoiceButtonOnlySwitch(true); // 交互模式下关闭其他菜单
|
|
@@ -480,7 +482,7 @@ public class HomeController : MonoBehaviour
|
|
|
// 用户语音呼唤上传,Voice call指令用于呼唤所有的狗,得分最高的过来进入交互模式
|
|
|
public void VoiceCommandRequest(string filePath)
|
|
|
{
|
|
|
- if (isInteractMode)
|
|
|
+ if (sceneMode == SceneMode.INACTIVE)
|
|
|
{
|
|
|
Debug.Log("Voice Command Post request");
|
|
|
|
|
@@ -491,7 +493,7 @@ public class HomeController : MonoBehaviour
|
|
|
|
|
|
StartCoroutine(WebController.PostRequest(url, form, filePath, callback: VoiceCommandCallback));
|
|
|
}
|
|
|
- else if (isTrainingMode)
|
|
|
+ else if (sceneMode == SceneMode.TRAINING)
|
|
|
{
|
|
|
Debug.Log("Voice training Post request");
|
|
|
|
|
@@ -512,7 +514,7 @@ public class HomeController : MonoBehaviour
|
|
|
// 语音呼唤上传回调函数
|
|
|
void VoiceCommandCallback(string json)
|
|
|
{
|
|
|
- if (isInteractMode)
|
|
|
+ if (sceneMode == SceneMode.INACTIVE)
|
|
|
{
|
|
|
Debug.Log("Voice command callback");
|
|
|
var data = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
|
|
@@ -564,7 +566,7 @@ public class HomeController : MonoBehaviour
|
|
|
Debug.Log(data["message"]);
|
|
|
}
|
|
|
}
|
|
|
- else if (isTrainingMode)
|
|
|
+ else if (sceneMode == SceneMode.TRAINING)
|
|
|
{
|
|
|
Debug.Log("Voice training Callback");
|
|
|
var data = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
|
|
@@ -580,7 +582,8 @@ public class HomeController : MonoBehaviour
|
|
|
MessageBoxController.ShowMessage(msg);
|
|
|
|
|
|
ResetTrainingModeParameters();
|
|
|
- isTrainingMode = false;
|
|
|
+ sceneMode = SceneMode.NORMAL;
|
|
|
+ //isTrainingMode = false;
|
|
|
foreach (var dog in dogsInScene)
|
|
|
{
|
|
|
if (dog.dogProperty.d_id == trainingDogId)
|
|
@@ -689,4 +692,11 @@ public enum ItemGroup
|
|
|
{
|
|
|
food,
|
|
|
water
|
|
|
+}
|
|
|
+
|
|
|
+enum SceneMode
|
|
|
+{
|
|
|
+ TRAINING,
|
|
|
+ INACTIVE,
|
|
|
+ NORMAL,
|
|
|
}
|