|
|
|
@ -9,8 +9,12 @@ const {ccclass, property, } = cc._decorator;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum moduleState {
|
|
|
|
export enum moduleState {
|
|
|
|
"INIT",
|
|
|
|
INIT1 = 0,
|
|
|
|
|
|
|
|
INIT2 = 1,
|
|
|
|
|
|
|
|
Ready = 2,
|
|
|
|
|
|
|
|
Spining = 3,
|
|
|
|
|
|
|
|
Stopping = 4,
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@ -18,10 +22,10 @@ enum moduleState {
|
|
|
|
export class gameMY extends cc.Component {
|
|
|
|
export class gameMY extends cc.Component {
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
columnCount = 5;
|
|
|
|
columnCount:number = 5;
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
itemSize = 240;
|
|
|
|
itemSize:number = 240;
|
|
|
|
|
|
|
|
|
|
|
|
@property(cc.Label)
|
|
|
|
@property(cc.Label)
|
|
|
|
betString: cc.Label = null;
|
|
|
|
betString: cc.Label = null;
|
|
|
|
@ -32,7 +36,6 @@ export class gameMY extends cc.Component {
|
|
|
|
@property(cc.Label)
|
|
|
|
@property(cc.Label)
|
|
|
|
balanceString: cc.Label = null;
|
|
|
|
balanceString: cc.Label = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property({type: cc.Prefab})
|
|
|
|
@property({type: cc.Prefab})
|
|
|
|
columnPrefab: cc.Prefab | null = null;
|
|
|
|
columnPrefab: cc.Prefab | null = null;
|
|
|
|
|
|
|
|
|
|
|
|
@ -46,6 +49,10 @@ export class gameMY extends cc.Component {
|
|
|
|
private balanceNumber: number;
|
|
|
|
private balanceNumber: number;
|
|
|
|
private bigFrameNumber: number;
|
|
|
|
private bigFrameNumber: number;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private stopCount:number;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nowState: moduleState = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// item 圖片資源存放區
|
|
|
|
// item 圖片資源存放區
|
|
|
|
itemNameMapping = {
|
|
|
|
itemNameMapping = {
|
|
|
|
'item_01':1, 'item_02':2, 'item_03':3, 'item_04':4, 'item_9':5,
|
|
|
|
'item_01':1, 'item_02':2, 'item_03':3, 'item_04':4, 'item_9':5,
|
|
|
|
@ -56,13 +63,14 @@ export class gameMY extends cc.Component {
|
|
|
|
item_spriteFrame = {};
|
|
|
|
item_spriteFrame = {};
|
|
|
|
itemBlur_spriteFrame = {};
|
|
|
|
itemBlur_spriteFrame = {};
|
|
|
|
|
|
|
|
|
|
|
|
init_Complete:boolean = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected onLoad () {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected onLoad () {
|
|
|
|
|
|
|
|
|
|
|
|
this.unitTestInit(); // for engineer use
|
|
|
|
this.unitTestInit(); // for engineer use
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.onColumnsSignal()
|
|
|
|
|
|
|
|
|
|
|
|
// 讀取 item 圖片資源
|
|
|
|
// 讀取 item 圖片資源
|
|
|
|
cc.resources.loadDir('item',cc.SpriteFrame, (err: any, sF) => {
|
|
|
|
cc.resources.loadDir('item',cc.SpriteFrame, (err: any, sF) => {
|
|
|
|
sF.forEach( (eachSpriteFrame)=>{
|
|
|
|
sF.forEach( (eachSpriteFrame)=>{
|
|
|
|
@ -82,26 +90,48 @@ export class gameMY extends cc.Component {
|
|
|
|
protected start () {
|
|
|
|
protected start () {
|
|
|
|
this.betNumber = 50;
|
|
|
|
this.betNumber = 50;
|
|
|
|
|
|
|
|
|
|
|
|
this.slotBoard.addChild( cc.instantiate(this.columnPrefab) )
|
|
|
|
this.slotBoard.addChild( cc.instantiate(this.columnPrefab), 1 )
|
|
|
|
this.slotBoard.addChild( cc.instantiate(this.columnPrefab) )
|
|
|
|
this.slotBoard.addChild( cc.instantiate(this.columnPrefab), 2 )
|
|
|
|
this.slotBoard.addChild( cc.instantiate(this.columnPrefab) )
|
|
|
|
this.slotBoard.addChild( cc.instantiate(this.columnPrefab), 3 )
|
|
|
|
this.slotBoard.addChild( cc.instantiate(this.columnPrefab) )
|
|
|
|
this.slotBoard.addChild( cc.instantiate(this.columnPrefab), 4 )
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected update (dt) {
|
|
|
|
protected update (dt) {
|
|
|
|
|
|
|
|
|
|
|
|
if(!this.init_Complete){
|
|
|
|
switch(this.nowState){
|
|
|
|
// 完成圖片載入再啟動 column
|
|
|
|
case moduleState.INIT1:
|
|
|
|
if((Object.keys(this.item_spriteFrame).length === 12)){
|
|
|
|
// 檢查圖片載入完成後
|
|
|
|
for(let i=0;i<=5;i++){
|
|
|
|
// 將必要資訊餵給 column 後再 active column
|
|
|
|
this.slotBoard.children[i].getComponent('columnControl').gameModule = this.node;
|
|
|
|
// 再完成初始化
|
|
|
|
this.slotBoard.children[i].active = true;
|
|
|
|
if((Object.keys(this.item_spriteFrame).length === Object.keys(this.itemNameMapping).length)){
|
|
|
|
this.init_Complete=true;
|
|
|
|
for(let i=0; i<this.columnCount; i++){
|
|
|
|
|
|
|
|
this.slotBoard.children[i].getComponent('columnControl').gameModule = this.node;
|
|
|
|
|
|
|
|
this.slotBoard.children[i].active = true;
|
|
|
|
|
|
|
|
this.nowState = moduleState.INIT2;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case moduleState.INIT2:
|
|
|
|
|
|
|
|
for(let i=0; i<this.columnCount; i++){
|
|
|
|
|
|
|
|
cc.log(this.slotBoard.children[i].x)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.nowState = moduleState.Ready;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case moduleState.Ready:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case moduleState.Spining:
|
|
|
|
|
|
|
|
this.stopCount = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case moduleState.Stopping:
|
|
|
|
|
|
|
|
if(this.stopCount == 5){
|
|
|
|
|
|
|
|
this.nowState = moduleState.Ready;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -115,22 +145,44 @@ export class gameMY extends cc.Component {
|
|
|
|
this.betNumber -= 50;
|
|
|
|
this.betNumber -= 50;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.betString.string = "" + this.betNumber
|
|
|
|
this.betString.string = "" + this.betNumber
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onSpinBtnClick():void {
|
|
|
|
onSpinBtnClick():void {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(this.nowState){
|
|
|
|
|
|
|
|
case moduleState.Ready:
|
|
|
|
|
|
|
|
this.nowState = moduleState.Spining;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case moduleState.Spining:
|
|
|
|
|
|
|
|
this.nowState = moduleState.Stopping;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
cc.log("do nothing");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onColumnsSignal():void {
|
|
|
|
|
|
|
|
this.node.on('AColumnStop', ()=>{
|
|
|
|
|
|
|
|
this.stopCount += 1;
|
|
|
|
|
|
|
|
}, this)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cc.log("nothing");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unitTestInit():void {
|
|
|
|
unitTestInit():void {
|
|
|
|
// for unitTest 1
|
|
|
|
// for unitTest 1
|
|
|
|
this.node.on('Bob', (arg1)=>{
|
|
|
|
this.node.on('Bob', (arg1)=>{
|
|
|
|
cc.log("columnControl Recieve Bob say " + arg1)
|
|
|
|
cc.log("gameModule Recieve Bob say " + arg1)
|
|
|
|
}, this)
|
|
|
|
}, this)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|