Commit 80e00ea1 authored by linzhiguo's avatar linzhiguo

+ 干扰不计贴纸

+ 连对连错不起过3
+ 避免干扰是正确的
parent 39a93037
...@@ -165,8 +165,12 @@ cc.Class({ ...@@ -165,8 +165,12 @@ cc.Class({
handleData(data){ handleData(data){
let arr = {}; let arr = {};
let len = data.mouses.length; let len = data.mouses.length;
if (len == 1) this._flag_number = len;
if (len == 1){
data.mouses[0].correct = true;
data.mouses[0].system = false;
return data; return data;
}
arr.time = data.time; arr.time = data.time;
arr.title = data.title; arr.title = data.title;
...@@ -178,6 +182,7 @@ cc.Class({ ...@@ -178,6 +182,7 @@ cc.Class({
words[i] = data.mouses[i].word; words[i] = data.mouses[i].word;
origin[i] = words[i]; origin[i] = words[i];
arr.mouses[i] = {}; arr.mouses[i] = {};
arr.mouses[i].system = false;
arr.mouses[i].word = data.mouses[i].word; arr.mouses[i].word = data.mouses[i].word;
arr.mouses[i].correct = true; arr.mouses[i].correct = true;
arr.mouses[i].audio_url = data.mouses[i].audio_url; arr.mouses[i].audio_url = data.mouses[i].audio_url;
...@@ -191,6 +196,7 @@ cc.Class({ ...@@ -191,6 +196,7 @@ cc.Class({
for(let i = 0; i < len; i++){ for(let i = 0; i < len; i++){
j = i+ len; j = i+ len;
arr.mouses[j] = {}; arr.mouses[j] = {};
arr.mouses[j].system = true;
letter = data.mouses[i].word; letter = data.mouses[i].word;
tmp = words[i]; tmp = words[i];
...@@ -207,7 +213,15 @@ cc.Class({ ...@@ -207,7 +213,15 @@ cc.Class({
initView() { initView() {
window.WL = this; window.WL = this;
this.data = this.handleData(this.data); this.data = this.handleData(this.data);
this.shuffle(this.data.mouses);
let count = 0;
do{
this.shuffle(this.data.mouses);
count++;
if (count > 50)
break;
}while(this.sameCount(this.data.mouses))
console.log(this.data.mouses); console.log(this.data.mouses);
this._touched = false; this._touched = false;
...@@ -301,19 +315,19 @@ cc.Class({ ...@@ -301,19 +315,19 @@ cc.Class({
let flag_area = cc.find('Canvas/flag_area'); let flag_area = cc.find('Canvas/flag_area');
flag_area.removeAllChildren(); flag_area.removeAllChildren();
let node = cc.find('res/img/icon_0'); let node = cc.find('res/img/icon_0');
let mouses = this.data.mouses;
let lyt = flag_area.getComponent(cc.Layout); let lyt = flag_area.getComponent(cc.Layout);
let width = flag_area.width - lyt.paddingRight; let width = flag_area.width - lyt.paddingRight;
let padding_x = lyt.spacingX; let padding_x = lyt.spacingX;
let item, len = mouses.length; let item, len = this._flag_number;
for(let i = 0; i < len; i++){ for(let i = 0; i < len; i++){
item = cc.instantiate(node); item = cc.instantiate(node);
flag_area.addChild(item); flag_area.addChild(item);
item.y = 0; item.y = 0;
item.scale = this.Between(0.5, (width/len - padding_x)/item.width, 1); item.scale = this.Between(0.5, (width/len - padding_x)/item.width, 1);
} }
this._mouse_index = 0;
this._flag_index = 0; this._flag_index = 0;
cb && cb(); cb && cb();
}, },
...@@ -323,7 +337,7 @@ cc.Class({ ...@@ -323,7 +337,7 @@ cc.Class({
nextMouse(){ nextMouse(){
let item, len = this.mouses.length; let item, len = this.mouses.length;
let mouse_id = RandomInt(len) let mouse_id = RandomInt(len)
let info = this.data.mouses[this._flag_index]; let info = this.data.mouses[this._mouse_index];
if (this._time_ani){ if (this._time_ani){
this._time_ani.stop(); this._time_ani.stop();
this._time_ani = null; this._time_ani = null;
...@@ -401,10 +415,10 @@ cc.Class({ ...@@ -401,10 +415,10 @@ cc.Class({
}, },
updateFlag(){ updateFlag(){
if (this._flag_index >= this.data.mouses.length || this.hit_result == false) if (this._flag_index >= this._flag_number || this.hit_result == false)
return; return;
let idx = this.data.mouses.length - this._flag_index - 1; let idx = this._flag_number- this._flag_index- 1;
let area = cc.find('Canvas/flag_area'); let area = cc.find('Canvas/flag_area');
let flag = area.children[idx].getComponent(cc.Sprite); let flag = area.children[idx].getComponent(cc.Sprite);
flag.enabled = false; flag.enabled = false;
...@@ -427,8 +441,13 @@ cc.Class({ ...@@ -427,8 +441,13 @@ cc.Class({
this._laugh = null; this._laugh = null;
} }
this._flag_index ++; let mouse = this.data.mouses[this._mouse_index];
if (this._flag_index >= this.data.mouses.length){ if (mouse.system == false){
this._flag_index ++;
}
this._mouse_index ++;
if (this._mouse_index >= this.data.mouses.length){
this._finished = true; this._finished = true;
if (this.allWrong() == true){ if (this.allWrong() == true){
...@@ -569,10 +588,29 @@ cc.Class({ ...@@ -569,10 +588,29 @@ cc.Class({
compareOne(a, b){ compareOne(a, b){
let len = a.length; let len = a.length;
for(let i = 0; i < len; i++){ for(let i = 0; i < len; i++){
if (a[i] == b[i]) if (a[i] == b[i].toUpperCase() || a[i] == b[i].toLowerCase())
return true; return true;
} }
return false; return false;
}, },
sameCount(mouses, max = 2){
let cnt = 0;
let v = mouses[0].correct;
let i, len = mouses.length;
for(i = 1; i < len; i++){
if (v == mouses[i].correct){
cnt++;
if (cnt >= max)
return true;
}
else{
v = mouses[i].correct;
cnt = 0;
}
}
return false;
},
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment