Commit febedac1 authored by Master Q's avatar Master Q

游戏整体逻辑添加

parent 18dd1f4c
resource/NewGuyScene/Guide1.png

62.2 KB | W: | H:

resource/NewGuyScene/Guide1.png

844 KB | W: | H:

resource/NewGuyScene/Guide1.png
resource/NewGuyScene/Guide1.png
resource/NewGuyScene/Guide1.png
resource/NewGuyScene/Guide1.png
  • 2-up
  • Swipe
  • Onion skin
{ {
"groups": [ "groups": [
{ {
"keys": "box1.png,box2.png,box3.png,box4.png,box5.png,box6.png,box7.png,box8.png", "keys": "GSB.png,platform.png,rabbit.png,scoreBoardBack.png",
"name": "Boxes"
},
{
"keys": "DFM1.png,DFMB.png",
"name": "DrawFailModal"
},
{
"keys": "DSM1.png,DSMB.png",
"name": "DrawSucModal"
},
{
"keys": "FGM1.png,FGMB.png",
"name": "FinalGiftModal"
},
{
"keys": "2b727ace1b5c959dbc6274cacb5b4e5f.png,3ed4431aad269ef7059929043bd45597.png,60377934f7cf618b52457273db65aace.png,9074d1305c0e7feb16037261986c7f4b.png,f3bde4659477f82338fcb2b134272321.png",
"name": "GameAtom"
},
{
"keys": "GOM0.png,GOM1.png,GameOverModalBack.png",
"name": "GameOverModal"
},
{
"keys": "GQM0.png,GQM1.png,GQMB.png",
"name": "GameQuitModal"
},
{
"keys": "GameResumeModalBack.png,cancelBtn.png,useRightNowBtn.png",
"name": "GameResumeModal"
},
{
"keys": "back.png,bottomAtom.png,gele1.png,goBackBtn.png,player.png,scoreboard-t.png",
"name": "GameScene" "name": "GameScene"
}, },
{ {
"keys": "2120075482341d7d94d8164b1a0f6d43.png,3ed4431aad269ef7059929043bd45597.png,4f4612689c9fde32a8c28c129e9f6e7d.png,60377934f7cf618b52457273db65aace.png,63b0a84f0f9b10842b5f83fa5e923534.png,f3bde4659477f82338fcb2b134272321.png", "keys": "Guide1.png,Guide2.png,Guide3.png,Guide4.png",
"name": "JumpEnd"
},
{
"keys": "Guide1.png,NGSB.jpg,nextStep.png,startGameBtn.png",
"name": "NewGuyScene" "name": "NewGuyScene"
}, },
{
"keys": "2120075482341d7d94d8164b1a0f6d43.png",
"name": "PerfectJumpEnd"
},
{ {
"keys": "closebtn.png,giftBoxIcon.png,waitingBg.png,waitingRot.png", "keys": "closebtn.png,giftBoxIcon.png,waitingBg.png,waitingRot.png",
"name": "common" "name": "common"
},
{
"keys": "786bf3500cf0986c9678f6b8a8cf24f6.png,b5d5c1070b13deb0230b0efe5c58ee9d.png,ca7b2a497afc6147cc076d55600154bd.png,d64a974a921d32ed81463c918bae137e.png,f49a78c8287be1a92ee75ce3a2b7a512.png",
"name": "countDown"
},
{
"keys": "548342251013e2f832a40380d1855bf5.png,af75d547153d9118b05d4dd8fbcfe022.png,fd0f936244fb973bddf520819997f5ba.png",
"name": "handLottie"
},
{
"keys": "nx1.jpg,ny1.jpg,nz1.jpg,px1.jpg,py1.jpg,pz1.jpg",
"name": "skybox"
},
{
"keys": "rabbit.spi",
"name": "spine"
} }
], ],
"path": "./resource/" "path": "./resource/"
......
export const ResJson = { export const ResJson = {
"groups": [ "groups": [
{ {
"keys": "box1.png,box2.png,box3.png,box4.png,box5.png,box6.png,box7.png,box8.png", "keys": "GSB.png,platform.png,rabbit.png,scoreBoardBack.png",
"name": "Boxes"
},
{
"keys": "DFM1.png,DFMB.png",
"name": "DrawFailModal"
},
{
"keys": "DSM1.png,DSMB.png",
"name": "DrawSucModal"
},
{
"keys": "FGM1.png,FGMB.png",
"name": "FinalGiftModal"
},
{
"keys": "2b727ace1b5c959dbc6274cacb5b4e5f.png,3ed4431aad269ef7059929043bd45597.png,60377934f7cf618b52457273db65aace.png,9074d1305c0e7feb16037261986c7f4b.png,f3bde4659477f82338fcb2b134272321.png",
"name": "GameAtom"
},
{
"keys": "GOM0.png,GOM1.png,GameOverModalBack.png",
"name": "GameOverModal"
},
{
"keys": "GQM0.png,GQM1.png,GQMB.png",
"name": "GameQuitModal"
},
{
"keys": "GameResumeModalBack.png,cancelBtn.png,useRightNowBtn.png",
"name": "GameResumeModal"
},
{
"keys": "back.png,bottomAtom.png,gele1.png,goBackBtn.png,player.png,scoreboard-t.png",
"name": "GameScene" "name": "GameScene"
}, },
{ {
"keys": "2120075482341d7d94d8164b1a0f6d43.png,3ed4431aad269ef7059929043bd45597.png,4f4612689c9fde32a8c28c129e9f6e7d.png,60377934f7cf618b52457273db65aace.png,63b0a84f0f9b10842b5f83fa5e923534.png,f3bde4659477f82338fcb2b134272321.png", "keys": "Guide1.png,Guide2.png,Guide3.png,Guide4.png",
"name": "JumpEnd"
},
{
"keys": "Guide1.png,NGSB.jpg,nextStep.png,startGameBtn.png",
"name": "NewGuyScene" "name": "NewGuyScene"
}, },
{
"keys": "2120075482341d7d94d8164b1a0f6d43.png",
"name": "PerfectJumpEnd"
},
{ {
"keys": "closebtn.png,giftBoxIcon.png,waitingBg.png,waitingRot.png", "keys": "closebtn.png,giftBoxIcon.png,waitingBg.png,waitingRot.png",
"name": "common" "name": "common"
},
{
"keys": "786bf3500cf0986c9678f6b8a8cf24f6.png,b5d5c1070b13deb0230b0efe5c58ee9d.png,ca7b2a497afc6147cc076d55600154bd.png,d64a974a921d32ed81463c918bae137e.png,f49a78c8287be1a92ee75ce3a2b7a512.png",
"name": "countDown"
},
{
"keys": "548342251013e2f832a40380d1855bf5.png,af75d547153d9118b05d4dd8fbcfe022.png,fd0f936244fb973bddf520819997f5ba.png",
"name": "handLottie"
},
{
"keys": "nx1.jpg,ny1.jpg,nz1.jpg,px1.jpg,py1.jpg,pz1.jpg",
"name": "skybox"
},
{
"keys": "rabbit.spi",
"name": "spine"
} }
], ],
"path": "./resource/" "path": "./resource/"
......
...@@ -4,7 +4,6 @@ import { ModalCtroller } from "./modules/ModalControl"; ...@@ -4,7 +4,6 @@ import { ModalCtroller } from "./modules/ModalControl";
import { RES } from "./modules/RES"; import { RES } from "./modules/RES";
import { ResJson } from "./ResJson"; import { ResJson } from "./ResJson";
import { GameScene } from "./scenes/GameScene/GameScene"; import { GameScene } from "./scenes/GameScene/GameScene";
import { HomeScene } from "./scenes/home";
import { NewGuyScene } from "./scenes/NewGuyScene/NewGuyScene"; import { NewGuyScene } from "./scenes/NewGuyScene/NewGuyScene";
import { Tools } from "./tools/Tools"; import { Tools } from "./tools/Tools";
import Tween = FYGE.Tween; import Tween = FYGE.Tween;
...@@ -109,7 +108,7 @@ export class Main { ...@@ -109,7 +108,7 @@ export class Main {
RES.loadConfig(ResJson) RES.loadConfig(ResJson)
await RES.loadGroup('common') await RES.loadGroup('common')
SceneController.changeScene(Tools.PageData.isFirstGame ? NewGuyScene : GameScene) SceneController.changeScene(GameScene)
} }
initWebEvent(){ initWebEvent(){
......
...@@ -190,7 +190,7 @@ export const ModalCtroller = (function() { ...@@ -190,7 +190,7 @@ export const ModalCtroller = (function() {
(_.ModalContainer as FYGE.Container).destroy(); (_.ModalContainer as FYGE.Container).destroy();
ModalMap.delete(ModalNode) ModalMap.delete(ModalNode)
} }
console.log('closeModal config:', _.props._config, ModalMap) // console.log('closeModal config:', _.props._config, ModalMap)
return return
} }
......
import { DreamContainer } from "../../components/DreamContainer/DreamContainer";
import { DreamSprite } from "../../components/DreamSprite/DreamSprite";
import Dream from "../../Dream";
import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload";
@UsePreload({
preAction: async function() {
await RES.loadGroup('DrawFailModal')
},
loadingComponent: null
})
export class DrawFailModal extends Dream.RenderContainer {
onConfirm = () => {
this.props.onConfirm()
this.props.closeModal()
}
render() {
const roleCont = RES.getRes('DFMB.png')
const confirmbtn = RES.getRes('DFM1.png')
return (
<DreamContainer>
<DreamSprite src={roleCont} />
{/* <DreamSprite onClick={this.onConfirm} inlineProps={{
x: roleCont.width - 50,
y: -50
}} src={RES.getRes('closebtn.png')}/> */}
<DreamSprite onClick={this.onConfirm} inlineProps={{
x: roleCont.width / 2 - confirmbtn.width / 2,
y: 300
}} src={confirmbtn}/>
</DreamContainer>
)
}
}
\ No newline at end of file
import { DreamContainer } from "../../components/DreamContainer/DreamContainer";
import { DreamSprite } from "../../components/DreamSprite/DreamSprite";
import { DreamTextField } from "../../components/DreamTextField/DreamTextField";
import Dream from "../../Dream";
import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload";
import { sendTbNet, TbNetName } from "../../tools/TbNet";
@UsePreload({
resList: [],
preAction: async function() {
await RES.loadGroup('DrawSucModal')
},
loadingComponent: null
})
export class DrawSucModal extends Dream.RenderContainer<{
closeModal: () => Promise<any>,
onConfirm: () => void
name: string,
img: string
}> {
onClose2GameOver = async () => {
await this.props.closeModal()
this.props.onConfirm()
}
onConfirm = () => {
// sendTbNet(TbNetName.goMyPrize)
this.onClose2GameOver()
}
render() {
const roleCont = RES.getRes('DSMB.png')
const confirmbtn = RES.getRes('DSM1.png')
const roleWidth = roleCont.width
const {
name,
img
} = this.props
return (
<DreamContainer>
<DreamSprite src={roleCont}></DreamSprite>
{/* <DreamSprite onClick={() => {
this.onClose2GameOver()
}} inlineProps={{
x: roleWidth - 50
}} src={RES.getRes('closebtn.png')}/> */}
<DreamSprite inlineProps={{
x: roleWidth / 2 - 100,
y: 210
}} src={img} width={200} height={200} />
<DreamTextField color="#b36d00" text={'获得 ' + name} textWidth={roleWidth} inlineProps={{
y: 445
}}></DreamTextField>
<DreamSprite onClick={this.onConfirm} src={confirmbtn} inlineProps={{
x: roleWidth / 2 - confirmbtn.width / 2,
y: 550
}} />
<DreamTextField text="奖品可在首页「我的奖品」中查看" textWidth={roleWidth} color="#ffffff" size={22} inlineProps={{
y: roleCont.height - 80
}} />
</DreamContainer>
)
}
}
\ No newline at end of file
import { DreamContainer } from "../../components/DreamContainer/DreamContainer";
import { DreamSprite } from "../../components/DreamSprite/DreamSprite";
import { ModalComponent } from "../../modules/ModalComponent";
import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload";
import Dream from "../../Dream";
import { DreamTextField } from "../../components/DreamTextField/DreamTextField";
import { sendTbNet, TbNetName } from "../../tools/TbNet";
console.log(Dream)
@UsePreload({
preAction: async function() {
await RES.loadGroup('GameOverModal')
}
})
export class GameOverModal extends ModalComponent<{
score: number
}> {
onCancel() {
sendTbNet(TbNetName.goBackHome)
this.props.closeModal()
}
onConfirm() {
sendTbNet(TbNetName.openCardTask)
}
render() {
const back = RES.getRes('GameOverModalBack.png')
const confirmbtn = RES.getRes("GOM1.png")
const cancelbtn = RES.getRes('GOM0.png')
const th = back.height - 220
const {
score
} = this.props
return (
<DreamContainer inlineProps={{
y: -50
}} className="GameOverModal">
<DreamSprite src={back}></DreamSprite>
<DreamTextField text={score+''} color="#b36d00" size={90} bold textWidth={back.width} inlineProps={{
y: 230
}} />
<DreamSprite src={confirmbtn} inlineProps={{
x: back.width / 2 - confirmbtn.width / 2,
y: th
}}
onClick={this.onConfirm}
></DreamSprite>
<DreamSprite inlineProps={{
x: back.width / 2 - cancelbtn.width / 2,
y: th + confirmbtn.height + 20
}} src={cancelbtn}
onClick={() => {
this.onCancel()
}}
></DreamSprite>
</DreamContainer>
)
}
}
\ No newline at end of file
import { DreamContainer } from "../../components/DreamContainer/DreamContainer";
import { DreamSprite } from "../../components/DreamSprite/DreamSprite";
import { DreamTextField } from "../../components/DreamTextField/DreamTextField";
import Dream from "../../Dream";
import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload";
import { sendTbNet, TbNetName } from "../../tools/TbNet";
@UsePreload({
async preAction() {
await RES.loadGroup('GameQuitModal')
}
})
export class GameQuitModal extends Dream.RenderContainer<{
pName: string,
closeModal: () => Promise<void>
}> {
onConfirm = () => {
this.props.closeModal()
sendTbNet(TbNetName.goBackHome)
}
render() {
const roleCont = RES.getRes('GQMB.png')
const roleWidth = roleCont.width
const {
pName
} = this.props
return (
<DreamContainer>
<DreamSprite src={roleCont} />
<DreamTextField text="现在退出游戏机会就浪费了哦" size={34} textWidth={roleWidth} inlineProps={{
y: 160
}} />
<DreamTextField text={`参与游戏 ${pName}奖励等你拿!`} color="#b5720d" size={26} textWidth={roleWidth} inlineProps={{y: 230}} />
<DreamContainer inlineProps={{y: 320}}>
<DreamSprite onClick={this.props.closeModal} inlineProps={{x: 50}} src={RES.getRes('GQM0.png')} />
<DreamSprite onClick={this.onConfirm} inlineProps={{x: 300}} src={RES.getRes('GQM1.png')} />
</DreamContainer>
</DreamContainer>
)
}
}
\ No newline at end of file
import { DreamContainer } from "../../components/DreamContainer/DreamContainer";
import { DreamSprite } from "../../components/DreamSprite/DreamSprite";
import { DreamTextField } from "../../components/DreamTextField/DreamTextField";
import Dream from "../../Dream";
import { DreamSpriteV2 } from "../../Dream/UI";
import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload";
import { sendTbNet, TbNetName } from "../../tools/TbNet";
import { throttle } from "../../tools/Tools";
@UsePreload({
preAction: async function() {
await RES.loadGroup('GameResumeModal')
},
loadingComponent: null
})
export class GameResumeModal extends Dream.RenderContainer<{
resumeNum: number,
closeModal: () => Promise<any>
onConfirm: () => void
onCancel: () => Promise<void>
}> {
countTextField: FYGE.TextField
intervalId: any
didRendered(): void {
this.intervalId = setInterval(() => {
if (this.count == 0) {
this.props.onCancel()
this.props.closeModal()
clearInterval(this.intervalId)
return
}
--this.count
}, 1000)
}
unMount(): void {
clearInterval(this.intervalId)
}
_count: number = 10
get count() {
return this._count
}
set count(v) {
this._count = v
this.countTextField.text = `${v}s`
}
/**
* 确认走复活逻辑
*/
onConfirm = throttle(async () => {
clearInterval(this.intervalId)
const {
success
} = await sendTbNet(TbNetName.reduceTools)
if (success) {
this.props.onConfirm()
this.props.closeModal()
} else {
this.props.closeModal()
}
})
render() {
const RoleContBack = RES.getRes('GameResumeModalBack.png')
const confirmBtn = RES.getRes('useRightNowBtn.png')
const RoleContWidth = RoleContBack.width
const cancelBtn = RES.getRes('cancelBtn.png')
return (
<FYGE.Container>
<DreamSpriteV2 src={RoleContBack}></DreamSpriteV2>
<DreamTextField text={`剩余复活卡:${this.props.resumeNum}张`} color="#b26f06" textWidth={RoleContBack.width} inlineProps={{
y: 230
}} />
<DreamSprite src={confirmBtn} inlineProps={{
x: RoleContWidth / 2 - confirmBtn.width / 2,
y: 320
}}
onClick={this.onConfirm}
/>
<DreamSprite src={cancelBtn}
inlineProps={{
x: RoleContWidth / 2 - cancelBtn.width / 2,
y: 320 + confirmBtn.height + 20
}}
onClick={async () => {
this.props.onCancel()
this.props.closeModal()
}}
>
<DreamTextField ref={el=> {
this.countTextField = el
}} inlineProps={{
x: 160,
y: 3
}} text={this.count + 's'} color="#7e5a32" textHeight={cancelBtn.height} />
</DreamSprite>
</FYGE.Container>
)
}
}
\ No newline at end of file
export enum BoxType { import { layers } from "../../modules/layers";
Box1 = 'Box1',
Box2 = 'Box2',
Box3 = 'Box3',
Box4 = 'Box4',
Box5 = 'Box5',
Box6 = 'Box6',
Box7 = 'Box7',
Box8 = 'Box8',
}
export const BoxTypeList: BoxType[] = [
BoxType.Box1,
BoxType.Box2,
BoxType.Box3,
BoxType.Box4,
BoxType.Box5,
BoxType.Box6,
BoxType.Box7,
BoxType.Box8
]
export const GameConfig = { export const GameConfig = {
debugger: false, debugger: true,
GenerateSpace: [300, 400], // 生成间距 offsetYLen: 180,
finalGiftPart: 0.1, // 最终奖励 概率 100% offsetXLen: 150,// 格子间隔
maxLen: 550, rowNum: 30, // 单个地图的显示 行数
totoalPart: 0, // 全部概率 speed: 100, // 卷轴速度
PartList: [] as { renderMapScreenNum: 200, //当卷轴 移动到视窗上面多少 会去生成地图
preSumPart: number, rabbitConfig: {
type: BoxType offsetX: 10,
}[], // 概率 offsetY: -203,
GenerateConfig: {
angle: Math.PI * 40 / 180,
tanNum: Math.tan(Math.PI * 40 / 180)
},
CameraConfig: {
pos: {
x: 375,
y: 1100
},
}, },
GameStagePos: { DecisionLine: [ // 判定线 当前屏幕显示区域
x: 160, 300, layers.stageHeight // 这里个需要后续设定
y: 1200 ],
}, boxColNum: 5, // 几列格子
boxConfig: { mapList: [
[BoxType.Box1]: { {
resName: 'box1.png', initPos: {
addScore: 4, x: 2,
oc: { y: 26
x: 142, y: 230 // 判断中心点 },
}, boxMap: [
oz: 90, // height [0, 1, 0, 1, 1],
dt: [-60, 50], [0, 1, 1, 0, 0],
part: 10 [1, 0, 0, 1, 0],
}, [0, 1, 1, 0, 1],
[BoxType.Box2]: { [1, 1, 0, 1, 0],
resName: 'box2.png', [0, 1, 1, 0, 0],
addScore: 5, [1, 0, 0, 0, 1],
oc: { [1, 0, 1, 1, 1],
x: 142, y: 230 [0, 1, 0, 0, 1],
}, [1, 0, 1, 0, 0],
oz: 60, [0, 1, 0, 1, 0],
dt: [-50, 50], [1, 0, 1, 0, 0],
part: 10 [0, 0, 1, 0, 1],
}, [1, 1, 0, 1, 1],
[BoxType.Box3]: { [0, 1, 0, 0, 0],
resName: 'box3.png', [1, 0, 0, 1, 0],
addScore: 6, [0, 1, 1, 0, 1],
oc: { [1, 1, 0, 0, 0],
x: 142, y: 230 [0, 0, 1, 0, 1],
}, [1, 1, 0, 1, 0],
oz: 140, [0, 0, 0, 0, 1],
dt: [-50, 50], [1, 0, 1, 0, 0],
part: 10 [0, 1, 0, 0, 1],
}, [1, 1, 0, 1, 0],
[BoxType.Box4]: { [1, 0, 0, 1, 0],
resName: 'box4.png', [1, 1, 0, 1, 1],
addScore: 8, [0, 1, 1, 0, 1],
oc: { [1, 0, 0, 1, 0],
x: 142, y: 250 [0, 1, 1, 0, 1],
}, [1, 1, 1, 1, 1],
oz: 160, ],
dt: [-40, 40], },
part: 10 ],
}, };
[BoxType.Box5]: {
resName: 'box5.png',
addScore: 10,
oc: {
x: 142, y: 260
},
oz: 60,
dt: [-40, 40],
part: 10
},
[BoxType.Box6]: {
resName: 'box6.png',
addScore: 1,
oc: {
x: 142, y: 230
},
oz: 70,
dt: [-50, 50],
part: 10
},
[BoxType.Box7]: {
resName: 'box7.png',
addScore: 15,
oc: {
x: 142, y: 360
},
oz: 300,
dt: [-50, 50],
part: 4
},
[BoxType.Box8]: {
resName: 'box8.png',
addScore: 15,
oc: {
x: 142, y: 360
},
oz: 305,
dt: [-40, 40],
part: 4
}
}
}
let temp = []
for (let k in GameConfig.boxConfig) {
let kType: BoxType = k as any
temp.push(kType)
}
const tp: {
preSumPart: number,
type: BoxType
}[] = []
GameConfig.totoalPart = temp.reduce((pre, cur) => {
const tt = pre + GameConfig.boxConfig[cur].part
tp.push({
preSumPart: tt,
type: cur
})
return tt
}, 0)
GameConfig.PartList = tp
import { DreamContainer } from "../../components/DreamContainer/DreamContainer";
import { DreamShape } from "../../components/DreamShape/DreamShape";
import { DreamSprite } from "../../components/DreamSprite/DreamSprite";
import { DreamTextField } from "../../components/DreamTextField/DreamTextField";
import Dream, {DreamProps } from "../../Dream";
import { fadeOutUpFactory } from "../../modules/animations";
import { RES } from "../../modules/RES";
import { BoxType, BoxTypeList, GameConfig } from "./GameConfig";
type GameEleType = DreamProps<{
type?: BoxType,
x?: number,
y?: number,
inlineProps?: Record<string, any>
isWithGift?: boolean
}, GameEle>
export class GameEle extends Dream.RenderContainer<GameEleType> {
GameBoxType: BoxType = BoxType.Box1
GiftIcon: FYGE.Sprite
constructor(props: GameEleType) {
super(props)
const {
type
} = this.props
if (type) {
this.GameBoxType = type
} else {
this.GameBoxType = BoxTypeList[Math.random() * BoxTypeList.length >> 0]
}
}
didRendered(): void {
}
onGetGift() {
if (this.GiftIcon) {
fadeOutUpFactory(500, 200)(this.GiftIcon)
}
}
render() {
const currGameBoxConfig = GameConfig.boxConfig[this.GameBoxType]
const boxRes = RES.getRes(currGameBoxConfig.resName)
const {
x,
y,
inlineProps,
isWithGift
} = this.props
const {
dt = [0, 0],
oc: {
x: ocx,
y: ocy
},
oz
} = currGameBoxConfig
const tanNum = Math.tan(GameConfig.GenerateConfig.angle)
// const offsetY = * Math.abs(spaceNum)
// console.log(boxRes, this.GameBoxType, GameConfig.boxConfig, currGameBoxConfig)
return (
<DreamContainer inlineProps={{
...inlineProps,
x,y
}}>
<DreamContainer inlineProps={{
x: -currGameBoxConfig.oc.x,
y: -currGameBoxConfig.oc.y
}}>
<DreamSprite src={boxRes}></DreamSprite>
{
isWithGift && (
<DreamSprite ref={el => {
this.GiftIcon = el
}} src={RES.getRes('giftBoxIcon.png')} inlineProps={{
x: currGameBoxConfig.oc.x - 60,
y: currGameBoxConfig.oc.y - 80 - currGameBoxConfig.oz,
}} />
)
}
{
GameConfig.debugger && (
<DreamContainer>
<DreamShape type="circle" drawData={[0,0, 8]} fillColor="#f17368" inlineProps={{
x: currGameBoxConfig.oc.x,
y: currGameBoxConfig.oc.y
}} />
<DreamShape type="circle" drawData={[0,0, 8]} fillColor="#f17368" inlineProps={{
x: ocx,
y: ocy - oz
}} />
<DreamShape type="circle" drawData={[0,0, 8]} fillColor="#f17368" inlineProps={{
x: ocx + dt[0],
y: ocy - oz + tanNum * Math.abs(dt[0])
}} ></DreamShape>
<DreamShape type="circle" drawData={[0,0, 8]} fillColor="#f17368" inlineProps={{
x: ocx + dt[1],
y: ocy - oz - tanNum * dt[1]
}} ></DreamShape>
</DreamContainer>
)
}
</DreamContainer>
</DreamContainer>
)
}
}
\ No newline at end of file
This diff is collapsed.
import { DreamContainer } from "../../components/DreamContainer/DreamContainer";
import { DreamSprite } from "../../components/DreamSprite/DreamSprite";
import Dream from "../../Dream";
import { RES } from "../../modules/RES";
export class Platform extends Dream.RenderContainer<{
type: number // 1 就是默认 2 道具 3 炸弹
x: number
}> {
render() {
const backRes = RES.getRes('platform.png')
return (
<DreamContainer inlineProps={{
x: this.props.x || 0
}}>
<DreamSprite src={backRes} inlineProps={{
x: 2
}} />
</DreamContainer>
)
}
}
\ No newline at end of file
import { DreamContainer } from "../../components/DreamContainer/DreamContainer"; import { DreamContainer } from "../../components/DreamContainer/DreamContainer";
import { DreamLottie } from "../../components/DreamLottie/DreamLottie"; import { DreamSprite } from "../../components/DreamSprite/DreamSprite";
import { DreamSpine, setSpineAni } from "../../components/DreamSpine/DreamSpine";
import { DreamTextField } from "../../components/DreamTextField/DreamTextField";
import Dream from "../../Dream"; import Dream from "../../Dream";
import { JumpEnd } from "../../lotties/JumpEnd";
import { PerfectJumpEnd } from "../../lotties/PerfectJumpEnd";
import { fadeOutUpFactory } from "../../modules/animations";
import { RES } from "../../modules/RES"; import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload"; import { GameConfig } from "./GameConfig";
import { getTbSpi } from "../../tools/simpleTools";
export enum PlayAniEnum { export class RabbitPlayer extends Dream.RenderContainer<{
Stand = 'daiji',
StandBy = 'dunxia1',
Jump = 'tiaoyue2'
}
const PlayerAction = {
JUMP: 'tiaoyue2',
STANDBY: 'dunxia1',
STAND: 'daiji'
}
export type PlayerIns = {
turnRound: (dir: 1 | -1) => void
jump: () => Promise<void>
jumpPrepare: () => Promise<void>
showJumpEndAtom: (score: number) => Promise<void>
}
@UsePreload({
preAction: async function() {
if (!window) {
await RES.getResAsync(getTbSpi(), () => {}, null, 'spi')
} else {
await RES.loadGroup('spine')
}
},
loadingComponent: null
})
export class Player extends Dream.RenderContainer<{
getPlayer?: (ins: PlayerIns) => void
inlineProps?: Record<string, any> inlineProps?: Record<string, any>
}> { }> {
SpineContainer: FYGE.Container
SpinePlayer: FYGE.Spine
AtomLottie: FYGE.Lottie
aniText: FYGE.TextField
didRendered(): void {
this.props.getPlayer && this.props.getPlayer({
turnRound: (dir) => {
this.SpineContainer.scaleX = dir
},
jump: () => {
return new Promise(r => {
setSpineAni(this.SpinePlayer, PlayerAction.JUMP, 1 , () => {
setSpineAni(this.SpinePlayer, PlayerAction.STAND)
r()
})
})
},
showJumpEndAtom:(score: number) => {
return new Promise(r => {
this.AtomLottie.visible = true
this.aniText.text = `+${score}`
fadeOutUpFactory(500, 100)(this.aniText)
this.AtomLottie.play(1, () => {
this.AtomLottie.visible = false
r()
})
})
},
jumpPrepare: () => {
return new Promise(r => {
setSpineAni(this.SpinePlayer, PlayerAction.STANDBY, 1 , () => {
r()
})
})
}
})
}
render() { render() {
const PlayerSpineData = RES.getRes(!window ? getTbSpi() : 'rabbit.spi', 'spi')
return ( return (
<DreamContainer inlineProps={{ <DreamContainer inlineProps={{
...this.props.inlineProps ...this.props.inlineProps,
anchorX: 75
}}> }}>
<DreamTextField ref={el=> { <DreamContainer inlineProps={{
this.aniText = el x: GameConfig.rabbitConfig.offsetX,
}} size={32} color="#fad99e" text="+0" textWidth={300} inlineProps={{ y: GameConfig.rabbitConfig.offsetY
y: -210,
x: -150,
alpha: 0
}} ></DreamTextField>
<DreamContainer ref={el => {
this.SpineContainer = el
}}> }}>
<DreamLottie ref={el => { <DreamSprite src={RES.getRes('rabbit.png')} />
this.AtomLottie = el
}} inlineProps={{
x: -125,
y: -230,
visible: false
}} lottieData={JumpEnd} />
<DreamSpine ref={el => {
this.SpinePlayer = el
}} aniName={PlayAniEnum.Stand} spineData={PlayerSpineData} inlineProps={{
y: 10,x: -5
}}></DreamSpine>
</DreamContainer> </DreamContainer>
</DreamContainer> </DreamContainer>
) )
......
import { DreamContainer } from "../../components/DreamContainer/DreamContainer"; import { DreamContainer } from "../../components/DreamContainer/DreamContainer";
import { DreamSprite } from "../../components/DreamSprite/DreamSprite"; import { DreamSprite } from "../../components/DreamSprite/DreamSprite";
import { DreamTextField } from "../../components/DreamTextField/DreamTextField";
import Dream from "../../Dream"; import Dream from "../../Dream";
import { layers } from "../../modules/layers"; import { layers } from "../../modules/layers";
import { RES } from "../../modules/RES"; import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload";
@UsePreload({ export class ScoreBoard extends Dream.RenderContainer {
preAction: async() => { _score:number = 0
await RES.loadGroup('FinalGiftModal') ScoreText: FYGE.TextField
get score() {
return this._score
} }
})
export class FinalGiftModal extends Dream.RenderContainer {
onConfirm() { set score(v: number) {
this.props.onConfirm() this._score = v
} this.ScoreText.text = v + ''
didRendered(): void {
layers.stage.once(FYGE.MouseEvent.CLICK, this.onConfirm, this)
} }
render() { render() {
const roleCont = RES.getRes('FGMB.png') const roleCont = RES.getRes('scoreBoardBack.png')
const confirmbtn = RES.getRes('FGM1.png')
return ( return (
<DreamContainer> <DreamContainer inlineProps={{
y: layers.stageOffsetY + 50,
x: 375 - roleCont.width / 2
}}>
<DreamSprite src={roleCont} /> <DreamSprite src={roleCont} />
<DreamSprite src={confirmbtn} inlineProps={{ <DreamTextField ref={el => {
x: roleCont.width / 2 - confirmbtn.width / 2, this.ScoreText = el
y: 500 }} text={this.score + ''} size={36} bold textWidth={roleCont.width} color="#9a4136" textHeight={roleCont.height} />
}} /> </DreamContainer>
</DreamContainer>
) )
} }
} }
\ No newline at end of file
export class Stack<T extends any = number> {
list: T[] = []
get stackHead() {
return this.list[this.list.length - 1]
}
pushStack(item: T) {
this.list.push(item)
return item
}
popStack() {
return this.list.pop()
}
traverse(callbackfn: (value: T, index: number, array: T[]) => void) {
const sliceItems = this.list.slice(0)
sliceItems.forEach(callbackfn)
}
}
\ No newline at end of file
...@@ -6,14 +6,11 @@ import Dream from "../../Dream"; ...@@ -6,14 +6,11 @@ import Dream from "../../Dream";
import { SceneController } from "../../modules/layers/ctrls"; import { SceneController } from "../../modules/layers/ctrls";
import { RES } from "../../modules/RES"; import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload"; import { UsePreload } from "../../modules/UseDecorator/usePreload";
import { BoxType, GameConfig } from "../GameScene/GameConfig";
import { GameScene } from "../GameScene/GameScene"; import { GameScene } from "../GameScene/GameScene";
import { Player } from "../GameScene/Player";
@UsePreload({ @UsePreload({
async preAction() { async preAction() {
await RES.loadGroup('NewGuyScene') await RES.loadGroup('NewGuyScene')
await RES.loadGroup('Boxes')
} }
}) })
export class NewGuyScene extends Dream.RenderContainer { export class NewGuyScene extends Dream.RenderContainer {
...@@ -31,94 +28,24 @@ export class NewGuyScene extends Dream.RenderContainer { ...@@ -31,94 +28,24 @@ export class NewGuyScene extends Dream.RenderContainer {
case 1: case 1:
this.GuideContainer.addChild(<DreamContainer onClick={nextStep}> this.GuideContainer.addChild(<DreamContainer onClick={nextStep}>
<DreamSprite src={RES.getRes('Guide1.png')} /> <DreamSprite src={RES.getRes('Guide1.png')} />
<Player inlineProps={{
x: 480,y: 1260, scaleX: -1
}}></Player>
</DreamContainer>) </DreamContainer>)
break break
case 2: case 2:
const n = RES.getRes('nextStep.png') this.GuideContainer.addChild(<DreamContainer onClick={nextStep}>
const posMap: Partial<Record<BoxType, [number, number]>> = { <DreamSprite src={RES.getRes('Guide2.png')} />
[BoxType.Box3]: [130, 300], </DreamContainer>)
[BoxType.Box4]: [420, 300],
[BoxType.Box1]: [40, 540],
[BoxType.Box2]: [280, 540],
[BoxType.Box5]: [500, 540]
}
const mapName = Object.keys(posMap)
this.GuideContainer.addChild(
<DreamContainer onClick={nextStep}>
<DreamShape alpha={0.7} />
<DreamContainer inlineProps={{
y: 160
}}>
{
mapName.map((item: BoxType) => {
const currConfig = GameConfig.boxConfig[item]
return (
<DreamContainer inlineProps={{
x: posMap[item][0],
y: posMap[item][1],
scaleX: 0.8,
scaleY: 0.8
}}>
<DreamSprite src={RES.getRes(currConfig.resName)} />
<DreamTextField text={`+${currConfig.addScore}`} color="#ffffff" inlineProps={{
y: 300
}} textWidth={283} size={fontSize} />
</DreamContainer>
)
})
}
</DreamContainer>
<DreamTextField inlineProps={{
y: 1100
}} text="踩到特殊格子 可获得额外得分" color="#ffffff" textWidth={750} size={32} />
<DreamSprite inlineProps={{
x: 375 - n.width / 2,
y: 1200
}} src={n} />
</DreamContainer>
)
break break
case 3: case 3:
const btn = RES.getRes('startGameBtn.png') this.GuideContainer.addChild(<DreamContainer onClick={nextStep}>
this.GuideContainer.addChild( <DreamSprite src={RES.getRes('Guide3.png')} />
<DreamContainer onClick={nextStep}> </DreamContainer>)
<DreamShape alpha={0.7} />
<DreamTextField text="踩到特殊道具" color="#ffffff" size={fontSize} textWidth={750} inlineProps={{
y: 700
}} />
<DreamTextField text="获得抽奖机会哦" color="#ffffff" size={fontSize} textWidth={750} inlineProps={{
y: 770
}} />
<DreamSprite src={btn} inlineProps={{
x: 375 - btn.width / 2,
y: 850
}} />
<DreamSprite src={RES.getRes('giftBoxIcon.png')} inlineProps={{
x: 133,
y: 950
}} />
<DreamSprite src={RES.getRes('box6.png')} inlineProps={{
x: 325,
y: 1095
}}></DreamSprite>
<Player inlineProps={{
x: 480,y: 1260, scaleX: -1
}}></Player>
</DreamContainer>
)
break break
case 4: case 4:
this.GuideContainer.addChild(<DreamContainer onClick={nextStep}>
<DreamSprite src={RES.getRes('Guide4.png')} />
</DreamContainer>)
break
case 5:
// 完成新手引导 // 完成新手引导
SceneController.changeScene(GameScene) SceneController.changeScene(GameScene)
break break
...@@ -134,7 +61,6 @@ export class NewGuyScene extends Dream.RenderContainer { ...@@ -134,7 +61,6 @@ export class NewGuyScene extends Dream.RenderContainer {
<DreamContainer ref={el => { <DreamContainer ref={el => {
this.SceneContainer = el this.SceneContainer = el
}}> }}>
<DreamSprite src={RES.getRes('NGSB.jpg')}></DreamSprite>
<DreamContainer ref={el => { <DreamContainer ref={el => {
this.GuideContainer = el this.GuideContainer = el
}} ></DreamContainer> }} ></DreamContainer>
......
...@@ -113,3 +113,49 @@ export function throttleDecorator(time: number = 1000) { ...@@ -113,3 +113,49 @@ export function throttleDecorator(time: number = 1000) {
descriptor.value = invokeFunc descriptor.value = invokeFunc
} }
} }
/**
* 只有装饰方法 执行完了之后 才可以第二次执行
* @param target
* @param property
* @param descriptor
*/
export function PromiseAwait(target: any, property: string, descriptor: PropertyDescriptor) {
const func: Function = descriptor.value
// let isPromiseFulfilled = true
let waitPromise: Promise<any> | null = null
let waitPromiseResolve: (value: unknown) => void
descriptor.value = async function(...args:any[]) {
if (waitPromise) return waitPromise
waitPromise = new Promise(resolve => {
waitPromiseResolve = resolve
})
// @ts-ignore
const res = await func.apply(this, args)
waitPromiseResolve(res)
waitPromise = null
return res
}
}
/**
* PromiseAwait 闭包版本
* @param func
* @returns
*/
export function promiseAwaitFunc(func: Function) {
let waitPromise: Promise<any> | null = null
let waitPromiseResolve: (value: unknown) => void
return async function(...args: any[]) {
if (waitPromise) return waitPromise
waitPromise = new Promise(resolve => {
waitPromiseResolve = resolve
})
// @ts-ignore
const res = await func.apply(this, args)
waitPromiseResolve(res)
waitPromise = null
return res
}
}
\ No newline at end of file
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