Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using GameCore;
- using UnityEngine;
- using UnityEngine.Analytics;
- using Lean.Pool;
- using UnityEngine.Events;
- namespace QuestEngine
- {
- public class Gift : MonoBehaviour
- {
- [SerializeField] private RewardInfoScripableDecorator _reward;
- [SerializeField] private GameEventIRewardInfo _getReward;
- [SerializeField] private PlayAudodestructSoundAction _audio;
- [SerializeField] private ADListener _ads;
- [SerializeField] private GameObject _adsIcon;
- public bool IsFirst { get; set; }
- private bool _isGeted = false;
- public UnityEvent OnGeted;
- public UnityEvent OnIgnored;
- private void OnEnable()
- {
- _isGeted = false;
- _adsIcon.SetActive(!IsFirst);
- }
- public void OnGet()
- {
- _isGeted = true;
- Analytics.SendEvent("Gift Taked", new Dictionary<string, object>() { { "Reward", _reward.name } });
- _audio.Play(gameObject, IsFirst ? (UnityAction)OnVideoShowed : ShowVideo);
- OnIgnored.RemoveAllListeners();
- LeanPool.Despawn(this);
- }
- private void ShowVideo() => _ads.Show("Gift", OnVideoShowed);
- private void OnVideoShowed()
- {
- Analytics.SendEvent("Gift Rewarded Video Showed", new Dictionary<string, object>() { { "Reward", _reward.name } });
- _getReward.Raise(_reward);
- OnGeted.Invoke();
- }
- public void OnPlayerIgonore(GameObject player)
- {
- if (_isGeted == false)
- {
- OnIgnored.Invoke();
- LeanPool.Despawn(this);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment