QHCControl.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using VertexAnimationTools_30;
  6. public class QHCControl : MonoBehaviour
  7. {
  8. public SCButton m_Button;
  9. public GameObject ShowObj;
  10. public GameObject BrockObj;
  11. MeshSequencePlayer mesh_script;
  12. private bool m_IsPoSui;
  13. private float m_Time;
  14. private void OnEnable()
  15. {
  16. m_IsPoSui = false;
  17. m_Time = 0;
  18. }
  19. void Start()
  20. {
  21. mesh_script = BrockObj.GetComponent<MeshSequencePlayer>();
  22. BrockObj.SetActive(false);
  23. m_Button.onDown.AddListener(OnButtonDown);
  24. }
  25. private void OnButtonDown()
  26. {
  27. ChinaOnDown();
  28. }
  29. // Update is called once per frame
  30. void Update()
  31. {
  32. if (m_IsPoSui)
  33. {
  34. m_Time += Time.deltaTime;
  35. if (m_Time >= 5f)
  36. {
  37. ResetChinaPlayer();
  38. }
  39. }
  40. }
  41. //青花瓷触碰 青花瓷破碎
  42. public void ChinaOnDown()
  43. {
  44. ShowObj.SetActive(false);
  45. BrockObj.SetActive(true);
  46. mesh_script.PlaybackMode = AutoPlaybackTypeEnum.Once;
  47. m_IsPoSui = true;
  48. }
  49. //重置青花瓷破碎效果
  50. private void ResetChinaPlayer()
  51. {
  52. ShowObj.SetActive(true);
  53. BrockObj.SetActive(false);
  54. mesh_script.PlaybackMode = AutoPlaybackTypeEnum.None;
  55. mesh_script.NormalizedTime = 0;
  56. m_Time = 0;
  57. m_IsPoSui = false;
  58. }
  59. private void OnDisable()
  60. {
  61. ResetChinaPlayer();
  62. }
  63. }