Commit 9aa73e19 authored by Master Q's avatar Master Q

简单的 一次

parent c0317d76
{
"success": true,
"message": "",
"code": "",
"data": {
"ruleIdList": [
"ru_1",
"ru_2",
"ru_3",
"ru_4"
],
"drawStatus": 12,
"prizeId": "aa",
"gameCounts": 1
}
}
\ No newline at end of file
{
"success": true,
"code": "in",
"message": "occaecat",
"data": {
"activityState": 1,
"needTikectCount": 23,
"gameTimeLimit": 60
}
}
\ No newline at end of file
{
"success": true
}
\ No newline at end of file
{
"success": true
}
\ No newline at end of file
......@@ -2,5 +2,8 @@
"success": true,
"message": "",
"code": "",
"data": 1234
"data": {
"startId": "123",
"newGuide": true
}
}
\ No newline at end of file
{
"success": true,
"data": {
"sendCount": 123
}
}
\ No newline at end of file
resource/GameScene/0.png

624 Bytes | W: | H:

resource/GameScene/0.png

1.74 KB | W: | H:

resource/GameScene/0.png
resource/GameScene/0.png
resource/GameScene/0.png
resource/GameScene/0.png
  • 2-up
  • Swipe
  • Onion skin
resource/GameScene/1.png

434 Bytes | W: | H:

resource/GameScene/1.png

1.23 KB | W: | H:

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

652 Bytes | W: | H:

resource/GameScene/2.png

1.83 KB | W: | H:

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

714 Bytes | W: | H:

resource/GameScene/3.png

1.87 KB | W: | H:

resource/GameScene/3.png
resource/GameScene/3.png
resource/GameScene/3.png
resource/GameScene/3.png
  • 2-up
  • Swipe
  • Onion skin
resource/GameScene/4.png

600 Bytes | W: | H:

resource/GameScene/4.png

1.54 KB | W: | H:

resource/GameScene/4.png
resource/GameScene/4.png
resource/GameScene/4.png
resource/GameScene/4.png
  • 2-up
  • Swipe
  • Onion skin
resource/GameScene/5.png

634 Bytes | W: | H:

resource/GameScene/5.png

1.8 KB | W: | H:

resource/GameScene/5.png
resource/GameScene/5.png
resource/GameScene/5.png
resource/GameScene/5.png
  • 2-up
  • Swipe
  • Onion skin
resource/GameScene/6.png

667 Bytes | W: | H:

resource/GameScene/6.png

1.92 KB | W: | H:

resource/GameScene/6.png
resource/GameScene/6.png
resource/GameScene/6.png
resource/GameScene/6.png
  • 2-up
  • Swipe
  • Onion skin
resource/GameScene/7.png

515 Bytes | W: | H:

resource/GameScene/7.png

1.51 KB | W: | H:

resource/GameScene/7.png
resource/GameScene/7.png
resource/GameScene/7.png
resource/GameScene/7.png
  • 2-up
  • Swipe
  • Onion skin
resource/GameScene/8.png

720 Bytes | W: | H:

resource/GameScene/8.png

1.91 KB | W: | H:

resource/GameScene/8.png
resource/GameScene/8.png
resource/GameScene/8.png
resource/GameScene/8.png
  • 2-up
  • Swipe
  • Onion skin
resource/GameScene/9.png

705 Bytes | W: | H:

resource/GameScene/9.png

1.86 KB | W: | H:

resource/GameScene/9.png
resource/GameScene/9.png
resource/GameScene/9.png
resource/GameScene/9.png
  • 2-up
  • Swipe
  • Onion skin
resource/loading/progress-track.png

2.25 KB | W: | H:

resource/loading/progress-track.png

3.82 KB | W: | H:

