12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using DG.Tweening;
- public class FinishKissTower : MonoBehaviour
- {
- public Transform Male;
- public Transform Female;
- private Animator _animMale;
- private Animator _animFemale;
- public bool Kiss;
- public float TimerKiss;
- public void Start()
- { _animMale = Male.GetComponent<Animator>();
- NotificationCenter.AddListener(OnSetMale, NotificationType.SetMale);
- NotificationCenter.AddListener(OnSetFemale, NotificationType.SetFemale);
- _animFemale = Female.GetComponent<Animator>();
- }
- public void OnDestroy()
- {
- NotificationCenter.RemoveListener(OnSetMale, NotificationType.SetMale);
- NotificationCenter.RemoveListener(OnSetFemale, NotificationType.SetFemale);
- }
- private void OnSetFemale(Notification note)
- {
- Male.gameObject.SetActive(true);
- Female.gameObject.SetActive(false);
- }
- private void OnSetMale(Notification note)
- {
- Male.gameObject.SetActive(false);
- Female.gameObject.SetActive(true);
- }
- public void ActiveKiss()
- {
- _animMale.enabled = true;
- //_animMale.SetBool("Kiss", true);
- _animFemale.enabled = true;
- //_animFemale.SetBool("Kiss", true);
- TimerKiss = Core.Instance.PlayerData.Heart;
-
- if (Core.Instance.PlayerGame)
- {
- Core.Instance.PlayerGame.EnableFlyToTowerAnim();
- Core.Instance.PlayerGame.Kiss();
- }
- Kiss = true;
- }
- private void Update()
- {
- if(Kiss)
- {
- TimerKiss -= Time.deltaTime;
- UIManager.Instance.BarHearthWays.fillAmount = TimerKiss / Core.Instance.PlayerData.Heart;
- UIManager.Instance.CounterHearth.text = ((int)TimerKiss).ToString();
- UIManager.Instance.CompleteCameraController.distance = Mathf.Lerp(UIManager.Instance.CompleteCameraController.distance, 4, Time.deltaTime * 2);
- UIManager.Instance.CompleteCameraController.targetHeight = Mathf.Lerp(UIManager.Instance.CompleteCameraController.targetHeight, 1, Time.deltaTime * 2);
- if (TimerKiss <= 0)
- {
- NotificationCenter.Post(NotificationType.GameWin);
- Kiss = false;
- _animFemale.enabled = false;
- _animMale.enabled = false;
- }
- }
-
- }
- }
|