const {ccclass, property} = cc._decorator; import {gameMY, moduleState, columnCondition} from './gameModule'; import {columnControl, columnState} from './columnControl'; @ccclass export default class NewClass extends cc.Component { @property((cc.Node)) gameModule: cc.Node = null; @property((cc.Node)) columnControl: cc.Node = null; private secCounter: number = 0; private fpsCount: number = 0; private gameModuleScript; private columnControlScript; spinCondition:columnCondition = { finalResult:[3,2,1], delayTime:100, accelerateTime:0.5, slowdownTime:0.5, holdspeedTime:0.5, N:2}; protected onLoad () { cc.log("this is ee onLoad"); // 呼叫其他 script 的方法或資源 this.gameModuleScript = this.gameModule.getComponent('gameMY') this.columnControlScript = this.columnControl.getComponent('columnControl') } protected onEnable(){ cc.log("this is ee onEnable"); } protected start () { cc.log("this is ee start"); this.secCounter = 0; // this.columnControlScript.spinCondition = this.spinCondition; } tempValue = true protected update (dt) { this.secCounter += dt; this.fpsCount += 1; // 測試 cc.resources.loadDir 載入時間 ==> 結論: 約需要 0.2~0.5秒 if(this.tempValue){ if(!(Object.keys(this.gameModuleScript.item_spriteFrame).length === 0)){ cc.log(" .loadDir Complete : " + this.secCounter) this.tempValue = false } } // if(this.secCounter >= 5) { // cc.log("engineer Function Update : " + this.fpsCount) // this.secCounter = 0 // this.fpsCount = 0 // } // cc.log(dt) if(this.test7on){ if(this.secCounter > 2){ this.columnControlScript.nowState = columnState.Slowing; this.secCounter = 0; } let a = this.columnControlScript.updateSpeedFactor(this.secCounter); cc.log("SF:" + a + ". T:" + this.secCounter); }else if(this.secCounter >= 5){ cc.log("engineer Function Update : " + this.fpsCount) this.secCounter = 0 this.fpsCount = 0 } } protected onDisable(): void { cc.log("this is ee onDisable") } unitTest1():void { this.gameModule.emit('Bob', 'unitTest1 Success') } disableColumn():void { // this.node.active = !this.node.active; this.columnControl.active = !this.columnControl.active; } unitTest3():void { // @ts-ignore this.itemPool = Object.values(this.gameModuleScript.itemNameMapping) for(let i=0;i{ this.columnControlScript.nowState = columnState.Spining; }, this.spinCondition.delayTime); } test7on:boolean = false; test7():void { this.test7on = !this.test7on; this.secCounter = 0 } otherLoadingMethod(){ const symbol = { 1: 'item_01', 2: 'item_02', 3: 'item_03', 4: 'item_04', 5: 'item_a', 6: 'item_k', 7: 'item_q', 8: 'item_j', 9: 'item_9', 10: 'item_10', 11: 'item_scatter', 12: 'item_wild', } const symbolSpriteList: Map = new Map() Object.keys(symbol).forEach((k, i) => { cc.resources.load(`poker/cat/${symbol[k]}`, cc.SpriteFrame, (err, sp: cc.SpriteFrame) => { symbolSpriteList.set(k, sp) }) }) } } // 棄置的扣 // 動畫相關 // actionSet = { // "stayPosition": cc.moveTo(0, new cc.Vec2(0, 240)), // "rollingUp2Button": cc.sequence(cc.moveTo(0, new cc.Vec2(0, 240)), cc.moveBy(1.5, new cc.Vec2(0, -240))), // }; // if(this.nowAction.isDone() == true) { // let a = this.itemList[Math.floor(Math.random() * 12)]; // this.columnItem.unshift( a ); // this.columnItem.pop(); // //換圖 // for(let i=0;i