ConversationManager.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System;
  4. using DataTools;
  5. using WebTools.Customizes.Behaviours;
  6. [Serializable]
  7. public class ConversationAudioData
  8. {
  9. public string audioId;
  10. public AudioClip voice;
  11. }
  12. public class ConversationManager : GameplayBase
  13. {
  14. public static ConversationManager instance;
  15. public event Action<DataTools.Dialog> onChangeDialog;
  16. [Header("DATA")]
  17. [SerializeField] protected DataUser dataUser;
  18. [Header("ANIMATIONS")]
  19. [SerializeField] private Animator dialogAnimation;
  20. [Header("GAME OBJECTS")]
  21. [SerializeField] private GameObject Dialog;
  22. [SerializeField] private GameObject Notification;
  23. [SerializeField] private GameObject nextButton;
  24. [SerializeField] private GameObject answersContainer;
  25. [SerializeField] private GameObject textGlobeConversation;
  26. [SerializeField] private GameObject textGlobePhone;
  27. [Header("TEXT")]
  28. [SerializeField] private Text currenConversationText;
  29. [SerializeField] private Text currentSpeakerText;
  30. [Header("TEXT MESSAGE")]
  31. [SerializeField] private PhoneUIMessages texMessage;
  32. [SerializeField] private PhoneUIMessages mailMessage;
  33. [Header("BUTTONS")]
  34. [SerializeField] private ButtonAnswer[] buttonsAnswer;
  35. [Header("SOUNDS")]
  36. [SerializeField] private ConversationAudioData[] conversationAudioData;
  37. [SerializeField] private AudioSource audioSource;
  38. [Header("CHARACTER")]
  39. [SerializeField] private CustomizeCharacterBehaviour currentCharacter;
  40. [Header("StyleCheck")]
  41. [SerializeField] private FillBar stylebar;
  42. [SerializeField] private Image styleImage;
  43. [SerializeField] private Sprite styleCasual;
  44. [SerializeField] private Sprite styleCouture;
  45. [SerializeField] private Sprite styleActivewear;
  46. [SerializeField] private Sprite styleSwimwear;
  47. [Header("Next dialog marks")]
  48. [SerializeField] private Image nextMark;
  49. [SerializeField] private Sprite basicMark;
  50. [SerializeField] private Sprite phoneMark;
  51. [Header("Sound for answers VFX")]
  52. [SerializeField] private AudioClip cameraSound;
  53. public AudioClip CameraSound
  54. {
  55. get
  56. {
  57. return cameraSound;
  58. }
  59. }
  60. private Characters characters;
  61. private int nextDialogIndex = 0;
  62. private string newLocationId = "";
  63. private float conversationDelay = 0;
  64. private bool dialogIsEnabled = true;
  65. private bool needToRestartConversation = false;
  66. private void Awake()
  67. {
  68. instance = this;
  69. }
  70. protected override void Start()
  71. {
  72. WebTools.UserInput.OnNameInput += ResetConversation;
  73. WebTools.UserInput.OnGenderInput += NextDialogue;
  74. DisableDialogItmes();
  75. characters = FindObjectOfType<Characters>();
  76. base.Start();
  77. }
  78. private void OnDestroy()
  79. {
  80. WebTools.UserInput.OnNameInput -= ResetConversation;
  81. WebTools.UserInput.OnGenderInput -= NextDialogue;
  82. }
  83. public void ClearText()
  84. {
  85. currenConversationText.text = "";
  86. currentSpeakerText.text = "";
  87. }
  88. private void SetNextMark()
  89. {
  90. if(currentConversation != null)
  91. {
  92. switch(currentConversation.ConvType)
  93. {
  94. case DataTools.ConversationType.PhoneCall:
  95. {
  96. nextMark.sprite = phoneMark;
  97. break;
  98. }
  99. default:
  100. {
  101. nextMark.sprite = basicMark;
  102. break;
  103. }
  104. }
  105. }
  106. }
  107. private bool LocationMatch
  108. {
  109. get
  110. {
  111. bool locationFlag = currentConversation.Location.ToUpper() == newLocationId.ToUpper();
  112. bool exteriorFlag = (currentConversation.Location.ToUpper() == "EXTERIOR") && GameGlobal.Instance.GetIsExterior();
  113. bool anyFlag = (currentConversation.Location.ToUpper() == "ANY");
  114. return (locationFlag || exteriorFlag || anyFlag);
  115. }
  116. }
  117. public void StartDialogue()
  118. {
  119. UnblockGame();
  120. if (!LocationMatch)
  121. {
  122. return;
  123. }
  124. ClearText();
  125. PanelQuestBehaviour.Instance.HideMainQuest();
  126. Notification.SetActive(false);
  127. Dialog.SetActive(true);
  128. SetupInitialDiaogue();
  129. EnableNextDialogue(0f, currentConversation.Dialog[dataUser.UserData.ProgressData.CurrentConversationIndex]);
  130. }
  131. public void FinishTask(bool resetDialog = true)
  132. {
  133. ContacsBehaviour.Instance.ShowContac();
  134. if (resetDialog)
  135. {
  136. dataUser.UserData.ProgressData.CurrentConversationIndex = 0;
  137. }
  138. UnblockGame();
  139. OnFinishConversation();
  140. }
  141. private void OnFinishConversation(bool mainStoryConvo = true)
  142. {
  143. currentConversation = null;
  144. if (mainStoryConvo)
  145. {
  146. GameplayManager.instance.NextChapterAction();
  147. }
  148. }
  149. private void DisableDialogItmes()
  150. {
  151. ClearText();
  152. Debug.Log("Disable dialog items");
  153. Dialog.SetActive(false);
  154. Notification.SetActive(false);
  155. }
  156. private void EnableNextDialogue(float animDelay, DataTools.Dialog dialog)
  157. {
  158. if(onChangeDialog != null)
  159. {
  160. onChangeDialog(dialog);
  161. }
  162. string prevNpcId = GameGlobal.Instance.CurrentNpc;
  163. GameGlobal.Instance.CurrentNpc = dialog.NpcId;
  164. if (prevNpcId != GameGlobal.Instance.CurrentNpc)
  165. {
  166. ClearText();
  167. dialogAnimation.StopPlayback();
  168. Dialog.SetActive(false);
  169. Invoke("PlayDialogue", 0.2f);
  170. }
  171. else
  172. {
  173. Invoke("PlayDialogue", animDelay);
  174. }
  175. }
  176. private bool isNoProblemWithNextDialog
  177. {
  178. get
  179. {
  180. return ((currentConversation != null) && (currentConversation.Dialog != null) && (currentConversation.Dialog.Count != 0));
  181. }
  182. }
  183. private void NextDialogue()
  184. {
  185. SetActiveButtons(false);
  186. if (nextDialogIndex == -1)
  187. {
  188. int nextIndex = isNoProblemWithNextDialog ? currentConversation.Dialog[dataUser.UserData.ProgressData.CurrentConversationIndex].NextDialogIndex : -1;
  189. if (nextIndex != -1)
  190. {
  191. dataUser.UserData.ProgressData.CurrentConversationIndex = nextIndex;
  192. }
  193. else
  194. {
  195. dataUser.UserData.ProgressData.CurrentConversationIndex = currentConversation.Dialog.Count;
  196. }
  197. }
  198. else
  199. {
  200. if (nextDialogIndex == dataUser.UserData.ProgressData.CurrentConversationIndex || nextDialogIndex == 0)
  201. {
  202. int nextIndex = isNoProblemWithNextDialog ? currentConversation.Dialog[dataUser.UserData.ProgressData.CurrentConversationIndex].NextDialogIndex : -1;
  203. if (nextIndex != -1)
  204. {
  205. dataUser.UserData.ProgressData.CurrentConversationIndex = nextIndex;
  206. }
  207. else
  208. {
  209. dataUser.UserData.ProgressData.CurrentConversationIndex = currentConversation.Dialog.Count;
  210. }
  211. }
  212. else
  213. {
  214. dataUser.UserData.ProgressData.CurrentConversationIndex = nextDialogIndex;
  215. }
  216. }
  217. if (currentConversation != null)
  218. {
  219. if (GameGlobal.Instance.GetCurrentQuest != null /*&& currentConversation.ConvType!=DataTools.ConversationType.Optional*/)
  220. {
  221. GameGlobal.Instance.SetCurrentDialogIndex(dataUser.UserData.ProgressData.CurrentConversationIndex);
  222. GameGlobal.Instance.SetActionID(GameGlobal.Instance.GetCurrentQuest.Tasks[GameGlobal.Instance.GetQuestIndex()].Action.PropertyId, currentConversation.Id);
  223. }
  224. if (dataUser.UserData.ProgressData.CurrentConversationIndex < currentConversation.Dialog.Count)
  225. {
  226. EnableNextDialogue(0.5f, currentConversation.Dialog[dataUser.UserData.ProgressData.CurrentConversationIndex]);
  227. }
  228. else
  229. {
  230. dialogIsEnabled = false;
  231. if (currentConversation.ConvType == DataTools.ConversationType.PhoneCall)
  232. {
  233. WebTools.Phone.PanelPhoneBehaviour.Instance.EndCall();
  234. }
  235. FinishTask();
  236. }
  237. }
  238. dataUser.UpdateUserProgress();
  239. }
  240. private void PlayAudio()
  241. {
  242. conversationDelay = 0;
  243. if (currentConversation != null)
  244. {
  245. if (currentConversation.Dialog[dataUser.UserData.ProgressData.CurrentConversationIndex].SoundId != "")
  246. {
  247. foreach (ConversationAudioData audioData in conversationAudioData)
  248. {
  249. if (audioData.audioId == currentConversation.Dialog[dataUser.UserData.ProgressData.CurrentConversationIndex].SoundId)
  250. {
  251. audioSource.clip = audioData.voice;
  252. audioSource.Play();
  253. conversationDelay = audioSource.clip.length;
  254. }
  255. }
  256. }
  257. }
  258. }
  259. public void SetNextDialogue(int _nextDialogIndex)
  260. {
  261. if (currentConversation != null)
  262. {
  263. if (currentConversation.ConvType == DataTools.ConversationType.Auto ||
  264. currentConversation.ConvType == DataTools.ConversationType.Basic ||
  265. currentConversation.ConvType == DataTools.ConversationType.PhoneCall ||
  266. currentConversation.ConvType == DataTools.ConversationType.Optional)
  267. {
  268. if (needToRestartConversation)
  269. {
  270. needToRestartConversation = false;
  271. ResetConversation();
  272. return;
  273. }
  274. nextDialogIndex = _nextDialogIndex;
  275. PlayAudio();
  276. dialogAnimation.Play("EndDialogue");
  277. Invoke("NextDialogue", conversationDelay);
  278. }
  279. }
  280. }
  281. public void GoToNextDialog()
  282. {
  283. int dialog = dataUser.UserData.ProgressData.CurrentConversationIndex;
  284. int next = currentConversation.Dialog[dialog].NextDialogIndex;
  285. SetNextDialogue(next);
  286. }
  287. public void ResetConversation()
  288. {
  289. if (GameplayManager.instance.QuestIsActive)
  290. {
  291. GameGlobal.Instance.DecreaseQuestIndex();
  292. }
  293. else
  294. {
  295. GameGlobal.Instance.DecreaseChapElementIndex();
  296. }
  297. FinishTask(false);
  298. }
  299. private void UnblockGame()
  300. {
  301. GameGlobal.Instance.PannigLocked = false;
  302. if (currentConversation.ConvType != DataTools.ConversationType.TextMessage)
  303. {
  304. if (currentConversation.ConvType != DataTools.ConversationType.Email)
  305. {
  306. Navigation.Instance.FinishCam();
  307. }
  308. }
  309. BlockerManager.Instance.UnblockAllButtons(GameplayManager.instance.isFirstGigPassed);
  310. }
  311. public void CancelConversation()
  312. {
  313. UnblockGame();
  314. DisableDialogItmes();
  315. SetConversation(currentConversation);
  316. }
  317. private void SetActiveButtons(bool setActive)
  318. {
  319. Button[] buttons = this.gameObject.GetComponentsInChildren<Button>();
  320. foreach (var button in buttons)
  321. {
  322. button.interactable = setActive;
  323. }
  324. }
  325. private void PlayDialogue()
  326. {
  327. Dialog.SetActive(true);
  328. string dialogFixed = "";
  329. if (!isNoProblemWithNextDialog)
  330. {
  331. return;
  332. }
  333. DataTools.Dialog currentDialog = currentConversation.Dialog[dataUser.UserData.ProgressData.CurrentConversationIndex];
  334. bool styleCheckRequred = currentDialog.StyleCheck;
  335. bool styleCheckPassed = false;
  336. if(styleCheckRequred)
  337. {
  338. styleCheckPassed = GetStyleBonusValue(currentDialog.StyleType) >= currentDialog.StyleValue;
  339. stylebar.CurrentValue = GetStyleBonusValue(currentDialog.StyleType) / 100.0f;
  340. stylebar.RequiredValue = currentDialog.StyleValue / 100.0f;
  341. stylebar.ShowRequired = true;
  342. }
  343. stylebar.gameObject.SetActive(styleCheckRequred);
  344. styleImage.gameObject.SetActive(styleCheckRequred);
  345. needToRestartConversation = (styleCheckRequred && !styleCheckPassed);
  346. dialogFixed = ChangeStrings.ChangeText(needToRestartConversation ? currentDialog.AltText : currentDialog.Text);
  347. currenConversationText.text = dialogFixed;
  348. currentSpeakerText.text = currentConversation.Dialog[dataUser.UserData.ProgressData.CurrentConversationIndex].NpcId;
  349. if (styleCheckRequred && !styleCheckPassed)
  350. {
  351. SetbuttonDataForStyleCheck();
  352. }
  353. else
  354. {
  355. SetAnswerButtons();
  356. }
  357. dialogAnimation.Play("StartDialogue");
  358. SetActiveButtons(true);
  359. GameObject npc = characters.NpcInstances.Find(n => n.GetComponent<NPC>().Name.ToUpper() == currentConversation.Dialog[dataUser.UserData.ProgressData.CurrentConversationIndex].NpcId.ToUpper());
  360. if (npc != null)
  361. {
  362. npc.GetComponent<NPC>().PlayAnimation(currentConversation.Dialog[dataUser.UserData.ProgressData.CurrentConversationIndex].AnimationIndex);
  363. }
  364. }
  365. private void DissableAllAnswerButtons()
  366. {
  367. for (int i = 0; i > buttonsAnswer.Length; i++)
  368. {
  369. buttonsAnswer[i].gameObject.SetActive(false);
  370. }
  371. }
  372. private void SetButtonData(int index)
  373. {
  374. DataTools.Reply reply = currentConversation.Dialog[dataUser.UserData.ProgressData.CurrentConversationIndex].Replies[index];
  375. string answerFixed = ChangeStrings.ChangeText(reply.Text);
  376. buttonsAnswer[index].SetAnswer(answerFixed, reply.Cost, reply.Reward, reply.StartAction==DataTools.StartAction.Repeat);
  377. buttonsAnswer[index].SetNextAnswerId(reply.NextDialogIndex);
  378. buttonsAnswer[index].UseCameraVFX = reply.UseCameraVFX;
  379. buttonsAnswer[index].SetAnimationToPlay(reply.AnimationId);
  380. }
  381. private void SetbuttonDataForStyleCheck()
  382. {
  383. nextButton.SetActive(false);
  384. answersContainer.SetActive(true);
  385. foreach (ButtonAnswer b in buttonsAnswer)
  386. {
  387. b.gameObject.SetActive(false);
  388. }
  389. buttonsAnswer[0].SetAnswer("(Change Clothes)", new DataTools.Currency(), new DataTools.Currency(),true,true);
  390. buttonsAnswer[1].SetAnswer("(Come back later)", new DataTools.Currency(), new DataTools.Currency(), true);
  391. buttonsAnswer[0].gameObject.SetActive(true);
  392. buttonsAnswer[1].gameObject.SetActive(true);
  393. buttonsAnswer[2].gameObject.SetActive(false);
  394. }
  395. public void OpenCustomization()
  396. {
  397. MenuOld.Instance.ChangePanel(MenuOld.Instance.GetMenuScenes()[1]);
  398. }
  399. private void SetAllButtons()
  400. {
  401. for (int i = 0; i < buttonsAnswer.Length; i++)
  402. {
  403. if (i < currentConversation.Dialog[dataUser.UserData.ProgressData.CurrentConversationIndex].Replies.Count)
  404. {
  405. buttonsAnswer[i].gameObject.SetActive(true);
  406. SetButtonData(i);
  407. }
  408. else
  409. {
  410. buttonsAnswer[i].gameObject.SetActive(false);
  411. }
  412. }
  413. }
  414. private void SetAnswerButtons()
  415. {
  416. DissableAllAnswerButtons();
  417. if (currentConversation.Dialog[dataUser.UserData.ProgressData.CurrentConversationIndex].Replies.Count == 0)
  418. {
  419. nextButton.SetActive(true);
  420. answersContainer.SetActive(false);
  421. }
  422. else
  423. {
  424. nextButton.SetActive(false);
  425. answersContainer.SetActive(true);
  426. SetAllButtons();
  427. }
  428. }
  429. private void SetupInitialDiaogue()
  430. {
  431. GameGlobal.Instance.PannigLocked = true;
  432. GameGlobal.Instance.SetCurrentDialogIndex(dataUser.UserData.ProgressData.CurrentConversationIndex);
  433. BlockerManager.Instance.BlockAllButtons("TextMessageButton");
  434. }
  435. protected override void OnLocationChanged(Location nLocation)
  436. {
  437. newLocationId = nLocation.ID;
  438. TryEnableDialogue(nLocation.ID);
  439. }
  440. protected override void SetConversation(DataTools.Conversation conversation)
  441. {
  442. dialogIsEnabled = true;
  443. base.SetConversation(conversation);
  444. GameGlobal.Instance.CurrentNpc = conversation.Dialog[0].NpcId;
  445. ConversationIndexCheck();
  446. if (!LocationMatch)
  447. {
  448. return;
  449. }
  450. TryEnableDialogue(newLocationId);
  451. }
  452. /// <summary>
  453. /// Prevents game from stuck if conversation index in UserData is incorrect
  454. /// </summary>
  455. private void ConversationIndexCheck()
  456. {
  457. if (dataUser.UserData.ProgressData.CurrentConversationIndex >= currentConversation.Dialog.Count)
  458. {
  459. dataUser.UserData.ProgressData.CurrentConversationIndex = 0;
  460. }
  461. }
  462. private void SetupPhoneMessage(PhoneUIMessages phoneMessage)
  463. {
  464. SetupInitialDiaogue();
  465. string dialogFixed = ChangeStrings.ChangeText(currentConversation.Dialog[0].Text);
  466. string replyFixed = "...";
  467. DataTools.Currency newCost = new DataTools.Currency(0,0,0,0,0);
  468. DataTools.Currency newReward = new DataTools.Currency(0, 0, 0, 0, 0);
  469. if (currentConversation.Dialog[0].Replies.Count > 0)
  470. {
  471. replyFixed = ChangeStrings.ChangeText(currentConversation.Dialog[0].Replies[0].Text);
  472. newCost = currentConversation.Dialog[0].Replies[0].Cost;
  473. newReward = currentConversation.Dialog[0].Replies[0].Reward;
  474. }
  475. phoneMessage.SetupPhoneMessage(currentConversation.Dialog[0].NpcId,
  476. currentConversation.Dialog[0].NpcId,
  477. dialogFixed,
  478. replyFixed,
  479. newCost,
  480. newReward);
  481. }
  482. public bool IsDialogEnabled
  483. {
  484. get
  485. {
  486. return dialogIsEnabled;
  487. }
  488. }
  489. private void SetButtonsBackgrounds(DataTools.ConversationType type)
  490. {
  491. switch(type)
  492. {
  493. case DataTools.ConversationType.PhoneCall:
  494. {
  495. foreach (ButtonAnswer b in buttonsAnswer)
  496. {
  497. b.SetPhoneConversationSprite();
  498. }
  499. break;
  500. }
  501. default:
  502. {
  503. foreach (ButtonAnswer b in buttonsAnswer)
  504. {
  505. b.SetBasicConversationSprite();
  506. }
  507. break;
  508. }
  509. }
  510. }
  511. private void EnableDialogue()
  512. {
  513. if (dialogIsEnabled)
  514. {
  515. SetButtonsBackgrounds(currentConversation.ConvType);
  516. SetNextMark();
  517. switch (currentConversation.ConvType)
  518. {
  519. case DataTools.ConversationType.PhoneCall:
  520. {
  521. Debug.LogError("PhoneCall");
  522. textGlobeConversation.SetActive(false);
  523. textGlobePhone.SetActive(true);
  524. DisableDialogItmes();
  525. BlockerManager.Instance.BlockAllButtons("AnswerCallButton");
  526. WebTools.Phone.PanelPhoneBehaviour.Instance.ActivateCall();
  527. break;
  528. }
  529. case DataTools.ConversationType.TextMessage:
  530. {
  531. Debug.LogError("TextMessage");
  532. AnimationPanelMain.Instance.ActiveRightBottomButtonsUIAnimation(true);
  533. WebTools.Phone.PanelPhoneBehaviour.Instance.ActivateTextMessage();
  534. SetupPhoneMessage(texMessage);
  535. break;
  536. }
  537. case DataTools.ConversationType.Email:
  538. {
  539. Debug.LogError("Email");
  540. AnimationPanelMain.Instance.ActiveRightBottomButtonsUIAnimation(true);
  541. WebTools.Phone.PanelPhoneBehaviour.Instance.ActivateEmailMessage();
  542. SetupPhoneMessage(mailMessage);
  543. break;
  544. }
  545. default:
  546. {
  547. textGlobeConversation.SetActive(true);
  548. textGlobePhone.SetActive(false);
  549. if (currentConversation.ConvType == DataTools.ConversationType.Auto /*|| dataUser.UserData.ProgressData.CurrentConversationIndex > 0*/)
  550. {
  551. StartDialogue();
  552. }
  553. else
  554. {
  555. Notification.SetActive(true);
  556. answersContainer.SetActive(false);
  557. dialogAnimation.Play("DialogueActive");
  558. }
  559. TalkIndicator.Instance.SetPositionObj(currentConversation.Dialog[dataUser.UserData.ProgressData.CurrentConversationIndex].NpcId);
  560. break;
  561. }
  562. }
  563. }
  564. else
  565. {
  566. DisableDialogItmes();
  567. }
  568. }
  569. private bool NoNotificationInQueue()
  570. {
  571. bool result = false;
  572. result = !GameNotificationManager.Instance.IsNotificationInQueue();
  573. return result;
  574. }
  575. private int GetStyleBonusValue(CustomizeType type)
  576. {
  577. int value = 0;
  578. currentCharacter.CheckStyle();
  579. CustomizeStats stats = currentCharacter.GetCustomizeStats();
  580. switch(type)
  581. {
  582. case CustomizeType.ACTIVEWEAR:
  583. {
  584. value = stats.ActiveWear;
  585. styleImage.sprite = styleActivewear;
  586. break;
  587. }
  588. case CustomizeType.CASUAL:
  589. {
  590. value = stats.Casual;
  591. styleImage.sprite = styleCasual;
  592. break;
  593. }
  594. case CustomizeType.COUTURE:
  595. {
  596. value = stats.Couture;
  597. styleImage.sprite = styleCouture;
  598. break;
  599. }
  600. case CustomizeType.MAKEUP:
  601. {
  602. value = stats.MakeUp;
  603. break;
  604. }
  605. case CustomizeType.SWIMWEAR:
  606. {
  607. value = stats.SwimWear;
  608. styleImage.sprite = styleSwimwear;
  609. break;
  610. }
  611. case CustomizeType.NONE:
  612. {
  613. value = currentCharacter.GetMaxCustomizeType();
  614. break;
  615. }
  616. default:
  617. {
  618. break;
  619. }
  620. }
  621. return value;
  622. }
  623. public void TryDialogIfPosssible()
  624. {
  625. if (!needToRestartConversation)
  626. {
  627. TryEnableDialogue(newLocationId);
  628. }
  629. else
  630. {
  631. Debug.Log("needToRestart is " + needToRestartConversation.ToString() + " - conversation will not be activated");
  632. }
  633. }
  634. public bool NeedToRestart
  635. {
  636. get
  637. {
  638. return needToRestartConversation;
  639. }
  640. }
  641. private void TryEnableDialogue(string newLocation)
  642. {
  643. if (currentConversation != null && NoNotificationInQueue())
  644. {
  645. bool locationFlag = currentConversation.Location.ToUpper() == newLocation.ToUpper();
  646. bool exteriorFlag = (currentConversation.Location.ToUpper() == "EXTERIOR") && GameGlobal.Instance.GetIsExterior();
  647. bool anyFlag = (currentConversation.Location.ToUpper() == "ANY");
  648. if (locationFlag || exteriorFlag || anyFlag)
  649. {
  650. switch(currentConversation.ConvType)
  651. {
  652. case DataTools.ConversationType.Basic:
  653. case DataTools.ConversationType.Auto:
  654. case DataTools.ConversationType.Optional:
  655. case DataTools.ConversationType.Email:
  656. case DataTools.ConversationType.PhoneCall:
  657. case DataTools.ConversationType.TextMessage:
  658. {
  659. EnableDialogue();
  660. break;
  661. }
  662. default:
  663. {
  664. DisableDialogItmes();
  665. break;
  666. }
  667. }
  668. }
  669. else
  670. {
  671. DisableDialogItmes();
  672. }
  673. }
  674. else
  675. {
  676. DisableDialogItmes();
  677. }
  678. }
  679. }