var area = {0:0,1:1,2:2,3:3,4:4,5:5};
var jessonArea = {0:30,1:20,2:0,3:0,4:0,5:0};
var areaMultiple = {0:0,1:0,2:0,3:0,4:0,5:0};
var randnum1= Math.floor(Math.random() * (6 - 0)) + 0;
var randnum2= Math.floor(Math.random() * (6 - 0)) + 0;
var randnum3= Math.floor(Math.random() * (6 - 0)) + 0;
console.log(randnum1);
console.log(randnum2);
console.log(randnum3);
for(var i = 0;i < 6;i++)
{
var count = 0;
if(randnum1 == i)
count++;
if(randnum2 == i)
count++;
if(randnum3 == i)
count++;
if(count == 1)
{
areaMultiple[i] = 2;
}
else if(count == 2)
{
areaMultiple[i] = 4;
}
else if(count == 3)
{
areaMultiple[i] = 10;
}
}
console.log(JSON.stringify(areaMultiple));
var loseWinScore = 0;
for(var i = 0 ;i < 6;i++)
{
if(jessonArea[i] == 0) continue;
if(areaMultiple[i] > 0)
{
loseWinScore += jessonArea[i] * (areaMultiple[i] -1);
}
else
{
loseWinScore -= jessonArea[i];
}
}
console.log(loseWinScore);
if(this.BodyAnim)
{
if(step == 1){
this.BodyAnim.play('oneStep');
}
else if(step == 2){
this.BodyAnim.play('twoStep');
}
}
for(let i = 1;i < this.roadLength;i++)
{
if(this._roda[i -1 ] == BlockType.BT_NONE)
{
this._rod.push(BlockType.BT_STONE);
}
else{
this._road.push(Math.floor(Math.random()*2));
}
}
for(let j = 0;j < this._road.roadLength;j++){
let block: Node = this.spawnBlockByType(this._road[j]);
if(block)
{
this.node.addChild(block);
block.setPosithion(j,-1.5,0);
}
}
spawnBlockByType(type: BlockType)
{
if(!this.cubePrfb){
return null;
}
let block: Node | null = null;
switch(type){
case BlockType.BT_STONE:
block = instantiate(this.cubePrfb);
break;
}
return block;
}
start(){
this.curState = GameState.GS_INIT;
}
init(){
if(this.startMenu){
this.startMenu.active = true;
}
this.generateRoad();
if(this.playerCtrl){
this.playerCtrl.setInputActive(false);
this.playerCtrl.node.setPosithion(Vec3.ZERO);
}
}
set curState (value: GameState){
switch(value){
case GameState.GS_INIT:
this.init();
break;
case GameState.GS_PLAYINT:
if(this.startMenu){
this.startMenu.active = false;
}
setTImeout(() =>{
if(this.playerCtrl){
this.playerCtrl.setInputActive(true);
}
},0.1);
case GameState.GS_END:
break;
}
}
console