difenduandada
2024-12-31 34abe6963b344c882358274957f4b992456fee40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
"use strict";
cc._RF.push(module, '58d29SBvEpKKr6JEg3T43Qw', 'hallows_preview_item_panel');
// Scripts/mod/hallows/view/hallows_preview_item_panel.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-02-20 20:59:54
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var HallowsConst = require("hallows_const");
 
var HallowsController = require("hallows_controller");
 
var HallowsEvent = require("hallows_event");
 
var Hallows_preview_itemPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("hallows", "hallows_preview_item");
    this.hallows_status = HallowsConst.Status.close;
    this.ctrl = HallowsController.getInstance();
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {},
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    this.container = this.root_wnd;
    this.hallows_select_node = this.root_wnd.getChildByName("hallows_select_node");
    this.hallows_select_sk = this.seekChild("hallows_select_node", sp.Skeleton);
    this.hallows_pos_node = this.root_wnd.getChildByName("hallows_pos_node");
    this.hallows_pos_node.setScale(0.65);
    this.hallows_pos_sk = this.seekChild("hallows_pos_node", sp.Skeleton);
    this.name_label = this.root_wnd.getChildByName("name_label").getComponent(cc.Label);
    ;
    this.hallows_bg = this.root_wnd.getChildByName("bg");
  },
  setData: function setData(data) {
    this.data = data;
 
    if (this.root_wnd) {
      this.updateData();
    }
  },
  updateData: function updateData() {
    if (this.data == null) return;
    var hallows_id = this.data.id; //引导需要
 
    this.container.name = "hallows_" + hallows_id;
    this.name_label.string = this.data.name;
    var action = PlayerAction.action_2;
    var cur_hallows_id = this.ctrl.getModel().getCurActivityHallowsId(); // 当前进行中的神器id
 
    if (cur_hallows_id == hallows_id) {
      this.hallows_status = HallowsConst.Status.underway;
      this.hallows_pos_node.color = new cc.Color(169, 169, 169, 255); // setChildUnEnabled(true, this.hallows_model)
 
      var anima_path = PathTool.getSpinePath(this.data.effect, "action");
      this.loadRes(anima_path, function (ske_data) {
        this.hallows_pos_sk.skeletonData = ske_data;
        this.hallows_pos_sk.setAnimation(0, PlayerAction.action_1, true);
      }.bind(this));
      this.handleEffect(true);
    } else if (this.ctrl.getModel().getHallowsById(hallows_id)) {
      this.hallows_status = HallowsConst.Status.open;
      this.hallows_pos_node.color = new cc.Color(255, 255, 255, 255); // setChildUnEnabled(false, this.hallows_model)
 
      var anima_path = PathTool.getSpinePath(this.data.effect, "action");
      this.loadRes(anima_path, function (ske_data) {
        this.hallows_pos_sk.skeletonData = ske_data;
        this.hallows_pos_sk.setAnimation(0, PlayerAction.action_2, true);
      }.bind(this));
    } else {
      this.hallows_status = HallowsConst.Status.close;
      this.hallows_pos_node.color = new cc.Color(169, 169, 169, 255); // setChildUnEnabled(true, this.hallows_model)
 
      var anima_path = PathTool.getSpinePath(this.data.effect, "action");
      this.loadRes(anima_path, function (ske_data) {
        this.hallows_pos_sk.skeletonData = ske_data;
        this.hallows_pos_sk.setAnimation(0, PlayerAction.action_1, true);
      }.bind(this));
    }
  },
  handleEffect: function handleEffect(status) {
    if (!status) {
      if (this.hallows_select_sk) {
        this.hallows_select_sk.setToSetupPose();
        this.hallows_select_sk.clearTracks();
      }
 
      if (this.hallows_pos_sk) {
        this.hallows_pos_sk.setToSetupPose();
        this.hallows_pos_sk.clearTracks();
      }
    } else {
      var anima_path = PathTool.getSpinePath(Config.effect_data.data_effect_info[546], "action");
      this.loadRes(anima_path, function (ske_data) {
        this.hallows_select_sk.skeletonData = ske_data;
        this.hallows_select_sk.setAnimation(0, PlayerAction.action, true);
      }.bind(this));
    }
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    this.container.on(cc.Node.EventType.TOUCH_END, function () {
      Utils.playButtonSound(ButtonSound.Normal);
 
      this._onClickContainer();
    }, this);
  },
  _onClickContainer: function _onClickContainer() {
    if (this.hallows_status == HallowsConst.Status.close) {
      message(Utils.TI18N("解锁上一神器后开启"));
    } else {
      //判断一下神器界面是否正在显示,没显示则打开它
      if (this.ctrl.getHallowsRoot()) {
        gcore.GlobalEvent.fire(HallowsEvent.UndateHallowsInfoEvent, this.data.id);
      } else {
        this.ctrl.openHallowsMainWindow(true, this.data.id);
      }
 
      this.ctrl.openHallowsPreviewWindow(false);
    }
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {
    this.updateData();
  },
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    this.handleEffect(false);
  }
});
 
cc._RF.pop();