123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- const SkillApi = require('../net/SkillApi');
- const DWTool = require("../utils/DWTool");
- const GameModule = require("../utils/GameModule");
- const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey;
- cc.Class({
- extends: cc.Component,
- properties: {
- topSkillItems:{
- tooltip: '技能顶部的四个实时技能',
- default: [],
- type: [cc.Node]
- },
-
- skillScrollView: cc.Node,
- mask: cc.Node,
- skillMask: cc.Prefab,
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- this.node.height = cc.view.getVisibleSize().height;
- this.setUpNotification();
- this.skillScrollView.active = false;
- this.handelGuide();
- if (Global.isCheck) {
- this.topSkillItems[3].active = false;
- }
- },
- start () {
- this.getAllSkills().then((respondData) => {
- console.log(respondData);
- /// 初始化这个scrollView
- Global.rcdSkillLevel = respondData.skills2[2].skillLevel;
- this.skillScrollView.getComponent('SkillScrollView').init(respondData);
- this.skillScrollView.active = true;
- this.initTopSkillItem(respondData.skills1);
- this.schedule(this.timeAction, 1);
- }).catch(({code, msg}) => {
- console.log(code, msg);
- });
- },
- onDestroy() {
- GameEvent.off("skillAlert_done", this);
- GameEvent.off('skill_1_unlocked', this);
- GameEvent.off('Fire_state17', this);
- GameEvent.off('skill3_use_begain',this);
- GameEvent.off(GameNotificationKey.GameShowNotificationKey, this);
- },
-
- //// 初始化通知相关
- setUpNotification() {
- /// 点击tabbar导致skill隐藏的通知
- GameEvent.on("skillAlert_done", this, () => {
- this.hidden();
- });
- ///通过 最后一个新手引导
- GameModule.homeGuide.on('Fire_state17', (event) => {
- this.hidden();
- GameEvent.fire(GameNotificationKey.TabbarClickCat);
- }, this);
- this.mask.on(cc.Node.EventType.TOUCH_END, (event) => {
- this.hidden();
- GameEvent.fire(GameNotificationKey.TabbarClickCat);
- }, this);
- GameEvent.on('skill3_use_begain', this, this.handelSkill1Unlocked);
- GameEvent.on(GameNotificationKey.GameShowNotificationKey, this, this.updateTopSkillData);
- },
- updateTopSkillData() {
- this.getAllSkills().then((respondData) => {
- /// 初始化这个scrollView
- this.initTopSkillItem(respondData.skills1);
- let arr = respondData.skills1.concat(respondData.skills2);
- GameModule.skill.skills = arr;
- GameModule.skill.getAllSkillInfo();
- }).catch(({code, msg}) => {
- console.log(code, msg);
- });
- },
- /// 解锁第一个技能的时候需要的动画效果
- handelSkill1Unlocked() {
- let SkillMask = cc.instantiate(this.skillMask).getComponent('SkillMask');
- SkillMask.show();
- },
- /// 显示 单例显示
- show() {
- this.node.setPosition(0, 0);
- this.skillScrollView.getComponent('SkillScrollView').updateUI();
- let scrollView = this.skillScrollView.getComponent(cc.ScrollView);
- scrollView.vertical = true;
- this.handelGuide();
- },
- ///直接隐藏
- hidden() {
- this.node.setPosition(10000, -100000);
- GameModule.homeGuide.getComponent('HomeGuide').changeGuideTask1315(false);
- },
- //// 点击之后隐藏
- hidenAction() {
- GameModule.audioMng.playClickButton();
- this.hidden();
- GameEvent.fire(GameNotificationKey.TabbarClickCat);
- },
- /// 处理新手引导的显示
- handelGuide() {
- let homeGuide = GameModule.homeGuide.getComponent('HomeGuide');
- for (let i = 12; i <= 17; ++ i) {
- let state = 'state' + i;
- if (!homeGuide.isPassGuideState(state)) {
- homeGuide.handleState(state);
- if (i === 13 || i === 15) {
- homeGuide.changeGuideTask1315(true);
- }
- let scrollView = this.skillScrollView.getComponent(cc.ScrollView);
- scrollView.vertical = false;
- break;
- }
- }
- },
- /// 初始化顶部的四个实时技能
- initTopSkillItem(timeSkill) {
- var isAllLocked = true;
- for(let i = 0; i < 3; ++i) {
- let skillItemScript = this.topSkillItems[i].getComponent('SkillTopItem');
- let timeSkillData = timeSkill[i];
- if (timeSkillData.isHave == 1) {
- isAllLocked = false;
- }
- skillItemScript.init(timeSkillData);
- }
- let upDateItemScript = this.topSkillItems[3].getComponent('SkillTopItem');
- upDateItemScript.initUpdateSkill(isAllLocked);
- },
- timeAction() {
- for(let i = 0; i < 4; ++i) {
- let skillItemScript = this.topSkillItems[i].getComponent('SkillTopItem');
- skillItemScript.updateTime();
- }
- },
- /// 网络请求
- getAllSkills() {
- return new Promise((resolve, reject) => {
- // 获取目标用户的建筑
- SkillApi.getAllSkills((respondData) => {
- resolve(respondData);
- }, (code, msg) => {
- reject({code, msg});
- });
- })
- },
- // update (dt) {},
- });
|