TestVideoControl.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using DG.Tweening;
  6. public class TestVideoControl : MonoBehaviour
  7. {
  8. public List<Vector3> VideoPos = new List<Vector3>();
  9. public List<TestVideoItem> m_Videos = new List<TestVideoItem>();
  10. private void Start()
  11. {
  12. for (int i = 0; i < m_Videos.Count; i++)
  13. {
  14. m_Videos[i].OnClickVideoItem += OnClickVideo;
  15. }
  16. }
  17. private void OnClickVideo(EState state, int id)
  18. {
  19. switch (state)
  20. {
  21. case EState.none:
  22. break;
  23. case EState.right:
  24. OnRight(id);
  25. break;
  26. case EState.left:
  27. OnLeft(id);
  28. break;
  29. default:
  30. break;
  31. }
  32. }
  33. private void OnLeft(int id)
  34. {
  35. int num = id - 3;
  36. List<TestVideoItem> videos = new List<TestVideoItem>();
  37. for (int i = 0; i < m_Videos.Count; i++)
  38. {
  39. int n = num + i;
  40. if (n < m_Videos.Count)
  41. {
  42. videos.Add(m_Videos[n]);
  43. }
  44. }
  45. for (int i = 0; i < num; i++)
  46. {
  47. videos.Add(m_Videos[i]);
  48. }
  49. m_Videos.Clear();
  50. m_Videos.AddRange(videos);
  51. for (int i = 0; i < videos.Count; i++)
  52. {
  53. //videos[i].transform.localPosition = VideoPos[i];
  54. videos[i].ID = i + 1;
  55. videos[i].Play(VideoPos[i], EState.left);
  56. }
  57. }
  58. private void OnRight(int id)
  59. {
  60. int num = 3 - id;
  61. List<TestVideoItem> videos = new List<TestVideoItem>();
  62. for (int i = m_Videos.Count - num; i < m_Videos.Count; i++)
  63. {
  64. videos.Add(m_Videos[i]);
  65. }
  66. for (int i = 0; i < m_Videos.Count - num; i++)
  67. {
  68. videos.Add(m_Videos[i]);
  69. }
  70. m_Videos.Clear();
  71. m_Videos.AddRange(videos);
  72. for (int i = 0; i < videos.Count; i++)
  73. {
  74. //videos[i].transform.DOLocalMove(VideoPos[i], 3f);
  75. //videos[i].transform.localPosition = VideoPos[i];
  76. videos[i].ID = i + 1;
  77. videos[i].Play(VideoPos[i], EState.right);
  78. }
  79. }
  80. }