Updates to Harvesting
This commit is contained in:
parent
2e618eec16
commit
b9958f9c43
|
|
@ -315,6 +315,16 @@
|
|||
"name":"forestTree",
|
||||
"type":"int",
|
||||
"value":40
|
||||
},
|
||||
{
|
||||
"name":"glass",
|
||||
"type":"int",
|
||||
"value":2
|
||||
},
|
||||
{
|
||||
"name":"rock",
|
||||
"type":"int",
|
||||
"value":4
|
||||
}]
|
||||
},
|
||||
{
|
||||
|
|
@ -324,6 +334,16 @@
|
|||
"name":"forestTree",
|
||||
"type":"int",
|
||||
"value":2
|
||||
},
|
||||
{
|
||||
"name":"glass",
|
||||
"type":"int",
|
||||
"value":2
|
||||
},
|
||||
{
|
||||
"name":"rock",
|
||||
"type":"int",
|
||||
"value":4
|
||||
}]
|
||||
},
|
||||
{
|
||||
|
|
@ -334,6 +354,11 @@
|
|||
"type":"int",
|
||||
"value":5
|
||||
},
|
||||
{
|
||||
"name":"glass",
|
||||
"type":"int",
|
||||
"value":2
|
||||
},
|
||||
{
|
||||
"name":"palmTree",
|
||||
"type":"int",
|
||||
|
|
@ -346,7 +371,21 @@
|
|||
{
|
||||
"name":"forestTree",
|
||||
"type":"int",
|
||||
"value":0
|
||||
"value":6
|
||||
},
|
||||
{
|
||||
"name":"glass",
|
||||
"type":"int",
|
||||
"value":3
|
||||
}]
|
||||
},
|
||||
{
|
||||
"id":5,
|
||||
"properties":[
|
||||
{
|
||||
"name":"glass",
|
||||
"type":"int",
|
||||
"value":3
|
||||
}]
|
||||
},
|
||||
{
|
||||
|
|
@ -366,10 +405,20 @@
|
|||
"type":"int",
|
||||
"value":15
|
||||
},
|
||||
{
|
||||
"name":"glass",
|
||||
"type":"int",
|
||||
"value":2
|
||||
},
|
||||
{
|
||||
"name":"palmTree",
|
||||
"type":"int",
|
||||
"value":2
|
||||
},
|
||||
{
|
||||
"name":"rock",
|
||||
"type":"int",
|
||||
"value":5
|
||||
}]
|
||||
},
|
||||
{
|
||||
|
|
@ -378,31 +427,51 @@
|
|||
{
|
||||
"name":"fish",
|
||||
"type":"int",
|
||||
"value":6
|
||||
"value":3
|
||||
},
|
||||
{
|
||||
"name":"glass",
|
||||
"type":"int",
|
||||
"value":2
|
||||
},
|
||||
{
|
||||
"name":"palmTree",
|
||||
"type":"int",
|
||||
"value":15
|
||||
"value":10
|
||||
},
|
||||
{
|
||||
"name":"rock",
|
||||
"type":"int",
|
||||
"value":6
|
||||
"value":1
|
||||
},
|
||||
{
|
||||
"name":"seaShell",
|
||||
"type":"int",
|
||||
"value":8
|
||||
"value":5
|
||||
}]
|
||||
},
|
||||
{
|
||||
"id":11,
|
||||
"properties":[
|
||||
{
|
||||
"name":"fish",
|
||||
"type":"int",
|
||||
"value":2
|
||||
},
|
||||
{
|
||||
"name":"glass",
|
||||
"type":"int",
|
||||
"value":5
|
||||
},
|
||||
{
|
||||
"name":"palmTree",
|
||||
"type":"int",
|
||||
"value":10
|
||||
"value":8
|
||||
},
|
||||
{
|
||||
"name":"rock",
|
||||
"type":"int",
|
||||
"value":3
|
||||
}]
|
||||
},
|
||||
{
|
||||
|
|
@ -420,6 +489,16 @@
|
|||
{
|
||||
"name":"boulder",
|
||||
"type":"int",
|
||||
"value":12
|
||||
},
|
||||
{
|
||||
"name":"glass",
|
||||
"type":"int",
|
||||
"value":2
|
||||
},
|
||||
{
|
||||
"name":"rock",
|
||||
"type":"int",
|
||||
"value":8
|
||||
}]
|
||||
},
|
||||
|
|
@ -438,12 +517,17 @@
|
|||
{
|
||||
"name":"boulder",
|
||||
"type":"int",
|
||||
"value":15
|
||||
"value":10
|
||||
},
|
||||
{
|
||||
"name":"forestTree",
|
||||
"type":"int",
|
||||
"value":2
|
||||
},
|
||||
{
|
||||
"name":"rock",
|
||||
"type":"int",
|
||||
"value":7
|
||||
}]
|
||||
}],
|
||||
"tilewidth":100
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 195 KiB After Width: | Height: | Size: 218 KiB |
|
|
@ -13,22 +13,33 @@
|
|||
<tile id="1">
|
||||
<properties>
|
||||
<property name="forestTree" type="int" value="40"/>
|
||||
<property name="glass" type="int" value="2"/>
|
||||
<property name="rock" type="int" value="4"/>
|
||||
</properties>
|
||||
</tile>
|
||||
<tile id="2">
|
||||
<properties>
|
||||
<property name="forestTree" type="int" value="2"/>
|
||||
<property name="glass" type="int" value="2"/>
|
||||
<property name="rock" type="int" value="4"/>
|
||||
</properties>
|
||||
</tile>
|
||||
<tile id="3">
|
||||
<properties>
|
||||
<property name="forestTree" type="int" value="5"/>
|
||||
<property name="glass" type="int" value="2"/>
|
||||
<property name="palmTree" type="int" value="2"/>
|
||||
</properties>
|
||||
</tile>
|
||||
<tile id="4">
|
||||
<properties>
|
||||
<property name="forestTree" type="int" value="0"/>
|
||||
<property name="forestTree" type="int" value="6"/>
|
||||
<property name="glass" type="int" value="3"/>
|
||||
</properties>
|
||||
</tile>
|
||||
<tile id="5">
|
||||
<properties>
|
||||
<property name="glass" type="int" value="3"/>
|
||||
</properties>
|
||||
</tile>
|
||||
<tile id="7">
|
||||
|
|
@ -39,20 +50,26 @@
|
|||
<tile id="8">
|
||||
<properties>
|
||||
<property name="forestTree" type="int" value="15"/>
|
||||
<property name="glass" type="int" value="2"/>
|
||||
<property name="palmTree" type="int" value="2"/>
|
||||
<property name="rock" type="int" value="5"/>
|
||||
</properties>
|
||||
</tile>
|
||||
<tile id="10">
|
||||
<properties>
|
||||
<property name="fish" type="int" value="6"/>
|
||||
<property name="palmTree" type="int" value="15"/>
|
||||
<property name="rock" type="int" value="6"/>
|
||||
<property name="seaShell" type="int" value="8"/>
|
||||
<property name="fish" type="int" value="3"/>
|
||||
<property name="glass" type="int" value="2"/>
|
||||
<property name="palmTree" type="int" value="10"/>
|
||||
<property name="rock" type="int" value="1"/>
|
||||
<property name="seaShell" type="int" value="5"/>
|
||||
</properties>
|
||||
</tile>
|
||||
<tile id="11">
|
||||
<properties>
|
||||
<property name="palmTree" type="int" value="10"/>
|
||||
<property name="fish" type="int" value="2"/>
|
||||
<property name="glass" type="int" value="5"/>
|
||||
<property name="palmTree" type="int" value="8"/>
|
||||
<property name="rock" type="int" value="3"/>
|
||||
</properties>
|
||||
</tile>
|
||||
<tile id="12">
|
||||
|
|
@ -62,7 +79,9 @@
|
|||
</tile>
|
||||
<tile id="13">
|
||||
<properties>
|
||||
<property name="boulder" type="int" value="8"/>
|
||||
<property name="boulder" type="int" value="12"/>
|
||||
<property name="glass" type="int" value="2"/>
|
||||
<property name="rock" type="int" value="8"/>
|
||||
</properties>
|
||||
</tile>
|
||||
<tile id="14">
|
||||
|
|
@ -72,8 +91,9 @@
|
|||
</tile>
|
||||
<tile id="16">
|
||||
<properties>
|
||||
<property name="boulder" type="int" value="15"/>
|
||||
<property name="boulder" type="int" value="10"/>
|
||||
<property name="forestTree" type="int" value="2"/>
|
||||
<property name="rock" type="int" value="7"/>
|
||||
</properties>
|
||||
</tile>
|
||||
</tileset>
|
||||
|
|
|
|||
BIN
raw/player.psd
BIN
raw/player.psd
Binary file not shown.
|
|
@ -20,7 +20,7 @@ const config = {
|
|||
},
|
||||
backgroundColor: '#000000',
|
||||
scene: [
|
||||
MenuScene,
|
||||
//MenuScene,
|
||||
// Intro,
|
||||
// Tutorial,
|
||||
Game
|
||||
|
|
|
|||
|
|
@ -68,8 +68,9 @@ export class ObjectManager {
|
|||
health: 200,
|
||||
fullHealth: 200,
|
||||
yield: 'rock',
|
||||
amount: [1,3],
|
||||
doneSprite: null
|
||||
amount: [2,4],
|
||||
doneSprite: null,
|
||||
dropSprite: 21
|
||||
};
|
||||
this.createHealthBar(boulder);
|
||||
} else if (key === 'seaShell' && Phaser.Math.Between(1,300) <= objectType[key]) {
|
||||
|
|
@ -82,7 +83,50 @@ export class ObjectManager {
|
|||
fullHealth: 1,
|
||||
yield: 'seaShell',
|
||||
amount: [1,1],
|
||||
doneSprite: null
|
||||
doneSprite: null,
|
||||
dropSprite: 15
|
||||
};
|
||||
this.createHealthBar(item);
|
||||
} else if (key === 'rock' && Phaser.Math.Between(1,300) <= objectType[key]) {
|
||||
const item = this.scene.physics.add.sprite(x, y, 'objects', 6);
|
||||
this.scene.objects.add(item);
|
||||
item.setImmovable(true);
|
||||
item.props = {
|
||||
type: key,
|
||||
health: 1,
|
||||
fullHealth: 1,
|
||||
yield: 'rock',
|
||||
amount: [1,1],
|
||||
doneSprite: null,
|
||||
dropSprite: 16
|
||||
};
|
||||
this.createHealthBar(item);
|
||||
} else if (key === 'fish' && Phaser.Math.Between(1,300) <= objectType[key]) {
|
||||
const item = this.scene.physics.add.sprite(x, y, 'objects', 7);
|
||||
this.scene.objects.add(item);
|
||||
item.setImmovable(true);
|
||||
item.props = {
|
||||
type: key,
|
||||
health: 1,
|
||||
fullHealth: 1,
|
||||
yield: 'fish',
|
||||
amount: [1,1],
|
||||
doneSprite: null,
|
||||
dropSprite: 17
|
||||
};
|
||||
this.createHealthBar(item);
|
||||
} else if (key === 'glass' && Phaser.Math.Between(1,300) <= objectType[key]) {
|
||||
const item = this.scene.physics.add.sprite(x, y, 'objects', 8);
|
||||
this.scene.objects.add(item);
|
||||
item.setImmovable(true);
|
||||
item.props = {
|
||||
type: key,
|
||||
health: 1,
|
||||
fullHealth: 1,
|
||||
yield: 'seaShell',
|
||||
amount: [1,1],
|
||||
doneSprite: null,
|
||||
dropSprite: 18
|
||||
};
|
||||
this.createHealthBar(item);
|
||||
}
|
||||
|
|
@ -158,15 +202,14 @@ export class ObjectManager {
|
|||
if (player.targetX === object.x && player.targetY === object.y) {
|
||||
switch (object.props.type){
|
||||
case 'palmTree':
|
||||
object.props.health -= dmg;
|
||||
this.scene.sound.play('chop');
|
||||
break;
|
||||
case 'forestTree':
|
||||
object.props.health -= dmg;
|
||||
player.harvest(object.x, object.y, 'axe');
|
||||
this.scene.sound.play('chop');
|
||||
break;
|
||||
default:
|
||||
player.harvest(object.x, object.y, 'hands');
|
||||
}
|
||||
object.props.health -= dmg;
|
||||
this.updateHealthBar(object);
|
||||
if (object.props.health <= 0) {
|
||||
this.destroyObject(object);
|
||||
|
|
@ -195,9 +238,9 @@ export class ObjectManager {
|
|||
} else {
|
||||
sprite = 12;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
sprite = object.props.dropSprite;
|
||||
}
|
||||
const drop = this.scene.physics.add.sprite(object.x-5, object.y-50, 'objects', sprite).setScale(.8);
|
||||
this.scene.tweens.add({
|
||||
|
|
|
|||
|
|
@ -18,6 +18,12 @@ export class Player extends Phaser.GameObjects.Sprite {
|
|||
this.dmgMax = 25;
|
||||
this.inventory = {};
|
||||
this.canMove = true;
|
||||
this.equipt = {
|
||||
tools: {},
|
||||
armor: {},
|
||||
weapons: {}
|
||||
}
|
||||
this.isHarvesting = false;
|
||||
|
||||
// Add input listener for mouse clicks
|
||||
scene.input.on('pointerdown', (pointer) => {
|
||||
|
|
@ -147,6 +153,37 @@ export class Player extends Phaser.GameObjects.Sprite {
|
|||
}
|
||||
}
|
||||
|
||||
// Method to show harvesting activity
|
||||
harvest(x, y, type) {
|
||||
if (this.isHarvesting) return;
|
||||
|
||||
this.isHarvesting = true;
|
||||
if (type === 'axe') {
|
||||
this.harvestTool(44, x, y, 2);
|
||||
}
|
||||
if (type === 'hands') {
|
||||
this.harvestTool(40, x, y, 1);
|
||||
}
|
||||
|
||||
this.scene.time.delayedCall(500, () => {
|
||||
this.isHarvesting = false;
|
||||
});
|
||||
}
|
||||
|
||||
harvestTool(startFrame, x, y, scale) {
|
||||
const tool = this.scene.add.sprite(x, y, 'player', startFrame).setDepth(90).setScale(scale);
|
||||
tool.anims.create({
|
||||
key: 'harvest',
|
||||
frames: this.anims.generateFrameNumbers('player', { start: startFrame, end: startFrame+3 }),
|
||||
frameRate: 8,
|
||||
repeat: -1
|
||||
});
|
||||
tool.anims.play('harvest');
|
||||
this.scene.time.delayedCall(500, () => {
|
||||
tool.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
// Method to stop player movement
|
||||
stop() {
|
||||
this.body.setVelocity(0, 0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue