FinishKissTower.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using DG.Tweening;
  6. public class FinishKissTower : MonoBehaviour
  7. {
  8. public Transform Male;
  9. public Transform Female;
  10. private Animator _animMale;
  11. private Animator _animFemale;
  12. public bool Kiss;
  13. public float TimerKiss;
  14. public void Start()
  15. { _animMale = Male.GetComponent<Animator>();
  16. NotificationCenter.AddListener(OnSetMale, NotificationType.SetMale);
  17. NotificationCenter.AddListener(OnSetFemale, NotificationType.SetFemale);
  18. _animFemale = Female.GetComponent<Animator>();
  19. }
  20. public void OnDestroy()
  21. {
  22. NotificationCenter.RemoveListener(OnSetMale, NotificationType.SetMale);
  23. NotificationCenter.RemoveListener(OnSetFemale, NotificationType.SetFemale);
  24. }
  25. private void OnSetFemale(Notification note)
  26. {
  27. Male.gameObject.SetActive(true);
  28. Female.gameObject.SetActive(false);
  29. }
  30. private void OnSetMale(Notification note)
  31. {
  32. Male.gameObject.SetActive(false);
  33. Female.gameObject.SetActive(true);
  34. }
  35. public void ActiveKiss()
  36. {
  37. _animMale.enabled = true;
  38. //_animMale.SetBool("Kiss", true);
  39. _animFemale.enabled = true;
  40. //_animFemale.SetBool("Kiss", true);
  41. TimerKiss = Core.Instance.PlayerData.Heart;
  42. if (Core.Instance.PlayerGame)
  43. {
  44. Core.Instance.PlayerGame.EnableFlyToTowerAnim();
  45. Core.Instance.PlayerGame.Kiss();
  46. }
  47. Kiss = true;
  48. }
  49. private void Update()
  50. {
  51. if(Kiss)
  52. {
  53. TimerKiss -= Time.deltaTime;
  54. UIManager.Instance.BarHearthWays.fillAmount = TimerKiss / Core.Instance.PlayerData.Heart;
  55. UIManager.Instance.CounterHearth.text = ((int)TimerKiss).ToString();
  56. UIManager.Instance.CompleteCameraController.distance = Mathf.Lerp(UIManager.Instance.CompleteCameraController.distance, 4, Time.deltaTime * 2);
  57. UIManager.Instance.CompleteCameraController.targetHeight = Mathf.Lerp(UIManager.Instance.CompleteCameraController.targetHeight, 1, Time.deltaTime * 2);
  58. if (TimerKiss <= 0)
  59. {
  60. NotificationCenter.Post(NotificationType.GameWin);
  61. Kiss = false;
  62. _animFemale.enabled = false;
  63. _animMale.enabled = false;
  64. }
  65. }
  66. }
  67. }