Commit 4d99bc54 authored by Master Q's avatar Master Q

概率处理完善

parent b154567c
......@@ -35,7 +35,7 @@ export default {
progress(),
BannerVariable({
values: {
__ENV__: JSON.stringify(process.env.NODE_ENV || 'pord'),
__ENV__: JSON.stringify(process.env.NODE_ENV || 'production'),
__version__: JSON.stringify(version),
__buildDate__: JSON.stringify(new Date()),
}
......
......@@ -199,7 +199,7 @@ export const ParkourGameConfig: ParkourGameConfigInfer = {
{
uniqueKey: 'shit', // 这个是障碍物
Container: 'obstack2.png',
ProbabilityPort: 1000,
ProbabilityPort: 10,
// anchorX: 130,
// anchorY: 130,
collisionConfig: {
......@@ -210,24 +210,24 @@ export const ParkourGameConfig: ParkourGameConfigInfer = {
h: 50
}
},
// {
// uniqueKey: 'protect',
// Container: 'obstack3.png',
// ProbabilityPort: 0,
// // anchorX: 100,
// // anchorY: 100,
// collisionConfig: {
// type: 'rect',
// x: -50,
// y: 0,
// w: 100,
// h: 50
// }
// }
{
uniqueKey: 'protect',
Container: 'obstack3.png',
ProbabilityPort: 10,
// anchorX: 100,
// anchorY: 100,
collisionConfig: {
type: 'rect',
x: -50,
y: 0,
w: 100,
h: 50
}
}
],
CommonConfig: {
speed: 300, // 速度 可以通过GAME_SPEEDUP 修改
CollisionDebug: true, // 碰撞检测 debug
CollisionDebug: __ENV__ === 'production' ? false : true, // 碰撞检测 debug
GamerAxisY: 1100, // 玩家轴Y
GamerIndex: 1, // 当前玩家索引 在哪条道
DetermineXAxis: 50, // 左右滑动判定距离
......
......@@ -102,7 +102,8 @@ export class ConveyorBeltItem extends FYGE.Container {
type ProbabilityItemType = {
value: number
index: number
index: number,
ownValuue: number
}
/**
......@@ -180,12 +181,14 @@ export class ConveyorBelt extends FYGE.Container {
const _ParkourGameEleList = this.ParkourGameEleList
const sumProbability = _ParkourGameEleList.reduce((prev, cur) => prev + cur.ProbabilityPort, 0)
const _ProbabilityList: ProbabilityItemType[] = []
_ParkourGameEleList.reduce((pre, curr, index) => {
_ParkourGameEleList.reduce((pre, curr, index, arr) => {
const tp = curr.ProbabilityPort / sumProbability
_ProbabilityList.push({
value: pre + curr.ProbabilityPort / sumProbability,
index
value: index == arr.length - 1 ? 1 : pre + tp,
index,
ownValuue: tp
})
return pre + curr.ProbabilityPort / sumProbability
return pre + tp
}, 0)
this.ProbabilityList = _ProbabilityList
console.log('ProbabilityList ==== > ', _ProbabilityList)
......@@ -327,9 +330,19 @@ export class ConveyorBelt extends FYGE.Container {
if (this.onJudgeNextObstacle) {
const b = this.onJudgeNextObstacle(ParkourGameEle)
if (!b) {
const skipPortList = portList.filter((item) => {
const skipPortList: ProbabilityItemType[] = portList.filter((item) => {
return item.index !== index
})
.reduce((pre, cur, index, arr) => {
if (randomItem.ownValuue === 1) return []
const cloneCur = {...cur}
const ownValue = cloneCur.ownValuue / (1 - randomItem.ownValuue)
cloneCur.ownValuue = ownValue
cloneCur.value = index == arr.length - 1 ? 1 : ((pre.length == 0 ? 0 : pre[pre.length - 1].value) + cloneCur.ownValuue)
return pre.concat(cloneCur)
}, [])
console.log('skipPortList:', skipPortList, randomItem.ownValuue, randomItem, portList)
// debugger
return this.onGetFinalObstacle(skipPortList)
}
}
......
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