Commit 2b88f7a8 authored by Joker Huang's avatar Joker Huang

1

parent 1db3ea86
...@@ -8,18 +8,20 @@ export default class Game { ...@@ -8,18 +8,20 @@ export default class Game {
beyondFriends = [] // 超越好友配置 beyondFriends = [] // 超越好友配置
targetScene targetScene
meshMatUrl meshMatUrl
gameLevels
addScoreConfig = { addScoreConfig = {
score:1, score:1,
continuouslyScore:1 continuouslyScore:1
} }
constructor(config,targetScene){ constructor(config,targetScene){
let {spFall,beyondFriends,meshMatUrl,addScoreConfig} = config let {spFall,beyondFriends,meshMatUrl,addScoreConfig,gameLevels} = config
this.spFall = spFall this.spFall = spFall
this.beyondFriends = beyondFriends this.beyondFriends = beyondFriends
this.addScoreConfig = addScoreConfig this.addScoreConfig = addScoreConfig
this.targetScene = targetScene this.targetScene = targetScene
this.meshMatUrl = meshMatUrl this.meshMatUrl = meshMatUrl
this.gameLevels = gameLevels
this.initScene() this.initScene()
} }
...@@ -103,7 +105,7 @@ export default class Game { ...@@ -103,7 +105,7 @@ export default class Game {
// skyBox.material=skyMat // skyBox.material=skyMat
this.scene = new BABYLON.Scene(engine); this.scene = new BABYLON.Scene(engine);
// this.scene.ambientColor = BABYLON.Color3.FromHexString("#ffffff"); // this.scene.ambientColor = BABYLON.Color3.FromHexString("#ffffff");
this.scene.clearColor = BABYLON.Color3.FromHexString("#ffffff"); this.scene.clearColor = BABYLON.Color3.FromHexString("#e5efb0");
this.scene.collisionsEnabled = true; this.scene.collisionsEnabled = true;
this.light = new BABYLON.HemisphericLight("dir01", new BABYLON.Vector3(0, 1, 0.3), this.scene); this.light = new BABYLON.HemisphericLight("dir01", new BABYLON.Vector3(0, 1, 0.3), this.scene);
...@@ -332,6 +334,7 @@ export default class Game { ...@@ -332,6 +334,7 @@ export default class Game {
} }
continuouslyScoreFlag = 0 continuouslyScoreFlag = 0
scoreFlag = 0
private onBeforeRender(){ private onBeforeRender(){
let now = Date.now() let now = Date.now()
...@@ -392,7 +395,7 @@ export default class Game { ...@@ -392,7 +395,7 @@ export default class Game {
let addScore = 1 let addScore = 1
if(this.continuouslyScoreFlag>0){ if(this.continuouslyScoreFlag>0){
if(this.continuouslyScoreFlag>3 ){ if(this.continuouslyScoreFlag>3 ){
addScore = 2*this._layerNum addScore = 2 * this._layerNum
}else{ }else{
addScore = this.addScoreConfig.continuouslyScore addScore = this.addScoreConfig.continuouslyScore
} }
...@@ -401,6 +404,19 @@ export default class Game { ...@@ -401,6 +404,19 @@ export default class Game {
} }
this.targetScene.addScore&&this.targetScene.addScore(addScore,this._layerNum); this.targetScene.addScore&&this.targetScene.addScore(addScore,this._layerNum);
this._score += addScore this._score += addScore
if(this.degree<8){
for(let i=7;i>=1;i++){
if(this._score > this.gameLevels['level'+i].endScore){
// 改变难度
this.handleTips(tipsType.levelChange)
break
}
}
}
if(this._score - this.scoreFlag > 200){
this.handleTips(tipsType.during200)
this.scoreFlag = this._score
}
this.continuouslyScoreFlag++ this.continuouslyScoreFlag++
if (this.beyondFriends.length > 0) { if (this.beyondFriends.length > 0) {
for (let i = this.beyondFriends.length - 1; i >= 0; i--) { for (let i = this.beyondFriends.length - 1; i >= 0; i--) {
...@@ -502,7 +518,7 @@ export default class Game { ...@@ -502,7 +518,7 @@ export default class Game {
case tipsType.beyondFriend: case tipsType.beyondFriend:
idx=1 idx=1
break break
case tipsType.degreeChange: case tipsType.levelChange:
idx = 2 idx = 2
break break
case tipsType.during200: case tipsType.during200:
......
export enum tipsType{ export enum tipsType{
"beyondFriend", "beyondFriend",
"degreeChange", "levelChange",
"during200", "during200",
"pickRocket", "pickRocket",
"bigScore" "bigScore"
......
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