Commit f923ffff authored by Edwise's avatar Edwise 🍷

Merge branch '20230322_tiaoyitiao_2.0' of...

Merge branch '20230322_tiaoyitiao_2.0' of gitlab2.dui88.com:wangyongxia/zjzy_client_game into 20230322_tiaoyitiao_2.0
parents 44cade3f 6f053187
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
position: absolute; position: absolute;
background-color: #9a3636; background-color: #54c5f4;
-webkit-user-select: none; -webkit-user-select: none;
/* Safari */ /* Safari */
-ms-user-select: none; -ms-user-select: none;
......
resource/GameScene/cdbg.png

9.21 KB | W: | H:

resource/GameScene/cdbg.png

6.09 KB | W: | H:

resource/GameScene/cdbg.png
resource/GameScene/cdbg.png
resource/GameScene/cdbg.png
resource/GameScene/cdbg.png
  • 2-up
  • Swipe
  • Onion skin
resource/GameScene/cloud.png

4.83 KB | W: | H:

resource/GameScene/cloud.png

13.5 KB | W: | H:

resource/GameScene/cloud.png
resource/GameScene/cloud.png
resource/GameScene/cloud.png
resource/GameScene/cloud.png
  • 2-up
  • Swipe
  • Onion skin
resource/GameScene/controlpeo.png

29.9 KB | W: | H:

resource/GameScene/controlpeo.png

23.3 KB | W: | H:

resource/GameScene/controlpeo.png
resource/GameScene/controlpeo.png
resource/GameScene/controlpeo.png
resource/GameScene/controlpeo.png
  • 2-up
  • Swipe
  • Onion skin
resource/GameScene/gamebg.jpg

288 KB | W: | H:

resource/GameScene/gamebg.jpg

347 KB | W: | H:

