Commit 5ec68f3c authored by yu's avatar yu

1

parent 92a53a1c
...@@ -12,6 +12,7 @@ const { ccclass, property } = cc._decorator; ...@@ -12,6 +12,7 @@ const { ccclass, property } = cc._decorator;
export default class LayerBack extends cc.Component { export default class LayerBack extends cc.Component {
private btn_back: cc.Node; private btn_back: cc.Node;
private img_npc_voice: cc.Node; private img_npc_voice: cc.Node;
private bg_forbid: cc.Node;
onLoad() { onLoad() {
this.initView(); this.initView();
this.initEvent(); this.initEvent();
...@@ -20,6 +21,7 @@ export default class LayerBack extends cc.Component { ...@@ -20,6 +21,7 @@ export default class LayerBack extends cc.Component {
initView() { initView() {
this.bg_forbid = pg.view.find(this, 'bg_forbid')
this.btn_back = pg.view.find(this, 'btn_back') this.btn_back = pg.view.find(this, 'btn_back')
this.label_title = pg.view.find(this, 'label_title') this.label_title = pg.view.find(this, 'label_title')
this.img_npc_voice = pg.view.find(this.label_title, 'img_npc_voice') this.img_npc_voice = pg.view.find(this.label_title, 'img_npc_voice')
...@@ -39,6 +41,7 @@ export default class LayerBack extends cc.Component { ...@@ -39,6 +41,7 @@ export default class LayerBack extends cc.Component {
pg.event.on('npc_layer_back_init', (data) => { pg.event.on('npc_layer_back_init', (data) => {
this.updateView(data); this.updateView(data);
if (!this.npcAudio) { if (!this.npcAudio) {
pg.view.visible(this.bg_forbid, false)
pg.event.emit('npc_voice_play_voice_end'); pg.event.emit('npc_voice_play_voice_end');
} else { } else {
this.playVoiceStart(); this.playVoiceStart();
...@@ -56,6 +59,7 @@ export default class LayerBack extends cc.Component { ...@@ -56,6 +59,7 @@ export default class LayerBack extends cc.Component {
this.schedule(this.playVoiceRunning, 0.3) this.schedule(this.playVoiceRunning, 0.3)
pg.audio.playAudioByUrl(this.npcAudio, () => { pg.audio.playAudioByUrl(this.npcAudio, () => {
this.playVoiceEnd(); this.playVoiceEnd();
pg.view.visible(this.bg_forbid, false)
pg.event.emit('npc_voice_play_voice_end') pg.event.emit('npc_voice_play_voice_end')
}, (audioId) => { }, (audioId) => {
this.audioId = audioId; this.audioId = audioId;
......
...@@ -21,20 +21,23 @@ ...@@ -21,20 +21,23 @@
"__id__": 2 "__id__": 2
}, },
{ {
"__id__": 7 "__id__": 6
},
{
"__id__": 11
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 22 "__id__": 27
}, },
{ {
"__id__": 23 "__id__": 28
} }
], ],
"_prefab": { "_prefab": {
"__id__": 24 "__id__": 29
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -85,7 +88,7 @@ ...@@ -85,7 +88,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "btn_back", "_name": "bg_forbid",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 1 "__id__": 1
...@@ -98,13 +101,128 @@ ...@@ -98,13 +101,128 @@
}, },
{ {
"__id__": 4 "__id__": 4
}
],
"_prefab": {
"__id__": 5
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1920,
"height": 1080
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.BlockInputEvents",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "0b87ca13-07e1-4237-ab3b-7f27c69deb2d"
},
"fileId": "07DTTDThBNdJCrgpsUtJSh",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "btn_back",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 7
},
{
"__id__": 8
}, },
{ {
"__id__": 5 "__id__": 9
} }
], ],
"_prefab": { "_prefab": {
"__id__": 6 "__id__": 10
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -158,7 +276,7 @@ ...@@ -158,7 +276,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 2 "__id__": 6
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -190,7 +308,7 @@ ...@@ -190,7 +308,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 2 "__id__": 6
}, },
"_enabled": true, "_enabled": true,
"_normalMaterial": null, "_normalMaterial": null,
...@@ -258,7 +376,7 @@ ...@@ -258,7 +376,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 2 "__id__": 6
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 1,
...@@ -300,17 +418,20 @@ ...@@ -300,17 +418,20 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 8 "__id__": 12
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 20 "__id__": 24
},
{
"__id__": 25
} }
], ],
"_prefab": { "_prefab": {
"__id__": 21 "__id__": 26
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -364,27 +485,27 @@ ...@@ -364,27 +485,27 @@
"_name": "img_npc_voice", "_name": "img_npc_voice",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 7 "__id__": 11
}, },
"_children": [ "_children": [
{ {
"__id__": 9 "__id__": 13
}, },
{ {
"__id__": 12 "__id__": 16
}, },
{ {
"__id__": 15 "__id__": 19
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 18 "__id__": 22
} }
], ],
"_prefab": { "_prefab": {
"__id__": 19 "__id__": 23
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -438,17 +559,17 @@ ...@@ -438,17 +559,17 @@
"_name": "p1", "_name": "p1",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 8 "__id__": 12
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 10 "__id__": 14
} }
], ],
"_prefab": { "_prefab": {
"__id__": 11 "__id__": 15
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -502,7 +623,7 @@ ...@@ -502,7 +623,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 9 "__id__": 13
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -545,17 +666,17 @@ ...@@ -545,17 +666,17 @@
"_name": "p2", "_name": "p2",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 8 "__id__": 12
}, },
"_children": [], "_children": [],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 13 "__id__": 17
} }
], ],
"_prefab": { "_prefab": {
"__id__": 14 "__id__": 18
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -609,7 +730,7 @@ ...@@ -609,7 +730,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 12 "__id__": 16
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -652,17 +773,17 @@ ...@@ -652,17 +773,17 @@
"_name": "p3", "_name": "p3",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 8 "__id__": 12
}, },
"_children": [], "_children": [],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 16 "__id__": 20
} }
], ],
"_prefab": { "_prefab": {
"__id__": 17 "__id__": 21
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -716,7 +837,7 @@ ...@@ -716,7 +837,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 15 "__id__": 19
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -759,7 +880,7 @@ ...@@ -759,7 +880,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 8 "__id__": 12
}, },
"_enabled": true, "_enabled": true,
"alignMode": 2, "alignMode": 2,
...@@ -797,7 +918,7 @@ ...@@ -797,7 +918,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 7 "__id__": 11
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -827,6 +948,33 @@ ...@@ -827,6 +948,33 @@
"_N$cacheMode": 0, "_N$cacheMode": 0,
"_id": "" "_id": ""
}, },
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 11
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 1,
"_left": 0,
"_right": 0,
"_top": 67.39999999999998,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
......
...@@ -69,3 +69,4 @@ export default class LayerCoin extends cc.Component { ...@@ -69,3 +69,4 @@ export default class LayerCoin extends cc.Component {
...@@ -57,3 +57,4 @@ export default class LayerEnding extends cc.Component { ...@@ -57,3 +57,4 @@ export default class LayerEnding extends cc.Component {
...@@ -39,13 +39,16 @@ export default class Candy extends cc.Component { ...@@ -39,13 +39,16 @@ export default class Candy extends cc.Component {
ch.y = 0; ch.y = 0;
let ju = cc.jumpBy(0.5, cc.v2(x, y), this.jumpHeight, 1); let ju = cc.jumpBy(0.5, cc.v2(x, y), this.jumpHeight, 1);
let call = cc.callFunc(() => { let call = cc.callFunc(() => {
if (idx == this.node.children.length - 1) if (idx == this.node.children.length - 1) {
pg.event.emit("camdy_action_end", this.node); pg.event.emit("camdy_action_end", this.node);
if (this.isHide) this.node.active = !this.isHide; let light = cc.find("pic_light", this.node);
cc.tween(light).to(1, { opacity: 0 }).start();
}
// if (this.isHide) this.node.active = !this.isHide;
}) })
// ch.runAction(ju); // ch.runAction(ju);
cc.tween(ch).sequence(ju, call).start(); cc.tween(ch).sequence(ju, call).start();
cc.tween(ch).delay(0.5).to(0.2, { opacity: 0 }).start();
}) })
...@@ -59,3 +62,4 @@ export default class Candy extends cc.Component { ...@@ -59,3 +62,4 @@ export default class Candy extends cc.Component {
...@@ -55,3 +55,4 @@ export default class ImgVoice extends cc.Component { ...@@ -55,3 +55,4 @@ export default class ImgVoice extends cc.Component {
...@@ -200,3 +200,4 @@ export default class LayerRecord extends cc.Component { ...@@ -200,3 +200,4 @@ export default class LayerRecord extends cc.Component {
...@@ -111,3 +111,4 @@ export default class LayerRight extends cc.Component { ...@@ -111,3 +111,4 @@ export default class LayerRight extends cc.Component {
...@@ -4,7 +4,7 @@ export let imageZize = { ...@@ -4,7 +4,7 @@ export let imageZize = {
} }
export class OptionJigsaw { export class Option {
type; type;
txt; txt;
picUrl; picUrl;
...@@ -17,11 +17,11 @@ export class OptionJigsaw { ...@@ -17,11 +17,11 @@ export class OptionJigsaw {
this.data = data; this.data = data;
this.type = data.type; this.type = data.type;
this.txt = data.text; this.txt = data.text;
this.picUrl = data.image; this.picUrl = data.pic_url;
this.audioUrl = data.optionAudio; this.audioUrl = data.optionAudio;
} }
} }
export class ItemJigsaw { export class Item {
public page; public page;
public audio; public audio;
public image; public image;
...@@ -29,26 +29,42 @@ export class ItemJigsaw { ...@@ -29,26 +29,42 @@ export class ItemJigsaw {
public voice; public voice;
public time; public time;
public id; public id;
public hotZoneItemArr;
count: number; count: number;
constructor(data, page) { constructor(data, page) {
// this.audio = data.audio;
this.image = data.pic_url; this.image = data.pic_url;
// this.voice = data.voice;
// this.time = data.time;
this.id = page; this.id = page;
// this.optionList = data.options.map(o => {
// return new Option(o, id++);
// })
// this.optionList.sort(function () { this.page = page;
// return (0.5 - Math.random()); this.audio = data.audioUrl;
// }); this.image = data.bgItem.url;
// for (let i = 0; i < this.optionList.length; i++) { this.hotZoneItemArr = [];
// this.optionList[i].count = i;
// } for (let i = 0; i < data.hotZoneItemArr.length; i++) {
let d = data.hotZoneItemArr[i];
this.hotZoneItemArr.push(new Option(d, i));
}
this.changepoints(data);
}
// this.page = page; public pointsArr;
private changepoints(data) {
let scX = imageZize.width / data.bgItem.rect.width;
let scY = imageZize.height / data.bgItem.rect.height;
let px = data.bgItem.rect.x;
let py = data.bgItem.rect.y;
this.pointsArr = [];
let arr = [];
data.hotZoneItemArr.forEach((item, idx) => {
let p = item.rect;
arr[idx] = {
x: (p.x + (p.width / 2)) * scX,// - px
y: -((p.y + (p.height / 2)) * scY)// - py
}
})
this.pointsArr = arr.concat();
} }
} }
export default class GameJigsaw { export default class GameJigsaw {
...@@ -58,7 +74,7 @@ export default class GameJigsaw { ...@@ -58,7 +74,7 @@ export default class GameJigsaw {
return GameJigsaw.ins; return GameJigsaw.ins;
} }
private data: any; private data: any;
public lists: Array<ItemJigsaw> public lists: Array<Item>
public title: string; public title: string;
public titleAudio: string; public titleAudio: string;
public image: string; public image: string;
...@@ -82,7 +98,7 @@ export default class GameJigsaw { ...@@ -82,7 +98,7 @@ export default class GameJigsaw {
public init(data) { public init(data) {
this.start = false; this.start = false;
this.lists = []; this.lists = [];
this.data = data.hotZoneItemArr; this.data = data.questions;
this.aniEnter = data.imgAni; this.aniEnter = data.imgAni;
this.endImgAni = data.endImgAni; this.endImgAni = data.endImgAni;
this.title = data.title; this.title = data.title;
...@@ -95,7 +111,6 @@ export default class GameJigsaw { ...@@ -95,7 +111,6 @@ export default class GameJigsaw {
this.tipSwitch = data.tipSwitch; this.tipSwitch = data.tipSwitch;
this.endImgTitle = data.endImgTitle; this.endImgTitle = data.endImgTitle;
this.jumpIdx = data.jumpIdx || -1; this.jumpIdx = data.jumpIdx || -1;
this.changepoints(data);
} }
public start: boolean; public start: boolean;
public page: number; public page: number;
...@@ -105,13 +120,13 @@ export default class GameJigsaw { ...@@ -105,13 +120,13 @@ export default class GameJigsaw {
this.lists = []; this.lists = [];
for (let i = 0; i < this.data.length; i++) { for (let i = 0; i < this.data.length; i++) {
let data = this.data[i]; let data = this.data[i];
this.lists.push(new ItemJigsaw(data, i)); this.lists.push(new Item(data, i + 1));
} }
this.lists.sort(function () { this.lists.sort(function () {
return (0.5 - Math.random()); return (0.5 - Math.random());
}); });
} }
checkSuccess(arr: OptionJigsaw[]) { checkSuccess(arr: Option[]) {
let data = this.getCurrentPage(); let data = this.getCurrentPage();
let options = data.optionList.concat(); let options = data.optionList.concat();
options.sort((A, B) => A.id - B.id) options.sort((A, B) => A.id - B.id)
...@@ -122,23 +137,7 @@ export default class GameJigsaw { ...@@ -122,23 +137,7 @@ export default class GameJigsaw {
} }
return true; return true;
} }
public pointsArr;
private changepoints(data) {
let scX = imageZize.width / data.bgItem.rect.width;
let scY = imageZize.height / data.bgItem.rect.height;
let px = data.bgItem.rect.x;
let py = data.bgItem.rect.y;
this.pointsArr = [];
let arr = [];
data.hotZoneItemArr.forEach((item, idx) => {
let p = item.rect;
arr[idx] = {
x: (p.x + (p.width / 2)) * scX,// - px
y: -((p.y + (p.height / 2)) * scY)// - py
}
})
this.pointsArr = arr.concat();
}
getTotalLabel() { getTotalLabel() {
let data = this.getCurrentPage(); let data = this.getCurrentPage();
...@@ -149,10 +148,10 @@ export default class GameJigsaw { ...@@ -149,10 +148,10 @@ export default class GameJigsaw {
return str; return str;
} }
getDataByPage(page): ItemJigsaw { getDataByPage(page): Item {
return this.lists.filter(li => li.page == page)[0] return this.lists.filter(li => li.page == page)[0]
} }
getCurrentPage(): ItemJigsaw { getCurrentPage(): Item {
let page = this.page; let page = this.page;
return this.lists.filter(li => li.page == page)[0] return this.lists.filter(li => li.page == page)[0]
} }
...@@ -190,3 +189,4 @@ let win: any = window; ...@@ -190,3 +189,4 @@ let win: any = window;
win.Game = GameJigsaw; win.Game = GameJigsaw;
This diff is collapsed.
import { asyncDelay, exchangeNodePos, getSprNode, onHomeworkFinish, onHomeworkStart, playAudio } from "../script/util_hy05_pintu"; import { asyncDelay, exchangeNodePos, getSprNode, onHomeworkFinish, onHomeworkStart, playAudio } from "../script/util_hy05_pintu";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_hy05_pintu"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_hy05_pintu";
import GameJigsaw, { imageZize, ItemJigsaw, OptionJigsaw } from "./Gamehy05_pintu"; import GameJigsaw, { imageZize, Item, Option } from "./Gamehy05_pintu";
import pg from "./pg_hy05_pintu"; import pg from "./pg_hy05_pintu";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -63,7 +63,6 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -63,7 +63,6 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
this.flyAction(); this.flyAction();
this.startGame(); this.startGame();
pg.view.setNetImg(this.img_bg, GameJigsaw.getIns().image, { w: imageZize.width, h: imageZize.height });
} }
initEvent() { initEvent() {
...@@ -79,7 +78,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -79,7 +78,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
}); });
pg.event.on('npc_voice_play_voice_end', () => { pg.event.on('npc_voice_play_voice_end', () => {
}) })
pg.event.emit('npc_layer_back_init', this.data) pg.event.emit('npc_layer_back_init', this.data)
...@@ -155,7 +154,6 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -155,7 +154,6 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
private currentCards: cc.Node[]; private currentCards: cc.Node[];
//开始游戏 //开始游戏
startGame() { startGame() {
GameJigsaw.getIns().reset();
this.nextPage(); this.nextPage();
} }
nextPage() { nextPage() {
...@@ -163,21 +161,22 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -163,21 +161,22 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
this.cards = []; this.cards = [];
this.currentCards = []; this.currentCards = [];
this.cardBgs = []; this.cardBgs = [];
let data = GameJigsaw.getIns().list; let data = GameJigsaw.getIns().getCurrentPage();
//自动创建卡片 //自动创建卡片
this.right_layout.active = true; this.right_layout.active = true;
this.createCrads(data); this.createCrads(data);
pg.view.setNetImg(this.img_bg, data.image, { w: imageZize.width, h: imageZize.height });
} }
//创建卡片 //创建卡片
private cards: cc.Node[]; private cards: cc.Node[];
private cardBgs: cc.Node[]; private cardBgs: cc.Node[];
createCrads(list) { createCrads(data: Item) {
this.right_layout.removeAllChildren(); this.right_layout.removeAllChildren();
// this.cleanLayoutSort(); // this.cleanLayoutSort();
this.layout_sort.removeAllChildren(); this.layout_sort.removeAllChildren();
let count = 0; let count = 0;
list.forEach((li, idx) => { data.hotZoneItemArr.forEach((li, idx) => {
let item = cc.instantiate(this.node_card); let item = cc.instantiate(this.node_card);
this.right_layout.addChild(item); this.right_layout.addChild(item);
li.count = count; li.count = count;
...@@ -185,7 +184,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -185,7 +184,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
count++; count++;
}) })
count = 0; count = 0;
let pos = GameJigsaw.getIns().pointsArr; let pos = data.pointsArr;
pos.forEach((li, idx) => { pos.forEach((li, idx) => {
let item = cc.instantiate(this.sort_card); let item = cc.instantiate(this.sort_card);
this.layout_sort.addChild(item); this.layout_sort.addChild(item);
...@@ -201,7 +200,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -201,7 +200,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
} }
private initTopCard(item, data, idx) { private initTopCard(item, data, idx) {
let img = cc.find("img", item); let img = cc.find("img", item);
pg.view.setNetImg(img, data.image, { w: 118, h: 118 }, false); pg.view.setNetImg(img, data.picUrl, { w: 118, h: 118 }, false);
img.x = idx % 2 == 0 ? -107 : 107 img.x = idx % 2 == 0 ? -107 : 107
item.active = true; item.active = true;
item.y = 0; item.y = 0;
...@@ -314,8 +313,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -314,8 +313,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
// }, 1000); // }, 1000);
if (this.checkRoundEnd()) { if (this.checkRoundEnd()) {
GameJigsaw.getIns().addPage(); this.checkGameOver();
pg.event.emit("gameOver");
} }
} else { } else {
this.playLocalAudio("error"); this.playLocalAudio("error");
...@@ -353,6 +351,19 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -353,6 +351,19 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
return this.currentCards.every(card => !!card); return this.currentCards.every(card => !!card);
} }
private checkGameOver() {
let audio = GameJigsaw.getIns().getCurrentPage().audio;
let over = GameJigsaw.getIns().addPage();
pg.audio.playAudioByUrl(audio).then(async () => {
await asyncDelay(1);
if (!over) {
pg.event.emit("gameOver");
} else {
this.nextPage();
}
});
}
gameOver() { gameOver() {
pg.event.once('layer_right_show_excellent_end', () => { pg.event.once('layer_right_show_excellent_end', () => {
pg.event.emit('layer_coin_show_coin', 3) //1 2 3硬币数量 pg.event.emit('layer_coin_show_coin', 3) //1 2 3硬币数量
...@@ -388,3 +399,4 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -388,3 +399,4 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
...@@ -587,3 +587,4 @@ let pg = { ...@@ -587,3 +587,4 @@ let pg = {
export default pg; export default pg;
...@@ -179,3 +179,4 @@ export class MyCocosSceneComponent extends cc.Component { ...@@ -179,3 +179,4 @@ export class MyCocosSceneComponent extends cc.Component {
} }
export const defaultData = { export const defaultData = {
"npcTitle": "pintu",
"npcAudio": "http://staging-teach.cdn.ireadabc.com/449e65975d358514cc3494f9f67bc012_l.mp3",
"npcAudioName": "cape.mp3",
"tipSwitch": 1, "tipSwitch": 1,
"tipType": "page", "tipType": "page",
"tipBg": "", "tipBg": "",
"tipPage": [{ "tipPage": [{
"title": "", "title": "",
"audio": "" "audio": ""
} }
], ],
"title": "", "title": "",
"audio": "", "audio": "",
...@@ -15,43 +18,37 @@ export const defaultData = { ...@@ -15,43 +18,37 @@ export const defaultData = {
"points": "", "points": "",
"questionScore": 0, "questionScore": 0,
"questions": [{ "questions": [{
"options": [{ "options": [{
"type": "img", "audio": "",
"image": "", "hotZoneItemArr": [],
"audio": "", "bgItem": "",
"text": "", "right": false
"time": "", }, {
"right": false "audio": "",
}, { "hotZoneItemArr": [],
"type": "img", "bgItem": "",
"image": "", "right": false
"audio": "", }, {
"text": "", "audio": "",
"time": "", "hotZoneItemArr": [],
"right": false "bgItem": "",
}, { "right": false
"type": "img",
"image": "",
"audio": "",
"text": "",
"time": "",
"right": false
}
],
"type": "img"
}
],
"bgItem": {
"url": "http://staging-teach.cdn.ireadabc.com/1553dfbd077983ec0c42e03c28ded825.png",
"rect": {
"x": 0,
"y": 62.27,
"width": 904,
"height": 567.45
} }
}, ],
"hotZoneItemArr": [{ "type": "img",
"id": "1686815485086", "audioUrl": "http://staging-teach.cdn.ireadabc.com/36067f9e2415d59fa37c3795a3929087_l.mp3",
"audioName": "bear_3.mp3",
"bgItem": {
"url": "http://staging-teach.cdn.ireadabc.com/1553dfbd077983ec0c42e03c28ded825.png",
"rect": {
"x": 0,
"y": 62.27,
"width": 904,
"height": 567.45
}
},
"hotZoneItemArr": [{
"id": "1688889611322",
"index": 0, "index": 0,
"pic_url": "http://staging-teach.cdn.ireadabc.com/43529c2ca99eb66d78fd920d863559a9.png", "pic_url": "http://staging-teach.cdn.ireadabc.com/43529c2ca99eb66d78fd920d863559a9.png",
"itemType": "pic", "itemType": "pic",
...@@ -70,12 +67,12 @@ export const defaultData = { ...@@ -70,12 +67,12 @@ export const defaultData = {
"ontColor": "#8f3758", "ontColor": "#8f3758",
"rect": { "rect": {
"x": 311.77, "x": 311.77,
"y": 143.51, "y": 143.5,
"width": 280.46, "width": 280.46,
"height": 280.46 "height": 280.46
} }
}, { }, {
"id": "1686815494742", "id": "1688889615595",
"index": 1, "index": 1,
"pic_url": "http://staging-teach.cdn.ireadabc.com/47041db332a1ba4cd5050abf729b817d.png", "pic_url": "http://staging-teach.cdn.ireadabc.com/47041db332a1ba4cd5050abf729b817d.png",
"itemType": "pic", "itemType": "pic",
...@@ -93,13 +90,13 @@ export const defaultData = { ...@@ -93,13 +90,13 @@ export const defaultData = {
"fontName": "ahronbd-1", "fontName": "ahronbd-1",
"ontColor": "#8f3758", "ontColor": "#8f3758",
"rect": { "rect": {
"x": 489.77, "x": 490.77,
"y": 330.5, "y": 331.5,
"width": 280.46, "width": 280.46,
"height": 280.46 "height": 280.46
} }
}, { }, {
"id": "1686815513031", "id": "1688889616169",
"index": 2, "index": 2,
"pic_url": "http://staging-teach.cdn.ireadabc.com/ce34627cca00e3eb7d869c95086d2a85.png", "pic_url": "http://staging-teach.cdn.ireadabc.com/ce34627cca00e3eb7d869c95086d2a85.png",
"itemType": "pic", "itemType": "pic",
...@@ -118,12 +115,12 @@ export const defaultData = { ...@@ -118,12 +115,12 @@ export const defaultData = {
"ontColor": "#8f3758", "ontColor": "#8f3758",
"rect": { "rect": {
"x": -33.23, "x": -33.23,
"y": 140.5, "y": 143.5,
"width": 280.46, "width": 280.46,
"height": 280.46 "height": 280.46
} }
}, { }, {
"id": "1686815513951", "id": "1688889617242",
"index": 3, "index": 3,
"pic_url": "http://staging-teach.cdn.ireadabc.com/feba2ef37c412aa71a46c3c5f20abda2.png", "pic_url": "http://staging-teach.cdn.ireadabc.com/feba2ef37c412aa71a46c3c5f20abda2.png",
"itemType": "pic", "itemType": "pic",
...@@ -133,27 +130,115 @@ export const defaultData = { ...@@ -133,27 +130,115 @@ export const defaultData = {
"imgSizeH": 300, "imgSizeH": 300,
"mapScale": 0.70625, "mapScale": 0.70625,
"dragDot": { "dragDot": {
"x": 452, "x": 320,
"y": 346 "y": 166
}, },
"gIdx": "0", "gIdx": "0",
"fontSize": 50, "fontSize": 50,
"fontName": "ahronbd-1", "fontName": "ahronbd-1",
"ontColor": "#8f3758", "ontColor": "#8f3758",
"rect": { "rect": {
"x": 129.77, "x": 128.77,
"y": -47.5, "y": -47.5,
"width": 280.46, "width": 280.46,
"height": 280.46 "height": 280.46
} }
} }
]
}, {
"options": [],
"type": "img",
"bgItem": {
"url": "http://staging-teach.cdn.ireadabc.com/1553dfbd077983ec0c42e03c28ded825.png",
"rect": {
"x": 0,
"y": 2.64,
"width": 1094,
"height": 686.72
}
},
"hotZoneItemArr": [{
"id": "1688889777085",
"index": 0,
"pic_url": "http://staging-teach.cdn.ireadabc.com/43529c2ca99eb66d78fd920d863559a9.png",
"itemType": "pic",
"fontScale": 0.8546875,
"imgScale": 1.1313340227507755,
"imgSizeW": 300,
"imgSizeH": 300,
"mapScale": 0.8546875,
"dragDot": {
"x": 547,
"y": 346
},
"gIdx": "0",
"fontSize": 50,
"fontName": "ahronbd-1",
"ontColor": "#8f3758",
"rect": {
"x": 377.3,
"y": 173.66,
"width": 339.4,
"height": 339.4
}
}, {
"id": "1688889778564",
"index": 1,
"pic_url": "http://staging-teach.cdn.ireadabc.com/47041db332a1ba4cd5050abf729b817d.png",
"itemType": "pic",
"fontScale": 0.8546875,
"imgScale": 1.1313340227507755,
"imgSizeW": 300,
"imgSizeH": 300,
"mapScale": 0.8546875,
"dragDot": {
"x": 547,
"y": 346
},
"gIdx": "0",
"fontSize": 50,
"fontName": "ahronbd-1",
"ontColor": "#8f3758",
"rect": {
"x": 592.3,
"y": 398.66,
"width": 339.4,
"height": 339.4
}
}, {
"id": "1688889788878",
"index": 2,
"pic_url": "http://staging-teach.cdn.ireadabc.com/feba2ef37c412aa71a46c3c5f20abda2.png",
"itemType": "pic",
"fontScale": 0.8546875,
"imgScale": 1.1313340227507755,
"imgSizeW": 300,
"imgSizeH": 300,
"mapScale": 0.8546875,
"dragDot": {
"x": 547,
"y": 346
},
"gIdx": "0",
"fontSize": 50,
"fontName": "ahronbd-1",
"ontColor": "#8f3758",
"rect": {
"x": 155.3,
"y": -60.34,
"width": 339.4,
"height": 339.4
}
}
],
"audioUrl": "http://staging-teach.cdn.ireadabc.com/36067f9e2415d59fa37c3795a3929087_l.mp3",
"audioName": "bear_3.mp3"
}
], ],
"questionText": "", "bgItem": "",
"npcTitle": "hi fiddler", "hotZoneItemArr": [],
"npcAudio": "http://staging-teach.cdn.ireadabc.com/449e65975d358514cc3494f9f67bc012_l.mp3", "questionText": ""
"npcAudioName": "cape.mp3"
} }
...@@ -444,3 +444,4 @@ export function onHomeworkStart(cb) { ...@@ -444,3 +444,4 @@ export function onHomeworkStart(cb) {
} }
...@@ -89,78 +89,56 @@ ...@@ -89,78 +89,56 @@
<span>{{ item.npcAudioName}}</span> <span>{{ item.npcAudioName}}</span>
</div> </div>
</div> </div>
<!-- <span style="margin-right: 20px;font-size: 18px;font-weight: bold;">提示开关 </span> </div>
<nz-radio-group [ngModel]="item.tipSwitch" (ngModelChange)="customRadioChange($event, item,'tipSwitch')"
style="font-size: 20px;display: flex; align-items: center; justify-content: left; flex-wrap: wrap;">
<label nz-radio nzValue="1">开</label>
<label nz-radio nzValue="0">关</label>
</nz-radio-group> --> <div style="margin: 20px;width: 1300px;">
<!-- <div *ngFor="let question of item.questions; let i = index">
<div *ngIf="item.tipSwitch == 1"> <div style="display: flex;margin-top: 20px;">
<span style="font-size: 20px;">提示动画: </span> <div class="border-solid" style="min-width: 1300px;">
<app-upload-dragon-bone style="width: 100%" (save)="onDragonBoneSave($event,item)" <div class="word-type-title">
[skeJsonData]="item.imgAni.ske" [texJsonData]="item.imgAni.tex" [texPngData]="item.imgAni.png"> 题目{{i+1}}
</app-upload-dragon-bone> </div>
<div>
<span style="font-size: 20px;">提示背景: </span> <div class="option-audio">
<div style="width:300px"> <div class="word-input-title">
<app-upload-image-with-preview [picUrl]="item.tipBg" 结束音频:
(imageUploaded)="onImageUploadSuccess($event,'tipBg', item)"></app-upload-image-with-preview> </div>
</div> <div style="display: flex">
</div> <div>
<div> <app-audio-recorder [audioUrl]="question.audioUrl"
<span style="font-size: 20px;">提示内容: </span> (audioUploaded)="onAudioUploadSuccess($event, 'audioUrl', question,'audioName')">
<input *ngIf="item.tipType == 'scroll'" type="text" nz-input [(ngModel)]="item.title" (blur)="save()">
<div *ngIf="item.tipType == 'page'">
<div *ngFor="let page of item.tipPage; let m = index" style="margin-bottom: 5px; ">
<div style="display: flex;">
<div style="font-size: 20px;line-height:32px">页{{m+1}}</div>
<input style="width:700px;margin-left: 10px;" type="text" nz-input [(ngModel)]="page.title"
(blur)="save()">
<div style="margin-left: 20px;">
<app-audio-recorder [audioUrl]="page.audio"
(audioUploaded)="onAudioUploadSuccess($event, 'audio',page)">
</app-audio-recorder> </app-audio-recorder>
</div> </div>
<button class="btn-red" style="width: 100px; height: 32px;margin-left: 20px;" nz-button nzType="default" <div style="margin: 5px">
nzDanger (click)="removePage(m)">删除</button> <span>
{{ question.audioName}}
</span>
</div>
</div>
<div class="border-dashed" style="margin: 20px;width: 1200px;">
<h2>热区配置:</h2>
<app-custom-hot-zone [bgItem]="question.bgItem" [hotZoneItemArr]="question.hotZoneItemArr"
[customTypeGroupArr]="customTypeGroupArr" (save)="saveHotZone(question, $event)">
</app-custom-hot-zone>
</div> </div>
</div> </div>
<button class="btn-blue" style="width: 150px; height: 32px;" nz-button nzType="default" nzDanger
(click)="addPage()">+增加提示内容</button> </div>
<div style="margin:0 20px">
<button class="btn-red" nz-button nzType="default" nzDanger (click)="removequestion(i)">删除题目</button>
</div> </div>
</div> </div>
</div> -->
<div style="margin-top: 20px;">
<!-- <button class="btn-blue" style="width: 1300px; height: 50px;" nz-button nzType="default" nzDanger
<div> (click)="addquestion()">+增加题目</button>
<span style="font-size: 20px;">游戏背景: </span>
<div style="width:300px">
<app-upload-image-with-preview [picUrl]="item.image"
(imageUploaded)="onImageUploadSuccess($event,'image', item)"></app-upload-image-with-preview>
</div> </div>
</div> </div>
<div style="display: flex; align-items: center; ">
<h2> 题目分值: </h2>
</div>
<input type="text" nz-input [(ngModel)]="item.questionScore" (blur)="save()">
<span style="font-size: 20px;">结束动画: </span>
<app-upload-dragon-bone style="width: 100%" (save)="onDragonBoneSave($event,item)"
[skeJsonData]="item.endImgAni.ske" [texJsonData]="item.endImgAni.tex" [texPngData]="item.endImgAni.png">
</app-upload-dragon-bone>
<span style="font-size: 20px;">结束动画文本: </span>
<input type="text" nz-input [(ngModel)]="item.endImgTitle" (blur)="save()">
<div style="display: flex; align-items: center; ">
<h2> 跳转页面: </h2>
</div>
<input type="text" nz-input [(ngModel)]="item.jumpIdx" (blur)="save()">
</div> -->
<div class="border-dashed" style="margin: 20px;width: 1000px;">
<h2>热区配置:</h2>
<app-custom-hot-zone [bgItem]="item.bgItem" [hotZoneItemArr]="item.hotZoneItemArr"
[customTypeGroupArr]="customTypeGroupArr" (save)="saveHotZone(item, $event)">
</app-custom-hot-zone>
</div> </div>
</div> </div>
......
...@@ -176,11 +176,9 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O ...@@ -176,11 +176,9 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
addoption(i) { addoption(i) {
this.item.questions[i].options.push({ this.item.questions[i].options.push({
type: "img",
image: "",
audio: "", audio: "",
text: "", hotZoneItemArr: [],
time: "", bgItem: "",
right: false right: false
}); });
this.save(); this.save();
......
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