interact_scene.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { _decorator, Component, instantiate, Node, Prefab, Widget } from 'cc';
  2. import { ui_base } from '../../run/ui/ui_base';
  3. import { interact_scene_data, scene_item_data } from '../../../data/data';
  4. import { tools } from '../../tools';
  5. import { scene_page } from '../../run/scene_page';
  6. import { taskServce } from '../TaskSchedule/taskServce';
  7. const { ccclass, property } = _decorator;
  8. @ccclass('interact_scene')
  9. export class interact_scene extends ui_base {
  10. @property(Prefab) scenePagePrefab:Prefab = null;
  11. @property(Node) content:Node = null;
  12. private mInteractScene:interact_scene_data;
  13. private mCurChildScene:scene_page = null;
  14. protected init(): void {
  15. this.mInteractScene = this.mTopData._interact_scene_data;
  16. if(this.mInteractScene===null||this.mInteractScene.scene.page_list.length<=0){
  17. return tools.showToast("错误的配置子场景")
  18. }
  19. // this.loadChildScene()
  20. }
  21. loadChildScene(){
  22. if(this.content.children.length<=0){
  23. const item_data:scene_item_data = this.mInteractScene.scene.page_list[0];
  24. let item:Node = instantiate(this.scenePagePrefab);
  25. item.parent = this.content;
  26. item.getComponent(Widget).target = this.content;
  27. item.getComponent(scene_page).initView(item_data)
  28. this.mCurChildScene = item.getComponent(scene_page)
  29. taskServce.StartChildSceneTask(item_data._task_data)
  30. }
  31. }
  32. }