1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636 |
- /**
- * @author liaomengcheng
- */
- FZ.GRID_COOR = FZ.newClass({
- line: 0,
- col: 0,
- init: function(){
- this.line = 0;
- this.col = 0;
- }
- });
- FZ.DiamondManager = FZ.newClass({
- EVT_MOUSE_OVER: "mouseover",
- EVT_MOUSE_MOVE: "mousemove",
- EVT_MOUSE_OUT: "mouseout",
- EVT_MOUSE_CLICK: "click",
-
- m_hintX: 0,
- m_hintY: 0,
- m_hintScore: null,
- m_last_selected: -1,
- // m_spr: null,
- m_dialog: false,
- m_leftNum: -1,
- m_allPets: null,
- m_missDiamonds: null,
- // m_worldMatrix: null,
- m_hintCount: 0,
- m_bonus_time: 0,
- m_firstPet: null,
- m_secondPet: null,
- m_PetFirstIndex: 0,
- m_PetSecondIndex: 0,
- m_drawLineTime: 0,
- m_left_pet: 0,
- m_ctx: null,
- m_level: 0,
- m_displayPetsIndex: null,
- m_reset_finished: true,
- m_parent: null,
- m_observer: null,
- m_stop_bubble: false,
-
- m_call_mOver: null,
- m_call_mOut: null,
- m_call_mMove: null,
- m_call_mClick: null,
-
- m_call_tStart: null,
- m_call_tMove: null,
- m_call_tEnd: null,
- m_div_line: [],
- isDebug: false,
- m_debug_div: null,
- init: function(){
- this.m_hintX = 0;
- this.m_hintY = 0;
- this.m_hintScore = "";
- this.m_last_selected = -1;
- // this.m_spr = null;
- this.m_dialog = false;
- this.m_leftNum = -1;
- // this.m_worldMatrix = new FZ.Math.Matrix3();
- // this.m_worldMatrix.identity();
- this.m_allPets = (this.m_allPets || []);
- this.m_missDiamonds = (this.m_missDiamonds || []);
- this.m_hintCount = 0;
- this.m_firstPet = null;
- this.m_secondPet = null;
- this.m_PetFirstIndex = 0;
- this.m_PetSecondIndex = 0;
- this.m_drawLineTime = 0;
- this.m_left_pet = FZ.GameDefs.ALL_PET_NUM;
-
- for (var index = 0; index < 3; ++index) {
- this.m_div_line[index] = document.createElement("div");
- this.m_div_line[index].style.position = "absolute";
- this.m_div_line[index].style.backgroundRepeat = "no-repeat";
- this.m_div_line[index].style.backgroundColor = "#ffff00";
- // this.m_div_line[index].style.display = "none";
- this.m_div_line[index].style.visibility = "hidden";
- FZ.DivManager.addChild(this.m_div_line[index]);
- }
- if (this.isDebug) {
- this.m_debug_div = document.createElement("div");
- this.m_debug_div.style.zIndex = 500;
- this.m_debug_div.style.width = 320 + "px";
- this.m_debug_div.style.height = 40 + "px";
- this.m_debug_div.style.left = 0 + "px";
- this.m_debug_div.style.top = 438 + "px";
- this.m_debug_div.style.position = "absolute";
- this.m_debug_div.style.color = "#ff0";
- this.m_debug_div.style.fontSize = FZ.GameDefs.STATS_FONT_SIZE + "px";
- this.m_debug_div.style.fontFamily = "Arial";
- this.m_debug_div.style.lineHeight = 40 + "px";
- this.m_debug_div.style.textAlign = "center";
- this.m_debug_div.style.innerHTML = "";
- FZ.DivManager.addChild(this.m_debug_div);
- }
- },
- removeEvent: function(){
- if (!this.m_parent) {
- return;
- }
- if (FZ.TARGET_DEF.MOBILE === FZ.TargetPort) {
-
- FZ.EventRemove(this, this.m_parent, FZ.EVENT_DEF.T_START, this.m_call_tStart);
- this.m_call_tStart = null;
- FZ.EventRemove(this, this.m_parent, FZ.EVENT_DEF.T_MOVE, this.m_call_tMove);
- this.m_call_tMove = null;
- FZ.EventRemove(this, this.m_parent, FZ.EVENT_DEF.T_END, this.m_call_tEnd);
- this.m_call_tEnd = null;
-
- }
- else {
-
- FZ.EventRemove(this, this.m_parent, FZ.EVENT_DEF.M_OVER, this.m_call_mOver);
- this.m_call_mOver = null;
- FZ.EventRemove(this, this.m_parent, FZ.EVENT_DEF.M_OUT, this.m_call_mOut);
- this.m_call_mOut = null;
- FZ.EventRemove(this, this.m_parent, FZ.EVENT_DEF.M_MOVE, this.m_call_mMove);
- this.m_call_mMove = null;
- FZ.EventRemove(this, this.m_parent, FZ.EVENT_DEF.M_CLICK, this.m_call_mClick);
- this.m_call_mClick = null;
-
- }
- },
- setParent: function(obj){
- // var that = this;
-
- if (obj) {
- this.m_parent = obj;
- if (FZ.TARGET_DEF.MOBILE === FZ.TargetPort) {
- FZ.EventHandler(this, this.m_parent, FZ.EVENT_DEF.T_START, this.mouseHandler);
- FZ.EventHandler(this, this.m_parent, FZ.EVENT_DEF.T_MOVE, this.mouseHandler);
- FZ.EventHandler(this, this.m_parent, FZ.EVENT_DEF.T_END, this.mouseHandler);
-
- // this.m_parent.ontouchstart = this.m_parent.ontouchmove = this.m_parent.ontouchend = function(evt) {
- // that.mouseHandler.call(that, evt);
- // };
- }
- else {
-
- FZ.EventHandler(this, this.m_parent, FZ.EVENT_DEF.M_OVER, this.mouseHandler);
- FZ.EventHandler(this, this.m_parent, FZ.EVENT_DEF.M_MOVE, this.mouseHandler);
- FZ.EventHandler(this, this.m_parent, FZ.EVENT_DEF.M_OUT, this.mouseHandler);
- FZ.EventHandler(this, this.m_parent, FZ.EVENT_DEF.M_CLICK, this.mouseHandler);
-
- // this.m_parent.onclick = this.m_parent.onmousemove = this.m_parent.onmouseout = this.m_parent.onmouseover = function(evt){
- // that.mouseHandler.call(that, evt);
- // };
- }
- }
- else
- if (this.m_parent) {
-
- if (FZ.TARGET_DEF.MOBILE === FZ.TargetPort) {
- FZ.EventRemove(this, this.m_parent, FZ.EVENT_DEF.T_START, this.m_call_tStart);
- this.m_call_tStart = null;
- FZ.EventRemove(this, this.m_parent, FZ.EVENT_DEF.T_MOVE, this.m_call_tMove);
- this.m_call_tMove = null;
- FZ.EventRemove(this, this.m_parent, FZ.EVENT_DEF.T_END, this.m_call_tEnd);
- this.m_call_tEnd = null;
-
- // this.m_parent.ontouchstart = null;
- // this.m_parent.ontouchmove = null;
- // this.m_parent.ontouchend = null;
- }
- else {
-
- FZ.EventRemove(this, this.m_parent, FZ.EVENT_DEF.M_OVER, this.m_call_mOver);
- this.m_call_mOver = null;
- FZ.EventRemove(this, this.m_parent, FZ.EVENT_DEF.M_OUT, this.m_call_mOut);
- this.m_call_mOut = null;
- FZ.EventRemove(this, this.m_parent, FZ.EVENT_DEF.M_MOVE, this.m_call_mMove);
- this.m_call_mMove = null;
- FZ.EventRemove(this, this.m_parent, FZ.EVENT_DEF.M_CLICK, this.m_call_mClick);
- this.m_call_mClick = null;
-
- // this.m_parent.onmouseover = null;
- // this.m_parent.onmouseout = null;
- // this.m_parent.onmousemove = null;
- // this.m_parent.onclick = null;
- }
-
- //// this.m_parent = obj;
- // if(FZ.TARGET_DEF.MOBILE === FZ.TargetPort) {
- // this.m_parent.ontouchstart = null;
- // this.m_parent.ontouchmove = null;
- // this.m_parent.ontouchend = null;
- // }
- // else {
- // this.m_parent.onmouseover = null;
- // this.m_parent.onmouseout = null;
- // this.m_parent.onmousemove = null;
- // this.m_parent.onmouseclick = null;
- // }
- }
-
- // this.createLabels();
-
- },
-
- setBubble: function(value){
- this.m_stop_bubble = value;
- },
-
- setObserver: function(obj){
- this.m_observer = obj;
- },
- setCtx: function(ctx){
- this.m_ctx = ctx;
- },
-
- setASprite: function(spr){
- this.m_spr = spr;
- },
-
- clearAllPets: function(){
- var pet = null;
- while (this.m_allPets.length > 0) {
- pet = this.m_allPets.pop();
- if (pet) {
- pet.destroy();
- }
- }
-
- },
-
- getTouchPetIndex: function(posX, posY){
- var index = 0;
-
- if ((posX < FZ.GameDefs.DREAMPET_OFFSET_X) ||
- (posX > (FZ.GameDefs.DREAMPET_OFFSET_X + (FZ.GameDefs.DREAMPET_NUM_COL + 1) * FZ.GameDefs.GRID_WIDTH)) ||
- (posY < FZ.GameDefs.DREAMPET_OFFSET_Y) ||
- (posY > (FZ.GameDefs.DREAMPET_OFFSET_Y + (FZ.GameDefs.DREAMPET_NUM_LINE + 1) * FZ.GameDefs.GRID_HEIGHT))) {
- return -1;
- }
- var col = (posY - FZ.GameDefs.DREAMPET_OFFSET_Y) / FZ.GameDefs.GRID_HEIGHT;
- var line = (posX - FZ.GameDefs.DREAMPET_OFFSET_X) / FZ.GameDefs.GRID_WIDTH;
- index = col * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + line;
- if (index >= ((FZ.GameDefs.DREAMPET_NUM_LINE + 2) * (FZ.GameDefs.DREAMPET_NUM_COL + 2))) {
- index = -1;
- }
- return index;
- },
- checkFocus: function(){
-
- var index = 0;
-
- for (index = 0; index < (FZ.GameDefs.ALL_GENERAL); index++) {
- var state = this.m_allPets[index].getState();
- if (state === FZ.GameDefs.DREAMPET_FOCUS) {
- //alert(index);
- return true;
- }
- }
- return false;
- },
- searchHint: function(){
- var p1 = new FZ.GRID_COOR();
- var p2 = new FZ.GRID_COOR();
- var randomId = Math.floor(FZ.Math.random(0, FZ.GameDefs.ALL_GENERAL - 1));
-
- for (var PetFirstIndex = randomId; PetFirstIndex < FZ.GameDefs.ALL_GENERAL; PetFirstIndex++) {
- if (this.m_allPets[PetFirstIndex].getState() === FZ.GameDefs.DREAMPET_REMOVE)
- continue;
- p1.col = this.m_allPets[PetFirstIndex].getCol();
- p1.line = this.m_allPets[PetFirstIndex].getLine();
- for (var PetSecondIndex = PetFirstIndex + 1; PetSecondIndex < FZ.GameDefs.ALL_GENERAL; PetSecondIndex++) {
- if (this.m_allPets[PetSecondIndex].getState() === FZ.GameDefs.DREAMPET_REMOVE)
- continue;
- if (this.m_allPets[PetFirstIndex].getStyle() !== this.m_allPets[PetSecondIndex].getStyle())
- continue;
- p2.col = this.m_allPets[PetSecondIndex].getCol();
- p2.line = this.m_allPets[PetSecondIndex].getLine();
- if ((FZ.AG.SearchSpecialPath.getPath(this.m_allPets, (FZ.GameDefs.DREAMPET_NUM_LINE + 2), (FZ.GameDefs.DREAMPET_NUM_COL + 2), p1.col, p1.line, p2.col, p2.line)) !== null) {
- this.m_allPets[PetFirstIndex].setState(FZ.GameDefs.DREAMPET_FLASH_HINT);
- this.m_allPets[PetFirstIndex].setPetFocus();
- this.m_allPets[PetSecondIndex].setState(FZ.GameDefs.DREAMPET_FLASH_HINT);
- this.m_allPets[PetSecondIndex].setPetFocus();
- // this.m_PetFirstIndex = PetFirstIndex;
- // this.m_PetSecondIndex = PetSecondIndex;
- //this.m_hasHint = true;
- this.m_hintCount--;
- return true;
- }
-
- }
- }
- for (var PetFirstIndex = 0; PetFirstIndex < randomId; PetFirstIndex++) {
- if (this.m_allPets[PetFirstIndex].getState() === FZ.GameDefs.DREAMPET_REMOVE)
- continue;
- p1.col = this.m_allPets[PetFirstIndex].getCol();
- p1.line = this.m_allPets[PetFirstIndex].getLine();
- for (var PetSecondIndex = PetFirstIndex + 1; PetSecondIndex < FZ.GameDefs.ALL_GENERAL; PetSecondIndex++) {
- if (this.m_allPets[PetSecondIndex].getState() === FZ.GameDefs.DREAMPET_REMOVE)
- continue;
- if (this.m_allPets[PetFirstIndex].getStyle() !== this.m_allPets[PetSecondIndex].getStyle())
- continue;
- p2.col = this.m_allPets[PetSecondIndex].getCol();
- p2.line = this.m_allPets[PetSecondIndex].getLine();
- if ((FZ.AG.SearchSpecialPath.getPath(this.m_allPets, (FZ.GameDefs.DREAMPET_NUM_LINE + 2), (FZ.GameDefs.DREAMPET_NUM_COL + 2), p1.col, p1.line, p2.col, p2.line)) !== null) {
- this.m_allPets[PetFirstIndex].setState(FZ.GameDefs.DREAMPET_FLASH_HINT);
- this.m_allPets[PetFirstIndex].setPetFocus();
- this.m_allPets[PetSecondIndex].setState(FZ.GameDefs.DREAMPET_FLASH_HINT);
- this.m_allPets[PetSecondIndex].setPetFocus();
- // this.m_PetFirstIndex = PetFirstIndex;
- // this.m_PetSecondIndex = PetSecondIndex;
- this.m_hintCount--;
- // this.m_hasHint = true;
- return true;
- }
-
- }
- }
- return false;
- },
- searchHasMatch: function(){
- var p1 = new FZ.GRID_COOR();
- var p2 = new FZ.GRID_COOR();
- // var randomId = Math.floor(FZ.Math.random(0, FZ.GameDefs.ALL_GENERAL - 1));
- var tmp = this.m_PointPath;
- for (var PetFirstIndex = 0; PetFirstIndex < FZ.GameDefs.ALL_GENERAL; PetFirstIndex++) {
- if (this.m_allPets[PetFirstIndex].getState() === FZ.GameDefs.DREAMPET_REMOVE)
- continue;
- p1.col = this.m_allPets[PetFirstIndex].getCol();
- if (p1.col < 0) {
- continue;
- }
-
- p1.line = this.m_allPets[PetFirstIndex].getLine();
- if (p1.line < 0) {
- continue;
- }
- for (var PetSecondIndex = PetFirstIndex + 1; PetSecondIndex < FZ.GameDefs.ALL_GENERAL; PetSecondIndex++) {
- if (this.m_allPets[PetSecondIndex].getState() === FZ.GameDefs.DREAMPET_REMOVE)
- continue;
- if (this.m_allPets[PetFirstIndex].getStyle() !== this.m_allPets[PetSecondIndex].getStyle())
- continue;
- p2.col = this.m_allPets[PetSecondIndex].getCol();
- if (p2.col < 0) {
- continue;
- }
- p2.line = this.m_allPets[PetSecondIndex].getLine();
- if (p2.line < 0) {
- continue;
- }
-
- if (FZ.AG.SearchSpecialPath.getPath(this.m_allPets, (FZ.GameDefs.DREAMPET_NUM_LINE + 2), (FZ.GameDefs.DREAMPET_NUM_COL + 2), p1.col, p1.line, p2.col, p2.line) !== null) {
- this.m_PointPath = tmp;
- return true;
- }
-
- }
- }
- if (this.isDebug) {
- this.m_debug_div.style.backgroundColor = "#000";
- }
- this.m_PointPath = tmp;
- return false;
- },
- ResetPosition: function(){
- var firstId;
- var secondId;
-
- var petIndex = null;
- this.getDisplayPet();
- petIndex = this.m_displayPetsIndex;
- var len = petIndex.length;
- var randId = 0;
-
-
- if (len === 4) {
- this.exchagePet(petIndex[0], petIndex[1]);
- return;
- }
- randId = Math.floor(FZ.Math.random(1, len - 2));
- for (var index = 0; index < randId - 1; index++) {
-
- firstId = petIndex[index];
- secondId = petIndex[index + 1];
- this.exchagePet(firstId, secondId);
- }
- for (var index = randId; index < len - 2; index++) {
-
- firstId = petIndex[index];
- secondId = petIndex[index + 1];
- this.exchagePet(firstId, secondId);
- }
-
- },
- ResetTwoPosition: function(){
- var firstId;
- var secondId;
-
- var petIndex = null;
- this.getDisplayPet();
- petIndex = this.m_displayPetsIndex;
- var len = petIndex.length;
- firstId = petIndex[0];
-
- for (var index = 1; index < len - 1; index++) {
- secondId = petIndex[index];
- if (this.m_allPets[firstId].getStyle() !== this.m_allPets[secondId].getStyle()) {
- continue;
- }
- else {
- this.exchagePet(petIndex[1], secondId);
- break;
- }
- }
-
- },
- resetPetPosEffect: function(){
- if (this.m_PetFirstIndex > 0) {
- var curLevel = FZ.GameBase.SaveObject.m_cur_level;
- switch (curLevel) {
- case 1:{
- // this.centerReset(this.m_PetFirstIndex, this.m_PetSecondIndex);
- break;
- }
- case 2:{
- break;
- }
- case 3:{
- this.updownReset(this.m_PetFirstIndex, this.m_PetSecondIndex);
- break;
- }
- case 4:{
- break;
- }
- case 5:{
- this.leftrightReset(this.m_PetFirstIndex, this.m_PetSecondIndex);
- break;
- }
- case 6:{
- //
- break;
- }
- case 7:{
- this.downReset(this.m_PetFirstIndex, this.m_PetSecondIndex);
- break;
- }
- case 8:{
- this.rightReset(this.m_PetFirstIndex, this.m_PetSecondIndex);
- break;
- }
- case 9:{
- this.leftReset(this.m_PetFirstIndex, this.m_PetSecondIndex);
- break;
- }
- case 10:{
- this.upReset(this.m_PetFirstIndex, this.m_PetSecondIndex);
- break;
- }
- default:
- break;
- }
-
- this.m_PetFirstIndex = 0;
- // this.m_left_pet = this.getDisplayPet();
- }
-
- },
- getDisplayPet: function(){
- var displayNum = 0;
- this.m_displayPetsIndex = [];
- for (var index = 0; index < FZ.GameDefs.ALL_GENERAL; index++) {
- var state = this.m_allPets[index].getState();
- if (state !== FZ.GameDefs.DREAMPET_REMOVE) {
- displayNum++;
- this.m_displayPetsIndex.push(index);
- }
- }
- return displayNum;
- },
- isGreat: function(x, y){
- if (x >= y) {
- return true;
- }
- else {
- return false;
- }
- },
- setPetDisappear: function(x, y){
- //
- var pet_index = 0;
- var path = [];
-
- if ((x < FZ.GameDefs.DREAMPET_OFFSET_X) ||
- (x > (FZ.GameDefs.DREAMPET_OFFSET_X + (FZ.GameDefs.DREAMPET_NUM_COL + 1) * FZ.GameDefs.GRID_WIDTH)) ||
- (y < FZ.GameDefs.DREAMPET_OFFSET_Y) ||
- (y > (FZ.GameDefs.DREAMPET_OFFSET_Y + (FZ.GameDefs.DREAMPET_NUM_LINE + 1) * FZ.GameDefs.GRID_HEIGHT))) {
- return false;
- }
- var line = Math.floor((y - FZ.GameDefs.DREAMPET_OFFSET_Y) / FZ.GameDefs.GRID_HEIGHT);
- var col = Math.floor((x - FZ.GameDefs.DREAMPET_OFFSET_X) / FZ.GameDefs.GRID_WIDTH);
- pet_index = line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + col;
- if (pet_index >= ((FZ.GameDefs.DREAMPET_NUM_LINE + 2) * (FZ.GameDefs.DREAMPET_NUM_COL + 2))) {
- pet_index = -1;
- }
- //alert("col: " + col +"; line" + line);
- //
- //index = getTouchPetIndex(x, y);
- if (pet_index < 0) {
- return false;
- }
- var tmp = this.m_allPets[pet_index];
-
- if (null === tmp || undefined === tmp) {
- return false;
- }
-
- if (tmp.getState() === FZ.GameDefs.DREAMPET_FOCUS || tmp.getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- return false;
- }
- else
- if (false === this.checkFocus()) {
- this.m_allPets[pet_index].setState(FZ.GameDefs.DREAMPET_FOCUS);
- this.m_allPets[pet_index].show();
- this.m_firstPet = this.m_allPets[pet_index];
-
- return false;
- }//start check two Pets can be disappeared
- else
- // if (true) {
- this.m_secondPet = tmp;
- p1 = new FZ.GRID_COOR();
- p1.line = this.m_firstPet.getLine();
- p1.col = this.m_firstPet.getCol();
- p2 = new FZ.GRID_COOR();
- p2.line = this.m_secondPet.getLine();
- p2.col = this.m_secondPet.getCol();
-
- if (this.m_firstPet.getStyle() !== this.m_secondPet.getStyle()) {
- this.m_allPets[pet_index].setState(FZ.GameDefs.DREAMPET_FOCUS);
- this.m_allPets[pet_index].show();
- this.m_firstPet.setState(FZ.GameDefs.DREAMPET_INIT);
-
- this.m_firstPet.hidden();
- this.m_firstPet = this.m_secondPet;
-
- return false;
- }
- //below for 4 kinds steps to check
- else
- if ((path = FZ.AG.SearchSpecialPath.getPath(this.m_allPets, (FZ.GameDefs.DREAMPET_NUM_LINE + 2), (FZ.GameDefs.DREAMPET_NUM_COL + 2), p1.col, p1.line, p2.col, p2.line)) !== null) {
-
- this.m_PointPath = path;
- this.m_allPets[(FZ.GameDefs.DREAMPET_NUM_COL + 2) * p1.line + p1.col].setState(FZ.GameDefs.DREAMPET_FLASH);
- this.m_allPets[(FZ.GameDefs.DREAMPET_NUM_COL + 2) * p2.line + p2.col].setState(FZ.GameDefs.DREAMPET_FLASH);
-
- this.m_PetFirstIndex = (FZ.GameDefs.DREAMPET_NUM_COL + 2) * p1.line + p1.col;
- this.m_allPets[this.m_PetFirstIndex].hidden();
-
- this.m_PetSecondIndex = (FZ.GameDefs.DREAMPET_NUM_COL + 2) * p2.line + p2.col;
- this.m_allPets[this.m_PetFirstIndex].setPetFocus();
- this.m_allPets[this.m_PetSecondIndex].setPetFocus();
- this.m_score += 100;
- this.m_bonus_time += 5;
- var lineNum = this.m_PointPath.length;
- var temp = [];
-
- for (var index = 0; index < lineNum - 1; ++index) {
-
- temp[1] = this.m_PointPath[index + 1][1];
- temp[0] = this.m_PointPath[index + 1][0];
-
- var resultW;
- var resultH;
- var w = this.ABS((FZ.GameDefs.DREAMPET_OFFSET_X + FZ.GameDefs.GRID_WIDTH * temp[0] + FZ.GameDefs.GRID_WIDTH_HALF), (FZ.GameDefs.DREAMPET_OFFSET_X + FZ.GameDefs.GRID_WIDTH * this.m_PointPath[index][0] + FZ.GameDefs.GRID_WIDTH_HALF));
- var h = this.ABS((FZ.GameDefs.DREAMPET_OFFSET_Y + FZ.GameDefs.GRID_HEIGHT * temp[1] + FZ.GameDefs.GRID_HEIGHT_HALF), (FZ.GameDefs.DREAMPET_OFFSET_Y + FZ.GameDefs.GRID_HEIGHT * this.m_PointPath[index][1] + FZ.GameDefs.GRID_HEIGHT_HALF));
- var left;
- var top;
- if (0 === Math.floor(w)) {
- w = 3;
- }
- if (0 === Math.floor(h)) {
- h = 3;
- }
- if (w === 3) {
- resultW = this.isGreat((FZ.GameDefs.DREAMPET_OFFSET_Y + FZ.GameDefs.GRID_HEIGHT * temp[1] + FZ.GameDefs.GRID_HEIGHT_HALF), (FZ.GameDefs.DREAMPET_OFFSET_Y + FZ.GameDefs.GRID_HEIGHT * this.m_PointPath[index][1] + FZ.GameDefs.GRID_HEIGHT_HALF));
- if (resultW) {
- left = FZ.GameDefs.DREAMPET_OFFSET_X + FZ.GameDefs.GRID_WIDTH * this.m_PointPath[index][0] + FZ.GameDefs.GRID_WIDTH_HALF;
- top = FZ.GameDefs.DREAMPET_OFFSET_Y + FZ.GameDefs.GRID_HEIGHT * this.m_PointPath[index][1] + FZ.GameDefs.GRID_HEIGHT_HALF;
-
- }
- else {
- left = FZ.GameDefs.DREAMPET_OFFSET_X + FZ.GameDefs.GRID_WIDTH * this.m_PointPath[index][0] + FZ.GameDefs.GRID_WIDTH_HALF;
- top = FZ.GameDefs.DREAMPET_OFFSET_Y + FZ.GameDefs.GRID_HEIGHT * temp[1] + FZ.GameDefs.GRID_HEIGHT_HALF;
- h += 3;
- }
- }
- if (h === 3) {
- resultH = this.isGreat((FZ.GameDefs.DREAMPET_OFFSET_X + FZ.GameDefs.GRID_WIDTH * temp[0] + FZ.GameDefs.GRID_WIDTH_HALF), (FZ.GameDefs.DREAMPET_OFFSET_X + FZ.GameDefs.GRID_WIDTH * this.m_PointPath[index][0] + FZ.GameDefs.GRID_WIDTH_HALF));
- if (resultH) {
- left = FZ.GameDefs.DREAMPET_OFFSET_X + FZ.GameDefs.GRID_WIDTH * this.m_PointPath[index][0] + FZ.GameDefs.GRID_WIDTH_HALF;
- top = FZ.GameDefs.DREAMPET_OFFSET_Y + FZ.GameDefs.GRID_HEIGHT * this.m_PointPath[index][1] + FZ.GameDefs.GRID_HEIGHT_HALF;
- }
- else {
- left = FZ.GameDefs.DREAMPET_OFFSET_X + FZ.GameDefs.GRID_WIDTH * temp[0] + FZ.GameDefs.GRID_WIDTH_HALF;
- top = FZ.GameDefs.DREAMPET_OFFSET_Y + FZ.GameDefs.GRID_HEIGHT * this.m_PointPath[index][1] + FZ.GameDefs.GRID_HEIGHT_HALF;
- w += 3;
- }
- }
- if (left < FZ.GameDefs.OFFSET_X) {
- this.m_div_line[index].style.left = 5 + "px";
- if (w > 3) {
- w -= 24;
- }
- }
- else
- if (left + w > FZ.GameDefs.SCREEN_W && w > 3) {
- w = 315 - left;
- this.m_div_line[index].style.left = left + "px";
- }
- else
- if (left > FZ.GameDefs.SCREEN_W) {
- this.m_div_line[index].style.left = 312 + "px";
-
- }
- else {
- this.m_div_line[index].style.left = left + "px";
- }
- if (top < FZ.GameDefs.OFFSET_Y) {
- this.m_div_line[index].style.top = 70 + "px";
- }
- else
- if (top + h > (FZ.GameDefs.SCREEN_H - FZ.GameDefs.SCREEN_BOTTOM_H) && h > 3) {
- h = FZ.GameDefs.SCREEN_H - FZ.GameDefs.SCREEN_BOTTOM_H - 5 - top;
- this.m_div_line[index].style.top = top + "px";
- }
- else
- if (top > (FZ.GameDefs.SCREEN_H - FZ.GameDefs.SCREEN_BOTTOM_H)) {
- this.m_div_line[index].style.top = (FZ.GameDefs.SCREEN_H - FZ.GameDefs.SCREEN_BOTTOM_H) - 5 + "px";
- if (resultH === true) {
- w += 3;
- }
- }
- else {
- this.m_div_line[index].style.top = top + "px";
- }
- this.m_div_line[index].style.width = w + "px";
- this.m_div_line[index].style.height = h + "px";
- this.m_div_line[index].style.zIndex = 100;
- // this.m_div_line[index].style.display = "inline";
- this.m_div_line[index].style.visibility = "visible";
- // this.m_allPets[this.m_PetFirstIndex].m_div.parentNode.appendChild(this.m_div_line[index]);
-
- }
-
- var that = this;
- that.m_reset_finished = false;
- setTimeout(function(){
- for (var index = 0; index < lineNum - 1; ++index) {
- // that.m_div_line[index].style.display = "none";
- that.m_div_line[index].style.visibility = "hidden";
- }
- }, 400);
-
- setTimeout(function(){
- that.resetPetPosEffect();
- if (that.getLeftPet() !== 0) {
- if (that.searchHasMatch() === false) {
- FZ.Game.GameState.m_isNoMatch = true;
- FZ.Game.GameState.levelCurrentTime = (new Date()).getTime();
- }
- }
- that.m_reset_finished = true;
- }, 600);
-
-
- this.m_left_pet -= 2;
-
-
- return true;
- }
- else {
- this.m_allPets[pet_index].setState(FZ.GameDefs.DREAMPET_FOCUS);
- if (this.m_firstPet) {
- this.m_firstPet.setState(FZ.GameDefs.DREAMPET_INIT);
- // this.m_firstPet.m_div_focus.style.display = "none";
- // this.m_firstPet.m_div_focus.style.visibility = "hidden";
- this.m_firstPet.hidden();
-
- if (this.m_secondPet) {
- this.m_secondPet.setState(FZ.GameDefs.DREAMPET_FOCUS);
- this.m_secondPet.show();
- this.m_firstPet = this.m_secondPet;
- }
- }
- return false;
- }
-
- // }//end if current pic not NULL
- },
-
-
- ABS: function(x, y){
- return ((x > y) ? (x - y) : (y - x));
- },
-
-
- updownReset: function(p1, p2){
- var lessId = 0;
- var greatId = 0;
- if (p1 > p2) {
- lessId = p1;
- greatId = p2;
- }
- else {
- lessId = p2;
- greatId = p1;
- }
-
- if (greatId > (FZ.GameDefs.DREAMPET_NUM_LINE_HALF + 1) * (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- for (var index = greatId; index > (FZ.GameDefs.DREAMPET_NUM_LINE_HALF + 2) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index - (FZ.GameDefs.DREAMPET_NUM_COL + 2));
-
- }
- for (var index = lessId; index > (FZ.GameDefs.DREAMPET_NUM_LINE_HALF + 2) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index - (FZ.GameDefs.DREAMPET_NUM_COL + 2));
-
- }
-
- }
- else
- if (lessId > (FZ.GameDefs.DREAMPET_NUM_LINE_HALF + 1) * (FZ.GameDefs.DREAMPET_NUM_COL + 2) &&
- greatId < (FZ.GameDefs.DREAMPET_NUM_LINE_HALF + 1) * (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- for (var index = greatId; index < (FZ.GameDefs.DREAMPET_NUM_LINE_HALF) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
-
- for (var index = lessId; index > (FZ.GameDefs.DREAMPET_NUM_LINE_HALF + 2) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index - (FZ.GameDefs.DREAMPET_NUM_COL + 2));
-
- }
- }
- else {
- for (var index = lessId; index < (FZ.GameDefs.DREAMPET_NUM_LINE_HALF) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- for (var index = greatId; index < (FZ.GameDefs.DREAMPET_NUM_LINE_HALF) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
-
- }
- },
-
- leftrightReset: function(p1, p2){
- var lessId = 0;
- var greatId = 0;
- if (p1 > p2) {
- lessId = p1;
- greatId = p2;
- }
- else {
- lessId = p2;
- greatId = p1;
- }
- var lessId_line = this.m_allPets[lessId].getLine();
- var lessId_col = this.m_allPets[lessId].getCol();
- var greatId_line = this.m_allPets[greatId].getLine();
- var greatId_col = this.m_allPets[greatId].getCol();
-
-
- if (lessId_col <= FZ.GameDefs.DREAMPET_NUM_COL_HALF && greatId_col <= FZ.GameDefs.DREAMPET_NUM_COL_HALF) {
- for (var index = lessId_col; index < FZ.GameDefs.DREAMPET_NUM_COL_HALF; index++) {
- this.exchagePet(lessId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index, lessId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index + 1);
- }
- for (var index = greatId_col; index < FZ.GameDefs.DREAMPET_NUM_COL_HALF; index++) {
- this.exchagePet(greatId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index, greatId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index + 1);
- }
- }
- else
- if (greatId_col > FZ.GameDefs.DREAMPET_NUM_COL_HALF && lessId_col > FZ.GameDefs.DREAMPET_NUM_COL_HALF) {
- for (var index = greatId_col; index > FZ.GameDefs.DREAMPET_NUM_COL_HALF + 1; index--) {
- this.exchagePet(greatId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index, greatId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index - 1);
- }
- for (var index = lessId_col; index > FZ.GameDefs.DREAMPET_NUM_COL_HALF + 1; index--) {
- this.exchagePet(lessId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index, lessId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index - 1);
- }
-
- }
- else
- if (greatId_col <= FZ.GameDefs.DREAMPET_NUM_COL_HALF && lessId_col > FZ.GameDefs.DREAMPET_NUM_COL_HALF) {
- for (var index = greatId_col; index < FZ.GameDefs.DREAMPET_NUM_COL_HALF; index++) {
- this.exchagePet(greatId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index, greatId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index + 1);
- }
- for (var index = lessId_col; index > FZ.GameDefs.DREAMPET_NUM_COL_HALF + 1; index--) {
- this.exchagePet(lessId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index, lessId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index - 1);
- }
-
- }
- else {
- for (var index = greatId_col; index > FZ.GameDefs.DREAMPET_NUM_COL_HALF + 1; index--) {
- this.exchagePet(greatId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index, greatId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index - 1);
- }
- for (var index = lessId_col; index < FZ.GameDefs.DREAMPET_NUM_COL_HALF; index++) {
- this.exchagePet(lessId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index, lessId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index + 1);
- }
- }
- },
- leftReset: function(p1, p2){
- var lessId = 0;
- var greatId = 0;
- if (p2 > p1) {
- lessId = p1;
- greatId = p2;
- }
- else {
- lessId = p2;
- greatId = p1;
- }
- var lessId_line = this.m_allPets[lessId].getLine();
- var lessId_col = this.m_allPets[lessId].getCol();
- var greatId_line = this.m_allPets[greatId].getLine();
- var greatId_col = this.m_allPets[greatId].getCol();
-
-
-
- for (var index = greatId_col; index < FZ.GameDefs.DREAMPET_NUM_COL; index++) {
- this.exchagePet(greatId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index, greatId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index + 1);
- }
- for (var index = lessId_col; index < FZ.GameDefs.DREAMPET_NUM_COL; index++) {
- this.exchagePet(lessId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index, lessId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index + 1);
- }
-
-
- },
- rightReset: function(p1, p2){
- var lessId = 0;
- var greatId = 0;
- if (p1 > p2) {
- lessId = p1;
- greatId = p2;
- }
- else {
- lessId = p2;
- greatId = p1;
- }
- var lessId_line = this.m_allPets[lessId].getLine();
- var lessId_col = this.m_allPets[lessId].getCol();
- var greatId_line = this.m_allPets[greatId].getLine();
- var greatId_col = this.m_allPets[greatId].getCol();
-
- for (var index = greatId_col; index > 0; index--) {
- if (index === 1) {
- break;
- }
- this.exchagePet(greatId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index, greatId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index - 1);
- }
- for (var index = lessId_col; index > 0; index--) {
- if (index === 1) {
- break;
- }
- this.exchagePet(lessId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index, lessId_line * (FZ.GameDefs.DREAMPET_NUM_COL + 2) + index - 1);
- }
-
-
- },
- downReset: function(p1, p2){
- var tmp = 0;
- var lessId = 0;
- var greatId = 0;
- if (p1 > p2) {
- lessId = p1;
- greatId = p2;
- }
- else {
- lessId = p2;
- greatId = p1;
- }
-
- if ((lessId - (FZ.GameDefs.DREAMPET_NUM_COL + 2)) < (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- return;
- }
- else
- if (((greatId - (FZ.GameDefs.DREAMPET_NUM_COL + 2)) > (FZ.GameDefs.DREAMPET_NUM_COL + 2)) && ((greatId - lessId) % (FZ.GameDefs.DREAMPET_NUM_COL + 2) == 0)) {
-
- for (var index = greatId - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index > (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index + (FZ.GameDefs.DREAMPET_NUM_COL + 2), index);
- tmp = index;
- }
-
- for (var index = lessId - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index >= tmp; index = index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index + (FZ.GameDefs.DREAMPET_NUM_COL + 2), index);
- }
-
-
- }
- else {
- for (var index = lessId - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index > (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index + (FZ.GameDefs.DREAMPET_NUM_COL + 2), index);
-
- }
- for (var index = greatId - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index > (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index + (FZ.GameDefs.DREAMPET_NUM_COL + 2), index);
-
- }
-
- }
-
- },
- upReset: function(p1, p2){
- var tmp = 0;
- var lessId;
- var greatId;
- if (p1 > p2) {
- lessId = p1;
- greatId = p2;
- }
- else {
- lessId = p2;
- greatId = p1;
- }
- if (FZ.GameDefs.ALL_GENERAL - greatId - (FZ.GameDefs.DREAMPET_NUM_COL + 2) < (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- return;
- }
- else {
- for (var index = lessId; index + (FZ.GameDefs.DREAMPET_NUM_COL + 2) < FZ.GameDefs.ALL_GENERAL - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- for (var index = greatId; index + (FZ.GameDefs.DREAMPET_NUM_COL + 2) < FZ.GameDefs.ALL_GENERAL - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index + (FZ.GameDefs.DREAMPET_NUM_COL + 2), index);
- }
- }
- },
- centerReset: function(p1, p2){
-
- var tmp = 0;
- var lessId;
- var greatId;
- if (p2 > p1) {
- lessId = p1;
- greatId = p2;
- }
- else {
- lessId = p2;
- greatId = p1;
- }
- var lessId_line = this.m_allPets[lessId].getLine();
- var lessId_col = this.m_allPets[lessId].getCol();
- var greatId_line = this.m_allPets[greatId].getLine();
- var greatId_col = this.m_allPets[greatId].getCol();
- //special 1
- if (lessId_col <= FZ.GameDefs.DREAMPET_NUM_COL_HALF && lessId_line > FZ.GameDefs.DREAMPET_NUM_LINE_HALF) {
- if (greatId_col <= FZ.GameDefs.DREAMPET_NUM_COL_HALF && greatId_line > FZ.GameDefs.DREAMPET_NUM_LINE_HALF &&
- (Math.floor((greatId - lessId) % (FZ.GameDefs.DREAMPET_NUM_COL + 2)) === 0 /*||(p2-p1)<FZ.GameDefs.DREAMPET_NUM_COL_HALF*/)) {
- tmp = greatId;
- for (var index = greatId; index > 0; index--) {
- if (this.m_allPets[index - 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index - 1);
- }
- }
- for (var index = tmp; index < FZ.GameDefs.ALL_GENERAL - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- tmp = lessId;
- for (var index = lessId; index > 0; index--) {
- if (this.m_allPets[index - 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index - 1);
- }
- }
- for (var index = tmp; index < FZ.GameDefs.ALL_GENERAL - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- return;
- }
- if (greatId_col <= FZ.GameDefs.DREAMPET_NUM_COL_HALF && greatId_line > FZ.GameDefs.DREAMPET_NUM_LINE_HALF &&
- Math.floor((greatId - lessId) % (FZ.GameDefs.DREAMPET_NUM_COL + 2)) === 0) {
-
- tmp = greatId;
- for (var index = greatId; index > 0; index--) {
- if (this.m_allPets[index - 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index - 1);
- }
- }
- for (var index = tmp; index < FZ.GameDefs.ALL_GENERAL - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- tmp = lessId;
- for (var index = lessId; index > 0; index--) {
- if (this.m_allPets[index - 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index - 1);
- }
- }
- for (var index = tmp; index < FZ.GameDefs.ALL_GENERAL - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- return;
- }
- }
- //special 2
- if (lessId_col > FZ.GameDefs.DREAMPET_NUM_COL_HALF && lessId_line <= FZ.GameDefs.DREAMPET_NUM_LINE_HALF) {
-
- if (greatId_col > FZ.GameDefs.DREAMPET_NUM_COL_HALF && greatId_line <= FZ.GameDefs.DREAMPET_NUM_LINE_HALF) {
- if ((greatId - lessId) < FZ.GameDefs.DREAMPET_NUM_COL_HALF) {
- tmp = greatId;
- for (var index = greatId; index < (greatId_line + 1) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index++) {
- if (this.m_allPets[index + 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index + 1);
- }
- }
- for (var index = tmp; index > (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- if (this.m_allPets[index].getState() === FZ.GameDefs.DREAMPET_REMOVE &&
- this.m_allPets[index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- this.exchagePet(index, index - (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- tmp = lessId;
- for (var index = lessId; index < (lessId_line + 1) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index++) {
- if (this.m_allPets[index + 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index + 1);
- }
- }
- for (var index = tmp; index > (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- if (this.m_allPets[index].getState() === FZ.GameDefs.DREAMPET_REMOVE &&
- this.m_allPets[index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- this.exchagePet(index, index - (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
-
- return;
- }
- }
- }
- //special 3
- if (lessId_col > FZ.GameDefs.DREAMPET_NUM_COL_HALF && lessId_line > FZ.GameDefs.DREAMPET_NUM_LINE_HALF) {
- if (greatId_col > FZ.GameDefs.DREAMPET_NUM_COL_HALF && greatId_line > FZ.GameDefs.DREAMPET_NUM_LINE_HALF &&
- (Math.floor((greatId - lessId) % (FZ.GameDefs.DREAMPET_NUM_COL + 2)) === 0 || (greatId - lessId) < FZ.GameDefs.DREAMPET_NUM_COL_HALF)) {
- tmp = greatId;
- for (var index = greatId; index < (greatId_line + 1) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index++) {
- if (this.m_allPets[index + 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index + 1);
- }
- }
- for (var index = tmp; index < FZ.GameDefs.ALL_GENERAL - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- tmp = lessId;
- for (var index = lessId; index < (lessId_line + 1) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index++) {
- if (this.m_allPets[index + 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index + 1);
- }
- }
- for (var index = tmp; index < FZ.GameDefs.ALL_GENERAL - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- return;
- }
- if (greatId_col > FZ.GameDefs.DREAMPET_NUM_COL_HALF && greatId_line > FZ.GameDefs.DREAMPET_NUM_LINE_HALF &&
- Math.floor((greatId - lessId) % (FZ.GameDefs.DREAMPET_NUM_COL + 2)) !== 0) {
-
- tmp = lessId;
- for (var index = lessId; index < (lessId_line + 1) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index++) {
- if (this.m_allPets[index + 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index + 1);
- }
- }
- for (var index = tmp; index < FZ.GameDefs.ALL_GENERAL - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- tmp = greatId;
- for (var index = greatId; index < (greatId_line + 1) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index++) {
- if (this.m_allPets[index + 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index + 1);
- }
- }
- for (var index = tmp; index < FZ.GameDefs.ALL_GENERAL - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- return;
- }
- }
-
- //lessId
- tmp = lessId;
- if (lessId_col <= FZ.GameDefs.DREAMPET_NUM_COL_HALF && lessId_line <= FZ.GameDefs.DREAMPET_NUM_LINE_HALF) {
- for (var index = lessId; index > 0; index--) {
- if (this.m_allPets[index - 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index - 1);
- }
- }
- for (var index = tmp; index > (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- if (this.m_allPets[index].getState() === FZ.GameDefs.DREAMPET_REMOVE &&
- this.m_allPets[index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- this.exchagePet(index, index - (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- }
- else
- if (lessId_col <= FZ.GameDefs.DREAMPET_NUM_COL_HALF && lessId_line > FZ.GameDefs.DREAMPET_NUM_LINE_HALF) {
- for (var index = lessId; index > 0; index--) {
- if (this.m_allPets[index - 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index - 1);
- }
- }
- for (var index = tmp; index < FZ.GameDefs.ALL_GENERAL - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- }
- else
- if (lessId_col > FZ.GameDefs.DREAMPET_NUM_COL_HALF && lessId_line > FZ.GameDefs.DREAMPET_NUM_LINE_HALF) {
- for (var index = lessId; index < (lessId_line + 1) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index++) {
- if (this.m_allPets[index + 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index + 1);
- }
- }
- for (var index = tmp; index < FZ.GameDefs.ALL_GENERAL - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- }
- else
- if (lessId_col > FZ.GameDefs.DREAMPET_NUM_COL_HALF && lessId_line <= FZ.GameDefs.DREAMPET_NUM_LINE_HALF) {
- for (var index = lessId; index < (lessId_line + 1) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index++) {
- if (this.m_allPets[index + 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index + 1);
- }
- }
- for (var index = tmp; index > (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
-
- this.exchagePet(index, index - (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- }
- tmp = greatId;
- //greatId
- if (greatId_col <= FZ.GameDefs.DREAMPET_NUM_COL_HALF && greatId_line <= FZ.GameDefs.DREAMPET_NUM_LINE_HALF) {
- for (var index = greatId; index > 0; index--) {
- if (this.m_allPets[index - 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index - 1);
- }
- }
- for (var index = tmp; index > (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index - (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- }
- else
- if (greatId_col <= FZ.GameDefs.DREAMPET_NUM_COL_HALF && greatId_line > FZ.GameDefs.DREAMPET_NUM_LINE_HALF) {
- for (var index = greatId; index > 0; index--) {
- if (this.m_allPets[index - 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index - 1);
- }
- }
- for (var index = tmp; index < FZ.GameDefs.ALL_GENERAL - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- }
- else
- if (greatId_col > FZ.GameDefs.DREAMPET_NUM_COL_HALF && greatId_line > FZ.GameDefs.DREAMPET_NUM_LINE_HALF) {
- for (var index = greatId; index < (greatId_line + 1) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index++) {
- if (this.m_allPets[index + 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index + 1);
- }
- }
- for (var index = tmp; index < FZ.GameDefs.ALL_GENERAL - (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index + (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index + (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- }
- else
- if (greatId_col > FZ.GameDefs.DREAMPET_NUM_COL_HALF && greatId_line <= FZ.GameDefs.DREAMPET_NUM_LINE_HALF) {
- for (var index = greatId; index < (greatId_line + 1) * (FZ.GameDefs.DREAMPET_NUM_COL + 2); index++) {
- if (this.m_allPets[index + 1].getState() === FZ.GameDefs.DREAMPET_REMOVE) {
- tmp = index;
- break;
- }
- else {
- this.exchagePet(index, index + 1);
- }
- }
- for (var index = tmp; index > (FZ.GameDefs.DREAMPET_NUM_COL + 2); index = index - (FZ.GameDefs.DREAMPET_NUM_COL + 2)) {
- this.exchagePet(index, index - (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- }
- }
-
-
- },
- exchagePet: function(firstPetIndex, secondPetIndex){
- var firstCol = this.m_allPets[firstPetIndex].getCol();
- var firstLine = this.m_allPets[firstPetIndex].getLine();
- // var firstState = this.m_allPets[firstPetIndex].getState();
- var secondCol = this.m_allPets[secondPetIndex].getCol();
- var secondLine = this.m_allPets[secondPetIndex].getLine();
- // var secondState = this.m_allPets[secondPetIndex].getState();
- var tmpPet = null;
- tmpPet = this.m_allPets[firstPetIndex];
- this.m_allPets[firstPetIndex] = this.m_allPets[secondPetIndex];
- this.m_allPets[firstPetIndex].setCol(firstCol);
- this.m_allPets[firstPetIndex].setLine(firstLine);
- //this.m_allPets[firstPetIndex].setState(firstState);
- this.m_allPets[firstPetIndex].updatePos();
- this.m_allPets[secondPetIndex] = tmpPet;
- this.m_allPets[secondPetIndex].setCol(secondCol);
- this.m_allPets[secondPetIndex].setLine(secondLine);
- // this.m_allPets[secondPetIndex].setState(secondState);
- this.m_allPets[secondPetIndex].updatePos();
- this.m_allPets[firstPetIndex].setPetFocus();
- this.m_allPets[secondPetIndex].setPetFocus();
- },
-
- getLeftPet: function(){
- return this.m_left_pet;
- },
- getScore: function(){
- return this.m_score;
- },
- setScore: function(score){
- this.m_score = score;
- },
- getBonusTime: function(){
- return this.m_bonus_time;
- },
- setBonusTime: function(time){
- this.m_bonus_time = time;
- },
- onDrawPathLine: function(){
-
- FZ.GameBase.MainContext.strokeStyle = '#ff0';
- FZ.GameBase.MainContext.lineWidth = 3;
-
- var tmpIndex = 0;
- var temp = [];
-
- for (var index = 0; index < (this.m_PointPath.length - 1); ++index) {
-
- temp[1] = this.m_PointPath[index + 1][1];
- temp[0] = this.m_PointPath[index + 1][0];
-
- FZ.GameBase.MainContext.setTransform(this.m_worldMatrix.m11, this.m_worldMatrix.m12, this.m_worldMatrix.m21, this.m_worldMatrix.m22, this.m_worldMatrix.dx, this.m_worldMatrix.dy);
-
- FZ.GameBase.MainContext.beginPath();
- FZ.GameBase.MainContext.moveTo(FZ.GameDefs.DREAMPET_OFFSET_X + FZ.GameDefs.GRID_WIDTH * this.m_PointPath[index][0] + FZ.GameDefs.GRID_WIDTH_HALF, FZ.GameDefs.DREAMPET_OFFSET_Y + FZ.GameDefs.GRID_HEIGHT * this.m_PointPath[index][1] + FZ.GameDefs.GRID_HEIGHT_HALF);
- FZ.GameBase.MainContext.lineTo(FZ.GameDefs.DREAMPET_OFFSET_X + FZ.GameDefs.GRID_WIDTH * temp[0] + FZ.GameDefs.GRID_WIDTH_HALF, FZ.GameDefs.DREAMPET_OFFSET_Y + FZ.GameDefs.GRID_HEIGHT * temp[1] + FZ.GameDefs.GRID_HEIGHT_HALF);
- FZ.GameBase.MainContext.closePath();
- FZ.GameBase.MainContext.stroke();
-
- }
-
-
- },
-
- showPets: function(){
- var tmp = null;
- for (var index = 0; index < FZ.GameDefs.ALL_GENERAL; index++) {
- tmp = this.m_allPets[index];
- if (tmp.m_div) {
- //tmp.m_div.style.display = "inline";
- tmp.m_div.style.visibility = "visible";
- if (FZ.GameDefs.DREAMPET_FOCUS === tmp.m_state) {
- tmp.m_div_focus.style.visibility = "visible";
- }
- }
- }
- },
- hidePets: function(){
- var tmp = null;
- for (var index = 0; index < FZ.GameDefs.ALL_GENERAL; index++) {
- tmp = this.m_allPets[index];
- if (tmp.m_div) {
- // tmp.m_div.style.display = "none";
- tmp.m_div.style.visibility = "hidden";
- tmp.m_div_focus.style.visibility = "hidden";
- }
- }
- },
- resumeLevel: function(){
- this.m_score = FZ.GameBase.SaveObject.m_cur_score;
- this.m_hintCount = FZ.GameBase.SaveObject.m_cur_hintCount;
- this.m_left_pet = FZ.GameBase.SaveObject.m_cur_left_pet;
- this.m_level = FZ.GameBase.SaveObject.m_cur_level;
- var index;
- var tmp = null;
- var tmpPetArr = null;
- tmpPetArr = [];
- var line = 0;
- var col = 0;
- var style = 0;
- var state = FZ.GameDefs.DREAMPET_INIT;
- this.clearAllPets();
- for (index = 0; index < FZ.GameDefs.ALL_GENERAL; index++) {
- state = FZ.GameBase.SaveObject.m_data[index].state;
- style = FZ.GameBase.SaveObject.m_data[index].style;
- line = Math.floor(index / (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- col = (index % (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- tmp = null;
- tmp = new FZ.Diamond(line, col, style, state);
-
- this.m_allPets.push(tmp);
-
- if (FZ.GameDefs.DREAMPET_REMOVE !== state) {
- this.m_parent.appendChild(tmp.m_div);
- }
- if (FZ.GameDefs.DREAMPET_FOCUS === state) {
- this.m_firstPet = tmp;
- }
- }
- },
- saveLevel: function(){
- FZ.GameBase.SaveObject.m_gamein = true;
- FZ.GameBase.SaveObject.m_cur_score = this.m_score;
- FZ.GameBase.SaveObject.m_cur_hintCount = this.m_hintCount;
- FZ.GameBase.SaveObject.m_cur_left_pet = this.m_left_pet;
- FZ.GameBase.SaveObject.m_level_usedTime = FZ.Game.GameState.m_level_usedTime;
- if (FZ.TargetMobile !== FZ.TARGET_DEF.ANDRIOD) {
- FZ.GameBase.SaveObject.m_sound = FZ.Game.GameState.m_sound;
- }
- var index;
- var tmp = null;
- var tmpPetArr = null;
- tmpPetArr = FZ.GameBase.SaveObject.m_data;
- for (index = 0; index < FZ.GameDefs.ALL_GENERAL; index++) {
- // tmpPetArr[index].line = this.m_allPets[index].m_line;
- // tmpPetArr[index].col = this.m_allPets[index].m_col;
- tmpPetArr[index].style = this.m_allPets[index].m_style;
- tmpPetArr[index].state = this.m_allPets[index].m_state;
- }
- // FZ.GameBase.SaveObject.m_data = tmpPetArr;
- FZ.GameBase.saveGame();
- },
- initAllPets: function(isNew){
- var line = 0;
- var col = 0;
- var style = 0;
- var state = FZ.GameDefs.DREAMPET_INIT;
- var index = 0;
- var tmp = null;
- var tmpPetArr = null;
- tmpPetArr = tmpPetArr || [];
- this.m_bonus_time = 0;
- this.m_score = 0;
- this.m_hintCount = FZ.GameDefs.LEVEL_HINT_NUMBER[this.getLevel()];
- this.clearAllPets();
- this.m_left_pet = FZ.GameDefs.ALL_PET_NUM;
- var styleStart = 0;
- var styleEnd = 0;
- styleStart = FZ.Math.random(0, (FZ.GameDefs.DIAMOND_TYPES - FZ.GameDefs.LEVEL_PET_KIND[FZ.GameBase.SaveObject.m_cur_level]));
- if (styleStart < 0) {
- styleStart = 0;
- }
- styleEnd = styleStart + FZ.GameDefs.LEVEL_PET_KIND[FZ.GameBase.SaveObject.m_cur_level];
- for (index = 0; index < FZ.GameDefs.ALL_GENERAL_HALF; index++) {
- style = FZ.Math.random(styleStart, styleEnd);
- state = FZ.GameDefs.DREAMPET_INIT;
- line = Math.floor(index / (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- col = (index % (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- if (((line === 0) || (line === (FZ.GameDefs.DREAMPET_NUM_LINE + 1)) || (col === 0) || (col === (FZ.GameDefs.DREAMPET_NUM_COL + 1)))) {
- state = FZ.GameDefs.DREAMPET_REMOVE;
- style = -1;
- }
- tmp = null;
-
- tmp = new FZ.Diamond(line, col, style, state);
- // tmp.m_spr = this.m_sprite.clone();
- this.m_allPets.push(tmp);
-
- if (FZ.GameDefs.DREAMPET_REMOVE !== state) {
- this.m_parent.appendChild(tmp.m_div);
- }
- tmpPetArr.push(tmp);
- }
-
-
- var tmpPet = null;
- var tmpLen;
-
- for (index = (FZ.GameDefs.ALL_GENERAL_HALF); index < (FZ.GameDefs.ALL_GENERAL); index++) {
- tmpLen = Math.floor(FZ.Math.random(0, tmpPetArr.length));
-
- // tmpPet = tmpPetArr.slice(tmpLen, tmpLen + 1);
- state = FZ.GameDefs.DREAMPET_INIT;
-
- style = tmpPetArr[tmpLen].getStyle();
-
- //alert("style :" + style + ":" + "tmpLen :" + tmpLen);
- // tmpPetArr.splice(tmpLen, 1);
-
- line = Math.floor(index / (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- col = (index % (FZ.GameDefs.DREAMPET_NUM_COL + 2));
- if (-1 === style) {
- if (!((line === 0) || (line === (FZ.GameDefs.DREAMPET_NUM_LINE + 1)) || (col === 0) || (col === (FZ.GameDefs.DREAMPET_NUM_COL + 1)))) {
- tmpLen = Math.floor(FZ.Math.random(0, tmpPetArr.length));
- style = tmpPetArr[tmpLen].getStyle();
- while (-1 === style) {
- tmpLen = Math.floor(FZ.Math.random(0, tmpPetArr.length));
- style = tmpPetArr[tmpLen].getStyle();
- }
- }
- else {
- state = FZ.GameDefs.DREAMPET_REMOVE;
- style = -1;
- }
- }
- else {
- if (((line === 0) || (line === (FZ.GameDefs.DREAMPET_NUM_LINE + 1)) || (col === 0) || (col === (FZ.GameDefs.DREAMPET_NUM_COL + 1)))) {
- tmpLen = Math.floor(FZ.Math.random(0, tmpPetArr.length));
- style = tmpPetArr[tmpLen].getStyle();
- while (-1 !== style) {
- tmpLen = Math.floor(FZ.Math.random(0, tmpPetArr.length));
- style = tmpPetArr[tmpLen].getStyle();
- }
- state = FZ.GameDefs.DREAMPET_REMOVE;
- }
- else {
-
-
- }
- }
- tmpPetArr.splice(tmpLen, 1);
- tmp = null;
-
- tmp = new FZ.Diamond(line, col, style, state);
-
- this.m_allPets.push(tmp);
-
- if (FZ.GameDefs.DREAMPET_REMOVE !== state) {
- this.m_parent.appendChild(tmp.m_div);
- }
-
- // this.m_parent.appendChild(tmp.m_div);
- }
-
- //this.debugAllPetsType();
-
- this.m_leftNum = -1;
- this.m_dialog = false;
- },
-
- debugAllPetsType: function(){
- var index = 0;
- debug_data = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 2, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ];
- for (index = 0; index < (FZ.GameDefs.ALL_GENERAL); index++) {
- if (-1 !== debug_data[index]) {
- this.m_allPets[index].m_module = debug_data[index];
- this.m_allPets[index].m_style = debug_data[index];
- }
-
- this.m_allPets[index].setModule();
- if (-1 === debug_data[index]) {
- this.m_allPets[index].m_state = -1;
- }
- else {
- this.m_allPets[index].m_state = 0;
- }
- }
-
- },
-
- getDiamondNumber: function(col){
- var number = 0;
- var index = 0;
- var tmp = null;
- for (index = col; index < (FZ.GameDefs.ALL_GENERAL); index += FZ.GameDefs.DIAMOND_COL_NUM) {
- tmp = this.m_allPets[index];
- if (null !== tmp) {
- number++;
- }
- }
- return number;
- },
-
-
-
-
- getLeftDiamonds: function(){
- var tmp = null;
- var index = 0;
- var leftNumber = 0;
- for (index = 0; index < (FZ.GameDefs.ALL_GENERAL); index++) {
- tmp = this.m_allPets[index];
- if (!tmp) {
- continue;
- }
- leftNumber++;
- }
- return leftNumber;
- },
- getLevel: function(){
- return this.m_level;
- },
- setLevel: function(level){
- this.m_level = level;
- },
- getHintCount: function(){
- return this.m_hintCount;
- },
- setHintCount: function(hintCount){
- this.m_hintCount = hintCount;
- },
- mouseHandler: function(evt){
- // evt.stopPropagation();
- // evt.preventDefault();
- var petDisappear = false;
- var type = "";
- var x = 0;
- var y = 0;
- //var result = this.RESULT_NONE;
- if (!this.m_reset_finished) {
- return;
- }
- if (FZ.TARGET_DEF.MOBILE === FZ.TargetPort) {
- if (FZ.EVENT_DEF.T_START === evt.type) {
- type = FZ.EVENT_DEF.M_MOVE;
- x = evt.touches[0].pageX - FZ.DivManager.getOffsetX();
- y = evt.touches[0].pageY - FZ.DivManager.getOffsetY();
- this.m_last_x = x;
- this.m_last_y = y;
- }
- else
- if (FZ.EVENT_DEF.T_MOVE === evt.type) {
- type = FZ.EVENT_DEF.M_MOVE;
- x = evt.touches[0].pageX - FZ.DivManager.getOffsetX();
- y = evt.touches[0].pageY - FZ.DivManager.getOffsetY();
- this.m_last_x = x;
- this.m_last_y = y;
- }
- else
- if (FZ.EVENT_DEF.T_END === evt.type) {
- type = FZ.EVENT_DEF.M_CLICK;
- x = this.m_last_x;
- y = this.m_last_y;
- this.m_last_x = 0;
- this.m_last_y = 0;
- }
- }
- else {
- x = evt.pageX - FZ.DivManager.getOffsetX();
- y = evt.pageY - FZ.DivManager.getOffsetY();
- type = evt.type;
- }
-
- if (FZ.EVENT_DEF.M_MOVE === type) {
- // result = this.startSearch(x, y);
- // if(this.RESULT_CHANGED === result) {
- //
- // }//end if (this.RESULT_CHANGED === result) {
- }//end if(this.EVT_MOUSE_MOVE === evt.type) {
- else
- if (FZ.EVENT_DEF.M_CLICK === type) {
- petDisappear = this.setPetDisappear(x, y);
- if (petDisappear === false) {
- return;
- }
- // if(this.m_PetFirstIndex !== 0){
- // this.m_timer = setTimeout(FZ.Tools.bind(this, this.wait1), 100);
- // }
-
- // this.setLabelText();
- if ((this.m_observer) && this.m_observer.checkWin) {
- // if(this.getDisplayPet() !== 0){
- this.m_observer.checkWin();
- // }
- }
-
- }
- return false;
- }
- });
- //
- //
|