Commit ab88cd1d authored by AU-Pro-mac's avatar AU-Pro-mac

something

parent 87d85010
{"code":"adipisicing sunt","success":false,"message":"ea non","data":{"list":{"useUrl":"elit non labore","openId":-16899820.960220918,"_id":"Ut nulla","userNick":"in","avatar":"ullamco eu aliqua mollit eiusmod","activityId":"dolor","prizeId":"nulla enim non aliquip ipsum","type":1,"image":"https://dummyimage.com/400x400","name":"Duis nostrud dolore","drawStatus":1,"createTime":1602033015243,"updateTime":1610946860060,"addressdetail":"laboris ea tempor elit","area":"西湖区","city":"杭州市","phone":16270225970,"provice":"浙江省","receiveName":"labore magna aliquip","receiveTime":1608949355424,"expiredTime":1612654245440}}}
\ No newline at end of file
const resCanvasListCsd = {
};
export default resCanvasListCsd;
\ No newline at end of file
import { Scene } from "../../module/views/Scene";
import { RES } from "../../module/RES";
import { Options } from './props'
import Root from './Root';
export class CsdScene extends Scene {
constructor(props) {
super(props)
}
initUi() {
super.initUi();
var canvas: FYGE.Container = new FYGE.Container();
canvas.position.set(0, 0);
this.addChild(canvas);
}
start() {
this.addChild(new Root(Options))
}
}
import { RES } from "../../module/RES"
import resCanvasList from '../../resCanvasList'
import GoodsCtrl from './game/GoodsCtrl'
import { GDispatcher } from './../Main';
import Catcher from './game/Catcher'
import { Tools } from "../Tools"
export default class Root extends FYGE.Container {
GDispatcher
baseOption // 配置(由外传入)
backGround: FYGE.Sprite // 背景
touchArea: FYGE.Graphics // 触摸层
goodsContainer: FYGE.Container // 掉落物的Container
scoreBoard // 记分板
catcher: Catcher // 接收物
countdownTimer // 倒计时
goodsCtrl: GoodsCtrl // 掉落物 数组
stageHeight: number // 舞台高度
timerFunc // 计时器
timerNumer: number // 计时器的倒数数字
score: number = 0
time: number = 0 // 游戏时间 倒计时 时长
constructor(options) {
super()
this.baseOption = options
this.time = options.gameParm.time
this.once(FYGE.Event.ADDED_TO_STAGE, this.onAddToStage, this)
// 全局-游戏开始
GDispatcher.addEventListener('game-start', this.gameStart, this)
// 全局-游戏结束(外部监听)
GDispatcher.dispatchEvent('game-over')
}
initUi () {
this.backGround = new FYGE.Sprite()
this.backGround.x = 0
this.backGround.y = 0
this.backGround.width = 750
this.backGround.height = 1624
// this.backGround.texture = RES.getRes(resCanvasList[this.baseOption.bgTexture].url)
this.addChild(this.backGround)
this.goodsContainer = this.createGoodsContainer()
this.addChild(this.goodsContainer)
this.goodsCtrl = new GoodsCtrl(this, this.baseOption)
this.catcher = new Catcher(this.baseOption.catcher)
this.scoreBoard = this.createScoreBoard(this.baseOption.scoreBoard)
this.countdownTimer = this.createCountdownTimer(this.baseOption.countdownTimer)
this.addChild(this.catcher)
this.addChild(this.scoreBoard)
this.addChild(this.countdownTimer)
this.createTouchRect()
}
/**
* 开始游戏
*/
gameStart () {
this.goodsCtrl.start()
this.score = 0
this.timerNumer = this.time
this.scoreBoard.updateScore(this.score)
this.countdownTimer.updateTime(this.timerNumer)
this.timerFunc = setInterval(() => {
this.countdownTimer.updateTime(--this.timerNumer)
// 时间消耗完毕
if (this.timerNumer <= 0) this.dispatchEvent('game-over')
}, 1000)
}
// 结束游戏
gameOver () {
let score = this.score
this.goodsCtrl.destroy()
clearInterval(this.timerFunc)
GDispatcher.dispatchEvent('game-over', {score: score})
}
// 分数变动
gameScoreChange (data) {
let score = this.score += data.data
this.score = score < 0 ? 0 : score
this.scoreBoard.updateScore(this.score)
// console.log(this.score)
}
// 创建 记分板
createScoreBoard (options) {
let sb = new FYGE.Container()
sb.width = options.width
sb.height = options.height
sb.x = 750 / 2 - options.width / 2
sb.y = options.y
let back = new FYGE.Sprite()
back.width = options.width
back.height = options.height
// back.texture = RES.getRes(resCanvasList[options.texture].url)
sb.addChild(back)
let text = Tools.getText(this.score.toString(), options.fontSize, options.color, FYGE.TEXT_ALIGN.CENTER, options.width)
text.textHeight = options.height
text.verticalAlign = FYGE.VERTICAL_ALIGN.MIDDLE
sb.addChild(text)
sb['updateScore'] = (score) => {
text.text = score.toString()
}
return sb
}
// 创建倒计时
createCountdownTimer (options) {
let cdt = new FYGE.Container()
cdt.width = 100
cdt.height = 100
let text = Tools.getText(this.time.toString() + 's', options.fontSize, options.color, FYGE.TEXT_ALIGN.LEFT)
text.x = options.iconWidth + 10
text.textHeight = options.iconHeight
text.verticalAlign = FYGE.VERTICAL_ALIGN.MIDDLE
cdt.addChild(text)
cdt['updateTime'] = (time) => {
text.text = time.toString() + 's'
}
return cdt
}
// 创建 掉落物的Container
createGoodsContainer () {
let gc = new FYGE.Container()
gc.width = 750
gc.height = 1624
gc.x = 0
gc.y = 0
return gc
}
// 创建 触摸层
createTouchRect () {
this.touchArea = Tools.getRect(750, 1624, 0xffffff, 0)
this.addChild(this.touchArea)
this.touchArea.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, this.onDownStage, this)
this.touchArea.addEventListener(FYGE.MouseEvent.MOUSE_MOVE, this.onMoveStage, this)
this.touchArea.addEventListener(FYGE.MouseEvent.MOUSE_OUT, this.onOutStage, this)
}
onDownStage (e) {
}
onMoveStage (e) {
// console.log(e)
}
onOutStage (e) {
// console.log(e)
}
onAddToStage () {
this.stageHeight = this.stage.viewRect.height
this.y = this.stage.viewRect.height / 2 - 1624 / 2
this.initUi()
}
}
import { RES } from "../../../module/RES"
import resCanvasList from '../../../resCanvasList'
import { Tools } from "../../Tools"
export default class Catecher extends FYGE.Sprite {
constructor (props) {
super()
this.create()
}
create () {
this.x = 0
this.y = 0
this.width = 750
this.height = 180
}
}
\ No newline at end of file
import { RES } from "../../../module/RES"
import resCanvasList from '../../../resCanvasListCsd'
import { Tools } from "../../Tools"
class Goods extends FYGE.Sprite {
private goodsInfo
private type
constructor (texture) {
super()
this.creatGoods(texture)
}
creatGoods (texture) {
if (texture.length > 1) {
let idx = this.sum(1, texture.length)
this.texture = RES.getRes(resCanvasList[texture[idx - 1]].url)
} else this.texture = RES.getRes(resCanvasList[texture[0]].url)
this.visible = false
}
sum = (m: number, n: number) => {
var num = Math.floor(Math.random() * (m - n) + n)
return num
}
}
export default Goods
\ No newline at end of file
import Root from '../../scenes/Root'
import { getStage } from '../../scenes/stage'
import Goods from './Goods'
export default class GoodsCtrl {
private _root: Root
private GoodsArr = [] // 掉落物数组
private baseOption // 基本参数
private gameRunFlag: boolean = false // 是否 游戏中
private speed: number // 初速度
private acceleratedSpeed: number // 加速度
private maxSpeed: number // 最大速度
private createGoodsTime: number = 0 // 本局 添加掉落物 的次数
private goodsNum: number // 需要生成 掉落物的 个数
private maxDistance: number // 掉落物 每帧 最大位移
private minDelayTime: number // 掉落物下落 间隔时间
constructor (root, options) {
this._root = root
this.baseOption = options
this.initResetParam()
}
/**
*  初始化 or 重制 参数
*/
initResetParam () {
const { num, time, speed, acceleratedSpeed, maxSpeed, maxDistance, minDelayTime } = this.baseOption.gameParm
this.goodsNum = num === 'auto' ? time * 1.3 : num
this.gameRunFlag = false
this.createGoodsTime = 0
if (this.GoodsArr.length) this.GoodsArr.forEach((item, index) => { this.removeGood(item, index, true) })
this.GoodsArr = []
this.speed = speed
this.acceleratedSpeed = acceleratedSpeed
this.maxSpeed = maxSpeed
this.maxDistance = maxDistance
this.minDelayTime = minDelayTime
}
/**
* 开始生成掉落物 并 开始凋落
*/
start () {
this.gameRunFlag = true
getStage().addEventListener(
FYGE.Event.ENTER_FRAME,
this.onEnterFrame,
this
)
this.createGoodsPushInArr()
}
/**
* 创建 掉落物 & 填充掉落物数组
*/
createGoodsPushInArr () {
let { goods, gameParm, col } = this.baseOption
// 根据 游戏参数-掉落物 行数,随机生成该掉落物出现在第几行
let countCol = parseInt(Math.round(Math.random() * 100).toString(col)) % col
let countWidth = 750 / col
this.createGoodsTime += 1
this.speed = this.speed > this.maxSpeed ? this.maxSpeed : this.toDecimal(this.speed + this.acceleratedSpeed * this.createGoodsTime)
let time = 2000 - (this.speed * 30) > this.minDelayTime ? 2000 - (this.speed * 30) : this.minDelayTime
setTimeout(() => {
if (this.gameRunFlag) {
let type: string = this.getGoodType(gameParm)
let good = new Goods(this.baseOption.goods[type].texture)
good['type'] = type
good.width = goods[type].width ? goods[type].width : 120
good.height = goods[type].height ? goods[type].height : 80
good.x = ((countCol) * countWidth) + (countWidth / 2 - (good.width / 2))
good.y = 0
good.mouseEnable = false
good.visible = true
this.GoodsArr.push(good)
// this._root.goodsContainer.addChild(good)
}
// 递归执行
if (!this.gameRunFlag) return
else if (this.createGoodsTime >= this.goodsNum) this._root.dispatchEvent('game-over')
else this.createGoodsPushInArr()
}, time)
}
/**
* 掉落物执行凋落
* @param good 掉落物对象
* @param index 掉落物索引值
*/
fall (good, index) {
// console.log(speed)
let { goods, gameParm } = this.baseOption
if (good.y > 1624) {
this.removeGood(good, index)
} else {
if (this.gameRunFlag) {
let y1 = Math.ceil(0.4 * this.speed > this.maxDistance ? this.maxDistance : 0.4 * this.speed)
good.y += y1
// 如果玩家和物品发生碰撞
// if (this.hasHit(this._root.catcher, good)) {
// let gdata = goods[good.type]
// if (!gdata.endGame) {
// if (gdata.hitTexture) this._root.dispatchEvent('game-catcher-hitTexture', gdata)
// this._root.dispatchEvent('game-score-change', gdata.score)
// } else {
// if (gdata.hitTexture) this._root.dispatchEvent('game-catcher-hitTexture', gdata)
// this._root.dispatchEvent('game-over')
// }
// this.removeGood(good, index)
// }
}
}
}
/**
* 移除掉落物
* @param good 掉落物对象
* @param index 掉落物索引值
*/
removeGood (good, index, destroy = false) {
// console.log('remove ', good, index)
// this._root.goodsContainer.removeChild(good)
if (!destroy) this.GoodsArr.splice(index, 1)
}
onEnterFrame () {
if (this.GoodsArr && this.GoodsArr.length) {
if (this.gameRunFlag) this.GoodsArr.forEach((item, index) => { this.fall(item, index) })
else this.GoodsArr.forEach((item, index) => { this.removeGood(item, index) })
}
}
/**
* 游戏结束 调用
*/
destroy() {
// 重置 参数
this.initResetParam()
getStage().removeEventListener(
FYGE.Event.ENTER_FRAME,
this.onEnterFrame,
this
)
}
/**
* 返回 掉落物 类型
* @param gameParm 游戏配置
*/
getGoodType (gameParm) {
let type
let num = this.sum(1, 100)
if (num >= 1 && num <= gameParm.getScorePR) type = 'getScore'
else if (num > gameParm.getScorePR && num <= 100 - gameParm.endGamePR ) type = 'delScore'
else type = 'endGame'
return type
}
/**
* 碰撞检测
* @param a a盒子
* @param b b盒子
*/
private hasHit(a, b) {
if (
Math.abs((a.x + a.width / 2) - (b.x + b.width / 2)) < a.width / 2 + b.width / 2 - 40
&&
Math.abs((a.y + a.height / 2) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2 - 40
) {
return true;
} else {
return false;
}
}
// 取 随机数
sum = (m: number, n: number) => {
var num = Math.floor(Math.random() * (m - n) + n)
return num
}
// 取 一位小数
toDecimal (x) {
let f = parseFloat(x)
if (isNaN(f)) {
console.warn('速度参数叠加出错')
return null
}
f = Math.round(x * 100)/100
return f
}
}
\ No newline at end of file
export const Options = {
// 基本参数
gameParm: {
// 填充 掉落物 数量 auto: time * 1.3, 也可配具体数量: number
num: 'auto',
// 时间
time: 90,
// 加分物品 掉落率 number %
getScorePR: 70,
// 减分物品 掉落率 number %
delScorePR: 20,
// 结束游戏物品(炸弹) 掉落率 number %
endGamePR: 10,
// 初速度
speed: 10,
// 最大速度
maxSpeed: 40,
// 加速度
acceleratedSpeed: 0.02,
// 掉落物 每帧 最大位移
maxDistance: 20,
// 掉落物 下落 最小间隔时间
minDelayTime: 350
},
// 背景
bgTexture: 'd0d0eb62-92dd-4144-be2b-b844788ffcb1',
// 接收物 配置项
catcher: {
texture: '10258c19-4b0d-4393-8419-edb5b5d32071',
width: 330,
height: 242,
x: 210,
y: 1220
},
// 掉落物 行数
col: 4,
// 掉落物 配置项
goods: {
getScore: {
width: 110,
height: 90,
score: 2, // 碰撞后得分 可为负(减分)
endGame: false, // 碰撞后是否结束游戏
hitTexture: '', // 碰撞后 Catcher右上角出现的图 (详细出现位置 可在 Catcher.ts 修改)
hitTWidht: 0, // 碰撞图 宽
hitTHeight: 0, // 碰撞图 高
texture: [ // 掉落物皮肤
'83e0087c-e887-4b59-9533-e4ffedf37ce0',
'da1c89ad-3fc3-4af5-bd64-dc2a0775caa8',
'975325a3-926e-400c-b60a-b21ea0df4bc0',
'436f2033-3466-48ec-b5d6-b191d3306311',
'a00742d4-6bef-48f4-9984-fd096b1f318e'
],
fn: testCb // 自定义回调函数
},
delScore: {
width: 112, height: 84, score: -2, endGame: false,
texture: ['07e13702-d050-4d18-8e28-eef8f22624a2'],
hitTexture: '', hitTWidht: 0, hitTHeight: 0,
fn: testCb
},
endGame: {
width: 110, height: 140, score: 0, endGame: true,
texture: ['ff9d2aba-9dad-4e2d-8170-489cd20169fc'],
hitTexture: '600a2350-65fd-4404-9375-ae3f765cca2f', hitTWidht: 120, hitTHeight: 100,
fn: testCb
}
},
// 记分板 配置项
scoreBoard: {
width: 260,
height: 130,
x: 230, // 暂时没用,居中
y: 220,
texture: 'c9e3a051-c5ff-481f-8f32-8d258eaedd0b',
fontSize: 64,
// fontWeight: 700,
color: '#ff8d05'
},
// 倒计时 配置项
countdownTimer: {
x: 22,
y: 224,
height: 38,
iconTexture: '57f938ef-4751-4cae-a763-1a2f814e0489',
iconWidth: 38,
iconHeight: 38,
fontSize: 30,
// fontWeight: 500,
color: '#27944d'
}
}
function testCb (type) {
console.log('good callback run, type:', type)
}
\ No newline at end of file
.mission-modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 20;
}
.mission-modal__shade {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.75);
}
.mission_wrapper {
width: 750rpx;
height: 1134rpx;
opacity: 1;
bottom: 0;
position: absolute;
}
.mission_wrapper_bg {
width: 750rpx;
height: 1078rpx;
opacity: 1;
top: 55rpx;
position: absolute;
}
.mission_block {
width: 702rpx;
height: 162rpx;
position: absolute;
left: 24rpx;
background: #fff;
border-radius: 10rpx;
}
.mission_block_5 {
top: 948rpx;
}
.mission_block_4 {
top: 763rpx;
}
.mission_block_3 {
top: 578rpx;
}
.mission_block_2 {
top: 393rpx;
}
.mission_block_1 {
top: 208rpx;
}
.mission_icon {
width: 100rpx;
height: 102rpx;
opacity: 1;
left: 37rpx;
top: 30rpx;
position: absolute;
}
.mission_content {
width: 300rpx;
height: 100rpx;
opacity: 1;
left: 168rpx;
top: 50rpx;
position: absolute;
}
.mission_title {
width: 100%;
height: 36rpx;
line-height: 32rpx;
font-size: 28rpx;
color: rgba(51, 51, 51, 1);
}
.mission_describe {
width: 100%;
height: 28rpx;
line-height: 25rpx;
margin-top: 10rpx;
font-size: 22rpx;
color: rgba(51, 51, 51, 1);
}
.mission_describe_hightlight {
color: #e66e64;
font-weight: 500;
}
.mission_btn {
width: 150rpx;
height: 60rpx;
right: 30rpx;
top: 50rpx;
position: absolute;
border-radius: 30rpx;
background: transparent;
background: linear-gradient(to right, #ddc59f, #d6b682 );
}
.mission_btn_active {
background: linear-gradient(to right, #da5d7b, #ffabab );
}
.mission_btn_back {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 1;
}
.mission_btn_text {
width: 100%;
height: 100%;
line-height: 60rpx;
text-align: center;
font-size: 25rpx;
color: #fff;
position: absolute;
z-index: 2;
}
.mission_close_btn {
width: 50rpx;
height: 50rpx;
opacity: 0.5019607843137255;
right: 30rpx;
top: -10prx;
position: absolute;
}
<view class="mission-modal">
<view class="mission-modal__shade modal-animate-fade-in">
<view class="mission_wrapper">
<image class="mission_wrapper_bg" src="{{resList['e0c8c1ea-bfa2-4ac6-a70a-1b21f516af10'].url}}" />
<view class="mission_block mission_block_1">
<view class="ju_xing14"></view>
<image class="mission_icon" src="{{resList['95dc5f5a-d1b2-4994-b1bb-e45ba9e53914'].url}}" />
<view class="mission_content">
<view class="mission_title">浏览制定商品30s</view>
<view class="mission_describe">乐园门票 <text class="mission_describe_hightlight">+1</text></view>
</view>
<view class="mission_btn mission_btn_active">
<!-- <image class="mission_btn_back" src="{{resList['e4530dc3-a3c7-4992-8553-2be55e6407b0'].url}}" /> -->
<text class="mission_btn_text">去浏览</text>
</view>
</view>
<view class="mission_block mission_block_2">
<view class="ju_xing19" />
<image class="mission_icon" src="{{resList['d2f81084-e23b-47f0-a016-eb590b6b7af2'].url}}" />
<view class="mission_content">
<view class="mission_title">观看直播1分钟</view>
<view class="mission_describe">乐园门票 <text class="mission_describe_hightlight">+1</text></view>
</view>
<view class="mission_btn">
<!-- <image class="mission_btn_back" src="{{resList['e4530dc3-a3c7-4992-8553-2be55e6407b0'].url}}" /> -->
<text class="mission_btn_text">去观看</text>
</view>
</view>
<view class="mission_block mission_block_3">
<view class="ju_xing114"></view>
<image class="mission_icon" src="{{resList['56f68e31-8eba-42ce-aafa-0ad9b0bf9f68'].url}}" />
<view class="mission_content">
<view class="mission_title">完成下单订单</view>
<view class="mission_describe">乐园门票 <text class="mission_describe_hightlight">+1</text></view>
</view>
<view class="mission_btn">
<!-- <image class="mission_btn_back" src="{{resList['e4530dc3-a3c7-4992-8553-2be55e6407b0'].url}}" /> -->
<text class="mission_btn_text">去下单</text>
</view>
</view>
<view class="mission_block mission_block_4">
<view class="ju_xing118"></view>
<image class="mission_icon" src="{{resList['2eb24d59-d131-4dfb-9dfe-7b9f61bd4293'].url}}" />
<view class="mission_content">
<view class="mission_title">关注店铺</view>
<view class="mission_describe">乐园门票 <text class="mission_describe_hightlight">+1</text></view>
</view>
<view class="mission_btn">
<!-- <image class="mission_btn_back" src="{{resList['120d6fd3-a52d-4e8e-9064-160f112ff0da'].url}}" /> -->
<text class="mission_btn_text">已关注</text>
</view>
</view>
<view class="mission_block mission_block_5">
<image class="mission_icon" src="{{resList['7b839a18-3277-41aa-9f41-0c3876651bdd'].url}}" />
<view class="mission_content">
<view class="mission_title">加入店铺会员</view>
<view class="mission_describe">乐园门票 <text class="mission_describe_hightlight">+1</text></view>
</view>
<view class="mission_btn">
<!-- <image class="mission_btn_back" src="{{resList['120d6fd3-a52d-4e8e-9064-160f112ff0da'].url}}" /> -->
<text class="mission_btn_text">已关注</text>
</view>
</view>
<image class="mission_close_btn" onTap="onModalClose" src="{{resList['4abc8bb6-5779-49ad-84b4-b4ade4f51fcb'].url}}" />
</view>
</view>
</view>
\ No newline at end of file
import API from '../../api';
const app = getApp();
const { tbcc } = app;
const { commonToast, getAuthUserInfo, navigateToOutside, getSystemInfo } = tbcc.tb;
import resList from '../../resconfig/resList'
Component({
data: {
resList: resList
},
props: {},
didMount() {
// this.setData({})
// this.init()
},
didUpdate(prevProps, prevData) {},
methods: {
onModalClose() {
const { onModalClose } = this.props;
onModalClose && onModalClose();
}
}
});
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
...@@ -53,7 +53,7 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => { ...@@ -53,7 +53,7 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
const requestMock = () => { const requestMock = () => {
const mockUrlPrefix = { const mockUrlPrefix = {
ams: 'https://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=218&uri=', ams: 'https://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=218&uri=',
yapi: 'https://docs.dui88.com/mock/140/' yapi: 'http://localhost:3000/'
}; };
const mockUrl = null; const mockUrl = null;
const requestPrefix = mockUrl || mockUrlPrefix[requestType]; const requestPrefix = mockUrl || mockUrlPrefix[requestType];
......
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