resource/GameScene/gamebg.jpg
resource/GameScene/gamebg.jpg
resource/GameScene/gamebg.jpg
resource/GameScene/gamebg.jpg
  • 2-up
  • Swipe
  • Onion skin
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
"name": "FailPanel" "name": "FailPanel"
}, },
{ {
"keys": "cdbg.png,closemusic.png,cloud.png,controlpeo.png,gamebg.jpg,gamebuild.png,leftbtn.png,monster.png,openmusic.png,rightbtn.png,scorebg.png,tianpop.png,xiangpop.png", "keys": "cdbg.png,cloud.png,controlpeo.png,gamebg.jpg,monster.png,num_0.png,num_1.png,num_2.png,num_3.png,num_4.png,num_5.png,num_6.png,num_7.png,num_8.png,num_9.png,num_s.png,reset.png,tianpop.png,xiangpop.png",
"name": "GameScene" "name": "GameScene"
}, },
{ {
"keys": "guide.png", "keys": "guide.png,step1_img.png,step1_tips.png,step2_img.png,step2_tips.png,step3_img.png,step3_tips.png,step4_img.png",
"name": "GuidePanel" "name": "GuidePanel"
}, },
{ {
...@@ -24,16 +24,12 @@ ...@@ -24,16 +24,12 @@
"keys": "infoline.png,light.png,sucbg.png,sucstar.png,sun.png", "keys": "infoline.png,light.png,sucbg.png,sucstar.png,sun.png",
"name": "SuccessPanel" "name": "SuccessPanel"
}, },
{
"keys": "bg.mp3,fail.mp3,get.mp3,jump.mp3",
"name": "bgm"
},
{ {
"keys": "closebtn.png,comCloseBtn.png,surebtn.png,toastBg.png,waitingBg.png,waitingRot.png,关闭按钮.png,关闭按钮2.png", "keys": "closebtn.png,comCloseBtn.png,surebtn.png,toastBg.png,waitingBg.png,waitingRot.png,关闭按钮.png,关闭按钮2.png",
"name": "common" "name": "common"
}, },
{ {
"keys": "crypeo.svga,guidecount.svga,jumppeo.svga,popstar.svga,startbtn.svga,startpeo.svga,startpeople.svga,startpop.svga", "keys": "atmosphere.svga,crypeo.svga,guidecount.svga,jumppeo.svga,left.svga,popstar.svga,right.svga,startbtn.svga,startpeo.svga,startpeople.svga,startpop.svga",
"name": "svga" "name": "svga"
} }
], ],
......
...@@ -11,7 +11,6 @@ import { G_EVENT } from "./common/G_EVENT"; ...@@ -11,7 +11,6 @@ import { G_EVENT } from "./common/G_EVENT";
import { Tools } from "./Tools"; import { Tools } from "./Tools";
import { destroyWebNetData } from "./webNet"; import { destroyWebNetData } from "./webNet";
import { StartScene } from "./scenes/StartScene"; import { StartScene } from "./scenes/StartScene";
import { preloadSound } from "./common/SoundWeb";
/** /**
* 全局事件,为了和小程序交互 * 全局事件,为了和小程序交互
...@@ -25,7 +24,12 @@ export class Main { ...@@ -25,7 +24,12 @@ export class Main {
private requestID; private requestID;
private _pause: boolean; private _pause: boolean;
private canvas: HTMLCanvasElement private canvas: HTMLCanvasElement
constructor(canvas: HTMLCanvasElement) { constructor(canvas: HTMLCanvasElement, data = {
time: 60,
longitude: "",
latitude: ""
}) {
Tools.configInfo = data;
var sysInfo; var sysInfo;
//淘宝小程序环境就用canvas初始化 //淘宝小程序环境就用canvas初始化
if (!window) {//自行处理吧,这么判断也不保险,万一淘宝小程序加进了window if (!window) {//自行处理吧,这么判断也不保险,万一淘宝小程序加进了window
...@@ -80,14 +84,6 @@ export class Main { ...@@ -80,14 +84,6 @@ export class Main {
console.log("通用资源加载完成") console.log("通用资源加载完成")
//h5环境时,隐藏加载中 //h5环境时,隐藏加载中
if (FYGE.getEnv() == "web" && document.getElementById("__loading__")) document.getElementById("__loading__").style.display = "none"; if (FYGE.getEnv() == "web" && document.getElementById("__loading__")) document.getElementById("__loading__").style.display = "none";
let isIOS = Tools.isIOS()
if(isIOS){
Tools.isMusic = false
}else{
Tools.isMusic = true
}
preloadSound("bg")
changeScene(StartScene) changeScene(StartScene)
......
...@@ -5,11 +5,11 @@ export const ResJson = { ...@@ -5,11 +5,11 @@ export const ResJson = {
"name": "FailPanel" "name": "FailPanel"
}, },
{ {
"keys": "cdbg.png,closemusic.png,cloud.png,controlpeo.png,gamebg.jpg,gamebuild.png,leftbtn.png,monster.png,openmusic.png,rightbtn.png,scorebg.png,tianpop.png,xiangpop.png", "keys": "cdbg.png,cloud.png,controlpeo.png,gamebg.jpg,monster.png,num_0.png,num_1.png,num_2.png,num_3.png,num_4.png,num_5.png,num_6.png,num_7.png,num_8.png,num_9.png,num_s.png,reset.png,tianpop.png,xiangpop.png",
"name": "GameScene" "name": "GameScene"
}, },
{ {
"keys": "guide.png", "keys": "guide.png,step1_img.png,step1_tips.png,step2_img.png,step2_tips.png,step3_img.png,step3_tips.png,step4_img.png",
"name": "GuidePanel" "name": "GuidePanel"
}, },
{ {
...@@ -24,16 +24,12 @@ export const ResJson = { ...@@ -24,16 +24,12 @@ export const ResJson = {
"keys": "infoline.png,light.png,sucbg.png,sucstar.png,sun.png", "keys": "infoline.png,light.png,sucbg.png,sucstar.png,sun.png",
"name": "SuccessPanel" "name": "SuccessPanel"
}, },
{
"keys": "bg.mp3,fail.mp3,get.mp3,jump.mp3",
"name": "bgm"
},
{ {
"keys": "closebtn.png,comCloseBtn.png,surebtn.png,toastBg.png,waitingBg.png,waitingRot.png,关闭按钮.png,关闭按钮2.png", "keys": "closebtn.png,comCloseBtn.png,surebtn.png,toastBg.png,waitingBg.png,waitingRot.png,关闭按钮.png,关闭按钮2.png",
"name": "common" "name": "common"
}, },
{ {
"keys": "crypeo.svga,guidecount.svga,jumppeo.svga,popstar.svga,startbtn.svga,startpeo.svga,startpeople.svga,startpop.svga", "keys": "atmosphere.svga,crypeo.svga,guidecount.svga,jumppeo.svga,left.svga,popstar.svga,right.svga,startbtn.svga,startpeo.svga,startpeople.svga,startpop.svga",
"name": "svga" "name": "svga"
} }
], ],
......
...@@ -303,127 +303,6 @@ export const SkinJson = { ...@@ -303,127 +303,6 @@ export const SkinJson = {
"source": "gamebg.jpg" "source": "gamebg.jpg"
}, },
"id": "bg" "id": "bg"
},
{
"name": "gamebuild",
"x": 0,
"y": 826,
"type": "sprite",
"props": {
"source": "gamebuild.png"
}
},
{
"name": "controlbtn",
"x": 80,
"y": 1164,
"type": "container",
"children": [
{
"name": "rightbtn",
"x": 0,
"y": 0,
"type": "sprite",
"props": {
"source": "rightbtn.png"
},
"id": "right"
},
{
"name": "leftbtn",
"x": 385,
"y": 0,
"type": "sprite",
"props": {
"source": "leftbtn.png"
},
"id": "left"
}
]
},
{
"name": "score",
"x": 280,
"y": 264,
"type": "container",
"children": [
{
"name": "scorebg",
"x": 0,
"y": 0,
"type": "sprite",
"props": {
"source": "scorebg.png"
},
"id": "scorebg"
},
{
"name": "scorenum",
"x": 140,
"y": 26,
"type": "text",
"props": {
"text": "",
"size": 44,
"fillColor": "#ffffff",
"textAlpha": 1,
"lineHeight": 44
},
"id": "scorenum"
}
]
},
{
"name": "countdown",
"x": 23,
"y": 264,
"type": "container",
"children": [
{
"name": "cdbg",
"x": 0,
"y": 0,
"type": "sprite",
"props": {
"source": "cdbg.png"
},
"id": "cdbg"
},
{
"name": "cdnum",
"x": 94,
"y": 26,
"type": "text",
"props": {
"text": "0s",
"size": 44,
"fillColor": "#ffffff",
"textAlpha": 1,
"lineHeight": 44
},
"id": "cdnum"
}
]
},
{
"name": "closemusic",
"x": 650,
"y": 265,
"type": "sprite",
"props": {
"source": "closemusic.png"
},
"id": "close"
},
{
"name": "openmusic",
"x": 650,
"y": 265,
"type": "sprite",
"props": {
"source": "openmusic.png"
},
"id": "open"
} }
] ]
}, },
......
...@@ -7,6 +7,11 @@ import Ease = FYGE.Ease; ...@@ -7,6 +7,11 @@ import Ease = FYGE.Ease;
* 定制,记录一些全局量和通用方法 * 定制,记录一些全局量和通用方法
*/ */
export class Tools { export class Tools {
public static configInfo: {
longitude: string,
latitude: string,
time: number
}
/** /**
* 缓存key * 缓存key
...@@ -15,8 +20,6 @@ export class Tools { ...@@ -15,8 +20,6 @@ export class Tools {
public static isMember: boolean; public static isMember: boolean;
public static isMusic:boolean = true;
/** /**
* 全局数据,重要数据 * 全局数据,重要数据
*/ */
......
...@@ -2,7 +2,7 @@ import { Panel } from "../../module/views/Panel"; ...@@ -2,7 +2,7 @@ import { Panel } from "../../module/views/Panel";
import { changeScene, getCurrentScene, showPanel, showToast } from "../../module/ctrls"; import { changeScene, getCurrentScene, showPanel, showToast } from "../../module/ctrls";
import { StartScene } from "../scenes/StartScene"; import { StartScene } from "../scenes/StartScene";
import { GuidePanel } from "./GuidePanel"; import { GuidePanel } from "./GuidePanel";
import { getWebData, WebNetName, sendLog, LOG_TYPE, getPxTokenSave, sendWebNet } from "../webNet"; import { getWebData, WebNetName, LOG_TYPE, getPxTokenSave, sendWebNet } from "../webNet";
export class FailPanel extends Panel { export class FailPanel extends Panel {
get groupNames() { return ["FailPanel"] }; get groupNames() { return ["FailPanel"] };
get skinName() { return "FailPanel" }; get skinName() { return "FailPanel" };
...@@ -24,18 +24,14 @@ export class FailPanel extends Panel { ...@@ -24,18 +24,14 @@ export class FailPanel extends Panel {
this.score.x = 92 this.score.x = 92
this.score.textWidth = 568 this.score.textWidth = 568
this.score.textAlign = FYGE.TEXT_ALIGN.CENTER this.score.textAlign = FYGE.TEXT_ALIGN.CENTER
sendLog(LOG_TYPE.EXPOSURE, 40)
sendLog(LOG_TYPE.EXPOSURE, 39)
} }
back() { back() {
this.hidePanel() this.hidePanel()
sendLog(LOG_TYPE.CLICK, 40)
changeScene(StartScene) changeScene(StartScene)
} }
isOpen = false isOpen = false
async restart() { async restart() {
sendLog(LOG_TYPE.CLICK, 39)
this.btnDelay(this.restartbtn) this.btnDelay(this.restartbtn)
if (!this.isOpen) { if (!this.isOpen) {
this.isOpen = true this.isOpen = true
......
...@@ -4,10 +4,16 @@ import { RES } from "../../module/RES"; ...@@ -4,10 +4,16 @@ import { RES } from "../../module/RES";
import { getCurrentScene } from "../../module/ctrls"; import { getCurrentScene } from "../../module/ctrls";
import { GameScene } from "../scenes/GameScene"; import { GameScene } from "../scenes/GameScene";
import { StartScene } from "../scenes/StartScene"; import { StartScene } from "../scenes/StartScene";
import UI from "../UI";
import { Tools } from "../Tools";
export class GuidePanel extends Panel { export class GuidePanel extends Panel {
get groupNames() { return ["GuidePanel"] }; get groupNames() { return ["GuidePanel", "GameScene"] };
get skinName() { return "GuidePanel" }; get skinName() { return "GuidePanel" };
rectlayer;
clicklayer;
guideStep = 1;
svga
initUi() { initUi() {
...@@ -15,35 +21,91 @@ export class GuidePanel extends Panel { ...@@ -15,35 +21,91 @@ export class GuidePanel extends Panel {
svga svga
async start(data) { async start(data) {
super.start(); super.start();
GameScene.instance.scorenum.text = "0" this.clicklayer = UI.Rect(this, 750, 1624, 0x000000, 0, 0, 0, 0.01);
GameScene.instance.cdnum.text = StartScene.instance.gameInfo.duration this.rectlayer = UI.Ctn(this, 0, 0);
let svgashow = this.svga = new FYGE.SvgaAni(await RES.getResAsync("guidecount.svga")) this.rectlayer.mouseEnable = false
this.rectlayer.mouseChildren = false
let svgashow = this.svga = new FYGE.SvgaAni(await RES.getResAsync("guidecount.svga"));
this.svga.position.set(170, 660)
this.svga.visible = false this.svga.visible = false
this.svga.stop() this.svga.stop()
this.addChild(svgashow) this.addChild(svgashow);
this.clicklayer.addEventListener(FYGE.MouseEvent.CLICK, () => {
if (this.guideStep < 4) {
this.guideStep++
this.guideUI();
} else if((this.guideStep == 4)) {
this.guideStep++
this.showCount();
}
}, this)
if(getWebData(WebNetName.indexInfo).data.ifFirstPlay){
this.guideUI();
} else {
this.showCount();
}
// GameScene.instance.scorenum.text = "0"
// GameScene.instance.cdnum.text = StartScene.instance.gameInfo.duration
// svgashow.lockStep = true // svgashow.lockStep = true
if(getWebData(WebNetName.startGame).data.firstGame){ }
step3_img;
async guideUI() {
this.rectlayer.removeChildren()
if (this.guideStep == 1) {
UI.Sp(this.rectlayer, 'step1_img.png', 48, 860);
let step1_tips = UI.Sp(this.rectlayer, 'step1_tips.png', 188, 776);
FYGE.Tween.get(step1_tips, {
loop: true
})
.to({ alpha: 0.2},500)
.to({ alpha: 1},500)
svgashow.startAniRange(0,200,1,()=>{ } else if (this.guideStep == 2) {
svgashow.startAniRange(200,270,0) UI.Sp(this.rectlayer, 'step2_img.png', 50, 492);
this.svga.addEventListener(FYGE.MouseEvent.CLICK,this.showCount,this) let step2_tips = UI.Sp(this.rectlayer, 'step2_tips.png', 198, 900);
FYGE.Tween.get(step2_tips, {
loop: true
}) })
this.svga.visible = true .to({ alpha: 0.2},500)
}else{ .to({ alpha: 1},500)
this.showCount() } else if (this.guideStep == 3) {
this.step3_img = UI.Sp(this.rectlayer, 'step3_img.png', 311, 333);
this.cdUIRender(Tools.configInfo.time)
let step3_tips = UI.Sp(this.rectlayer, 'step3_tips.png', 236, 850);
FYGE.Tween.get(step3_tips, {
loop: true
})
.to({ alpha: 0.2},500)
.to({ alpha: 1},500)
} else if (this.guideStep == 4){
let atmosphere = new FYGE.SvgaAni(await RES.getResAsync("atmosphere.svga"))
this.rectlayer.addChild(atmosphere)
atmosphere.position.set(18, 324)
UI.Sp(this.rectlayer, 'step4_img.png', 95, 540);
} }
}
cdUIRender(num = 60) {
// 先清除所有节点
this.step3_img.removeChildren();
let str = num + 's';
let arr = str.split("");
let startPos = (130 - (30 * arr.length)) / 2
arr.forEach((item, index) => {
UI.Sp(this.step3_img, `num_${item}.png`, startPos + (index * 30), 38)
})
} }
showCount(){ showCount(){
this.svga.removeEventListener(FYGE.MouseEvent.CLICK,this.showCount,this) this.removeChild(this.rectlayer)
this.svga.startAniRange(275,undefined,1,()=>{ this.svga.visible = true
this.svga.startAniRange(1,105,1,()=>{
this.removeChild(this.svga) this.removeChild(this.svga)
setTimeout(()=>{
this.hidePanel() this.hidePanel()
getCurrentScene().upDateInfo() getCurrentScene().upDateInfo()
},100)
}) })
this.svga.visible = true
} }
initEvents() { initEvents() {
super.initEvents(); super.initEvents();
......
...@@ -2,7 +2,7 @@ import { Panel } from "../../module/views/Panel"; ...@@ -2,7 +2,7 @@ import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES"; import { RES } from "../../module/RES";
import { changeScene } from "../../module/ctrls"; import { changeScene } from "../../module/ctrls";
import { StartScene } from "../scenes/StartScene"; import { StartScene } from "../scenes/StartScene";
import { getWebData, WebNetName, sendLog, LOG_TYPE } from "../webNet"; import { getWebData, WebNetName, LOG_TYPE } from "../webNet";
export class SuccessPanel extends Panel { export class SuccessPanel extends Panel {
get groupNames() { return ["SuccessPanel"] }; get groupNames() { return ["SuccessPanel"] };
get skinName() { return "SuccessPanel" }; get skinName() { return "SuccessPanel" };
...@@ -38,11 +38,9 @@ export class SuccessPanel extends Panel { ...@@ -38,11 +38,9 @@ export class SuccessPanel extends Panel {
let endInfo = getWebData(WebNetName.submitGame).data let endInfo = getWebData(WebNetName.submitGame).data
this.score.text = endInfo.score+"" this.score.text = endInfo.score+""
this.sunscore.text = "x"+endInfo.sunNum+"" this.sunscore.text = "x"+endInfo.sunNum+""
sendLog(LOG_TYPE.EXPOSURE,38)
} }
back(){ back(){
this.hidePanel() this.hidePanel()
sendLog(LOG_TYPE.CLICK,38)
changeScene(StartScene) changeScene(StartScene)
} }
initEvents() { initEvents() {
......
import { Scene } from "../../module/views/Scene"; import { Scene } from "../../module/views/Scene";
import * as Matter from "matter-js"; import * as Matter from "matter-js";
import Role from "./components/Role"; import Role from "./components/Role";
import { RES } from "../../module/RES";
import AddProp from "./components/AddProp"; import AddProp from "./components/AddProp";
import ObstacleProp from "./components/ObstacleProp"; import ObstacleProp from "./components/ObstacleProp";
import MapItem from "./components/MapItem"; import MapItem from "./components/MapItem";
import { import { getWebData, WebNetName, sendWebNet, LOG_TYPE } from "../webNet";
getWebData,
WebNetName,
sendWebNet,
sendLog,
LOG_TYPE,
} from "../webNet";
import { showPanel, showToast, changeScene } from "../../module/ctrls"; import { showPanel, showToast, changeScene } from "../../module/ctrls";
import { GuidePanel } from "../panels/GuidePanel"; import { GuidePanel } from "../panels/GuidePanel";
import { StartScene } from "./StartScene"; import { StartScene } from "./StartScene";
...@@ -18,96 +13,115 @@ import { SuccessPanel } from "../panels/SuccessPanel"; ...@@ -18,96 +13,115 @@ import { SuccessPanel } from "../panels/SuccessPanel";
import { FailPanel } from "../panels/FailPanel"; import { FailPanel } from "../panels/FailPanel";
import { duiba_md5 } from "../../module/tools/security"; import { duiba_md5 } from "../../module/tools/security";
import { Tools } from "../Tools"; import { Tools } from "../Tools";
import { playAllSound, stopAllSound, cusPlaySound } from "../common/SoundWeb"; import { playAllSound } from "../common/SoundWeb";
import { layers } from "../../module/views/layers"; import { layers } from "../../module/views/layers";
import UI from "../UI";
export class GameScene extends Scene { export class GameScene extends Scene {
get groupNames() { get groupNames() { return ["GameScene"] };
return ["GameScene"]; get skinName() { return "GameScene" };
}
get skinName() {
return "GameScene";
}
bg: FYGE.Sprite; bg: FYGE.Sprite;
left;
right;
cdbg: FYGE.Sprite;
time = Tools.configInfo.time;
// --------
cloud: FYGE.Sprite; cloud: FYGE.Sprite;
peo: FYGE.Sprite; peo: FYGE.Sprite;
tianpop: FYGE.Sprite; tianpop: FYGE.Sprite;
xiangpop: FYGE.Sprite; xiangpop: FYGE.Sprite;
monster: FYGE.Sprite; monster: FYGE.Sprite;
right: FYGE.Sprite;
left: FYGE.Sprite;
scorebg: FYGE.Sprite;
scorenum: FYGE.TextField;
cdbg: FYGE.Sprite;
cdnum: FYGE.TextField;
close: FYGE.Sprite;
open: FYGE.Sprite;
jumpLock = false; jumpLock = false;
isonce = false; isonce = false;
public static instance: GameScene; public static instance: GameScene;
initUi() {} initUi() {
start(data) {
super.start();
sendLog(LOG_TYPE.EXPOSURE, 37);
GameScene.instance = this;
showPanel(GuidePanel);
if (Tools.isMusic) {
this.open.visible = true;
this.close.visible = false;
cusPlaySound("bg", true);
} else {
this.open.visible = false;
this.close.visible = true;
} }
this.createPhyWorld(); async start(data) {
super.start();
GameScene.instance = this
// showPanel(GuidePanel);
// 左右按钮
this.left = new FYGE.SvgaAni(await RES.getResAsync("left.svga"))
this.left = this.addChild(this.left)
this.left.position.set(8, 979);
this.left.startAniRange(1, 1, 1);
this.right = new FYGE.SvgaAni(await RES.getResAsync("right.svga"))
this.right = this.addChild(this.right)
this.right.position.set(524, 979);
this.right.startAniRange(1, 1, 1);
this.left.addEventListener(FYGE.MouseEvent.CLICK, () => {
this.left.startAniRange(1, undefined, 1, () => {})
this._role.leftMove()
})
this.right.addEventListener(FYGE.MouseEvent.CLICK, () => {
this.right.startAniRange(1, undefined, 1, () => {})
this._role.rightMove()
})
// 倒计时
this.cdbg = UI.Sp(this, "cdbg.png", 280, 330)
this.cdUIRender(this.time)
// 物理引擎
this.createPhyWorld()
this.bgCon = this.addChild(new FYGE.Container()); this.bgCon = this.addChild(new FYGE.Container());
this.setChildIndex(this.bgCon, 2); this.setChildIndex(this.bgCon, 1)
this.initMap(); this.initMap();
this.scorenum.text = "0";
this.cdnum.text = StartScene.instance.gameInfo.duration; // TODO_wyx
this.upDateInfo()
} }
score; score;
time;
changeMusic() {
this.open.visible = !this.open.visible;
this.close.visible = !this.close.visible;
Tools.isMusic = !Tools.isMusic;
if (Tools.isMusic) {
// playAllSound()
cusPlaySound("bg", true);
} else {
stopAllSound();
}
}
upDateInfo() { upDateInfo() {
this.score = 0; // this.score = 0
this.time = StartScene.instance.gameInfo.duration; // this.time = StartScene.instance.gameInfo.duration
this.scorenum.text = this.score + ""; this.time = Tools.configInfo.time;
this.cdnum.text = this.time + ""; this.cdUIRender(this.time)
this.startGame(); this.startGame()
this.countDown(this.time); this.countDown(this.time)
} }
countDown(time) { countDown(time) {
if (this.timer) {
clearTimeout(this.timer);
}
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
if (Number(this.cdnum.text) <= 0) { if (this.time <= 0) {
clearTimeout(this.timer); clearTimeout(this.timer);
this.composites.remove(this.world, this._role.phyBody); this.composites.remove(this.world, this._role.phyBody);
console.log("zale"); console.log("zale")
this.gameOver(); this.gameOver()
return; return
}
this.time = this.time - 1;
this.cdUIRender(this.time)
this.countDown(this.time)
}, 1000)
} }
this.cdnum.text = Number(this.cdnum.text) - 1 + "";
this.countDown(Number(this.cdnum.text)); cdUIRender(num = 60) {
}, 1000); // 先清除所有节点
this.cdbg.removeChildren();
let str = num + 's';
let arr = str.split("");
let startPos = (192 - (30 * arr.length)) / 2
arr.forEach((item, index) => {
UI.Sp(this.cdbg, `num_${item}.png`, startPos + (index * 30), 46)
})
} }
startGame() { startGame() {
this.isonce = false; this.isonce = false
this.addRole(); this.addRole();
this.addEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this); this.addEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this);
...@@ -118,7 +132,7 @@ export class GameScene extends Scene { ...@@ -118,7 +132,7 @@ export class GameScene extends Scene {
addRole() { addRole() {
let offset = (1624 - this.stage.viewRect.height) / 2; let offset = (1624 - this.stage.viewRect.height) / 2;
let role = (this._role = new Role()); let role = this._role = new Role();
role.fx = 380; role.fx = 380;
role.fy = 980 - offset; role.fy = 980 - offset;
...@@ -133,15 +147,35 @@ export class GameScene extends Scene { ...@@ -133,15 +147,35 @@ export class GameScene extends Scene {
addPropsMap = new Map(); addPropsMap = new Map();
obstaclePropMap = new Map(); obstaclePropMap = new Map();
private createPhyWorld() { private createPhyWorld() {
const { Engine, Render, Runner, Composite, Bodies, World, Composites } = // const { Engine, Render, Runner, Composite, Bodies, World, Composites } = Matter;
Matter; // // 创建引擎
// const engine = Engine.create();
this.engine = Engine.create({ // // 创建渲染器
enableSleeping: true, // const render = Render.create({
}); // engine: engine
// })
// Engine.run(engine);
// Render.run(render);
const { Engine, Render, Runner, Composite, Bodies, World, Composites } = Matter;
this.engine = Engine.create(
{
enableSleeping: true
}
);
this.world = this.engine.world; this.world = this.engine.world;
this.engine.gravity.y = 1.5; this.engine.gravity.y = 1.5;
/** 真正运行 */
this.runner = Runner.create();
Runner.run(this.runner, this.engine);
// @ts-ignore
this.composites = Composite;
Matter.Events.on(this.engine, "collisionStart", this.onCollisionStart.bind(this));
Matter.Events.on(this.engine, "tick", this.onCollisionTick.bind(this));
// 创建一个渲染器 // 创建一个渲染器
const render = Render.create({ const render = Render.create({
// element: document.body, // element: document.body,
...@@ -174,97 +208,76 @@ export class GameScene extends Scene { ...@@ -174,97 +208,76 @@ export class GameScene extends Scene {
}, },
}); });
Render.run(render); Render.run(render);
/** 真正运行 */
this.runner = Runner.create();
Runner.run(this.runner, this.engine);
// @ts-ignore
this.composites = Composite;
Matter.Events.on(
this.engine,
"collisionStart",
this.onCollisionStart.bind(this)
);
Matter.Events.on(this.engine, "tick", this.onCollisionTick.bind(this));
} }
onCollisionTick(e) {} onCollisionTick(e) {
}
onCollisionStart(e) { onCollisionStart(e) {
let pairs = e.pairs; let pairs = e.pairs;
pairs.map((p) => { pairs.map((p) => {
// 🌹与人的碰撞 // 🌹与人的碰撞
if (p.bodyB == this._role.phyBody || p.bodyA == this._role.phyBody) { if (p.bodyB == this._role.phyBody || p.bodyA == this._role.phyBody) {
if ( if (p.bodyB.gameType?.split("_")[0] == 'addProp' || p.bodyA.gameType?.split("_")[0] == 'addProp') {
p.bodyB.gameType?.split("_")[0] == "addProp" || console.log("加分")
p.bodyA.gameType?.split("_")[0] == "addProp" let body = p.bodyB.gameType?.split("_")[0] == 'addProp' ? p.bodyB : p.bodyA;
) {
console.log("加分");
let body =
p.bodyB.gameType?.split("_")[0] == "addProp" ? p.bodyB : p.bodyA;
let prop = this.addPropsMap.get(body.id); let prop = this.addPropsMap.get(body.id);
let num = 1; let num = 1
if (body.gameType.split("_")[1] == "tian") { if (body.gameType.split("_")[1] == "tian") {
num = 1; num = 1
} else { } else {
num = 2; num = 2
}
this._role.addScore("+" + num, "#ffffff");
if (Tools.isMusic) {
cusPlaySound("get", false);
} }
this._role.addScore('+' + num, '#ffffff')
this.scorenum.text = Number(this.scorenum.text) + num + ""; this.score += num
this.score += num;
this.composites.remove(this.world, prop.phyBody); this.composites.remove(this.world, prop.phyBody);
prop.destroy(); prop.destroy();
this.bgCon.removeChild(prop); this.bgCon.removeChild(prop)
this.addPropsMap.delete(body.id); this.addPropsMap.delete(body.id);
} else if (
p.bodyB.gameType == "dieProp" || } else if (p.bodyB.gameType == 'dieProp' || p.bodyA.gameType == 'dieProp') {
p.bodyA.gameType == "dieProp"
) {
// 死亡💀 // 死亡💀
console.log("死亡"); console.log("死亡")
if (Tools.isMusic) { let body = p.bodyB.gameType == 'dieProp' ? p.bodyB : p.bodyA;
cusPlaySound("fail", false);
}
let body = p.bodyB.gameType == "dieProp" ? p.bodyB : p.bodyA;
let prop = this.obstaclePropMap.get(body.id); let prop = this.obstaclePropMap.get(body.id);
this.composites.remove(this.world, prop.phyBody); this.composites.remove(this.world, prop.phyBody);
prop.destroy(); prop.destroy();
this.bgCon.removeChild(prop); this.bgCon.removeChild(prop)
this.obstaclePropMap.delete(body.id); this.obstaclePropMap.delete(body.id);
// this.removeWorld() // this.removeWorld()
this.composites.remove(this.world, this._role.phyBody); this.composites.remove(this.world, this._role.phyBody);
clearTimeout(this.timer); clearTimeout(this.timer);
this.gameOver(); this.gameOver()
} else { } else {
if (!this.jumpLock) { if (!this.jumpLock) {
if (Tools.isMusic) { this._role.jump()
cusPlaySound("jump", false);
}
this._role.jump();
this.jumpLock = true; this.jumpLock = true;
setTimeout(() => { setTimeout(() => {
this.jumpLock = false; this.jumpLock = false
}, 300); }, 300)
} }
} }
} }
}); });
} }
initMap() { initMap() {
let stageHeight = this.stage.stageHeight; let stageHeight = this.stage.stageHeight;
this.createLineItem(stageHeight - 240, 380, false); this.createLineItem(stageHeight - 100, 380, false);
// for (let i = 0; i < 10; i++) {
// if (i < 4) {
// this.createLineItem(stageHeight - (240 * (i + 2)), 0, false);
// } else {
// this.createLineItem(stageHeight - (240 * (i + 2)));
// }
// }
for (let i = 0; i < 10; i++) {
if (i < 4) {
this.createLineItem(stageHeight - 240 * (i + 2), 0, false);
} else {
this.createLineItem(stageHeight - 240 * (i + 2));
}
}
} }
mapList = []; mapList = [];
createLineItem(h, x?: number, isprop = true) { createLineItem(h, x?: number, isprop = true) {
...@@ -279,167 +292,144 @@ export class GameScene extends Scene { ...@@ -279,167 +292,144 @@ export class GameScene extends Scene {
let addProp = new AddProp(); let addProp = new AddProp();
addProp.fx = nx; addProp.fx = nx;
addProp.fy = h - 25; addProp.fy = h - 25;
this.bgCon.addChildAt(addProp, 0); this.bgCon.addChildAt(addProp, 0)
this.composites.add(this.world, [addProp.phyBody]); this.composites.add(this.world, [addProp.phyBody]);
this.addPropsMap.set(addProp.phyBody.id, addProp); this.addPropsMap.set(addProp.phyBody.id, addProp);
break; break;
case rate >= 19 && rate <= 20: case rate >= 19 && rate <= 20:
// 添加障碍元素 // 添加障碍元素
let obstacleProp = new ObstacleProp(); let obstacleProp = new ObstacleProp()
obstacleProp.fx = nx; obstacleProp.fx = nx;
obstacleProp.fy = h - 40; obstacleProp.fy = h - 40;
this.bgCon.addChildAt(obstacleProp, 0); this.bgCon.addChildAt(obstacleProp, 0)
this.composites.add(this.world, [obstacleProp.phyBody]); this.composites.add(this.world, [obstacleProp.phyBody]);
this.obstaclePropMap.set(obstacleProp.phyBody.id, obstacleProp); this.obstaclePropMap.set(obstacleProp.phyBody.id, obstacleProp)
break; break
default: default:
break;
break
} }
} }
let mapItem = new MapItem(); let mapItem = new MapItem();
mapItem.fx = nx; mapItem.fx = nx;
mapItem.fy = h; mapItem.fy = h
this.bgCon.addChildAt(mapItem, 0); this.bgCon.addChildAt(mapItem, 0)
this.composites.add(this.world, [mapItem.phyBody]); this.composites.add(this.world, [mapItem.phyBody]);
let spriteItem = this.createOtherItem(nx, h); let spriteItem = this.createOtherItem(nx, h);
this.mapList.push([mapItem, spriteItem]); this.mapList.push([mapItem, spriteItem])
} }
createOtherItem(x, h) { createOtherItem(x, h) {
let dx = Math.floor(Math.random() * 280 + 90); let dx = Math.floor(Math.random() * 280 + 90);
if (dx + 90 > x - 90) { if (dx + 90 > x - 90) {
dx = dx + 310; dx = dx + 310
} }
let mapItem = new MapItem(); let mapItem = new MapItem();
mapItem.fx = dx; mapItem.fx = dx;
mapItem.fy = h; mapItem.fy = h
this.bgCon.addChildAt(mapItem, 0); this.bgCon.addChildAt(mapItem, 0);
this.composites.add(this.world, [mapItem.phyBody]); this.composites.add(this.world, [mapItem.phyBody]);
return mapItem; return mapItem
} }
timer = null; timer = null;
onFarm() { onFarm() {
let roleY = this._role.y + this.bgCon.y; let roleY = this._role.y + this.bgCon.y;
if (roleY < 600) { if (roleY < 600) {
this.moveMap(600 - roleY); this.moveMap(600 - roleY)
} }
let lastLine = this.mapList[0], let lastLine = this.mapList[0],
lastItem = lastLine[0]; lastItem = lastLine[0];
if (lastItem.y + this.bgCon.y > this.stage.stageHeight + 10) { if (lastItem.y + this.bgCon.y > this.stage.stageHeight + 10) {
lastLine.forEach((item) => { lastLine.forEach(item => {
this.composites.remove(this.world, item.phyBody); this.composites.remove(this.world, item.phyBody);
item.destroy(); item.destroy();
this.bgCon.removeChild(item); this.bgCon.removeChild(item)
}); })
this.mapList.shift(); this.mapList.shift()
} }
let firstLine = this.mapList[this.mapList.length - 1], let firstLine = this.mapList[this.mapList.length - 1],
firstItem = firstLine[0]; firstItem = firstLine[0];
if (firstItem.y + this.bgCon.y > -100) { if (firstItem.y + this.bgCon.y > -100) {
this.createLineItem(firstItem.y - 240); this.createLineItem(firstItem.y - 240)
} }
// console.log(this._role.y,this.bgCon.y,layers.stageHeight) // console.log(this._role.y,this.bgCon.y,layers.stageHeight)
if (this._role.y >= -(this.bgCon.y - 1624)) { if (this._role.y >= -(this.bgCon.y-1624)) {
if (!this.isonce) { if (!this.isonce) {
this.composites.remove(this.world, this._role.phyBody); this.composites.remove(this.world, this._role.phyBody);
console.log("siwang"); console.log("siwang")
clearTimeout(this.timer); clearTimeout(this.timer);
this.gameOver(); this.gameOver()
// 复活需要初始化 // 复活需要初始化
this.isonce = true; this.isonce = true
} }
} }
} }
moveMap(y) { moveMap(y) {
this.bgCon.y = this.bgCon.y + y; this.bgCon.y = this.bgCon.y + y;
} }
removeWorld() { removeWorld(){
this.composites.clear(this.world); this.composites.clear(this.world)
// console.log(this.composites) // console.log(this.composites)
this.mapList = []; this.mapList = [];
this.addPropsMap.clear(); this.addPropsMap.clear()
this.obstaclePropMap.clear(); this.obstaclePropMap.clear()
console.log(this.obstaclePropMap); console.log(this.obstaclePropMap)
console.log(this.addPropsMap); console.log(this.addPropsMap)
console.log(this.mapList); console.log(this.mapList)
} }
//游戏结束 //游戏结束
async gameOver() { async gameOver() {
this.removeEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this); this.removeEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this);
this.removeWorld(); this.removeWorld()
let startInfo = getWebData(WebNetName.startGame).data.currInfo; // let startInfo = getWebData(WebNetName.startGame).data.currInfo
let timestamp = new Date().getTime(); // let timestamp = new Date().getTime()
//签名方式: md5(score=分值&startId=游戏开始id&timestamp=timestamp&key=key) // //签名方式: md5(score=分值&startId=游戏开始id&timestamp=timestamp&key=key)
//其中key的值为开始游戏接口里返回的key+固定值9ef16b33920749fb26e8fc2f2913150a, 例如1234569ef16b33920749fb26e8fc2f2913150a // //其中key的值为开始游戏接口里返回的key+固定值9ef16b33920749fb26e8fc2f2913150a, 例如1234569ef16b33920749fb26e8fc2f2913150a
let sign = duiba_md5( // let sign = duiba_md5(`score=${this.score}&startId=${startInfo.startId}&timestamp=${timestamp}&key=${startInfo.key + "9ef16b33920749fb26e8fc2f2913150a"}`)
`score=${this.score}&startId=${ // const { success, data, message } = await sendWebNet(WebNetName.submitGame, { score: this.score, sign: sign, code: startInfo.code, timestamp: timestamp ,startId:startInfo.startId})
startInfo.startId
}&timestamp=${timestamp}&key=${ // this._role.die(() => {
startInfo.key + "9ef16b33920749fb26e8fc2f2913150a" // this.bgCon.removeChildren()
}` // this.bgCon.y = 0
); // if (!success) {
const { success, data, message } = await sendWebNet(WebNetName.submitGame, { // showToast(message || "网络异常,请重试~")
score: this.score, // changeScene(StartScene)
sign: sign, // return
code: startInfo.code, // }
timestamp: timestamp, // if (data.pass) {
startId: startInfo.startId, // showPanel(SuccessPanel)
}); // } else {
// showPanel(FailPanel)
// }
// })
this._role.die(() => {
this.bgCon.removeChildren();
this.bgCon.y = 0;
if (!success) {
showToast(message || "网络异常,请重试~");
changeScene(StartScene);
return;
}
if (data.pass) {
showPanel(SuccessPanel);
} else {
showPanel(FailPanel);
}
});
} }
initEvents() { initEvents() {
super.initEvents(); super.initEvents();
this.left.addEventListener(FYGE.MouseEvent.CLICK, () => {
sendLog(LOG_TYPE.CLICK, 37);
this._role.leftMove();
});
this.right.addEventListener(FYGE.MouseEvent.CLICK, () => {
sendLog(LOG_TYPE.CLICK, 37);
this._role.rightMove();
});
this.open.addEventListener(FYGE.MouseEvent.CLICK, this.changeMusic, this);
this.close.addEventListener(FYGE.MouseEvent.CLICK, this.changeMusic, this);
} }
removeEvents() { removeEvents() {
super.removeEvents(); super.removeEvents();
this.open.removeEventListener(
FYGE.MouseEvent.CLICK,
this.changeMusic,
this
);
this.close.removeEventListener(
FYGE.MouseEvent.CLICK,
this.changeMusic,
this
);
stopAllSound();
} }
} }
...@@ -61,8 +61,8 @@ export class StartScene extends Scene { ...@@ -61,8 +61,8 @@ export class StartScene extends Scene {
"sun": 10 "sun": 10
} }
// TODO_wyx
// this.openGame() this.openGame()
// for (let i = 0; i < data.gamecfs.length; i++) { // for (let i = 0; i < data.gamecfs.length; i++) {
// if (data.gamecfs[i].code == data.gameCode) { // if (data.gamecfs[i].code == data.gameCode) {
...@@ -75,35 +75,39 @@ export class StartScene extends Scene { ...@@ -75,35 +75,39 @@ export class StartScene extends Scene {
openRule() { openRule() {
GDispatcher.dispatchEvent("openRule"); GDispatcher.dispatchEvent("openRule");
} }
isOpen = false startId;
getWordList() {
let dataInfo = getWebData(WebNetName.indexInfo).data.dataInfo;
let hasWordList:any = [];
let noWordList:any = [];
dataInfo.forEach(item => {
if (item.context) {
hasWordList = hasWordList.concat(item.context.split(""))
}
})
allWords.forEach(item => {
if (!hasWordList.includes(item) && !noWordList.includes(item)) {
noWordList.push(item)
}
})
return noWordList
}
async openGame() { async openGame() {
this.btnDelay(this.startbtn) this.btnDelay(this.startbtn)
if (this.indexInfo) { if (this.getWordList().length == 0) {
if (!this.indexInfo.dailyPass) { showToast("您已获取今日全部游戏奖励,\n请明日再来");
if (!this.isOpen) {
this.isOpen = true
let token = ""
const { success, code, data, message } = await sendWebNet(WebNetName.startGame, { token: token })
if (!success) {
this.isOpen = false
if (code == "20004") {
showToast("今日已过关,明日再来~")
} else {
showToast(message || "网络异常,请重试~")
}
return return
} }
this.isOpen = false const { success, code, data, desc } = await sendWebNet(WebNetName.startGame, {
activityId: getUrlParams('activityId'),
type: 3
})
if (success) {
this.startId = data.startId;
changeScene(GameScene) changeScene(GameScene)
}
} else { } else {
showToast("今日已过关,明日再来~") showToast(desc || "网络开小差了,稍后再试")
}
} else {
showToast("网络异常,请重试~")
} }
} }
goback() { goback() {
GDispatcher.dispatchEvent("backIndex"); GDispatcher.dispatchEvent("backIndex");
......
import * as Matter from "matter-js"; import * as Matter from "matter-js";
import { RES } from "../../../module/RES"; import { RES } from "../../../module/RES";
import UI from "../../UI";
export default class MapItem extends FYGE.Container { export default class MapItem extends FYGE.Container {
public phyBody: Matter.Body; public phyBody: Matter.Body;
itemImg: FYGE.Sprite; itemImg: FYGE.Sprite;
constructor() { constructor() {
super(); super();
let itemImg = this.itemImg = new FYGE.Sprite(); // itemImg.position.set(-itemImg.width / 2, -10);
itemImg.texture = RES.getRes("cloud.png"); let itemImg = this.itemImg = UI.Sp(this, "cloud.png", 0, 0);
itemImg.width = itemImg.width*1.4
itemImg.position.set(-itemImg.width / 2, -10);
this.addChild(itemImg);
this.phyBody = Matter.Bodies.rectangle(this.x, this.y,itemImg.width,5, { this.phyBody = Matter.Bodies.rectangle(this.x, this.y,itemImg.width, 5, {
isStatic: true, isStatic: true,
friction: 1, friction: 1,
isSensor: true, // 传感器,可以检测到碰撞,但是不参与碰撞 isSensor: true, // 传感器,可以检测到碰撞,但是不参与碰撞
render: {
fillStyle: "blue" // 填充的颜色
}
}); });
this.phyBody.gameType = 'item' this.phyBody.gameType = 'item'
setTimeout(() => { setTimeout(() => {
this.setPhyPos(); this.setPhyPos();
}, 200) }, 200)
} }
......
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