ajout de deux nouveaux outils, le couteau et la truelle #91
This commit is contained in:
44
common/inventory/scripts/items/fork.gd
Normal file
44
common/inventory/scripts/items/fork.gd
Normal file
@@ -0,0 +1,44 @@
|
||||
extends Item
|
||||
class_name Fork
|
||||
|
||||
const USE_INTERVAL = 0.15
|
||||
|
||||
func get_item_name() -> String:
|
||||
return "Fork"
|
||||
|
||||
func get_description() -> String:
|
||||
return "Use it to harvest mature plants."
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/fork.svg")
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 1
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return 50
|
||||
|
||||
func get_usage_object_affected(i : InspectableEntity) -> bool:
|
||||
return i is Plant
|
||||
|
||||
func use_text() -> String:
|
||||
return "Harvest"
|
||||
|
||||
func can_use(_player : Player, zone : Player.ActionZone) -> bool:
|
||||
var areas = zone.get_affected_areas()
|
||||
for area in areas :
|
||||
if area is Plant:
|
||||
return true
|
||||
return false
|
||||
|
||||
func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
for area in zone.get_affected_areas():
|
||||
if area and area is Plant:
|
||||
harvest(area, player)
|
||||
await player.get_tree().create_timer(USE_INTERVAL).timeout
|
||||
|
||||
return true
|
||||
|
||||
func harvest(p : Plant, player: Player):
|
||||
player.play_sfx("harvest")
|
||||
p.harvest()
|
||||
1
common/inventory/scripts/items/fork.gd.uid
Normal file
1
common/inventory/scripts/items/fork.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cg5to3g2bqyks
|
||||
19
common/inventory/scripts/items/knife.gd
Normal file
19
common/inventory/scripts/items/knife.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
extends Fork
|
||||
class_name Knife
|
||||
|
||||
const KNIFE_ZONE_RADIUS = 10
|
||||
|
||||
func get_item_name() -> String:
|
||||
return "Knife"
|
||||
|
||||
func get_description() -> String:
|
||||
return "Use it to harvest mature plants. Do not cost energy."
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 0
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/slice.svg")
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return KNIFE_ZONE_RADIUS
|
||||
1
common/inventory/scripts/items/knife.gd.uid
Normal file
1
common/inventory/scripts/items/knife.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://clyixfqc8rmo
|
||||
@@ -1,8 +1,7 @@
|
||||
extends Item
|
||||
extends Fork
|
||||
class_name Shovel
|
||||
|
||||
const USE_INTERVAL = 0.15
|
||||
const SHOVEL_ZONE_RADIUS = 30
|
||||
const SHOVEL_ZONE_RADIUS = 50
|
||||
|
||||
func get_item_name() -> String:
|
||||
return "Shovel"
|
||||
@@ -13,9 +12,6 @@ func get_description() -> String:
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/shovel.svg")
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 1
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return SHOVEL_ZONE_RADIUS
|
||||
|
||||
@@ -33,20 +29,16 @@ func can_use(_player : Player, zone : Player.ActionZone) -> bool:
|
||||
return false
|
||||
|
||||
func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
dig(
|
||||
zone.get_affected_areas(),
|
||||
player
|
||||
)
|
||||
for area in zone.get_affected_areas():
|
||||
if area and area is Plant:
|
||||
harvest(area, player)
|
||||
await player.get_tree().create_timer(USE_INTERVAL).timeout
|
||||
if area and area is UndergroundLoot:
|
||||
dig(area, player)
|
||||
await player.get_tree().create_timer(USE_INTERVAL).timeout
|
||||
|
||||
return true
|
||||
|
||||
func dig(areas: Array[Area2D], player: Player):
|
||||
for area in areas :
|
||||
if area and area is Plant:
|
||||
player.play_sfx("harvest")
|
||||
area.harvest()
|
||||
await player.get_tree().create_timer(USE_INTERVAL).timeout
|
||||
if area and area is UndergroundLoot:
|
||||
player.play_sfx("dig")
|
||||
area.dig()
|
||||
await player.get_tree().create_timer(USE_INTERVAL).timeout
|
||||
func dig(u: UndergroundLoot, player: Player):
|
||||
player.play_sfx("dig")
|
||||
u.dig()
|
||||
21
common/inventory/scripts/items/trowel.gd
Normal file
21
common/inventory/scripts/items/trowel.gd
Normal file
@@ -0,0 +1,21 @@
|
||||
extends Fork
|
||||
class_name Trowel
|
||||
|
||||
const TROWEL_ZONE_RADIUS = 50
|
||||
|
||||
func get_item_name() -> String:
|
||||
return "Trowel"
|
||||
|
||||
func get_description() -> String:
|
||||
return "Use it to harvest mature plants, can get a [b]bonus seed[/b] from each plant."
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/trowel.svg")
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return TROWEL_ZONE_RADIUS
|
||||
|
||||
func harvest(p : Plant, player: Player):
|
||||
ProduceSeedsEffect.new(1).effect(p)
|
||||
player.play_sfx("harvest")
|
||||
p.harvest()
|
||||
1
common/inventory/scripts/items/trowel.gd.uid
Normal file
1
common/inventory/scripts/items/trowel.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://gvq5vic12srt
|
||||
Reference in New Issue
Block a user