Commit 88dfd6e5 authored by Master Q's avatar Master Q

我是傻逼

parent 4510bcfd
{
"success": true
}
\ No newline at end of file
......@@ -10,18 +10,10 @@
"skiingOneCardScore": 2,
"skiingScoreRewardCreditsList": [
{
"score": 100,
"score": 10,
"rewardCredits": 10
},
{
"score": 200,
"rewardCredits": 10
},
{
"score": 500,
"rewardCredits": 40
}
],
"skiingGuideFlag": 0
"skiingGuideFlag": 1
}
}
\ No newline at end of file
{
"success": true,
"message": "",
"code": "",
"data": {
"startId": 1234,
"haveRadish": true
}
}
\ No newline at end of file
{
"success": true,
"message": "",
"code": "",
"data": {
"score": 123,
"maxScore": 234,
"rewardCredits": 10
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -15,17 +15,19 @@
"mock-webpack-plugin": "^2.0.0",
"path": "^0.12.7",
"progress": "^2.0.0",
"psd": "^3.2.0",
"readline": "^1.3.0",
"ts-loader": "^4.0.0",
"tslint": "^5.9.1",
"typescript": "^3.5.1",
"webpack": "^4.1.0",
"webpack-cli": "^3.1.1",
"webpack-dev-server": "^3.1.0",
"webpack-merge": "^4.1.2",
"psd": "^3.2.0",
"readline": "^1.3.0"
"webpack-merge": "^4.1.2"
},
"dependencies": {
"js-md5": "^0.7.3"
},
"dependencies": {},
"scripts": {
"psd": "node scripts/psdH && node scripts/flushRes",
"psdSin": "node scripts/psdHSin",
......
{
"groups": [
{
"keys": "GameSceneBack.png,PrizeCard.png,Rabbit.png,Radish.png,SnowBall.png,Star.png,guide1.png,score+.png,score0.png,score1.png,score2.png,score3.png,score4.png,score5.png,score6.png,score7.png,score8.png,score9.png,雪人.svga",
"keys": "GameOverPanelBack.png,atomphere.png,back.png,cancel-btn.png,confirm-btn.png",
"name": "GameOverPanel"
},
{
"keys": "GameSceneBack.png,PrizeCard.png,Rabbit.png,SnowBall.png,Star.png,countDown-back.png,finalgiftbox-disabled.png,finalgiftbox.png,giftbox-disabled.png,giftbox.png,goal0.png,guide1.png,progress-back.png,progress-point.png,radish-tips.png,score+.png,score-back.png,score0.png,score1.png,score2.png,score3.png,score4.png,score5.png,score6.png,score7.png,score8.png,score9.png,雪人.svga",
"name": "GameScene"
},
{
......@@ -9,11 +13,11 @@
"name": "IndexScene"
},
{
"keys": "comCloseBtn.png,com_light.png,com_light2.png,index_sound_off.png,index_sound_on.png,percennt0.png,percennt1.png,percennt2.png,percennt3.png,percennt4.png,percennt5.png,percennt6.png,percennt7.png,percennt8.png,percennt9.png,percenntp.png,toastBg.png,waitingBg.png,waitingRot.png",
"keys": "Radish.png,comCloseBtn.png,com_light.png,com_light2.png,gn0.png,gn1.png,gn2.png,gn3.png,gn4.png,gn5.png,gn6.png,gn7.png,gn8.png,gn9.png,gnm.png,index_sound_off.png,index_sound_on.png,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common"
},
{
"keys": "左右建筑.svga,游戏倒计时 2.svga,游戏兔子.svga,游戏道路循环.svga,道具光环.svga,首页兔子.svga,首页背景动画.svga",
"keys": "左右建筑.svga,游戏倒计时 2.svga,游戏兔子.svga,游戏道路循环.svga,获奖弹窗.svga,道具光环.svga,首页兔子.svga,首页背景动画.svga",
"name": "svga"
}
],
......
......@@ -21,6 +21,11 @@ export default class Clock {
}
restart() {
this.reset()
this.start()
}
stop() {
this.running = false;
......
......@@ -10,6 +10,7 @@ import { SkinJson } from "./SkinJson";
import { G_EVENT } from "./common/G_EVENT";
import { Tools } from "./Tools";
import IndexScene from './scenes/IndexScene';
import { GameOverPanel } from "./components/GameOverPanel";
/**
* 全局事件,为了和小程序交互
......@@ -183,6 +184,11 @@ export class Main {
// vtodo 是否是新手
changeScene(IndexScene);
// showPanel(GameOverPanel, {
// "score": 11,
// "maxScore": 11,
// "rewardCredits": 11
// })
}
}
......
This diff is collapsed.
......@@ -110,7 +110,15 @@ export enum TbNetName {
closeCustomLoading = 'mine.closeCustomLoading',
// 首页接口
doIndex = 'snow.index'
doIndex = 'snow.doIndex',
doSubmit = 'snow.doSubmit',
doStart = 'snow.doStart',
doModifySkiingGuideFlag = 'snow.doModifySkiingGuideFlag',
judgeLogin = 'mine.judgeLogin',
showRuleModal = 'mine.showRuleModal',
back = 'mine.back',
indexSceneVisible="mine.indexSceneVisible",
turnBgm = 'mine.turnBgm'
}
export enum TBBgm {
......@@ -161,7 +169,7 @@ export function sendTbNet(
//网络超时
// let waitObj;
//@ts-ignore 本地开发,直接取数据
if (!my) {
if (window.location.port == "8099") {
const netInfo = netName.split(".");
var url = `../../mock/miniTb/${netInfo[0]}/${netInfo[1]}.json`;
fetchAsync(url)
......
......@@ -60,8 +60,12 @@ export default class UI {
public static Sp(
parent: Container,
imageName: string,
x: number = 0, y: number = 0
x: number = 0, y: number = 0,
anchorCenter: boolean = false
): Sprite {
if (!/\./i.test(imageName)) {
imageName += '.png'
}
var texture = RES.getRes(imageName)
var sprite
if (texture) {
......@@ -69,6 +73,9 @@ export default class UI {
} else {
sprite = Sprite.fromUrl(imageName)
}
if (anchorCenter) {
sprite.anchorTexture.set(0.5)
}
sprite.position.set(x, y);
parent && parent.addChild(sprite);
return sprite;
......
......@@ -62,6 +62,7 @@ export default class CircleProgressBar extends FYGE.Container {
this.backCircle.beginStroke(this.opt.backColor, this.opt.lineWidth)
this.backCircle.arc(this.circlePointer.x, this.circlePointer.y, radius, 0, 2*Math.PI)
this.backCircle.endStroke()
this.backCircle.alpha = 0.5
}
strokeProgress(v) {
......@@ -71,18 +72,19 @@ export default class CircleProgressBar extends FYGE.Container {
}
var radius = this.opt.radius
var lw = this.opt.lineWidth
// FYGE.LINE_CAP.ROUND
if (!this.progressCircle) {
this.progressCircle = this.addChild(new FYGE.Shape)
this.progressCircle.anchorX = radius + lw
this.progressCircle.anchorY = radius + lw
this.progressCircle.rotation = -90 // 好看点
this.progressCircle.beginStroke(this.opt.circleColor, this.opt.lineWidth, FYGE.LINE_CAP.ROUND)
this.progressCircle.arc(radius + lw, radius + lw, radius, 0, 2*Math.PI * v)
this.progressCircle.beginStroke(this.opt.circleColor, this.opt.lineWidth)
this.progressCircle.arc(radius + lw, radius + lw, radius, 0, 2*Math.PI * v, true)
this.progressCircle.endStroke()
} else {
this.progressCircle.clear()
this.progressCircle.beginStroke(this.opt.circleColor, this.opt.lineWidth, FYGE.LINE_CAP.ROUND)
.arc(this.circlePointer.x, this.circlePointer.y, radius, 0, 2*Math.PI * v)
this.progressCircle.beginStroke(this.opt.circleColor, this.opt.lineWidth)
.arc(this.circlePointer.x, this.circlePointer.y, radius, 0, 2*Math.PI * v, true)
.endStroke()
}
}
......
......@@ -84,7 +84,7 @@ export class ProgressBar extends FYGE.Container {
var length = this._value * this.maxLength
this.upImage.clear()
.beginFill(this.barColor)
.drawRoundedRect(0, 0, length, this.pHeight, 10)
.drawRoundedRect(0, 1, length, this.pHeight - 2, (this.pHeight - 2) / 2)
.endFill();
}
}
......@@ -3,11 +3,11 @@
* @param time 毫秒计算
* @param onChange 根据时间倒计时的执行函数
*/
export function countDown(time: number, onChange: (t: number) => void) {
export function countDown(time: number, onChange: (t: number) => void, onCallBack?: Function) {
var timeObj = { a: time };
FYGE.Tween.get(timeObj, {
onChange: () => {
onChange(timeObj.a)
onChange && onChange(timeObj.a)
// this.timeTxt.text = "" + Math.round(timeObj.a / 1000) + "s"
// if (timeObj.a < 100) {
// FYGE.Tween.removeTweens(timeObj)
......@@ -16,6 +16,9 @@ export function countDown(time: number, onChange: (t: number) => void) {
}
})
.to({ a: 0 }, time)
.call(() => {
onCallBack && onCallBack()
})
//返回一个,可以中途取消
return timeObj
}
......
import { changeScene } from './../../module/ctrls/index';
import { RES } from "../../module/RES";
import { Panel } from "../../module/views/Panel";
import UI from "../UI";
import IndexScene from '../scenes/IndexScene';
interface GameOverPanelInfer {
"score": number,
"maxScore": number,
"rewardCredits": number,
onGameRestart?: Function
}
export class GameOverPanel extends Panel {
closeBtn: FYGE.Button;
get groupNames(): string[] {
return ['GameOverPanel']
}
onGameRestart: Function
constructor(data: GameOverPanelInfer) {
super()
this.onGameRestart = data.onGameRestart
}
RoleContainer: FYGE.Container
initUi(): void {
const RoleContainer = this.RoleContainer = UI.Ctn(this, (750 - 616) / 2, (1624 -600) / 2)
UI.Sp(RoleContainer, 'atomphere.png', -50, -300)
RoleContainer.addChild(new FYGE.MovieClip(RES.getRes('获奖弹窗.svga')))
.position.set(-70, -330)
UI.Sp(RoleContainer, 'GameOverPanelBack')
// this.closeBtn = UI.Btn(RoleContainer, 'comCloseBtn.png')
// this.closeBtn.position.set( 560, -100)
UI.Btn(RoleContainer, 'cancel-btn.png', function() {
this.hidePanel()
changeScene(IndexScene)
}, this, 40, 430)
UI.Btn(RoleContainer, 'confirm-btn.png', async function() {
this.onGameRestart()
this.hidePanel()
// changeScene(IndexScene)
}, this, 320, 430)
}
start(data?: GameOverPanelInfer): void {
UI.Txt(this.RoleContainer, `获得${data.rewardCredits}活力值`, 36, '#914533', FYGE.TEXT_ALIGN.CENTER, 616, 0, 145)
UI.Txt(this.RoleContainer, `${data.score}`, 48,'#e34539', FYGE.TEXT_ALIGN.CENTER, 305, 0, 310, true)
UI.Txt(this.RoleContainer, `${data.maxScore}`, 48,'#e34539', FYGE.TEXT_ALIGN.CENTER, 385, 265, 310, true)
}
}
\ No newline at end of file
interface NormalScoreGoalCompInfer {
score?: number
}
export class NormalScoreGoalComp extends FYGE.Container {
score
constructor(data: NormalScoreGoalCompInfer) {
super()
this.initUi()
}
initUi() {
}
}
\ No newline at end of file
import { Tools } from './../Tools';
import { RES } from "../../module/RES"
import { Pos } from "./GameScene/ConveyorBelt"
import { GDispatcher } from '../Main';
import { ConveyorBeltGameEle } from './GameScene/ConveyorBeltConfig';
import UI from '../UI';
export interface GameEleInfer {
type: number,
......@@ -8,18 +13,51 @@ export interface GameEleInfer {
export class GameEle extends FYGE.Sprite {
_resType: string // 游戏元素type src
_resType2: string | number // 游戏元素类型 0, 1
_resType2: string | number // 游戏元素类型 0, 1, 2
_score: number
constructor(config:GameEleInfer) {
super(RES.getRes(config.res))
this._resType = config.res
this._resType2 = config.type
this._score = config.score
// const l = UI.Sp(this, 'com_light2.png')
// this.setChildIndex(l, -100)
}
onCollision() {
if (this._resType2 == 1) {
console.log('加分:', this.x, this.y)
GDispatcher.dispatchEvent('update-score', {
score: this._score
})
this.onShowScoreAni(`+${this._score}`, {
x: this.x,
y: this.y
})
} else if (this._resType2 == 0) {
GDispatcher.dispatchEvent('game-over')
} else {
GDispatcher.dispatchEvent('rabbit-buff')
}
}
onShowLightRatation() {
}
onShowScoreAni(scoreText: string, pos: Pos) {
const BitmapTextTextures = Tools.getNumTextures('score')
BitmapTextTextures['+'] = RES.getRes('score+.png')
const BitmapText = new FYGE.BitmapText(BitmapTextTextures)
this.parent.parent.addChild(BitmapText)
BitmapText.text = scoreText
BitmapText.alpha = 0
BitmapText.position.set(pos.x, pos.y)
FYGE.Tween.get(BitmapText)
.to({ y: pos.y - 150, alpha: 1 }, 600)
.wait(300)
.to({alpha: 0}, 300)
.call(() => {
BitmapText.destroy()
})
}
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import { ConveyorBeltGameEle } from './ConveyorBeltConfig'
import { RES } from '../../../module/RES';
import { getRandomArrayElements } from '../../Tools';
import { RabbitPos } from './GameSceneConfig';
import { GDispatcher } from '../../Main';
// 非障碍元素
const CollsionEle = ConveyorBeltGameEle.filter(item => item.type)
......@@ -23,12 +24,12 @@ interface ConveyorBeltInfer {
export class ConveyorBelt extends FYGE.Container {
ConveyorBeltConfigData: ConveyorBeltInfer
speed: number = 200 // 传送带速度 这里就是 y方向上的速度
speed: number = 200 // 传送带速度 这里就是 y方向上的速度 200 - 650
spt: number // 每隔多长时间会出现下一个
spl: number = 300 // 距离
clock: Clock
tanValue: number // tan 值
conveyorItems: Array<any> = [] // 传送带上的 item
conveyorItems: Array<GameEle> = [] // 传送带上的 item
isStarted: boolean = false // 是否开始
totalDisY: number
startY: number
......@@ -74,6 +75,7 @@ export class ConveyorBelt extends FYGE.Container {
this.removeEventListener(FYGE.Event.ENTER_FRAME, this.onUpdate, this)
}
// 因为碰撞或者移动出去的 销毁
popConveyor(item: GameEle, didu?: boolean) {
if (didu) {
item.onCollision()
......@@ -83,6 +85,16 @@ export class ConveyorBelt extends FYGE.Container {
GPool.takeIn(item['_resType'], item)
}
onReset() {
for (var i = this.conveyorItems.length- 1; i >= 0; i--) {
this.popConveyor(this.conveyorItems[i])
}
}
popConveyorItems(item: GameEle) {
spliceArrItem(this.conveyorItems, item)
}
destroy(): void {
super.destroy()
this.removeEvents
......@@ -105,6 +117,7 @@ export class ConveyorBelt extends FYGE.Container {
this.isStarted = true
// getRandomArrayElements
this.onRenderGameEleData()
this.clock.restart()
}
stop() {
......@@ -114,6 +127,10 @@ export class ConveyorBelt extends FYGE.Container {
onRenderGameEleData() {
const item = getRandomArrItem(ConveyorBeltGameEle)
if (item.type) {
if (item.type == 2) {
GDispatcher.dispatchEvent('show-radish')
ConveyorBeltGameEle.pop()
}
this.onInitGameElement(item)
} else {
const isShouldRenderObstacle = this.ConveyorBeltConfigData.obstacleFunc()
......
......@@ -12,8 +12,12 @@ export const ConveyorBeltGameEle = [
{
type: 0,
res: 'SnowBall.png'
}, {
type: 2, // TODO
}
]
export const specialGameEle = [
{
type: 2,
res: 'Radish.png'
}
]
\ No newline at end of file
This diff is collapsed.
export const RabbitPos = {
y: 1100
}
export const GameCfg = {
totalTime: 3000,
radishTime: 5000
}
\ No newline at end of file
......@@ -4,8 +4,13 @@ import { Scene } from "../../module/views/Scene";
import UI from "../UI";
import { RES } from '../../module/RES';
import { GDispatcher } from '../Main';
import { GameScene } from './GameScene/GameScene';
import { getTbData, TbNetName } from '../TaoBaoNet';
import { GameScene, RadishCountDown } from './GameScene/GameScene';
import { getTbData, sendTbNet, TbNetName } from '../TaoBaoNet';
import CircleProgressBar from '../common/CircleProgressBar';
export const IndexSceneConfig = {
ms: false
}
export default class IndexScene extends Scene {
startBtn: FYGE.Button
......@@ -32,10 +37,10 @@ export default class IndexScene extends Scene {
initUi() {
this.indexSceneData = getTbData(TbNetName.doIndex).data
UI.Sp(this, 'index-scene-back.png')
const ani = this.addChild(new FYGE.SvgaAni(RES.getRes('首页兔子.svga')))
ani.position.set((750 - ani.width) / 2, 0)
const ani = this.addChild(new FYGE.MovieClip(RES.getRes('首页兔子.svga')))
ani.position.set(0, 0)
this.addChild(new FYGE.SvgaAni(RES.getRes('首页背景动画.svga')))
this.addChild(new FYGE.MovieClip(RES.getRes('首页背景动画.svga')))
const startBtnCont = UI.Ctn(this, 0, 1270)
this.startBtn = UI.Btn(startBtnCont, 'start-btn.png')
......@@ -48,8 +53,16 @@ export default class IndexScene extends Scene {
this.musicBtn = UI.Btn(this, 'index_sound_on.png')
this.musicBtn.position.set(750 - this.musicBtn.width - 10, 310)
// TODO
this.ms = true
// var c = this.addChild(new RadishCountDown(5000))
// c.position.set(690, 370)
this.ms = IndexSceneConfig.ms
}
start(data?: any): void {
super.start()
sendTbNet(TbNetName.judgeLogin)
sendTbNet(TbNetName.indexSceneVisible, {visible: true})
}
initEvents(): void {
......@@ -59,31 +72,43 @@ export default class IndexScene extends Scene {
this.backBtn.addEventListener(FYGE.MouseEvent.CLICK, this.onBackActivity, this)
}
onGameStart() {
console.log('GameStart')
changeScene(GameScene, {
isNewGuy: !this.indexSceneData.skiingGuideFlag
})
async onGameStart() {
const { success, data } = await sendTbNet(TbNetName.doStart)
if (success) {
sendTbNet(TbNetName.indexSceneVisible, {visible: false})
changeScene(GameScene, {
isNewGuy: !this.indexSceneData.skiingGuideFlag,
haveRadish: data.haveRadish
})
}
}
onRuleShowPanel() {
GDispatcher.dispatchEvent('showRulePanel')
sendTbNet(TbNetName.showRuleModal, {
ruleText: getTbData(TbNetName.doIndex).data.gameRuleDesc
})
}
onBackActivity() {
GDispatcher.dispatchEvent('backActivity')
sendTbNet(TbNetName.back)
}
onMusicChangeStatus() {
this.ms = !this.ms
}
onMusicOperation(v) {
onMusicOperation(v: boolean) {
this.musicBtn.texture = RES.getRes(v ? 'index_sound_on.png' : 'index_sound_off.png')
IndexSceneConfig.ms = v
if (v) {
sendTbNet(TbNetName.turnBgm, {
play: v
})
} else {
sendTbNet(TbNetName.turnBgm, {
play: v
})
}
}
}
\ No newline at end of file
This diff is collapsed.
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