123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- import hallScene from "../../hallScene";
- import { App } from "../../Manager/App";
- import SuperListItem from "../SuperScrollview/SuperListItem";
- import TipPanel from "../tipPanel/TipPanel";
- import TipPanelMediator from "../tipPanel/TipPanelMediator";
- import NodeLevel from "./NodeLevel";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class LevelItem extends SuperListItem {
- @property(cc.Label)
- label: cc.Label = null;
- private level: number = 1;
- @property(cc.Node)
- lock: cc.Node = null;
- @property(cc.Node)
- open: cc.Node = null;
- @property(cc.Node)
- pass: cc.Node = null;
- @property([cc.Node])
- star: cc.Node[] = [];
- @property(cc.Node)
- key: cc.Node = null;
- private isPass: boolean = false;
- // LIFE-CYCLE CALLBACKS:
- onLoad() {
- // this.lock.on(cc.Node.EventType.TOUCH_END, this.btnClickCallBack.bind(this), this);
- this.open.on(cc.Node.EventType.TOUCH_END, this.btnClickCallBack.bind(this), this);
- this.pass.on(cc.Node.EventType.TOUCH_END, this.btnClickCallBack.bind(this), this);
- }
- setData(data: any) {
- // console.log('LevelItem:', data)
- this.label.string = data;
- this.level = Number(data);
- // 判断这一关是都通过,通过是否有值
- this.isPass = (App.DataManager.PassProgress[this.level]) ? true : false;
- this.lock.active = !this.isPass;
- this.label.node.active = this.isPass;
-
- if(this.isPass){
- if(App.DataManager.PassProgress[this.level] > 3){
- this.pass.active = true;
- }
- else if(App.DataManager.PassProgress[this.level] > 1){
- this.pass.active = true;
- }
- else{
- this.open.active = true;
- this.pass.active = false;
- }
- for(let i = 0; i < 3; i++){
- let star = this.node.getChildByName("star" + i);
- let passStar = Number(App.DataManager.PassProgress[this.level]);
- star.active = passStar - 1 > i;
- }
- }
- else{
- for(let i = 0; i < 3; i++){
- let star = this.node.getChildByName("star" + i);
- star.active = false;
- }
- }
- console.log('是否通关', App.DataManager.PassProgress[this.level]);
- this.key.active = App.DataManager.PassProgress[this.level] > App.DataManager.keyPos[this.level];
- }
- btnClickCallBack(){
-
- if (this.isPass) {
- if(App.DataManager.PassProgress[this.level] > 3){
- console.log('Game level pass~');
- App.Facade.popView(TipPanelMediator, TipPanel, "Game level pass~", false);
- return;
- }
- else{
- cc.find("Canvas/ChooseLevelPanel/nodeLevel").getComponent(NodeLevel).freshLevelNum(this.level);
- // console.log("aaa---------------", cc.find("Canvas/ChooseLevelPanel/nodeLevel").name);
- }
- }
- else{
- console.log('Level not unlocked~');
- App.Facade.popView(TipPanelMediator, TipPanel, "Level not unlocked~", false);
- return;
- }
- }
- }
|