fun: optional growAt, fast tomatoes
|
@ -68,6 +68,9 @@ export class Plant extends decorate(Trait) {
|
|||
growToNextStage: () => {
|
||||
const growthStage = this.entity.growthStage;
|
||||
const stageSpec = this.params.stageSpecs[growthStage];
|
||||
if (!('growAt' in stageSpec)) {
|
||||
return;
|
||||
}
|
||||
this.growthElapsed = stageSpec.growAt;
|
||||
this.entity.growthStage = growthStage + 1;
|
||||
},
|
||||
|
@ -81,8 +84,10 @@ export class Plant extends decorate(Trait) {
|
|||
const stageSpec = this.params.stageSpecs[growthStage];
|
||||
// TODO variance
|
||||
this.growthElapsed += elapsed;
|
||||
if (this.growthElapsed >= stageSpec.growAt) {
|
||||
this.entity.growthStage = growthStage + 1;
|
||||
if ('growAt' in stageSpec) {
|
||||
if (this.growthElapsed >= stageSpec.growAt) {
|
||||
this.entity.growthStage = growthStage + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 187 B |
Before Width: | Height: | Size: 241 B After Width: | Height: | Size: 197 B |
Before Width: | Height: | Size: 313 B After Width: | Height: | Size: 367 B |
Before Width: | Height: | Size: 296 B After Width: | Height: | Size: 384 B |
|
@ -20,22 +20,22 @@ export function tomatoPlantJSON() {
|
|||
uri: '/tomato-stage-0.png',
|
||||
},
|
||||
'stage-1': {
|
||||
offset: [0, 0],
|
||||
offset: [0, 3],
|
||||
size: [16, 16],
|
||||
uri: '/tomato-stage-1.png',
|
||||
},
|
||||
'stage-2': {
|
||||
offset: [0, 0],
|
||||
offset: [0, 3],
|
||||
size: [16, 16],
|
||||
uri: '/tomato-stage-2.png',
|
||||
},
|
||||
'stage-3': {
|
||||
offset: [0, 0],
|
||||
offset: [0, 3],
|
||||
size: [16, 16],
|
||||
uri: '/tomato-stage-3.png',
|
||||
},
|
||||
'stage-4': {
|
||||
offset: [0, 0],
|
||||
offset: [0, 3],
|
||||
size: [16, 16],
|
||||
uri: '/tomato-stage-4.png',
|
||||
},
|
||||
|
@ -46,23 +46,22 @@ export function tomatoPlantJSON() {
|
|||
params: {
|
||||
stageSpecs: {
|
||||
0: {
|
||||
growAt: 20,
|
||||
growAt: 2,
|
||||
image: 'initial',
|
||||
},
|
||||
1: {
|
||||
growAt: 40,
|
||||
growAt: 4,
|
||||
image: 'stage-1',
|
||||
},
|
||||
2: {
|
||||
growAt: 60,
|
||||
growAt: 6,
|
||||
image: 'stage-2',
|
||||
},
|
||||
3: {
|
||||
growAt: 80,
|
||||
growAt: 8,
|
||||
image: 'stage-3',
|
||||
},
|
||||
4: {
|
||||
growAt: 99999999,
|
||||
image: 'stage-4',
|
||||
},
|
||||
}
|
||||
|
|