GM.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { _decorator, Component, EditBox, instantiate, Node, Prefab, ScrollView } from 'cc';
  2. import { User } from 'db://assets/script/Manager/LocalDataMgr';
  3. import { GDM } from '../dtta/JsonMgr';
  4. import { item_changelevel } from './item_changelevel';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('GM')
  7. export class GM extends Component {
  8. @property(Prefab)
  9. item_level: Prefab = null;
  10. @property(EditBox)
  11. editBox_time: EditBox = null;
  12. @property(ScrollView)
  13. scrollview: ScrollView = null;
  14. protected start(): void {
  15. this.ShowLevel()
  16. }
  17. OnClickClose() {
  18. if (this.editBox_time.string.length > 0) {
  19. User.userData.leveltime = parseInt(this.editBox_time.string)
  20. User.saveUserData()
  21. }
  22. GDM.gamecfgMgr.paixuLevelinfo = []
  23. for (let index = 0; index < this.scrollview.content.children.length; index++) {
  24. const element = this.scrollview.content.children[index]
  25. GDM.gamecfgMgr.paixuLevelinfo.push(element.getComponent(item_changelevel).data)
  26. }
  27. console.error(GDM.gamecfgMgr.paixuLevelinfo)
  28. this.node.destroy()
  29. }
  30. ShowLevel() {
  31. for (let index = 0; index < GDM.gamecfgMgr.data.length; index++) {
  32. let node_unit: Node = instantiate(this.item_level)
  33. node_unit.parent = this.scrollview.content
  34. node_unit.getComponent(item_changelevel).Init(GDM.gamecfgMgr.data[index], index)
  35. }
  36. }
  37. }