1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- import GameModel from "../Model/GameModel";
- import {GRID_WIDTH, GRID_HEIGHT} from '../Model/ConstValue';
- import Toast from '../Utils/Toast';
- import SdkUtil from "../Utils/SdkUtil";
- cc.Class({
- extends: cc.Component,
- properties: {
- grid: {
- default: null,
- type: cc.Node
- },
- skillTip: {
- default: null,
- type: cc.Node
- },
- isVideoAd: false
- },
- isCrushOne: false,
- isStepPause: false,
- // use this for initialization
- onLoad: function () {
- SdkUtil.Instance.motivational_Video_Load()
- this.gameModel = new GameModel();
- this.gameModel.init(4);
- this.gridScript = this.grid.getComponent("GridView");
- this.gridScript.setController(this);
- this.gridScript.initWithCellModels(this.gameModel.getCells());
- },
- selectCell: function (pos) {
- return this.gameModel.selectCell(pos);
- },
- cleanCmd: function () {
- this.gameModel.cleanCmd();
- },
- processCrushOne(pos){
- return this.gameModel.processCrushOne(pos)
- },
- onSkill(e, type){
- if(this.isVideoAd){
- SdkUtil.Instance.motivational_Video_Show(()=>{
- this[type]()
- }, ()=>{
- console.log('激励广告加载失败')
- })
- }else{
- this[type]()
- }
- },
- onSkillCrushOne(){
- if(this.gridScript.isInPlayAni) return
- this.isCrushOne = true
- const msg = this.skillTip.getChildByName('msg')
- msg.getComponent(cc.Label).string = '选择一个需要消除的块'
- this.showSkillTip(true)
- },
- onSkillStepPause(){
- if(this.gridScript.isInPlayAni) return
- this.isStepPause = true
- const msg = this.skillTip.getChildByName('msg')
- msg.getComponent(cc.Label).string = '步数暂停中'
- this.showSkillTip(true)
- },
- onSkillShuffle(){
- if(this.gridScript.isInPlayAni) return
- this.grid.children.forEach(item=>{
- if(item.name != 'bg') item.destroy()
- })
- this.gameModel = new GameModel();
- this.gameModel.init(6);
- this.gridScript = this.grid.getComponent("GridView");
- this.gridScript.setController(this);
- this.gridScript.initWithCellModels(this.gameModel.getCells());
- },
- showSkillTip(isShow){
- this.skillTip.active = isShow
- }
- });
|