page_set.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { _decorator, Component, Node } from 'cc';
  2. import { AudioManager } from 'db://assets/script/Manager/AudioMgr';
  3. import { User } from 'db://assets/script/Manager/LocalDataMgr';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('page_set')
  6. export class page_set extends Component {
  7. @property(Node)
  8. yinxiao_kai: Node = null
  9. @property(Node)
  10. yinxiao_guan: Node = null
  11. @property(Node)
  12. yinyue_guan: Node = null
  13. @property(Node)
  14. yinyue_kai: Node = null
  15. protected start(): void {
  16. if (User.userData.sound) {
  17. this.yinxiao_kai.active = false
  18. this.yinxiao_guan.active = true
  19. } else {
  20. this.yinxiao_kai.active = true
  21. this.yinxiao_guan.active = false
  22. }
  23. if (User.userData.music) {
  24. this.yinyue_kai.active = false
  25. this.yinyue_guan.active = true
  26. } else {
  27. this.yinyue_kai.active = true
  28. this.yinyue_guan.active = false
  29. }
  30. }
  31. OnClickYinxiao() {
  32. AudioManager.instance.playBundleAudio("button")
  33. if (User.userData.sound) {
  34. User.setUserData({ sound: false })
  35. AudioManager.instance.yinxiaoValue = 0
  36. this.yinxiao_kai.active = true
  37. this.yinxiao_guan.active = false
  38. } else {
  39. User.setUserData({ sound: true })
  40. AudioManager.instance.yinxiaoValue = 1
  41. this.yinxiao_kai.active = false
  42. this.yinxiao_guan.active = true
  43. }
  44. }
  45. OnClickYinyue() {
  46. AudioManager.instance.playBundleAudio("button")
  47. if (User.userData.music) {
  48. User.setUserData({ music: false })
  49. AudioManager.instance.yinyueValue = 0
  50. this.yinyue_kai.active = true
  51. this.yinyue_guan.active = false
  52. AudioManager.instance.stop()
  53. } else {
  54. AudioManager.instance.playBgm("bgm");
  55. User.setUserData({ music: true })
  56. AudioManager.instance.yinyueValue = 1
  57. this.yinyue_kai.active = false
  58. this.yinyue_guan.active = true
  59. }
  60. }
  61. OnClickBack() {
  62. AudioManager.instance.playBundleAudio("button")
  63. this.node.destroy()
  64. }
  65. }