|
@@ -9,9 +9,6 @@ using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
using UnityEngine.InputSystem;
|
|
using UnityEngine.Animations;
|
|
using UnityEngine.Animations;
|
|
|
|
|
|
-//using UnityEngine.Rendering.PostProcessing;
|
|
|
|
-using UnityEngine.SceneManagement;
|
|
|
|
-using ZXing.Common;
|
|
|
|
|
|
|
|
/* 本代码控制室内场景
|
|
/* 本代码控制室内场景
|
|
* 控制宠物在Home场景动画
|
|
* 控制宠物在Home场景动画
|
|
@@ -131,56 +128,64 @@ public class HomeController : MonoBehaviour
|
|
{
|
|
{
|
|
trainingContent = "voiceCall";
|
|
trainingContent = "voiceCall";
|
|
}
|
|
}
|
|
- else if (dog.dogProperty.voiceCall >= 40 && dog.dogProperty.voiceCallEnable && !GameData.isVoiceTrainingToday)
|
|
|
|
|
|
+ else if (dog.dogProperty.voiceCallEnable && !GameData.isVoiceTrainingToday)
|
|
{
|
|
{
|
|
- // 当狗的voiceCall大于等于40,进入第一阶段指令训练模式
|
|
|
|
- int random = UnityEngine.Random.Range(0, 100);
|
|
|
|
- if (random < 25 && !dog.dogProperty.commandSit)
|
|
|
|
|
|
+ if (dog.dogProperty.voiceCall >= 40 && dog.dogProperty.CommandTrainingPhase() < 4)
|
|
{
|
|
{
|
|
- trainingContent = "commandSit";
|
|
|
|
- }
|
|
|
|
- else if (random < 50 && !dog.dogProperty.commandStand)
|
|
|
|
- {
|
|
|
|
- trainingContent = "commandStand";
|
|
|
|
- }
|
|
|
|
- else if (random < 75 && !dog.dogProperty.commandBark)
|
|
|
|
- {
|
|
|
|
- trainingContent = "commandBark";
|
|
|
|
- }
|
|
|
|
- else if (random < 100 && !dog.dogProperty.commandLieDown)
|
|
|
|
- {
|
|
|
|
- trainingContent = "commandLieDown";
|
|
|
|
- }
|
|
|
|
- // else
|
|
|
|
- // {
|
|
|
|
- // trainingContent = String.Empty;
|
|
|
|
- // }
|
|
|
|
- }
|
|
|
|
- else if (dog.dogProperty.voiceCommand >= 40 && dog.dogProperty.voiceCommandEnable && !GameData.isVoiceTrainingToday)
|
|
|
|
- {
|
|
|
|
- // 当狗的voiceCommand大于等于40,进入第二阶段指令训练模式
|
|
|
|
- int random = UnityEngine.Random.Range(0, 100);
|
|
|
|
- if (random < 20 && !dog.dogProperty.commandRotate)
|
|
|
|
- {
|
|
|
|
- trainingContent = "commandRotate";
|
|
|
|
- }
|
|
|
|
- else if (random < 40 && !dog.dogProperty.commandHug)
|
|
|
|
- {
|
|
|
|
- trainingContent = "commandHug";
|
|
|
|
- }
|
|
|
|
- else if (random < 60 && !dog.dogProperty.commandDeath)
|
|
|
|
- {
|
|
|
|
- trainingContent = "commandDeath";
|
|
|
|
- }
|
|
|
|
- else if (random < 80 && !dog.dogProperty.commandTurnL)
|
|
|
|
- {
|
|
|
|
- trainingContent = "commandTurnL";
|
|
|
|
|
|
+ // 当狗的voiceCall大于等于40,进入第一阶段指令训练模式
|
|
|
|
+ int random = UnityEngine.Random.Range(0, 100);
|
|
|
|
+ if (GameTool.IntBetween(0, 25, random) && !dog.dogProperty.commandSit)
|
|
|
|
+ {
|
|
|
|
+ trainingContent = "commandSit";
|
|
|
|
+ }
|
|
|
|
+ else if (GameTool.IntBetween(25, 50, random) && !dog.dogProperty.commandStand)
|
|
|
|
+ {
|
|
|
|
+ trainingContent = "commandStand";
|
|
|
|
+ }
|
|
|
|
+ else if (GameTool.IntBetween(50, 75, random) && !dog.dogProperty.commandBark)
|
|
|
|
+ {
|
|
|
|
+ trainingContent = "commandBark";
|
|
|
|
+ }
|
|
|
|
+ else if (GameTool.IntBetween(75, 100, random) && !dog.dogProperty.commandLieDown)
|
|
|
|
+ {
|
|
|
|
+ trainingContent = "commandLieDown";
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ GameData.isVoiceTrainingToday = true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- else if (random < 100 && !dog.dogProperty.commandTurnR)
|
|
|
|
|
|
+ else if (dog.dogProperty.voiceCommand >= 40 && dog.dogProperty.CommandTrainingPhase() >= 4)
|
|
{
|
|
{
|
|
- trainingContent = "commandTurnR";
|
|
|
|
|
|
+ // 当狗的voiceCommand大于等于40并且完成第一阶段所有训练,进入第二阶段指令训练模式
|
|
|
|
+ int random = UnityEngine.Random.Range(0, 100);
|
|
|
|
+ if (GameTool.IntBetween(0, 20, random) && !dog.dogProperty.commandRotate)
|
|
|
|
+ {
|
|
|
|
+ trainingContent = "commandRotate";
|
|
|
|
+ }
|
|
|
|
+ else if (GameTool.IntBetween(20, 40, random) && !dog.dogProperty.commandHug)
|
|
|
|
+ {
|
|
|
|
+ trainingContent = "commandHug";
|
|
|
|
+ }
|
|
|
|
+ else if (GameTool.IntBetween(40, 60, random) && !dog.dogProperty.commandDeath)
|
|
|
|
+ {
|
|
|
|
+ trainingContent = "commandDeath";
|
|
|
|
+ }
|
|
|
|
+ else if (GameTool.IntBetween(60, 80, random) && !dog.dogProperty.commandTurnL)
|
|
|
|
+ {
|
|
|
|
+ trainingContent = "commandTurnL";
|
|
|
|
+ }
|
|
|
|
+ else if (GameTool.IntBetween(80, 100, random) && !dog.dogProperty.commandTurnR)
|
|
|
|
+ {
|
|
|
|
+ trainingContent = "commandTurnR";
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ GameData.isVoiceTrainingToday = true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
else
|
|
else
|
|
{
|
|
{
|
|
trainingContent = String.Empty;
|
|
trainingContent = String.Empty;
|
|
@@ -347,8 +352,6 @@ public class HomeController : MonoBehaviour
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -356,13 +359,7 @@ public class HomeController : MonoBehaviour
|
|
{
|
|
{
|
|
Debug.Log("Home scene is destoried.");
|
|
Debug.Log("Home scene is destoried.");
|
|
}
|
|
}
|
|
- //void AniOrWalk(DogInScene dog) // 狗在普通状态下,随机或播放动画,或移动
|
|
|
|
- //{
|
|
|
|
|
|
|
|
- //}
|
|
|
|
-
|
|
|
|
- // 初始化场景,加载所有的狗,并配置components,添加到dogsInScene List里面去
|
|
|
|
- //void InitialScene()
|
|
|
|
IEnumerator InitialScene()
|
|
IEnumerator InitialScene()
|
|
{
|
|
{
|
|
yield return null; // 跳过三帧,初始化最多三只狗
|
|
yield return null; // 跳过三帧,初始化最多三只狗
|
|
@@ -495,7 +492,7 @@ public class HomeController : MonoBehaviour
|
|
{
|
|
{
|
|
return Vector3.zero;
|
|
return Vector3.zero;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
Vector3 center = Vector3.zero;
|
|
Vector3 center = Vector3.zero;
|
|
foreach (var dog in dogsInScene)
|
|
foreach (var dog in dogsInScene)
|
|
{
|
|
{
|
|
@@ -614,15 +611,6 @@ public class HomeController : MonoBehaviour
|
|
}
|
|
}
|
|
else if (sceneMode == SceneMode.TRAINING)
|
|
else if (sceneMode == SceneMode.TRAINING)
|
|
{
|
|
{
|
|
- // todo 临时代码查上传数据
|
|
|
|
- Debug.Log("Voice training Post request");
|
|
|
|
- Debug.Log("filepath:" + filePath);
|
|
|
|
- Debug.Log("dog_id:" + UserProperty.dogs[GameData.focusDog].d_id);
|
|
|
|
- Debug.Log("user_id:" + UserProperty.userId);
|
|
|
|
- Debug.Log("trainingContent:" + trainingContent);
|
|
|
|
- Debug.Log("current times:" + this.currentTrainingTimes.ToString());
|
|
|
|
- Debug.Log("total times:" + totalTrainingTimes.ToString());
|
|
|
|
-
|
|
|
|
//Debug.Log("current times before ++:" + this.currentTrainingTimes.ToString());
|
|
//Debug.Log("current times before ++:" + this.currentTrainingTimes.ToString());
|
|
this.currentTrainingTimes++;
|
|
this.currentTrainingTimes++;
|
|
string url = "/api/voice/training/";
|
|
string url = "/api/voice/training/";
|
|
@@ -666,12 +654,20 @@ public class HomeController : MonoBehaviour
|
|
}
|
|
}
|
|
}
|
|
}
|
|
dogsInScene[GameData.focusDog].ResetAnimationStatus(); // 重置狗的动画状态
|
|
dogsInScene[GameData.focusDog].ResetAnimationStatus(); // 重置狗的动画状态
|
|
- if (highestScore >= 60)
|
|
|
|
|
|
+ if (highestScore >= 0.6f)
|
|
{
|
|
{
|
|
string animationTrigger = highestScoreCommand.Substring(7);
|
|
string animationTrigger = highestScoreCommand.Substring(7);
|
|
string animationBool = highestScoreCommand + "_status";
|
|
string animationBool = highestScoreCommand + "_status";
|
|
var animator = dogsInScene[GameData.focusDog].gameObject.GetComponent<Animator>();
|
|
var animator = dogsInScene[GameData.focusDog].gameObject.GetComponent<Animator>();
|
|
- animator.SetTrigger(animationTrigger);
|
|
|
|
|
|
+ if (highestScoreCommand == "commandBark")
|
|
|
|
+ {
|
|
|
|
+ DogBarkController.Instance.PlayDogBarkWithDelay(3); // 狗叫相应一下
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ HomeSoundEffectController.Instance.PlaySoundEffect(5);
|
|
|
|
+ }
|
|
|
|
+ animator.SetTrigger(animationTrigger);
|
|
animator.SetBool(animationBool, true);
|
|
animator.SetBool(animationBool, true);
|
|
|
|
|
|
// 交互动画执行一段时间后停止
|
|
// 交互动画执行一段时间后停止
|
|
@@ -696,7 +692,7 @@ public class HomeController : MonoBehaviour
|
|
if (data["message"].ToString().ToLower() == "pass")
|
|
if (data["message"].ToString().ToLower() == "pass")
|
|
{
|
|
{
|
|
|
|
|
|
- // TODO 刷新狗的数据
|
|
|
|
|
|
+ // 刷新狗的数据,包含dogsInScene
|
|
string dogJson = data["dogs"].ToString();
|
|
string dogJson = data["dogs"].ToString();
|
|
UserProperty.FreshDogInfo(dogJson);
|
|
UserProperty.FreshDogInfo(dogJson);
|
|
|
|
|
|
@@ -712,6 +708,10 @@ public class HomeController : MonoBehaviour
|
|
}
|
|
}
|
|
|
|
|
|
string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", trainingContent + "_10", EnviromentSetting.languageCode });
|
|
string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", trainingContent + "_10", EnviromentSetting.languageCode });
|
|
|
|
+ if (msg.Contains("<<dog_name>>"))
|
|
|
|
+ {
|
|
|
|
+ msg = msg.Replace("<<dog_name>>", interactDog.name);
|
|
|
|
+ }
|
|
GameTool.PauseGameTime();
|
|
GameTool.PauseGameTime();
|
|
|
|
|
|
MessageBoxController.ShowMessage(msg, ExitTrainingMode);
|
|
MessageBoxController.ShowMessage(msg, ExitTrainingMode);
|
|
@@ -729,6 +729,10 @@ public class HomeController : MonoBehaviour
|
|
HomeSoundEffectController.Instance.PlaySoundEffect(4);
|
|
HomeSoundEffectController.Instance.PlaySoundEffect(4);
|
|
|
|
|
|
string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", trainingContent + "_20", EnviromentSetting.languageCode });
|
|
string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", trainingContent + "_20", EnviromentSetting.languageCode });
|
|
|
|
+ if (msg.Contains("<<dog_name>>"))
|
|
|
|
+ {
|
|
|
|
+ msg = msg.Replace("<<dog_name>>", interactDog.name);
|
|
|
|
+ }
|
|
GameTool.PauseGameTime();
|
|
GameTool.PauseGameTime();
|
|
MessageBoxController.ShowMessage(msg, RestartTraining);
|
|
MessageBoxController.ShowMessage(msg, RestartTraining);
|
|
}
|
|
}
|
|
@@ -736,6 +740,19 @@ public class HomeController : MonoBehaviour
|
|
else
|
|
else
|
|
{
|
|
{
|
|
Debug.Log(data["message"]);
|
|
Debug.Log(data["message"]);
|
|
|
|
+
|
|
|
|
+ if (EnviromentSetting.runEnv == "Release")
|
|
|
|
+ {
|
|
|
|
+ HomeSoundEffectController.Instance.PlaySoundEffect(4);
|
|
|
|
+ string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", trainingContent + "_20", EnviromentSetting.languageCode });
|
|
|
|
+ if (msg.Contains("<<dog_name>>"))
|
|
|
|
+ {
|
|
|
|
+ msg = msg.Replace("<<dog_name>>", interactDog.name);
|
|
|
|
+ }
|
|
|
|
+ GameTool.PauseGameTime();
|
|
|
|
+ MessageBoxController.ShowMessage(msg, RestartTraining);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -770,14 +787,6 @@ public class HomeController : MonoBehaviour
|
|
{
|
|
{
|
|
FadeBGM(BGM.GetComponent<AudioSource>(), true);
|
|
FadeBGM(BGM.GetComponent<AudioSource>(), true);
|
|
}
|
|
}
|
|
- // 恢复因为交互,训练模式隐藏的狗
|
|
|
|
- // foreach (var dog in dogsInScene)
|
|
|
|
- // {
|
|
|
|
- // if (dog.gameObject.activeSelf == false)
|
|
|
|
- // {
|
|
|
|
- // dog.gameObject.SetActive(true);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void RestartTraining()
|
|
private void RestartTraining()
|
|
@@ -836,8 +845,7 @@ public class HomeController : MonoBehaviour
|
|
if (interactTime > 2.5) // 如果交互时间超过1秒,播放心形粒子效果
|
|
if (interactTime > 2.5) // 如果交互时间超过1秒,播放心形粒子效果
|
|
{
|
|
{
|
|
HeartParticlePlay();
|
|
HeartParticlePlay();
|
|
- var animation = interactDog.GetComponent<Animator>();
|
|
|
|
- animation.SetTrigger("Hug");
|
|
|
|
|
|
+ DogBarkController.Instance.PlayDogBarkWithDelay(1); // 狗叫相应一下
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -909,8 +917,8 @@ public class HomeController : MonoBehaviour
|
|
|
|
|
|
public enum ItemGroup
|
|
public enum ItemGroup
|
|
{
|
|
{
|
|
- food,
|
|
|
|
- water
|
|
|
|
|
|
+ FOOD,
|
|
|
|
+ WATER
|
|
}
|
|
}
|
|
|
|
|
|
public enum SceneMode
|
|
public enum SceneMode
|