123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.Timeline;
- using UnityEngine.Playables;
- using UnityGameFramework.Runtime;
- using UnityEngine.Video;
- public class NoviceTimeLineController : MonoBehaviour
- {
- public VideoPlayer _timelineController1;
- public VideoPlayer _timelineController2;
- //public PlayableDirector _timelineController2;
- //public PlayableDirector _timelineController3;
- //public PlayableDirector _timelineController4;
- //public PlayableDirector _timelineController5;
- //public PlayableDirector _timelineController6;
- //public PlayableDirector _timelineController7;
- public GameObject _slefObj;
- //public GameObject _canvasObj;
- //public Camera _TLCamera;
- public Button _skipBtn;
- public GameObject _skipDialogObj;
- /// <summary>
- /// 确认跳过
- /// </summary>
- public Button _continueBtn;
- /// <summary>
- /// 取消跳过
- /// </summary>
- public Button _skipOKBtn;
- //public GameObject _battleCamera;
- float _countTime;
- float oldY;
- bool _isAttack;
- // 播放时长
- float _duration;
- int playIndex;
- private void Awake()
- {
- _timelineController1 = transform.Find("UICanvas/NoviceCG").GetComponent<VideoPlayer>();
- _timelineController2 = transform.Find("UICanvas/SceneCG").GetComponent<VideoPlayer>();
- _timelineController2.gameObject.SetActive(false);
- //_timelineController2 = transform.Find("TimelineTwo/Timeline_piantou2").GetComponent<PlayableDirector>();
- //_timelineController3 = transform.Find("TimelineTwo/Timeline_piantou3").GetComponent<PlayableDirector>();
- //_timelineController4 = transform.Find("TimelineTwo/Timeline_piantou4").GetComponent<PlayableDirector>();
- //_timelineController5 = transform.Find("TimelineTwo/Timeline_piantou5").GetComponent<PlayableDirector>();
- //_timelineController6 = transform.Find("TimelineTwo/Timeline_piantou6").GetComponent<PlayableDirector>();
- //_timelineController7 = transform.Find("TimelineTwo/Timeline_piantou7").GetComponent<PlayableDirector>();
- _slefObj = transform.Find("Canvas").gameObject;
- //_canvasObj = transform.Find("TimelineTwo/Canvas").gameObject;
- //_TLCamera = transform.Find("Main Camera").GetComponent<Camera>();
- _skipBtn = transform.Find("UICanvas/Button").GetComponent<Button>();
- _skipDialogObj = transform.Find("UICanvas/SkipDialog").gameObject;
- _continueBtn = _skipDialogObj.transform.Find("continue_btn").GetComponent<Button>();
- _skipOKBtn = _skipDialogObj.transform.Find("skip_btn").GetComponent<Button>();
- EventTriggerListener.Get(_continueBtn.gameObject).onClick = CloseSkipDialog;
- EventTriggerListener.Get(_skipBtn.gameObject).onClick = OpenSkipDialog;
- EventTriggerListener.Get(_skipOKBtn.gameObject).onClick = SkipTimeLine;
- _skipDialogObj.SetActive(false);
- }
- // Start is called before the first frame update
- void Start()
- {
- //closeAllTimeLine();
- }
- public void OpenSkipDialog(GameObject obj)
- {
- _skipDialogObj.SetActive(true);
- }
- public void CloseSkipDialog(GameObject obj)
- {
- _skipDialogObj.SetActive(false);
- }
- public void SkipTimeLine(GameObject obj)
- {
- //_TLCamera.gameObject.SetActive(false);
- //_canvasObj.SetActive(false);
- _skipBtn.gameObject.SetActive(false);
- _skipDialogObj.SetActive(false);
- ConvertEffect.Instance.PlayEffect(ConvertEffect.convertEffectType.LucencyToBlack, SkipTimeLineFinish);
- }
- public void SkipTimeLineFinish(GameObject obj)
- {
- ConvertEffect.Instance.PlayEffect(ConvertEffect.convertEffectType.BlackToLucency, null);
- CloseFinish(null);
- }
- // Update is called once per frame
- void Update()
- {
- if (_duration > 0)
- {
- _duration -= Time.deltaTime;
- if (_duration <= 0)
- {
- if (playIndex == 1)
- {
- _timelineController1.gameObject.SetActive(false);
- _skipDialogObj.gameObject.SetActive(false);
- // 观看重要剧情; 添加 钻石货币 2颗
- UserProxy.Instance.SendImportantStoryViewFullReward();
- PlayByIndex(2);
- }
- else if(playIndex == 2)
- {
- CloseAllTimeLine();
- }
- HpbarManager.Instance.SetShowState(true);
- if (playIndex == 6)
- {
- return;
- }
- }
- }
- }
- public void CloseAllTimeLine()
- {
- ConvertEffect.Instance.PlayEffect(ConvertEffect.convertEffectType.LucencyToBlack, CloseFinish);
- }
- public void CloseFinish(GameObject obj)
- {
- playIndex = 2;
- ConvertEffect.Instance.PlayEffect(ConvertEffect.convertEffectType.BlackToLucency, null);
- _skipBtn.gameObject.SetActive(false);
- Image img = this.transform.Find("UICanvas").GetComponent<Image>();
- img.raycastTarget = false;
- this._slefObj.gameObject.SetActive(false);
- EventComponent nowEvent = GameEntry.GetComponent<EventComponent>();
- nowEvent.FireNow(this, new NoviceEventTimeLineComplete(playIndex));
- _duration = 0;
- }
- public void PlayByIndex(int index)
- {
- HpbarManager.Instance.SetShowState(false);
- //this._battleCamera.gameObject.SetActive(false);
- switch (index)
- {
- case 1:
- this._slefObj.gameObject.SetActive(true);
- _duration = (float)_timelineController1.clip.length;
- _duration -= 0.3f;
- playIndex = 1;
- _timelineController1.Play();
- break;
- case 2:
- this._slefObj.gameObject.SetActive(true);
- _duration = (float)_timelineController2.clip.length;
- playIndex = 2;
- _timelineController2.gameObject.SetActive(true);
- _timelineController2.Play();
- //UserProxy.Instance.UpdateNewbieGuideStep(2, null);
- break;
- //case 2:
- // _timelineController2.gameObject.SetActive(true);
- // _duration = (float)_timelineController2.duration;
- // playIndex = 2;
- // _timelineController2.Play();
- // break;
- //case 3:
- // _timelineController3.gameObject.SetActive(true);
- // _duration = (float)_timelineController3.duration;
- // playIndex = 3;
- // _timelineController3.Play();
- // break;
- //case 4:
- // _timelineController4.gameObject.SetActive(true);
- // _duration = (float)_timelineController4.duration;
- // playIndex = 4;
- // _timelineController4.Play();
- // break;
- //case 5:
- // _timelineController5.gameObject.SetActive(true);
- // _duration = (float)_timelineController5.duration;
- // playIndex = 5;
- // _timelineController5.Play();
- // break;
- //case 6:
- // _timelineController6.gameObject.SetActive(true);
- // //_duration = (float)_timelineController6.duration;
- // _duration = 2.5f;
- // playIndex = 6;
- // _timelineController6.Play();
- // break;
- //case 7:
- // _timelineController7.gameObject.SetActive(true);
- // _duration = (float)_timelineController7.duration;
- // playIndex = 7;
- // _timelineController7.Play();
- // break;
- }
- }
- }
|