JSGame = "lt_4096"; G.W = 480; G.H = 800; G.RW = G.W; G.RH = G.H; G.X = 0; G.Y = 0; G.RX2 = G.W; G.RY2 = G.H; const B_SIZE = 110; const B_HSIZE = B_SIZE*0.5; const MAP_X = G.X + (G.W-B_SIZE*4)/2 + B_HSIZE; const MAP_Y = G.Y + 163; const MAP_XS = 8; const MAP_YS = 8; const MOVE_SPEED = 0.09; const BTN_OK = 99; const BTN_OPTION = 100; var COLLECTION_FINISH = 10; const BTN_GOLDSHOP = 101; const BTN_GETFREE = 102; const BTN_COLLECTION = 103; const BTN_SOUND = 104; const BTN_LANGUAGE = 105; const BTN_LOGIN = 106; const BTN_HELP = 107; const BTN_CLOSE = 108; const LOGIN_GOOGLE = 109; const LOGOUT_GOOGLE = 110; const BTN_RANKSCORE = 111; const BTN_ACHIEVEMENT = 112; const BTN_SHARE2 = 120; const BTN_REPLAY = 113; var CMyInfo = cc.Class.extend({ id:"guest", ltype:-1, gift:0, giftNew:0, giftTime:0, cash:0, gitem:{}, lvCheckSum:0, star:0, hint:0, memo:0, gold:0, ugold:0, cstage:0, ucstage:0, ustar:0, test:0, helpItem:null, arcadeHighScore:0, arrCollect:null, ctor:function() { cc.associateWithNative( this, cc.Class ); this.arrCollect = []; }, setItem:function(item, num) { this.gitem[item] = num; Noti.push(item, num); }, setCash:function(cash) { this.cash = cash; Noti.push("cash", cash); }, loadGold:function() { this.gold = LocalDB.ival("gold"); Noti.push("gold", this.gold); }, setGold:function(gold) { this.gold = gold; Noti.push("gold", gold); LocalDB.update("gold", gold); }, addGold:function(gold) { this.setGold(this.gold + int(gold)); }, }); MyInfo = new CMyInfo(); var CScore = cc.Layer.extend({ m_txtTitle:null, m_txtScore:null, ctor:function(w, code, color) { this._super(); cc.associateWithNative( this, cc.Layer ); // 배경화면 // var ibBack = new zg.ImageBox(); // ibBack.init(Main.m_gameDB.getSprite("bgScore"), w, 64, 20); // ibBack.setPosition(0, 0); // ibBack.setAnchorPoint(0.5, 0.5); // this.addChild(ibBack); this.addChild(Main.newSprite("bgScore", 0, 0)); // 점수 타이틀 this.m_txtTitle = BFont.create(0, 12, TEXT_CENTER, LnkLang.val(code), 16); this.addChild(this.m_txtTitle); // 점수 this.m_txtScore = BFont.create(0, -12, TEXT_CENTER, 0, 20); this.addChild(this.m_txtScore); this.m_txtScore.setBold(); this.m_txtScore.setColorHex(color); }, setScore:function(score) { this.m_txtScore.setString(score); }, }); var CGame = cc.Layer.extend({ m_bCreate:false, m_lyrTop:null, m_nLv:0, m_bChanged:false, m_btnSetting:null, m_btnMore:null, m_btnShare:null, m_bUpdate:false, m_lyrBlock:null, m_lyrEffect:null, m_poolEffect:null, m_lyrCollect:null, m_poolCollect:null, m_arrMap:[], m_arrMap2:[], m_arrBlock:[], m_arrTile:[], m_arrNo:[], m_mapInfo:null, m_bnBlock:null, m_sprTitle:null, m_sprTitle2:null, m_state:0, m_nGameScore:0, m_bnScore:null, m_lyrScore:null, m_bTouch:false, m_bMoved:false, m_bReady:false, m_nFinishNum:0, m_nFinishTime:0, m_bScoreSave:false, m_nBestScore:0, m_nMaxNo:0, m_bContinue:true, m_txtGold:null, m_sprGold:null, m_btnGoldShop:null, m_txtGoldTarget:null, m_nGold:0, m_btnInBanner:null, m_btnGetFree:null, m_btnCollection:null, m_sprCollection:null, // 타일 나올 빈도수 설정하기 m_arrRate:[ { "rate":100, "rand":1, }, { "rate":10, "rand":2, }, { "rate":1, "rand":3, }, ], m_arrBest:null, m_http:null, m_psPang:null, m_nXS:4, m_nYS:4, m_txtContent:null, m_lyrReplay:null, m_lyrScore:null, m_lyrBestScore:null, m_lyrTxt:null, ctor:function(db) { this._super(); // cc.associateWithNative( this, cc.Layer ); this.hide(); var listener1 = cc.EventListener.create({ event: cc.EventListener.TOUCH_ONE_BY_ONE, swallowTouches: true, onTouchBegan: this.onTouchBegan.bind(this), onTouchMoved: this.onTouchMoved.bind(this), onTouchEnded: this.onTouchEnded.bind(this) }); cc.eventManager.addListener(listener1, this); }, create:function() { if(this.m_bCreate) return; // 바닥, 블록 배경 this.addChild(Main.newSprite("game_bg", G.CX, G.CY)); this.addChild(Main.newSprite("block_bg", G.CX, G.CY-70)); var i, j; for(i=0; i 30 || Math.abs(this.m_ptMoved.y - pt.y) > 30) { this.m_bMoved = true; this.m_bReady = true; this.m_bChanged = true; if(this.checkGameOver() == false) { this.moveBlock(pt.x - this.m_ptMoved.x, pt.y - this.m_ptMoved.y); // if(int(Game.callGetJni("AdColony_isReady")) == 1) // { // Main.m_lyrContinue.open(); // } // Game.adMob(true); // trace("///"); } else { // 이어하기 가능이면 처리하기 // if(this.m_bContinue == true && VideoAD.isReady() == true) if(this.m_bContinue == true && 0) { Main.m_lyrContinue.open(); // 이어하기 불가로 설정하기 // this.m_bContinue = false; } else { // this.m_state = GAME_OVER; this.gameover(); } } } touch = null; event = null; pt = null; }, onTouchEnded: function(touch, event) { this.m_ptMoved = null; this.m_bTouch = false; touch = null; event = null; }, moveBlock:function(mx, my) { var nMoveNo = 0; var mtile, utile; var bMoved = false; var spr; var onFunc = null; var nMove; var arrMap; var maxNo = 0; if(Math.abs(mx) > Math.abs(my)) { arrMap = this.m_arrMap nMove = mx>0 ? 1 : -1; } else { arrMap = this.m_arrMap2; nMove = my>0 ? 1 : -1; } var arrNo = this.m_arrNo; for(var i=0; i maxNo) maxNo = tile.spr.no; utile.spr.stopAllActions(); utile.spr.setScale(1.0); utile.spr.setPosition(utile); this.onUp(utile.spr); utile.spr.bUp = true; utile.spr.runAction( cc.sequence( cc.moveTo(MOVE_SPEED, mtile), cc.callFunc(this.onUp, this) ) ); utile.spr.tile = mtile mtile.spr = utile.spr; utile.spr = null; onFunc = this.onHide; bMoved = true; j = k; break; } if(mtile != tile) { if(onFunc == this.onEmpty) { tile.spr.tile = mtile mtile.spr = spr; } else { tile.spr.no = 0; tile.spr.tile = null; } tile.spr = null; bMoved = true; } spr.stopAllActions(); spr.setScale(1.0); spr.setPosition(tile); onFunc(spr); spr.bHide = true; spr.runAction( cc.sequence( cc.moveTo(MOVE_SPEED, mtile), cc.callFunc(onFunc, this) ) ); nMoveNo++; } } nMoveNo = null; mtile = null; utile = null; spr = null; onFunc = null; nMove = null; arrMap = null; arrNo = null; if(bMoved == false) { bMoved = null; this.m_bReady = false; return; } bMoved = null; this.runAction( cc.sequence( cc.delayTime(MOVE_SPEED), cc.callFunc(this.onEndMove, this, maxNo) ) ); maxNo = null; GameSnd.play("SOUND_MERGE"); }, onEndMove:function(obj, no) { // 128이상 생성시 if(no >= 6) { GameSnd.play("SOUND_GET_TILE"); } this.randomBlock(); this.m_bReady = false; }, onEmpty:function(obj) { obj.bHide = null; }, onHide:function(obj) { if(obj.bHide == null) return; obj.no = 0; obj.tile = null; obj.hide(); obj.bHide = null; }, getDirection:function(dia, angle) { return cc.p(dia * Math.cos(angle * M_DEG), -dia * Math.sin(angle * M_DEG)); }, onUp:function(obj) { if(obj.bUp == null) return; obj.bUp = null; obj.no++; obj.stop(obj.no); obj.setScale(0.8); obj.runAction( cc.sequence( cc.easeElasticOut(cc.scaleTo(0.4, 1.0), 1.0) ) ); if(obj.no >= 7) { spr = this.m_poolEffect.newSprite("effCircle", obj.x, obj.y); spr.setScale(0.4); spr.runAction( cc.sequence( cc.spawn( cc.scaleTo(0.4, 1.5), cc.fadeOut(0.4) ), cc.hide() ) ); // 별 이팩트 var arrStar = [ [0.3, 1, 75, -120], [0.2, 0.5, 70, -45], [0.3, 0.5, 75, 45], ]; var starNum = obj.no - 3; var angleStep = 360/starNum; var angle = zg.rand(angleStep); for(i=0; i this.m_nFinishNum) { /* var alpha = int(Math.pow(1.5, obj.no) / this.m_nMaxNo * 255); // var alpha = int((obj.no * obj.no) / this.m_nMaxNo * 255); if(alpha > 255) alpha = 255; // this.m_sprTitle.setColor(cc.color(alpha, alpha, alpha, 0xff)); */ this.m_nFinishNum = obj.no; var nNo = Math.pow(2, obj.no); /* // 구글 로그인이 되어 있을 경우에만 처리하기 // 32부터 32768사이이면 업적 unlock하기 if(Login.type == LOGIN_GOOGLE && (nNo >= 32 && nNo <= 32768)) { var aCode = "MAKE_" + nNo; // 업데이트가 안된 업적이면 처리하기 if(G.iVal(aCode) < 1) { Game.callNative("unlockAchievement", Game.getRes(aCode)); G.setVal(aCode, 1) } } nNo = null; */ //unlockAchievement /* if(obj.no < 8) { this.lyrBg.setColor(XRGB(0x826218)); } else { // 2:4, 3:8, 4:16, 5:32, 6:64, 7:128, 8:256, 9:512, 10:1024, 11:2048, 12:4096 // 256-083501 // 512-601060 // 1024-620101 // 2048-a50078 switch(obj.no) { case 8 : this.lyrBg.setColor(XRGB(0x083518)); break; case 9 : this.lyrBg.setColor(XRGB(0x601060)); break; case 10 : this.lyrBg.setColor(XRGB(0x620101)); break; case 11 : this.lyrBg.setColor(XRGB(0xa50078)); break; default : this.lyrBg.setColor(XRGB(0xa50078)); break; } } */ // 4096에 도달했다면 도달 시간 저장하기... if(obj.no == LnkCfg.ival("GAME_FINISH")) { this.finish4096(); Game.submitScore("TIME", Math.round(this.m_nFinishTime), true); } // Game.saveScore(LEADERBOARD_TIME, Math.round(this.m_nFinishTime), true); } this.addScore(Math.pow(2, obj.no)); // this.m_bnScore.add(obj.getPositionX(), obj.getPositionY(), Math.pow(2, obj.no), 101); }, addCollection:function(obj) { var no = obj.no; if(no >= 2 && no <= 12) { MyInfo.arrCollect[no]++; // 컬랙션을 다 모으지 않았으면 처리하기 if(MyInfo.arrCollect[no] <= COLLECTION_FINISH) { var spr = this.m_poolCollect.newSprite("block", obj); spr.stop(obj.no); // 보너스 아이템 이동하기 spr.runAction( cc.sequence( cc.spawn( cc.jumpTo(0.85, cc.p(200, 423), -200, 1), cc.sequence( cc.scaleTo(0.5, 1.5), cc.scaleTo(0.3, 0.5) ) ), // cc.fadeOut(0.1), cc.hide(), cc.callFunc(this.collectionEnd, this, no) ) ); } LocalDB.uadd("collect"+ no, 1); } }, collectionEnd:function(self, no) { this.m_sprCollection.show(); this.m_sprCollection.setHexColor(0x777777); this.m_sprCollection.runAction( cc.sequence( cc.tintTo(0.3, 0xff, 0xff, 0xff), cc.tintTo(0.3, 0, 0, 0), cc.hide() ) ); if(MyInfo.arrCollect[no] >= COLLECTION_FINISH) { Main.m_gameDB.setFrameCopy("block", no+8, no); var arrTile = this.m_arrTile; var block; for(var i=arrTile.length; i--; ) { block = arrTile[i]; // 이미 존재하면 패스... if(block.spr == null) continue; if(block.spr.no == no) { block.spr.stop(1); block.spr.stop(no); } } } }, checkGameOver:function() { var i, j; var arrTile = this.m_arrTile; // 타일이 모두 생성되었는지 체크한다... for(i=arrTile.length; i--; ) { if(arrTile[i].spr == null) { i = null; j = null; arrTile = null; return false; } } // 실제로 타일 체크하기... for(i=0; i= COLLECTION_FINISH) { this.m_gameDB.copyFrame("block", i+8, i); } } this.m_lyrGame = this.newChild(new CGame(this.m_mapDB), 20); // 게임 this.m_lyrResult = this.newChild(new CResult()); // 결과 this.m_lyrCollection = this.newChild(new CCollection()); // 콜랙션 this.m_lyrOption = this.newChild(new COption()); // 옵션 this.m_lyrHelp = this.newChild(new CHelp(), 120); // 도움말 this.m_lyrContinue = this.newChild(new CContinue()); // 이어하기 this.m_lyrRestart = this.newChild(new CRestart()); // 다시시작 this.m_lyrGoldShop = this.newChild(new CGoldShop(), 150); // 골드상점 this.m_lyrLoading = this.newChild(new CLoading(), 199); // 로딩중 this.m_sprBG = this.newSprite("game_bg", G.CX, G.CY); this.addChild(this.m_sprBG, 98); this.m_sprBG.hide(); // 페이드 this.m_fadeBlock = new zg.Fade(G.RX, G.RY, G.RW, G.RH, 0x000000); this.addChild(this.m_fadeBlock, 99); this.m_fadeBlockBlack = new zg.Fade(G.RX, G.RY, G.RW, G.RH, 0x000000); this.addChild(this.m_fadeBlockBlack, 99); this.m_fadeBlockWhite = new zg.Fade(G.RX, G.RY, G.RW, G.RH, 0xff0000); this.addChild(this.m_fadeBlockWhite, 99); this.m_lyrGame.readyGame(); // this.m_lyrResult.open(0, 10, 100); } });