#57 rework des inputs et actions
This commit is contained in:
@@ -13,23 +13,15 @@ class_name Seed
|
||||
func _init(_plant_type : PlantType = null):
|
||||
plant_type = _plant_type
|
||||
|
||||
func generate_action_area(player : Player) -> ActionArea:
|
||||
return ActionArea.new(
|
||||
player,
|
||||
10
|
||||
)
|
||||
|
||||
func use_text(_player) -> String:
|
||||
func use_text() -> String:
|
||||
return "Plant " + plant_type.name
|
||||
|
||||
func is_one_time_use():
|
||||
return true
|
||||
|
||||
func can_use(player : Player) -> bool:
|
||||
return not player.planet.is_there_contamination(player.action_area.global_position)
|
||||
func can_use(player : Player, zone : Area2D) -> bool:
|
||||
return not player.planet.is_there_contamination(zone.global_position)
|
||||
|
||||
func use(player : Player) -> bool:
|
||||
if not can_use(player):
|
||||
return false
|
||||
func use(player : Player, zone : Area2D) -> bool:
|
||||
player.play_sfx("dig")
|
||||
return player.planet.plant(plant_type, player.action_area.global_position)
|
||||
return player.planet.plant(plant_type, zone.global_position)
|
||||
|
||||
@@ -1,35 +1,32 @@
|
||||
extends ToolItem
|
||||
extends Item
|
||||
class_name Shovel
|
||||
|
||||
const USE_INTERVAL = 0.15
|
||||
|
||||
func use_text(_player) -> String:
|
||||
return "Dig"
|
||||
func use_text() -> String:
|
||||
return "Dig"
|
||||
|
||||
func can_use(player : Player) -> bool:
|
||||
var areas = player.action_area.get_overlapping_areas()
|
||||
for area in areas :
|
||||
if area is Plant or area is UndergroundLoot:
|
||||
return true
|
||||
return false
|
||||
func can_use(_player : Player, zone : Area2D) -> bool:
|
||||
var areas = zone.get_overlapping_areas()
|
||||
for area in areas :
|
||||
if area is Plant or area is UndergroundLoot:
|
||||
return true
|
||||
return false
|
||||
|
||||
func use(player : Player) -> bool:
|
||||
if not can_use(player):
|
||||
return false
|
||||
|
||||
dig(
|
||||
player.action_area.get_overlapping_areas(),
|
||||
player
|
||||
)
|
||||
|
||||
return true
|
||||
func use(player : Player, zone : Area2D) -> bool:
|
||||
dig(
|
||||
zone.get_overlapping_areas(),
|
||||
player
|
||||
)
|
||||
|
||||
return true
|
||||
|
||||
func dig(areas: Array[Area2D], player: Player):
|
||||
for area in areas :
|
||||
if area is Plant:
|
||||
player.play_sfx("harvest")
|
||||
area.harvest()
|
||||
if area is UndergroundLoot:
|
||||
player.play_sfx("dig")
|
||||
area.dig()
|
||||
await player.get_tree().create_timer(USE_INTERVAL).timeout
|
||||
for area in areas :
|
||||
if area is Plant:
|
||||
player.play_sfx("harvest")
|
||||
area.harvest()
|
||||
if area is UndergroundLoot:
|
||||
player.play_sfx("dig")
|
||||
area.dig()
|
||||
await player.get_tree().create_timer(USE_INTERVAL).timeout
|
||||
|
||||
Reference in New Issue
Block a user