resource/loading/progress-track.png
resource/loading/progress-track.png
resource/loading/progress-track.png
resource/loading/progress-track.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -5,20 +5,32 @@
"name": "GameRes"
},
{
"keys": "0.png,1.png,2.png,3.png,4.png,5.png,6.png,7.png,8.png,9.png,back.png,countdownback.png,fkingCar.png,obstack1.png,obstack2.png,obstack3.png,scoreboardback.png,倒计时.svga,护盾.png,背景移动元素.svga,跑道.svga,路架子.svga",
"keys": "0.png,1.png,2.png,3.png,4.png,5.png,6.png,7.png,8.png,9.png,Guide1.png,GuideBack.jpg,back.png,countdownback.png,fkingCar.png,next-step.png,obstack1.png,obstack2.png,obstack3.png,s.png,scoreboardback.png,倒计时.svga,护盾.png,背景移动元素.svga,跑道.svga,路架子.svga",
"name": "GameScene"
},
{
"keys": "actTitle.png,awardBtn.png,indexSceneBack.jpg,ruleBtn.png,startBtn.png",
"keys": "awardBtn.png,indexSceneBack.jpg,indexSceneLogo.png,ruleBtn.png,startBtn.png,首页氛围.svga",
"name": "IndexScene"
},
{
"keys": "comCloseBtn.png,com_bg.jpg,toastBg.png,waitingBg.png,waitingRot.png",
"keys": "cancelBtn.png,oneMoreTime.png,resultModalback.png",
"name": "ResultModal"
},
{
"keys": "ruleModalBack.png",
"name": "RuleModal"
},
{
"keys": "close-btn.png,comCloseBtn.png,com_bg.jpg,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common"
},
{
"keys": "loadBack.jpg,progress-back.png,progress-icon.png,progress-track.png",
"keys": "l+.png,l0.png,l1.png,l2.png,l3.png,l4.png,l5.png,l6.png,l7.png,l8.png,l9.png,loadBack.jpg,progress-back.png,progress-icon.png,progress-track.png",
"name": "loading"
},
{
"keys": "fkBtn.png,lookBtn.png,rescurrectionModalBack.png",
"name": "rescurrectionModal"
}
],
"path": "./resource/"
......
import { showPanel } from './../module/ctrls/index';
import { layers, destroyLayers } from "../module/views/layers";
import { RES } from "../module/RES";
import { changeScene, destroyAllCtrls, showToast } from "../module/ctrls";
......@@ -16,8 +17,9 @@ import Event = FYGE.Event;
import getEnv = FYGE.getEnv;
import Texture = FYGE.Texture;
import { ParkourScene } from "./scenes/ParkourGameScene";
import { LoadingScene } from "./scenes/loadingScene/loadingScene";
import { ResultModal } from './panels/ResultModal';
import { RescurrectionModal } from './panels/RescurrectionModal';
/**
* 全局事件,为了和小程序交互
......@@ -139,6 +141,8 @@ export class Game {
// changeScene(ParkourScene, { from: "main" });
changeScene(LoadingScene)
// showPanel(RescurrectionModal)
}
initWebEvent(){
......
......@@ -5,20 +5,32 @@ export const ResJson = {
"name": "GameRes"
},
{
"keys": "0.png,1.png,2.png,3.png,4.png,5.png,6.png,7.png,8.png,9.png,back.png,countdownback.png,fkingCar.png,obstack1.png,obstack2.png,obstack3.png,scoreboardback.png,倒计时.svga,护盾.png,背景移动元素.svga,跑道.svga,路架子.svga",
"keys": "0.png,1.png,2.png,3.png,4.png,5.png,6.png,7.png,8.png,9.png,Guide1.png,GuideBack.jpg,back.png,countdownback.png,fkingCar.png,next-step.png,obstack1.png,obstack2.png,obstack3.png,s.png,scoreboardback.png,倒计时.svga,护盾.png,背景移动元素.svga,跑道.svga,路架子.svga",
"name": "GameScene"
},
{
"keys": "actTitle.png,awardBtn.png,indexSceneBack.jpg,ruleBtn.png,startBtn.png",
"keys": "awardBtn.png,indexSceneBack.jpg,indexSceneLogo.png,ruleBtn.png,startBtn.png,首页氛围.svga",
"name": "IndexScene"
},
{
"keys": "comCloseBtn.png,com_bg.jpg,toastBg.png,waitingBg.png,waitingRot.png",
"keys": "cancelBtn.png,oneMoreTime.png,resultModalback.png",
"name": "ResultModal"
},
{
"keys": "ruleModalBack.png",
"name": "RuleModal"
},
{
"keys": "close-btn.png,comCloseBtn.png,com_bg.jpg,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common"
},
{
"keys": "loadBack.jpg,progress-back.png,progress-icon.png,progress-track.png",
"keys": "l+.png,l0.png,l1.png,l2.png,l3.png,l4.png,l5.png,l6.png,l7.png,l8.png,l9.png,loadBack.jpg,progress-back.png,progress-icon.png,progress-track.png",
"name": "loading"
},
{
"keys": "fkBtn.png,lookBtn.png,rescurrectionModalBack.png",
"name": "rescurrectionModal"
}
],
"path": location.origin + "/resource/"
......
import { CountDownFac, CountDownWithTweenCls } from './../scenes/utils';
import { ExtraConfig } from './../scenes/ExtraConfig';
import { Panel } from "../../module/views/Panel";
import UI from "../tools/UI";
export class RescurrectionModal extends Panel {
get groupNames(): string[] {
return ['rescurrectionModal']
}
roleCont: FYGE.Container
protected initUi(): void {
const roleCont = this.roleCont = UI.Ctn(this, (750 - 547) / 2, 812 - 389 / 2)
UI.Sp(roleCont, 'rescurrectionModalBack.png')
const t = UI.Txt(roleCont, ExtraConfig.RescurrectionText, 36, '#f7468d', FYGE.TEXT_ALIGN.CENTER, 507, 20, 70)
t.lineType = FYGE.TEXT_lINETYPE.MULTI
const bt = UI.Txt(roleCont, `是否复活: ${ExtraConfig.tt}s`, 28, '#f7468d', FYGE.TEXT_ALIGN.CENTER, 507, 20, 330)
const simpleCountDonwFac = CountDownFac(ExtraConfig.tt)
simpleCountDonwFac.start((t) => {
bt.text = `是否复活: ${t}s`
}, () => {
this.hidePanel()
this.data && this.data.onGiveUp()
})
UI.Btn(roleCont, 'fkBtn.png', () => {
simpleCountDonwFac.end()
this.hidePanel()
this.data && this.data.onGiveUp()
}, this, 270, 230)
UI.Btn(roleCont, 'lookBtn.png', () => {
simpleCountDonwFac.end()
this.onShowPreviewImg()
}, this, 20, 230)
}
onShowPreviewImg() {
this.roleCont.visible = false
FYGE.GlobalLoader.loadImage((s, img) => {
const texture = FYGE.Texture.from(img)
const sprite = new FYGE.Sprite(texture)
sprite.width = 700
sprite.height = 700 * img.height / img.width
const PreviewCont = UI.Ctn(this,25, (1624 - sprite.height) / 2)
PreviewCont.addChild(sprite)
const ct = UI.Txt(PreviewCont, '4s', 36, '#ffffff', FYGE.TEXT_ALIGN.CENTER, 700, 0, sprite.height + 30)
const countDownFac = new CountDownWithTweenCls(3000, (t) => {
ct.text = `${~~(t/1000)}s`
}, () => {
this.hidePanel()
this.data && this.data.onResurrection()
})
countDownFac.start()
// if (img.width > img.height) {
// } else {
// }
}, ExtraConfig.PreviewImg)
}
}
\ No newline at end of file
import { changeScene } from "../../module/ctrls";
import { Panel } from "../../module/views/Panel";
import { IndexScene } from "../scenes/IndexScene/IndexScene";
import { promiseAwaitFunc } from "../scenes/utils";
import UI from "../tools/UI";
import { sendWebNet, WebNetName } from "../tools/WebNet";
export class ResultModal extends Panel {
get groupNames(): string[] {
return ['ResultModal']
}
initUi() {
const roleCont = UI.Ctn(this, (750 - 667) / 2 + 10, 170)
UI.Sp(roleCont, 'resultModalback.png')
UI.Txt(roleCont, `恭喜获得${this.data && this.data.coins || 0}周年币`, 36, '#fd4ca4', FYGE.TEXT_ALIGN.CENTER, 667, -10, 700)
UI.Txt(roleCont, `${this.data && this.data.score || 0}`, 36, '#fce461', FYGE.TEXT_ALIGN.CENTER, 667, -10, 410)
UI.Btn(roleCont, 'cancelBtn.png', () => {
changeScene(IndexScene)
this.hidePanel()
}, this, 60, 810)
UI.Btn(roleCont, 'oneMoreTime.png', promiseAwaitFunc(async () => {
const {
success
} = await sendWebNet(WebNetName.start)
if (success) {
this.data && this.data.onAgain && this.data.onAgain()
this.hidePanel()
} else {
changeScene(IndexScene)
this.hidePanel()
}
}), this, 320, 810)
}
}
\ No newline at end of file
import { Panel } from "../../module/views/Panel"
import UI from "../tools/UI"
interface BeforeGameMadalInfer {
onConfirm: Function
}
let protocolSection
const ProtocolContent = `<p style="white-space: break-spaces"><span> 感谢您参与此次活动!我们非常重视您的个人信息和隐私保护。\n<span><span> 为了更好的保障您的权益,请您认真阅读<span style="color:#c23d25;margin: 0 5px" class="protocol-text">《隐私协议》</span>的全部内容,同意并接受全部条款后开始使用我们的产品和服务。</span></p>`
export class RuleModal extends Panel {
onConfirm: Function
constructor(data?: any) {
super()
}
get groupNames(): string[] {
return ['RuleModal']
}
RoleContainer: FYGE.Container
initUi() {
const RoleContainer = this.RoleContainer = UI.Ctn(this, (750 - 547) / 2, (1624 - 697) / 2)
UI.Sp(RoleContainer, 'ruleModalBack.png')
UI.Btn(RoleContainer, 'close-btn.png', this.hidePanel, this, 250, 760)
}
start(data?: any): void {
super.start()
//原先视图上有一个
// this.removeChild(this.ruleTxt);
//文案
// var scroll = this.addChild(new FYGE.ScrollPage(610, 816, 100, true, false))
// scroll.position.copy(this.ruleTxt.position)
// //加文案
// var txt = scroll.view.addChild(Tools.getText(
// ruleStr,
// 30,//this.ruleTxt.size,
// this.ruleTxt.fillColor,
// FYGE.TEXT_ALIGN.LEFT,
// 610
// ))
// //多行设置
// txt.lineType = FYGE.TEXT_lINETYPE.MULTI;
// //行间距设置
// txt.lineSpacing = 20;
// //滚动最大长度按文本高度
// scroll.maxDistance = txt.textHeight
if (!protocolSection) {//避免文案过长,用这种方式
document.getElementById("cusEngine").style.position = "absolute"
protocolSection = document.createElement('section');
protocolSection.id = "protocol-section";
protocolSection.style.overflowX = "hidden";
protocolSection.style.overflowY = "auto";
protocolSection.style.width = 460 + "px";
protocolSection.style.height = 476 + "px";
protocolSection.style.lineHeight = 48 + "px";
protocolSection.style.fontSize = 28 + 'px';
protocolSection.style.color = '#503423';
protocolSection.style.whiteSpace = "pre-line";
}
var rule = this.RoleContainer.addChild(new FYGE.FloatDisplay());
rule.position.set(40, 120)
protocolSection.innerHTML = data.ruleTxt || ProtocolContent;
rule.init(protocolSection);
}
initEvents(): void {
}
removeEvents(): void {
}
}
\ No newline at end of file
......@@ -7,6 +7,13 @@ import { ConveyorBeltItem } from './comp/ConveyorBelt';
import { ExtraConfig, ExtraEvents } from './ExtraConfig';
import { ParkourGameEvents } from './ParkourGameConfig';
import { CountDownWithTween, CountDownWithTweenCls, PromiseAwait } from './utils';
import { getWebData, sendWebNet, WebNetName } from '../tools/WebNet';
import { RES } from '../../module/RES';
import { changeScene, showPanel } from '../../module/ctrls';
import { ResultModal } from '../panels/ResultModal';
import { duiba_md5 } from '../../module/tools/security';
import { IndexScene } from './IndexScene/IndexScene';
import { RescurrectionModal } from '../panels/RescurrectionModal';
export class BalalaScene extends Module {
get groupNames(): string[] {
......@@ -27,12 +34,19 @@ export class BalalaScene extends Module {
countDownFactory: CountDownWithTweenCls
StartGameData: {
startId: number,
newGuide: boolean
}
resurrectionTimes: number // 复活次数
get score() {
return this._score
}
set score(v: number) {
this.scoreText.text = (~~v) + ''
this.scoreText.text = '+' + (~~v) + ''
}
countDownText: FYGE.BitmapText
......@@ -47,6 +61,8 @@ export class BalalaScene extends Module {
initUi(): void {
this.StartGameData = getWebData(WebNetName.start).data
const BaseScene = UI.Ctn(this)
UI.Sp(BaseScene, 'back.png')
this.MovieClipList.push(UI.MoiveClip(BaseScene, '跑道.svga'))
......@@ -58,31 +74,117 @@ export class BalalaScene extends Module {
const scoreBoardCont = UI.Ctn(BaseScene, 0, 200)
UI.Sp(scoreBoardCont, 'scoreboardback.png')
this.scoreText = scoreBoardCont.addChild(new FYGE.BitmapText(Tools.getNumTextures('')))
this.scoreText.position.set(30, 20)
const tmap = Tools.getNumTextures('l')
tmap['+'] = RES.getRes('l+.png')
this.scoreText = scoreBoardCont.addChild(new FYGE.BitmapText(tmap))
this.scoreText.position.set(30, 28)
this.scoreText.textAlign = FYGE.TEXT_ALIGN.LEFT
this.score = 0
const countDownCont = UI.Ctn(BaseScene, 750 - 171, 200)
UI.Sp(countDownCont, 'countdownback.png')
this.countDownText = countDownCont.addChild(new FYGE.BitmapText(Tools.getNumTextures('')))
this.countDownText.position.set(120, 40)
this.countDownText.position.set(120, 53)
this.countDownNum = ExtraConfig.CountDownTime
this.countDownFactory = new CountDownWithTweenCls(ExtraConfig.CountDownTime * 1000, (t) => {
this.countDownNum = ~~(t / 1000)
}, () => {
this.onPause()
this.onGameOver()
})
this.onPause()
if (this.StartGameData.newGuide) {
this.onShowGameGuidance(() => {
this.onGameRestart()
})
} else {
this.onGameRestart()
}
// setTimeout(() => {
// this.onGameRestart()
// }, 1000)
}
GuidanceCont: FYGE.Container
realRenderGuideCont: FYGE.Container
onShowGameGuidance(cb: Function) {
let _GuidanceCont = this.GuidanceCont
let realRenderGuideCont = this.realRenderGuideCont
if (!this.GuidanceCont) {
_GuidanceCont = this.GuidanceCont = UI.Ctn(layers.topLayer)
UI.Sp(_GuidanceCont, 'GuideBack.jpg')
realRenderGuideCont = this.realRenderGuideCont = UI.Ctn(_GuidanceCont)
UI.Sp(_GuidanceCont, 'next-step.png', 375, 1370).anchorTexture.set(0.5, 0.5)
}
const showStep = (n: number) => {
realRenderGuideCont.removeAllChildren()
switch(n) {
case 0:
realRenderGuideCont.addChild(new FYGE.Graphics())
.clear()
.beginFill(0x000000, 0.65)
.drawRect(0,0,750,1624)
.endFill()
.beginHole()
.drawCircle(375, 1150, 160)
.endHole()
UI.Sp(realRenderGuideCont, 'Guide1.png', 375, 1150).anchorTexture.set(0.5, 0.5)
UI.Txt(realRenderGuideCont, '左右滑动控制车子移动', 30, '#ffffff', FYGE.TEXT_ALIGN.CENTER, 750, 0,920)
break
case 1:
realRenderGuideCont.addChild(new FYGE.Graphics())
.clear()
.beginFill(0x000000, 0.65)
.drawRect(0,0,750,1624)
.endFill()
.beginHole()
.drawCircle(220, 760, 60)
.endHole()
UI.Txt(realRenderGuideCont, `撞击金币可得${ExtraConfig.CoinsScore}分`, 30, '#ffffff', FYGE.TEXT_ALIGN.CENTER, 750, 0,920)
break
case 2:
realRenderGuideCont.addChild(new FYGE.Graphics())
.clear()
.beginFill(0x000000, 0.65)
.drawRect(0,0,750,1624)
.endFill()
.beginHole()
.drawCircle(378, 570, 60)
.endHole()
UI.Txt(realRenderGuideCont, `撞击护盾可受${ExtraConfig.shieldTime / 1000}秒保护\n无障碍前进并自动吸收赛道中的金币`, 30, '#ffffff', FYGE.TEXT_ALIGN.CENTER, 750, 0, 680)
break
case 3:
realRenderGuideCont.addChild(new FYGE.Graphics())
.clear()
.beginFill(0x000000, 0.65)
.drawRect(0,0,750,1624)
.endFill()
.beginHole()
.drawCircle(536, 725, 60)
.endHole()
UI.Txt(realRenderGuideCont, `注意!躲避障碍 触碰则游戏结束`, 30, '#ffffff', FYGE.TEXT_ALIGN.CENTER, 750, 0, 920)
break
case 4:
this.stage.removeEventListener(FYGE.MouseEvent.CLICK, showNextStep)
_GuidanceCont.visible = false
cb()
break
}
}
let currStep = 0
function showNextStep() {
showStep(currStep++)
}
showNextStep()
this.stage.addEventListener(FYGE.MouseEvent.CLICK, showNextStep)
}
initEvents(): void {
GDispatcher.addEventListener(ParkourGameEvents.GAME_COLLESION, this.onGameEleCollision, this)
......@@ -110,9 +212,12 @@ export class BalalaScene extends Module {
onGameEleCollision(e: FYGE.Event) {
const CollisionContainer: ConveyorBeltItem = e.data
if (CollisionContainer.uniqueKey === 'shit') {
this.isInShieldTime || this.onPause()
if (!this.isInShieldTime) {
this.onPause()
this.onJudgeIsRealDie()
}
} else if (CollisionContainer.uniqueKey === 'coins') {
this.score += 100
this.score += ExtraConfig.CoinsScore
} else if (CollisionContainer.uniqueKey === 'protect') {
this.onGetShieldTime()
}
......@@ -139,7 +244,7 @@ export class BalalaScene extends Module {
return new Promise<void>((resolve, reject) => {
let _CountDownAniMoiveClipCont = this.CountDownAniMoiveClipCont
if (!_CountDownAniMoiveClipCont) {
_CountDownAniMoiveClipCont = this.CountDownAniMoiveClipCont = UI.Ctn(layers.popupLayer)
_CountDownAniMoiveClipCont = this.CountDownAniMoiveClipCont = UI.Ctn(layers.topLayer)
UI.Rect(_CountDownAniMoiveClipCont, 750,1624, 0x000000,0,0,0,0.6)
this.CountDownAniMoiveClip = UI.MoiveClip(_CountDownAniMoiveClipCont, '倒计时.svga', 0, 200)
}
......@@ -160,21 +265,78 @@ export class BalalaScene extends Module {
async onGameRestart() {
// TODO do something
this.score = 0
this.resurrectionTimes = 0
this.countDownNum = ExtraConfig.CountDownTime
GDispatcher.dispatchEvent(ParkourGameEvents.GAME_RESET)
await this.onGameStartBeforeCountdownAni()
console.log('倒计时结束')
this.onGameStart()
}
/**
* 复活
*/
async onResurrectionForResume() {
await sendWebNet(WebNetName.revive)
this.resurrectionTimes += 1
this.onResume()
this.countDownFactory.resume()
GDispatcher.dispatchEvent(ParkourGameEvents.GAME_RESUME)
}
onPause() {
this.countDownFactory.stop()
this.MovieClipList.forEach(item => {
item.stop()
})
GDispatcher.dispatchEvent(ParkourGameEvents.GAME_PAUSE)
}
onGameOver() {
this.onPause()
@PromiseAwait
async onJudgeIsRealDie() {
if (this.resurrectionTimes === ExtraConfig.RescurrectionTimes) {
this.onGameOver()
} else {
const {
success
} = await sendWebNet(WebNetName.pause, {
startId: getWebData(WebNetName.start).data.startId
})
success && showPanel(RescurrectionModal, {
onGiveUp: () => {
this.onGameOver()
},
onResurrection: () => {
this.onResurrectionForResume()
}
})
}
}
@PromiseAwait
async onGameOver() {
const startId = getWebData(WebNetName.start).data.startId
const sign = duiba_md5(`score=${this.score}&startId=${startId}&key=dui88zhcx715znq1234`)
const {
success,
data
} = await sendWebNet(WebNetName.submit, {
startId,
score: this.score,
sign
})
if (success) {
showPanel(ResultModal, {
coins: data.sendCount,
score: this.score,
onAgain: () => {
this.onGameRestart()
}
})
} else {
changeScene(IndexScene)
}
}
/**
......@@ -187,4 +349,11 @@ export class BalalaScene extends Module {
})
}
destroy() {
super.destroy()
layers.topLayer.removeChild(this.GuidanceCont)
layers.topLayer.removeChild(this.CountDownAniMoiveClip)
}
}
\ No newline at end of file
......@@ -7,4 +7,9 @@ export enum ExtraEvents {
export const ExtraConfig = {
shieldTime: 3000,
CountDownTime: 60, // 倒计时时间 后续接口会修改的
CoinsScore: 20, // 得分
RescurrectionText: 'XX分公司赠送您一次复活机会 查看页面后立即复活!', // 复活提示文字
RescurrectionTimes: 1, // 复活次数
PreviewImg: 'http://qnpic.top/yoona2.jpg', // 预览图片
tt: 5, // 复活弹窗停留时间
}
\ No newline at end of file
import { changeScene, showPanel } from "../../../module/ctrls";
import { RES } from "../../../module/RES";
import { Scene } from "../../../module/views/Scene";
import { RuleModal } from "../../panels/RulePanel";
import { Tools } from "../../tools/Tools";
import UI from "../../tools/UI";
import { getWebData, sendWebNet, WebNetName } from "../../tools/WebNet";
import { ParkourScene } from "../ParkourGameScene";
import { PromiseAwait } from "../utils";
export class IndexScene extends Scene {
get groupNames(): string[] {
......@@ -8,17 +15,53 @@ export class IndexScene extends Scene {
ruleBtn: FYGE.Sprite
awardBtn: FYGE.Sprite
startBtn: FYGE.Button
IndexSceneData: {
needTikectCount: number,
gameTimeLimit: number
}
protected initUi(): void {
this.IndexSceneData = getWebData(WebNetName.index).data
UI.Sp(this, 'indexSceneBack.jpg')
UI.MoiveClip(this, '首页氛围.svga')
const indexSceneLogo = UI.Ctn(this, 0, 360)
UI.Sp(indexSceneLogo, 'indexSceneLogo.png')
const textMap = Tools.getNumTextures('')
textMap['s'] = RES.getRes('s.png')
const countDownTimeFromLogo = indexSceneLogo.addChild(new FYGE.BitmapText(textMap))
countDownTimeFromLogo.position.set(395, 103)
countDownTimeFromLogo.text = `${this.IndexSceneData.gameTimeLimit}s`
this.ruleBtn = UI.Sp(this, 'ruleBtn.png', 0, 230)
this.awardBtn = UI.Sp(this, 'awardBtn.png', 750 - 136, 230)
const startBtnCont = UI.Ctn(this, (750 - 374) / 2, 1150)
this.startBtn = UI.Btn(startBtnCont, 'startBtn.png', this.onJump2Scene, this)
UI.Txt(startBtnCont, `消耗${this.IndexSceneData.needTikectCount}门票`, 24, '#000000', FYGE.TEXT_ALIGN.CENTER, 374, 0, 120)
}
onShowRulePanel() {
@PromiseAwait
async onJump2Scene() {
const {
success
} = await sendWebNet(WebNetName.start)
if (success) {
changeScene(ParkourScene)
}
}
onShowRulePanel() {
showPanel(RuleModal, {
ruleTxt: '123'
})
}
onJump2AwardPage() {
......
......@@ -71,6 +71,8 @@ export enum ParkourGameEvents {
// GAME_OVER = 'GAME_OVER', // 游戏完成
GAME_PAUSE ='GAME_PAUSE', // 游戏暂停
GAME_RESET = 'GAME_RESET', // 游戏重置
GAME_RESET_PARKOURELE = 'GAME_RESET_PARKOURELE', // 重新设置 游戏元素配置
GAME_SPEEDUP = 'GAME_SPEEDUP', // 游戏加速
......@@ -197,7 +199,7 @@ export const ParkourGameConfig: ParkourGameConfigInfer = {
{
uniqueKey: 'shit', // 这个是障碍物
Container: 'obstack2.png',
ProbabilityPort: 10,
ProbabilityPort: 1000,
// anchorX: 130,
// anchorY: 130,
collisionConfig: {
......@@ -208,20 +210,20 @@ export const ParkourGameConfig: ParkourGameConfigInfer = {
h: 50
}
},
{
uniqueKey: 'protect',
Container: 'obstack3.png',
ProbabilityPort: 10,
// anchorX: 100,
// anchorY: 100,
collisionConfig: {
type: 'rect',
x: -50,
y: 0,
w: 100,
h: 50
}
}
// {
// uniqueKey: 'protect',
// Container: 'obstack3.png',
// ProbabilityPort: 0,
// // anchorX: 100,
// // anchorY: 100,
// collisionConfig: {
// type: 'rect',
// x: -50,
// y: 0,
// w: 100,
// h: 50
// }
// }
],
CommonConfig: {
speed: 300, // 速度 可以通过GAME_SPEEDUP 修改
......
......@@ -116,8 +116,6 @@ export class ParkourScene extends Scene {
initEvents(): void {
this.addEventListener(FYGE.Event.ENTER_FRAME, this.onEnterFrame, this)
GDispatcher.addEventListener(ParkourGameEvents.GAME_COLLESION, this.onGameEleCollision)
GDispatcher.addEventListener(ParkourGameEvents.GAME_RESTART, this.onResetUi, this)
GDispatcher.addEventListener(ParkourGameEvents.GAME_PAUSE, this.onGamePause, this)
......@@ -131,8 +129,6 @@ export class ParkourScene extends Scene {
removeEvents(): void {
this.removeEventListener(FYGE.Event.ENTER_FRAME, this.onEnterFrame, this)
GDispatcher.removeEventListener(ParkourGameEvents.GAME_COLLESION, this.onGameEleCollision)
GDispatcher.removeEventListener(ParkourGameEvents.GAME_RESTART, this.onResetUi, this)
GDispatcher.removeEventListener(ParkourGameEvents.GAME_PAUSE, this.onGamePause, this)
......@@ -140,14 +136,6 @@ export class ParkourScene extends Scene {
this.stage.removeEventListener(FYGE.MouseEvent.MOUSE_DOWN, this.onGameDetermineMouseDown, this)
}
/**
* 碰撞检测
* @param e
*/
onGameEleCollision(e: FYGE.Event) {
// console.log(e.data)
}
/**
* 游戏左右滑动的 检测
* @param e
......
......@@ -256,6 +256,8 @@ export class ConveyorBelt extends FYGE.Container {
GDispatcher.addEventListener(ParkourGameEvents.GAME_RESUME, this.onGameResume, this)
GDispatcher.addEventListener(ParkourGameEvents.GAME_RESTART, this.onRestartRoll, this)
GDispatcher.addEventListener(ParkourGameEvents.GAME_RESET, this.onReset, this)
}
/**
......@@ -272,6 +274,8 @@ export class ConveyorBelt extends FYGE.Container {
GDispatcher.removeEventListener(ParkourGameEvents.GAME_RESUME, this.onGameResume, this)
GDispatcher.removeEventListener(ParkourGameEvents.GAME_RESTART, this.onRestartRoll, this)
GDispatcher.removeEventListener(ParkourGameEvents.GAME_RESET, this.onReset, this)
}
/**
......
......@@ -3,8 +3,8 @@ import { RES } from "../../../module/RES";
import { Scene } from "../../../module/views/Scene";
import { ProgressBarS } from "../../common/ProgressBarS";
import UI from "../../tools/UI";
import { ParkourScene } from '../ParkourGameScene';
import { IndexScene } from '../IndexScene/IndexScene';
import { sendWebNet, WebNetName } from '../../tools/WebNet';
export class LoadingScene extends Scene {
......@@ -40,6 +40,9 @@ export class LoadingScene extends Scene {
// 加载首页资源
await RES.loadGroup('IndexScene')
// 走下接口,这里有点小问题, 接口报错了, 还让进去吗
await sendWebNet(WebNetName.index, {}, undefined, true)
this.setProgressValue(1)
}
......@@ -48,7 +51,7 @@ export class LoadingScene extends Scene {
FYGE.Tween.get(this.ProgressFactory)
.to({
value
}, 1000)
}, 600)
.call(() => {
if (value === 1) {
changeScene(IndexScene)
......
......@@ -41,6 +41,27 @@ export function promiseAwaitFunc(func: Function) {
}
}
export function CountDownFac(totalCount) {
let count = totalCount;
let intervalId = null
return {
start(step, cb) {
intervalId = setInterval(() => {
if (count == 0) {
cb && cb()
this.end()
return
}
count--
step && step(count)
}, 1000)
},
end() {
intervalId && clearInterval(intervalId)
}
}
}
export class CountDownWithTweenCls {
onChangeCb: (t: number) => void
onEnd: () => void
......
......@@ -12,11 +12,11 @@ export enum WebNetName {
* 首页
* 参数a 参数b
*/
index = "/projectx/{projectId}/game/index.do",
index = "/projectx/{projectId}/racingGame/index.do",
/**
* 参与
*/
join = "/projectx/{projectId}/game/join.do",
start = "/projectx/{projectId}/racingGame/start.do",
/**
* 获取结果
*/
......@@ -24,7 +24,13 @@ export enum WebNetName {
/**
* 获取规则
*/
projectRule = "/projectx/{projectId}/projectRule.query"
projectRule = "/projectx/{projectId}/projectRule.query",
submit = "/projectx/{projectId}/racingGame/submit.do",
pause = "/projectx/{projectId}/racingGame/pause.do",
revive = "/projectx/{projectId}/racingGame/revive.do",
}
//返回数据类型
......
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