Commit 86132dab authored by wildfirecode's avatar wildfirecode

1

parent a9eac5bb
No preview for this file type
This diff is collapsed.
......@@ -46,7 +46,7 @@ function launchWithCustomModule(customModule) {
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('recycling-start', { time: 200, maxScore: 6 });
engine.globalEvent.dispatchEvent('recycling-start', { time: 1000, maxScore: 200 });
const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 200);
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -134,13 +134,6 @@
"uuid": "2614eb6c-9153-4149-b8d6-ef02ac2200ae",
"ext": ".png"
},
{
"name": "g38",
"url": "//yun.duiba.com.cn/aurora/assets/b4542db81f188832e04caaf85ab17aef4d44c814.png",
......
......@@ -2,13 +2,13 @@ import { props } from "../props";
import Conveyor from "./Conveyor";
import GarbageConfig from "./datas/GarbageConfig";
import { GarbageTypes } from "./datas/GarbageTypes";
import transStores from "./datas/transStores";
import GameView from "./GameView";
import { getTextureByName } from "./utils";
import checkHit from "./utils/checkHit";
import removeChild from "./utils/removeChild";
import removeEle from "./utils/removeEle";
import shuffle from "./utils/shuffle";
import transStores from "./datas/transStores";
export default class Conveyors extends engine.Sprite {
......@@ -46,7 +46,7 @@ export default class Conveyors extends engine.Sprite {
// 本局游戏的20种垃圾
const allConfigs = shuffle(this.GarbageConfig);
for (let i = 0; i < 20; i++) {
for (let i = 0; i < GarbageConfig.config.length; i++) {
allConfigs[i].idx = i;
allConfigs[i].isRight = false;
allConfigs[i].isMistake = false;
......@@ -69,7 +69,7 @@ export default class Conveyors extends engine.Sprite {
view.x = -data.width / 2;
view.y = -data.height + 40;
this.conveyor1[`idx${i}`].addChild(view)
view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDwon_garbage, this);
view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown_garbage, this);
}
}
......@@ -81,6 +81,7 @@ export default class Conveyors extends engine.Sprite {
onEnterFrame(ENTER_FRAME: string, onEnterFrame: any, arg2: this) {
if (this.score == (props.maxScore || 100)) {
this.gameOver();
this.wrapper.stop();
}
// console.log('this.conveyorsPool.length', this.conveyorsPool.length)
......@@ -122,7 +123,7 @@ export default class Conveyors extends engine.Sprite {
view.x = -data.width / 2;
view.y = -data.height + 40;
lastConveyor[`idx${m}`].addChild(view);
view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDwon_garbage, this);
view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown_garbage, this);
} else {
break
......@@ -226,14 +227,20 @@ export default class Conveyors extends engine.Sprite {
gameOver() {
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
engine.globalEvent.dispatchEvent('recycling-game-end', transStores( this.stores));
engine.globalEvent.dispatchEvent('recycling-game-end', transStores(this.stores));
}
private _currentView: engine.Sprite;
onDwon_garbage(e: engine.MouseEvent) {
private _currentDragView: engine.Sprite;
private _currentTarget: engine.Sprite;
onDown_garbage(e: engine.MouseEvent) {
if(this._currentDragView){
removeChild(this._currentDragView)
}
const target: engine.Sprite = e.target;
let view: any = new engine.Sprite(target.texture);
this._currentView = view;
this._currentDragView = view;
this._currentTarget = target;
target.scaleX = target.scaleY = 0;
this.wrapper.addChild(view);
view.x = e.stageX - target.texture.width / 2;
view.y = e.stageY - target.texture.height / 2;
......@@ -244,30 +251,33 @@ export default class Conveyors extends engine.Sprite {
}
onStageMouseMove(e: engine.MouseEvent) {
const view = this._currentView;
const view = this._currentDragView;
view.x = e.stageX - view.texture.width / 2;
view.y = e.stageY - view.texture.height / 2;
}
onStageMouseUp(e: engine.MouseEvent) {
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this)
if (!this._currentView) return;
if (!this._currentDragView) return;
const result: GarbageTypes = this.checkHitRect();
if (result) {
console.log('落入垃圾桶类型', result, '垃圾类型', this._currentView['type']);
if (result == this._currentView['type']) {
if (result) {//落入
if (result == this._currentDragView['type']) {//匹配
this.addscore();
} else {//不匹配
engine.Tween.get(this._currentTarget).to({ scaleX: 1, scaleY: 1 }, 300).call(() => { });
}
this.stores.push({ targetType: result, itemType: this._currentDragView['type'], itemName: this._currentDragView['name'] });
this.stores.push({ targetType: result, itemType: this._currentView['type'], itemName: this._currentView['name'] });
} else {
console.log('没有落入')
} else { //没有落入
engine.Tween.get(this._currentTarget).to({ scaleX: 1, scaleY: 1 }, 300).call(() => { });
}
this._currentView.anchorX = this._currentView.texture.width / 2;
this._currentView.anchorY = this._currentView.texture.height / 2;
engine.Tween.get(this._currentView).to({ scaleX: 0, scaleY: 0 }, 300).call(() => {
removeChild(this._currentView);
this._currentDragView.anchorX = this._currentDragView.texture.width / 2;
this._currentDragView.anchorY = this._currentDragView.texture.height / 2;
engine.Tween.get(this._currentDragView).to({ scaleX: 0, scaleY: 0 }, 300).call(() => {
removeChild(this._currentDragView);
// this._currentDragView = null;
// this._currentTarget = null;
});
}
......@@ -285,16 +295,16 @@ export default class Conveyors extends engine.Sprite {
}
checkHitRect() {
if (checkHit(this._currentView, this.wrapper.wetWaste)) {
if (checkHit(this._currentDragView, this.wrapper.wetWaste)) {
return GarbageTypes.wetWaste
}
if (checkHit(this._currentView, this.wrapper.harmfulWaste)) {
if (checkHit(this._currentDragView, this.wrapper.harmfulWaste)) {
return GarbageTypes.harmfulWaste
}
if (checkHit(this._currentView, this.wrapper.dryWaste)) {
if (checkHit(this._currentDragView, this.wrapper.dryWaste)) {
return GarbageTypes.dryWaste
}
if (checkHit(this._currentView, this.wrapper.recoverableWaste)) {
if (checkHit(this._currentDragView, this.wrapper.recoverableWaste)) {
return GarbageTypes.recoverableWaste
}
return null;
......
import { GarbageTypes } from "./GarbageTypes"
export default (list: any[]) => {
let tmp = [];
const contains = (val) => {
for (const i of tmp) {
if (val.targetType == i.targetType && val.itemType == i.itemType && val.itemName == i.itemName)
return true;
}
return false;
}
list.forEach(i => {
if (!contains(i))
tmp.push(i)
})
list = tmp;
tmp = [];
const nameList = [];
const contains2 = (val) => {
for (const i of tmp) {
if (val.itemName == i.itemName) {
nameList.push(i.itemName);
return true;
}
}
return false;
}
list.forEach(i => {
if (!contains2(i))
tmp.push(i)
})
list = tmp;
list.forEach(i=>{
if(nameList.indexOf(i.itemName) !=-1) {
i.targetType=i.itemType
}
})
return list.map(i => {
return {
'targetName': getTargetName(i.targetType),
......
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