|
@@ -40,7 +40,7 @@ public class HomeController : MonoBehaviour
|
|
|
float interactTime = 0f; // 交互时间
|
|
|
|
|
|
//private bool isTrainingMode = false; // 是否在训练状态
|
|
|
- private string trainingContent = ""; // 训练内容
|
|
|
+ private string trainingContent = String.Empty; // 训练内容 _xx 对于language.json 0x开始提示 1x成功提示 2x失败提示
|
|
|
private int totalTrainingTimes = 2; // 训练总次数
|
|
|
private int currentTrainingTimes = 0; // 当前训练次数
|
|
|
private string trainingDogId = ""; // 训练的狗id
|
|
@@ -125,7 +125,7 @@ public class HomeController : MonoBehaviour
|
|
|
{
|
|
|
foreach (var dog in dogsInScene)
|
|
|
{
|
|
|
- if (dog.dogProperty.voiceCall == 0)
|
|
|
+ if (!dog.dogProperty.voiceCallEnable)
|
|
|
{
|
|
|
//isTrainingMode = true;
|
|
|
sceneMode = SceneMode.TRAINING;
|
|
@@ -140,11 +140,49 @@ public class HomeController : MonoBehaviour
|
|
|
interactDog = dogsInScene[GameData.focusDog].gameObject;
|
|
|
VoiceButtonOnlySwitch(true); // 交互模式下关闭其他菜单
|
|
|
}
|
|
|
+ else if (dog.dogProperty.voiceCall > 40 && !dog.dogProperty.voiceCommandEnable && dog.dogProperty.voiceCallEnable)
|
|
|
+ {
|
|
|
+ // 当狗的voiceCall大于40,且没有voiceCommand能力时,进入第一阶段指令训练模式
|
|
|
+ int random = UnityEngine.Random.Range(0, 100);
|
|
|
+ if (random < 25 && !dog.dogProperty.commandSit)
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (trainingContent != String.Empty)
|
|
|
+ {
|
|
|
+ sceneMode = SceneMode.TRAINING;
|
|
|
+ dog.RemoveZzzParticle();
|
|
|
+ trainingDogId = dog.dogProperty.d_id;
|
|
|
+ totalTrainingTimes = 2;
|
|
|
+ currentTrainingTimes = 0;
|
|
|
+ GameData.focusDog = dogsInScene.IndexOf(dog);
|
|
|
+ //GameData.focusDog = UserProperty.GetDogIndexById(dog.dogProperty.d_id);
|
|
|
+ dogsInScene[GameData.focusDog].SetupInteract();
|
|
|
+ interactDog = dogsInScene[GameData.focusDog].gameObject;
|
|
|
+ VoiceButtonOnlySwitch(true); // 交互模式下关闭其他菜单
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if (this.sceneMode == SceneMode.TRAINING)
|
|
|
+ else if (this.sceneMode == SceneMode.TRAINING)
|
|
|
{
|
|
|
foreach (var dog in dogsInScene)
|
|
|
{
|
|
@@ -159,28 +197,31 @@ public class HomeController : MonoBehaviour
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //dog.dogState = "training";
|
|
|
dog.dogState = DogState.TRAINING;
|
|
|
if (!isTrainingMsgShowed_1 && !isTrainingMsgShowed_2 && currentTrainingTimes == 0)
|
|
|
{
|
|
|
- string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", "record_dog_name", EnviromentSetting.languageCode });
|
|
|
+ string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", trainingContent + "_00", EnviromentSetting.languageCode });
|
|
|
MessageBoxController.ShowMessage(msg);
|
|
|
var BGM = GameObject.Find("BGM");
|
|
|
if (BGM != null)
|
|
|
{
|
|
|
- //BGM.GetComponent<AudioSource>().Stop();
|
|
|
FadeBGM(BGM.GetComponent<AudioSource>(), false);
|
|
|
}
|
|
|
isTrainingMsgShowed_1 = true;
|
|
|
}
|
|
|
else if (!isTrainingMsgShowed_2 && isTrainingMsgShowed_1 && currentTrainingTimes == 1)
|
|
|
{
|
|
|
- string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", "record_again", EnviromentSetting.languageCode });
|
|
|
+ string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", trainingContent + "_01", EnviromentSetting.languageCode });
|
|
|
MessageBoxController.ShowMessage(msg);
|
|
|
isTrainingMsgShowed_2 = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // 暂时将其他非训练状态的狗game object隐藏
|
|
|
+ dog.gameObject.SetActive(false);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else if (sceneMode == SceneMode.INACTIVE)
|
|
@@ -200,7 +241,7 @@ public class HomeController : MonoBehaviour
|
|
|
{
|
|
|
dog.ExitInteract();
|
|
|
sceneMode = SceneMode.NORMAL; // 交互结束,退出交互状态
|
|
|
- //isInteractMode = false; // 交互结束,退出交互状态
|
|
|
+ //isInteractMode = false; // 交互结束,退出交互状态
|
|
|
VoiceButtonOnlySwitch(false); // 交互结束,打开其他菜单
|
|
|
}
|
|
|
else
|
|
@@ -217,7 +258,11 @@ public class HomeController : MonoBehaviour
|
|
|
foreach (var dog in dogsInScene)
|
|
|
{
|
|
|
// 如果在eat drink进程结束前不执行随机场景代码
|
|
|
- //if (dog.itemConsumeProgress) // TODO 以后用DogInScene.dogState来判断
|
|
|
+ // 检测有隐藏的狗,显示出来
|
|
|
+ if (dog.gameObject.activeSelf == false)
|
|
|
+ {
|
|
|
+ dog.gameObject.SetActive(true);
|
|
|
+ }
|
|
|
if (dog.dogState == DogState.ITEM_CONSUME)
|
|
|
{
|
|
|
if (dog.isMovingToBowl)
|
|
@@ -261,8 +306,9 @@ public class HomeController : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void OnDestroy()
|
|
@@ -596,7 +642,7 @@ public class HomeController : MonoBehaviour
|
|
|
string dogJson = data["dogs"].ToString();
|
|
|
UserProperty.FreshDogInfo(dogJson);
|
|
|
|
|
|
- string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", "record_success", EnviromentSetting.languageCode });
|
|
|
+ string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", trainingContent + "_10", EnviromentSetting.languageCode });
|
|
|
Time.timeScale = 0f;
|
|
|
foreach (var dog in dogsInScene)
|
|
|
{
|
|
@@ -607,14 +653,18 @@ public class HomeController : MonoBehaviour
|
|
|
}
|
|
|
MessageBoxController.ShowMessage(msg, ResetTrainingModeParameters);
|
|
|
this.sceneMode = SceneMode.NORMAL;
|
|
|
- //isTrainingMode = false;
|
|
|
+
|
|
|
+ GameData.isVoiceTrainingToday = true; // 训练完成,设置为true
|
|
|
+ string todayDate = System.DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
+ PlayerPrefs.SetString("lastTrainingDate", todayDate);
|
|
|
+ PlayerPrefs.Save();
|
|
|
|
|
|
}
|
|
|
else if (data["message"].ToString() == "fail")
|
|
|
{
|
|
|
HomeSoundEffectController.Instance.PlaySoundEffect(4);
|
|
|
|
|
|
- string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", "record_fail", EnviromentSetting.languageCode });
|
|
|
+ string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", trainingContent + "_20", EnviromentSetting.languageCode });
|
|
|
Time.timeScale = 0f;
|
|
|
MessageBoxController.ShowMessage(msg, RestartTraining);
|
|
|
}
|
|
@@ -634,7 +684,7 @@ public class HomeController : MonoBehaviour
|
|
|
private void ResetTrainingModeParameters()
|
|
|
{
|
|
|
//isTrainingMode = false;
|
|
|
- trainingContent = "";
|
|
|
+ trainingContent = String.Empty;
|
|
|
totalTrainingTimes = 2;
|
|
|
currentTrainingTimes = 0;
|
|
|
trainingDogId = "";
|
|
@@ -718,7 +768,7 @@ public class HomeController : MonoBehaviour
|
|
|
|
|
|
#region 场景环境控制
|
|
|
// 淡入或淡出背景音乐
|
|
|
- private void FadeBGM(AudioSource bgmSource, bool fadeIn, float duration=2f)
|
|
|
+ private void FadeBGM(AudioSource bgmSource, bool fadeIn, float duration = 2f)
|
|
|
{
|
|
|
// fadeIn: true表示淡入 false表示淡出
|
|
|
if (bgmSource == null) return; // 如果没有 AudioSource,则直接返回
|