Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- using Harmony.Apps.ThomsonR;
- /// <summary>
- /// Provides a common base for Fast, Flexible, Secure application info theme popups
- /// </summary>
- public abstract class PopUpTheme : UIPopUp
- {
- [Header("Themed Popup Properties")]
- public GameObject showPosition;
- public GameObject hidePosition;
- //Like feature
- public GameObject likedSprite;
- //game/menu switch
- public Text buttonLabel;
- //video path and timer
- public string videoPath;
- public float videoLength;
- private bool paused;
- private float timeSinceStart = 0;
- void Start()
- {
- this.gameObject.transform.localPosition = hidePosition.transform.localPosition;
- base.Start();
- }
- void Update()
- {
- if(paused)
- {
- timeSinceStart += Time.deltaTime;
- }
- else
- {
- if(timeSinceStart > 0)
- {
- Debug.Log(timeSinceStart);
- if(timeSinceStart > videoLength) Debug.Log("seen the whole film");
- else if(timeSinceStart < videoLength) Debug.Log("film not seen in full");
- timeSinceStart = 0;
- }
- }
- }
- #region Button Operations
- public bool Liked { get ; private set; }
- public void LikeButton()
- {
- Liked = !Liked;
- if (Liked) likedSprite.SetActive(true);
- else likedSprite.SetActive(false);
- }
- public void VideoButton()
- {
- //Handheld.PlayFullScreenMovie("sample_mpeg4.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput);
- StartCoroutine(PlayVideo("sample_mpeg4.mp4"));
- }
- private IEnumerator PlayVideo(string path)
- {
- Handheld.PlayFullScreenMovie(path, Color.black, FullScreenMovieControlMode.CancelOnInput);
- Debug.Log("play called");
- paused = true;
- yield return new WaitForEndOfFrame();
- Debug.Log("first wait");
- yield return new WaitForEndOfFrame();
- Debug.Log("video completed");
- paused = false;
- }
- public void EnquireNow()
- {
- HidePositionAnimated(hidePosition);
- if(ViewGame.instance.currentScene == Scene.game) ViewGame.instance.pausePopUp.HideAlphaAnimated();
- ViewGame.instance.contactPopUp.ShowAlphaAnimated();
- }
- #endregion
- #region Override Base Event Triggers
- /// <summary>
- /// Override the base implementation of <c>PopUpClosed</c>
- /// to also trigger the <c>ContentLiked</c> event, if the user
- /// has also clicked the Like button.
- /// </summary>
- protected override void PopUpClosed()
- {
- base.PopUpClosed();
- // If the user has liked this and haven't already done so, then track the like
- if (this.Liked && !AppCommon.Instance.HasUserLiked(this.contentType))
- {
- this.ContentLiked();
- }
- // Keep track of the user preference
- AppCommon.Instance.SetContentLiked(this.contentType, this.Liked);
- }
- #endregion
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement