Commit 964c8b01 authored by Tt's avatar Tt

通用部分添加完成

parent b57939a8
...@@ -6949,6 +6949,12 @@ ...@@ -6949,6 +6949,12 @@
"__id__": 2 "__id__": 2
}, },
"_enabled": true, "_enabled": true,
"layout_start": {
"__id__": 141
},
"layout_finish": {
"__id__": 122
},
"_id": "eaTVUpqahPfZeO9+sUI7RP" "_id": "eaTVUpqahPfZeO9+sUI7RP"
} }
] ]
\ No newline at end of file
...@@ -8,6 +8,10 @@ const { ccclass, property } = cc._decorator; ...@@ -8,6 +8,10 @@ const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class SceneComponent extends MyCocosSceneComponent { export default class SceneComponent extends MyCocosSceneComponent {
@property(cc.Node)
layout_start: cc.Node = null;
@property(cc.Node)
layout_finish: cc.Node = null;
addPreloadImage() { addPreloadImage() {
// TODO 根据自己的配置预加载图片资源 // TODO 根据自己的配置预加载图片资源
this._imageResList.push({ url: this.data.pic_url }); this._imageResList.push({ url: this.data.pic_url });
...@@ -29,7 +33,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -29,7 +33,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.initView(); this.initView();
this.initEvent(); this.initEvent();
this.log("statr!!!!!!!!!!!!!") this.log("statr!!!!!!!!!!!!!")
this.initStart().then(() => {
this.gameStart() this.gameStart()
})
} }
protected onDestroy(): void { protected onDestroy(): void {
pg.event.clear(); pg.event.clear();
...@@ -61,6 +68,69 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -61,6 +68,69 @@ export default class SceneComponent extends MyCocosSceneComponent {
}) })
} }
private resetGame() {
cc.audioEngine.stopAllEffects();
this.playLocalAudio("again");
this.initData();
this.gameStart();
}
private onAgain() {
this.layout_finish.active = false;
this.resetGame();
}
private onNext() {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const mc = middleLayer.getComponent('middleLayer');
// // 切换下一页
mc.goNextPage();
}
}
private initStart() {
return new Promise((resolve, reject) => {
this.layout_start.active = true;
cc.find("layout_top/label_title", this.node).getComponent(cc.Label).string = Game.getIns().title;
pg.event.emit("mouse_09_num", Game.getIns().total);
let start_ske = cc.find("layout_start/start_ske", this.node);
pg.load.loadDB(start_ske, { ske: Game.getIns().aniEnter.ske.url, tex: Game.getIns().aniEnter.tex.url, png: Game.getIns().aniEnter.png.url }).then((animationName) => {
if (animationName && animationName != "") {
let db = start_ske.getComponent(dragonBones.ArmatureDisplay);
let anis = db.getAnimationNames(db.armatureName);
db.playAnimation(anis[0], 0);
cc.tween(start_ske).by(1, { x: -500 }).call(() => {
pg.audio.playAudioByUrl(Game.getIns().startAudio).then(() => {
cc.tween(start_ske).delay(1).by(1, { x: 500 }).call(() => {
this.layout_start.active = false;
resolve('');
}).start();
});
}).start();
} else {
this.layout_start.active = false;
resolve('');
}
})
});
}
private showFinal() {
this.playLocalAudio("finish");
let layout_finish = cc.find("layout_finish", this.node);
layout_finish.active = true;
let finish_db = cc.find("finish_db", layout_finish);
let btn_again = cc.find("btn_again", layout_finish);
let btn_next = cc.find("btn_next", layout_finish);
btn_again.on(cc.Node.EventType.TOUCH_END, this.onAgain, this);
btn_next.on(cc.Node.EventType.TOUCH_END, this.onNext, this);
finish_db.active = true;
btn_again.active = false;
btn_next.active = false;
finish_db.getComponent(dragonBones.ArmatureDisplay).playAnimation("newAnimation", 1);
this.playLocalAudio("finish").then(() => {
finish_db.active = false;
btn_again.active = true;
btn_next.active = true;
});
}
gameStart() { gameStart() {
pg.audio.playLocalAudio(cc.find(`Canvas/res/audio/btn`)); pg.audio.playLocalAudio(cc.find(`Canvas/res/audio/btn`));
if (this.audioId > -1) { if (this.audioId > -1) {
...@@ -73,6 +143,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -73,6 +143,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 出现鱼 // 出现鱼
let fishList = Game.getIns().getFishList(); let fishList = Game.getIns().getFishList();
let layout_fish = pg.view.find(this, 'layout_bottom/layout_fish') let layout_fish = pg.view.find(this, 'layout_bottom/layout_fish')
layout_fish.removeAllChildren();
let item = pg.view.find(this, 'layout_bottom/item') let item = pg.view.find(this, 'layout_bottom/item')
fishList.forEach((fish, index) => { fishList.forEach((fish, index) => {
let node = cc.instantiate(item); let node = cc.instantiate(item);
...@@ -121,16 +192,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -121,16 +192,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
item.on(cc.Node.EventType.TOUCH_END, this.onItemTouchEnd, this); item.on(cc.Node.EventType.TOUCH_END, this.onItemTouchEnd, this);
item.on(cc.Node.EventType.TOUCH_CANCEL, this.onItemTouchCancel, this); item.on(cc.Node.EventType.TOUCH_CANCEL, this.onItemTouchCancel, this);
} }
onTouchItem(e) {
let item = e.target;
let data = item.data;
item.x = 0;
item.y = 0;
cc.Tween.stopAllByTarget(item);
setTimeout(() => {
this.updateItem(item, data);
}, 100);
}
private setTouchPos(e) { private setTouchPos(e) {
let item = e.target; let item = e.target;
let location = e.getLocation(); let location = e.getLocation();
...@@ -175,6 +236,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -175,6 +236,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
Game.getIns().boatRight.setRight(data); Game.getIns().boatRight.setRight(data);
currentRect = rightRect; currentRect = rightRect;
} }
if (!currentRect) return;
if (isRight) { if (isRight) {
// target // target
let item = target; let item = target;
...@@ -190,6 +252,11 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -190,6 +252,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
let time = space / 10; let time = space / 10;
cc.tween(item).by(time, { x: -space }).start(); cc.tween(item).by(time, { x: -space }).start();
} }
item.off(cc.Node.EventType.TOUCH_START, this.onItemTouchStart, this);
item.off(cc.Node.EventType.TOUCH_MOVE, this.onItemTouchMove, this);
item.off(cc.Node.EventType.TOUCH_END, this.onItemTouchEnd, this);
item.off(cc.Node.EventType.TOUCH_CANCEL, this.onItemTouchCancel, this);
pg.event.emit('mouse_05_add')
} else { } else {
this.updateItem(target, data); this.updateItem(target, data);
} }
...@@ -204,20 +271,21 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -204,20 +271,21 @@ export default class SceneComponent extends MyCocosSceneComponent {
private showGameOver() { private showGameOver() {
let gameover = cc.find("gameover", this.node); this.showFinal();
gameover.scale = 3; // let gameover = cc.find("gameover", this.node);
gameover.active = true; // gameover.scale = 3;
this.playLocalAudio("gameover"); // gameover.active = true;
cc.tween(gameover).to(0.3, { scale: 1 }) // this.playLocalAudio("gameover");
.delay(2) // cc.tween(gameover).to(0.3, { scale: 1 })
.call(() => { // .delay(2)
gameover.active = false; // .call(() => {
//发送给上端最后的数据 // gameover.active = false;
// alert("game_finish") // //发送给上端最后的数据
let player = { right: Game.getIns().player.score, error: Game.getIns().player.error } // // alert("game_finish")
onHomeworkFinish(player) // let player = { right: Game.getIns().player.score, error: Game.getIns().player.error }
this.log("player: " + JSON.stringify(player)); // onHomeworkFinish(player)
}).start(); // this.log("player: " + JSON.stringify(player));
// }).start();
} }
playLocalAudio(audioName) { playLocalAudio(audioName) {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// Learn life-cycle callbacks: // Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import pg from "../pg"; import pg from "../tool/pg";
// import Game from "../../scene/Game"; // import Game from "../../scene/Game";
...@@ -13,7 +13,7 @@ import pg from "../pg"; ...@@ -13,7 +13,7 @@ import pg from "../pg";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class Ngt_star_05 extends cc.Component { export default class Ngt_star_7 extends cc.Component {
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
onLoad() { onLoad() {
pg.event.on("mouse_05_num", (max: number) => { pg.event.on("mouse_05_num", (max: number) => {
...@@ -110,7 +110,7 @@ export default class Ngt_star_05 extends cc.Component { ...@@ -110,7 +110,7 @@ export default class Ngt_star_05 extends cc.Component {
// this.checkGameEnd(); // this.checkGameEnd();
return; return;
} }
const bigStarBg = this.bigStarArr[curGroupIndex]//[this.curGroupIndex++]; const bigStarBg = this.bigStarArr[this.curGroupIndex++];//[curGroupIndex]//
if (!bigStarBg) return; if (!bigStarBg) return;
const star_wrong = bigStarBg.star_wrong; const star_wrong = bigStarBg.star_wrong;
star_wrong.active = true; star_wrong.active = true;
...@@ -131,7 +131,7 @@ export default class Ngt_star_05 extends cc.Component { ...@@ -131,7 +131,7 @@ export default class Ngt_star_05 extends cc.Component {
if (!this.bigStarArr || this.bigStarArr.length <= 0) { if (!this.bigStarArr || this.bigStarArr.length <= 0) {
return; return;
} }
const bigStarBg = this.bigStarArr[curGroupIndex]//[this.curGroupIndex++]; const bigStarBg = this.bigStarArr[this.curGroupIndex++];//[curGroupIndex]//
if (!bigStarBg) return; if (!bigStarBg) return;
const starBig = bigStarBg.starBig; const starBig = bigStarBg.starBig;
......
...@@ -107,6 +107,10 @@ export default class Game { ...@@ -107,6 +107,10 @@ export default class Game {
public player: Player; public player: Player;
public state: GAME_STATE; public state: GAME_STATE;
public title: string;
public total: number;
public aniEnter;
public startAudio;
constructor() { constructor() {
this.start = false; this.start = false;
this.lists = []; this.lists = [];
...@@ -120,6 +124,10 @@ export default class Game { ...@@ -120,6 +124,10 @@ export default class Game {
this.start = false; this.start = false;
this.lists = []; this.lists = [];
this.data = data.questions; this.data = data.questions;
this.title = data.title;
this.startAudio = data.startAudio || "";
this.aniEnter = data.imgAni;
} }
public start: boolean; public start: boolean;
public boatLeft: Item; public boatLeft: Item;
......
...@@ -4589,6 +4589,9 @@ declare namespace cc { ...@@ -4589,6 +4589,9 @@ declare namespace cc {
!#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ !#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
forward: Vec3; forward: Vec3;
data: Option; data: Option;
starBig: any;
star: any;
star_wrong: any;
/** /**
@param name name @param name name
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