Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.71 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4.  
  5. using Harmony.Apps.ThomsonR;
  6.  
  7.  
  8. /// <summary>
  9. /// Provides a common base for Fast, Flexible, Secure application info theme popups
  10. /// </summary>
  11. public abstract class PopUpTheme : UIPopUp
  12. {
  13.    
  14.     [Header("Themed Popup Properties")]
  15.    
  16.     public GameObject showPosition;
  17.     public GameObject hidePosition;
  18.  
  19.     //Like feature
  20.     public GameObject likedSprite;
  21.  
  22.     //game/menu switch
  23.     public Text buttonLabel;
  24.  
  25.  
  26.     //video path and timer
  27.     public string videoPath;
  28.     public float videoLength;
  29.     private bool paused;
  30.     private float timeSinceStart = 0;
  31.  
  32.     void Start()
  33.     {
  34.         this.gameObject.transform.localPosition = hidePosition.transform.localPosition;
  35.         base.Start();
  36.     }
  37.  
  38.  
  39.     void Update()
  40.     {
  41.         if(paused)
  42.         {
  43.             timeSinceStart += Time.deltaTime;
  44.         }
  45.         else
  46.         {
  47.             if(timeSinceStart > 0)
  48.             {
  49.                 Debug.Log(timeSinceStart);
  50.                 if(timeSinceStart > videoLength) Debug.Log("seen the whole film");
  51.                 else if(timeSinceStart < videoLength) Debug.Log("film not seen in full");
  52.                 timeSinceStart = 0;
  53.             }
  54.         }
  55.     }
  56.  
  57.  
  58.  
  59.     #region Button Operations
  60.  
  61.     public bool Liked { get ; private set; }
  62.  
  63.     public void LikeButton()
  64.     {
  65.         Liked = !Liked;
  66.         if (Liked) likedSprite.SetActive(true);
  67.         else likedSprite.SetActive(false);
  68.     }
  69.  
  70.    
  71.     public void VideoButton()
  72.     {
  73.         //Handheld.PlayFullScreenMovie("sample_mpeg4.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput);
  74.         StartCoroutine(PlayVideo("sample_mpeg4.mp4"));
  75.     }
  76.  
  77.  
  78.  
  79.     private IEnumerator PlayVideo(string path)
  80.     {
  81.         Handheld.PlayFullScreenMovie(path, Color.black, FullScreenMovieControlMode.CancelOnInput);
  82.         Debug.Log("play called");
  83.         paused = true;
  84.         yield return new WaitForEndOfFrame();
  85.         Debug.Log("first wait");
  86.         yield return new WaitForEndOfFrame();
  87.         Debug.Log("video completed");
  88.         paused = false;
  89.     }
  90.  
  91.  
  92.     public void EnquireNow()
  93.     {
  94.         HidePositionAnimated(hidePosition);
  95.         if(ViewGame.instance.currentScene == Scene.game) ViewGame.instance.pausePopUp.HideAlphaAnimated();
  96.         ViewGame.instance.contactPopUp.ShowAlphaAnimated();
  97.     }
  98.  
  99.  
  100.  
  101.     #endregion
  102.  
  103.  
  104.     #region Override Base Event Triggers
  105.  
  106.     /// <summary>
  107.     /// Override the base implementation of <c>PopUpClosed</c>
  108.     /// to also trigger the <c>ContentLiked</c> event, if the user
  109.     /// has also clicked the Like button.
  110.     /// </summary>
  111.     protected override void PopUpClosed()
  112.     {
  113.         base.PopUpClosed();
  114.  
  115.         // If the user has liked this and haven't already done so, then track the like
  116.         if (this.Liked && !AppCommon.Instance.HasUserLiked(this.contentType))
  117.         {
  118.             this.ContentLiked();
  119.         }
  120.  
  121.         // Keep track of the user preference
  122.         AppCommon.Instance.SetContentLiked(this.contentType, this.Liked);
  123.     }
  124.  
  125.     #endregion
  126.  
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement