Dev Démo 1.2
* les plantes se placent désormais sur une grille * ajouts de curseurs relatifs à l'item * ajout de settings sur la sensibilité à la souris * ajout d'un défi en fin de run
This commit is contained in:
@@ -186,6 +186,7 @@ texture = ExtResource("3_rbgiq")
|
||||
|
||||
[node name="LifeTimeSprite" type="Sprite2D" parent="." unique_id=799762981]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
scale = Vector2(0.26000002, 0.26000005)
|
||||
texture = SubResource("ViewportTexture_rbgiq")
|
||||
|
||||
|
||||
@@ -5,26 +5,26 @@ var radius : int
|
||||
var sprite : Circle
|
||||
var collision_shape : CollisionShape2D
|
||||
var show_influence : bool = false :
|
||||
set(v):
|
||||
show_influence = v
|
||||
if sprite:
|
||||
sprite.visible = v
|
||||
set(v):
|
||||
show_influence = v
|
||||
if sprite:
|
||||
sprite.visible = v
|
||||
|
||||
func _init(_radius = 100):
|
||||
radius = _radius
|
||||
radius = _radius
|
||||
|
||||
func _ready():
|
||||
sprite = Circle.new()
|
||||
# sprite.z_index = 100
|
||||
sprite.radius = radius
|
||||
sprite.fill = false
|
||||
sprite.width = 1
|
||||
sprite.opacity = 0.5
|
||||
sprite.visible = show_influence
|
||||
add_child(sprite)
|
||||
sprite = Circle.new()
|
||||
# sprite.z_index = 100
|
||||
sprite.radius = radius
|
||||
sprite.fill = false
|
||||
sprite.width = 1
|
||||
sprite.opacity = 0.5
|
||||
sprite.visible = show_influence
|
||||
add_child(sprite)
|
||||
|
||||
collision_shape = CollisionShape2D.new()
|
||||
var circle_shape : CircleShape2D = CircleShape2D.new()
|
||||
circle_shape.radius = radius
|
||||
collision_shape.shape = circle_shape
|
||||
add_child(collision_shape)
|
||||
collision_shape = CollisionShape2D.new()
|
||||
var circle_shape : CircleShape2D = CircleShape2D.new()
|
||||
circle_shape.radius = radius
|
||||
collision_shape.shape = circle_shape
|
||||
add_child(collision_shape)
|
||||
@@ -56,8 +56,8 @@ func start_harvest_animation():
|
||||
|
||||
func set_display_lifetime_sprite(d := display_lifetime_sprite):
|
||||
display_lifetime_sprite = d
|
||||
if is_node_ready():
|
||||
%LifeTimeSprite.visible = d
|
||||
# if is_node_ready():
|
||||
# %LifeTimeSprite.visible = d
|
||||
|
||||
func set_sprite_modulate(c := sprite_modulate):
|
||||
sprite_modulate = c
|
||||
|
||||
@@ -14,6 +14,7 @@ enum ItemType {TOOL_ITEM, CONSUMABLE_ITEM}
|
||||
@export var type: ItemType : get = get_item_type
|
||||
@export var description: String : get = get_description
|
||||
var icon: Texture2D : get = get_icon
|
||||
var pointer: Texture2D : get = get_pointer
|
||||
@export var usage_zone_radius: int = 5 : get = get_usage_zone_radius
|
||||
@export var energy_usage : int = 1 : get = get_energy_used
|
||||
|
||||
@@ -29,6 +30,9 @@ func get_description() -> String:
|
||||
func get_icon() -> Texture2D:
|
||||
return icon
|
||||
|
||||
func get_pointer() -> Texture2D:
|
||||
return null
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return energy_usage
|
||||
|
||||
@@ -50,6 +54,9 @@ func get_usage_object_affected(_i : Area2D) -> bool:
|
||||
func is_one_time_use():
|
||||
return false
|
||||
|
||||
func snap_usage_to_grid():
|
||||
return false
|
||||
|
||||
func can_use(_player : Player, _zone: Player.ActionZone) -> bool:
|
||||
return false
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ func get_description() -> String:
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/broadcast.svg")
|
||||
|
||||
func get_pointer() -> Texture2D:
|
||||
return preload("res://gui/pointer/assets/cursors/pointer-signal.svg")
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 0
|
||||
|
||||
|
||||
@@ -12,9 +12,15 @@ func get_description() -> String:
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/fork.svg")
|
||||
|
||||
func get_pointer() -> Texture2D:
|
||||
return preload("res://gui/pointer/assets/cursors/pointer-fork.svg")
|
||||
|
||||
func get_item_type() -> ItemType:
|
||||
return Item.ItemType.TOOL_ITEM
|
||||
|
||||
func snap_usage_to_grid():
|
||||
return true
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 1
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ func get_description() -> String:
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/pick.svg")
|
||||
|
||||
func get_pointer() -> Texture2D:
|
||||
return preload("res://gui/pointer/assets/cursors/pointer-dig.svg")
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 1
|
||||
|
||||
|
||||
@@ -65,15 +65,21 @@ func get_icon() -> Texture2D:
|
||||
stored_icon = PlantTextureBuilder.build_seed_texture(plant_name.hash())
|
||||
return stored_icon
|
||||
|
||||
func get_pointer() -> Texture2D:
|
||||
return preload("res://gui/pointer/assets/cursors/pointer-seed.svg")
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 1
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return 50
|
||||
return 10
|
||||
|
||||
func get_usage_object_affected(i : Area2D) -> bool:
|
||||
return i is PlantSprite
|
||||
|
||||
func snap_usage_to_grid():
|
||||
return true
|
||||
|
||||
func use_text() -> String:
|
||||
return tr("PLANT_%s") % plant_name
|
||||
|
||||
@@ -88,13 +94,12 @@ func can_use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
|
||||
var is_there_a_plant_here = false
|
||||
for area in zone.get_affected_areas():
|
||||
if area is PlantSprite:
|
||||
if area is PlantSprite or area is TruckRecharge:
|
||||
is_there_a_plant_here = true
|
||||
|
||||
var plant_tiles = Math.get_tiles_in_circle(
|
||||
var plant_tiles = [Math.get_tile_from_pos(
|
||||
zone.get_global_position(),
|
||||
20
|
||||
)
|
||||
)] as Array[Vector2i]
|
||||
|
||||
return (
|
||||
not is_there_a_plant_here
|
||||
|
||||
@@ -13,6 +13,9 @@ func get_description() -> String:
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/rocket.svg")
|
||||
|
||||
func get_pointer() -> Texture2D:
|
||||
return preload("res://gui/pointer/assets/cursors/pointer-ship.svg")
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 0
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@ signal player_updated(player: Player)
|
||||
signal upgraded
|
||||
|
||||
var terrain : Terrain
|
||||
var region : Region :
|
||||
get(): return terrain if terrain is Region else null
|
||||
@export var region : Region
|
||||
|
||||
var data : PlayerData
|
||||
var last_action_area_movement_timer : float = 100.
|
||||
@@ -91,11 +90,16 @@ func _process(delta):
|
||||
instruction.do(self)
|
||||
instruction = null
|
||||
|
||||
|
||||
if instruction and instruction.need_movement:
|
||||
if input_direction.length() != 0:
|
||||
instruction = null
|
||||
input_direction = calculate_direction_instruction_direction()
|
||||
|
||||
if instruction == null and action_zone:
|
||||
action_zone.destroy()
|
||||
action_zone = null
|
||||
|
||||
velocity = input_direction * SPEED
|
||||
turn_animate(input_direction)
|
||||
|
||||
@@ -286,8 +290,8 @@ func recharge(amount : int = data.max_energy):
|
||||
func full_recharge():
|
||||
data.energy = max(data.energy, data.max_energy)
|
||||
|
||||
func generate_action_zone(item : Item) -> ActionZone:
|
||||
var zone = ActionZone.new(item)
|
||||
func generate_action_zone(item : Item, preview = true) -> ActionZone:
|
||||
var zone = ActionZone.new(item, region.plant_grid, preview)
|
||||
|
||||
if not get_parent().is_node_ready():
|
||||
await get_parent().ready
|
||||
@@ -303,12 +307,12 @@ func setup_preview_zone(item : Item):
|
||||
preview_zone = null
|
||||
|
||||
if item:
|
||||
preview_zone = await generate_action_zone(item)
|
||||
preview_zone = await generate_action_zone(item, true)
|
||||
|
||||
func setup_action_zone(zone_position : Vector2, item: Item) -> ActionZone:
|
||||
if action_zone:
|
||||
action_zone.destroy()
|
||||
action_zone = await generate_action_zone(item)
|
||||
action_zone = await generate_action_zone(item, false)
|
||||
action_zone.move_to_position(zone_position)
|
||||
last_action_area_movement_timer = 0.
|
||||
return action_zone
|
||||
@@ -316,6 +320,7 @@ func setup_action_zone(zone_position : Vector2, item: Item) -> ActionZone:
|
||||
func move_preview_zone(zone_position : Vector2):
|
||||
if preview_zone:
|
||||
preview_zone.move_to_position(zone_position)
|
||||
preview_zone.update_preview(self)
|
||||
|
||||
class Instruction:
|
||||
|
||||
@@ -414,12 +419,21 @@ class InteractableInstruction extends Instruction:
|
||||
interactable.interact(player)
|
||||
|
||||
class ActionZone:
|
||||
const ZONE_ACTIVATED_COLOR = Color("#96B3DB")
|
||||
const ZONE_DEACTIVATED_COLOR = Color("#FF006E")
|
||||
const ZONE_OPACITY = 0.6
|
||||
|
||||
var item : Item = null
|
||||
var area : Area2D = Area2D.new()
|
||||
var affected_areas : Array[Area2D]= []
|
||||
var plant_grid : PlantGrid
|
||||
var circle : Circle
|
||||
var preview: bool
|
||||
|
||||
func _init(_i : Item):
|
||||
func _init(_i : Item, _grid : PlantGrid, _preview = false):
|
||||
item = _i
|
||||
plant_grid = _grid
|
||||
preview = _preview
|
||||
if item and item.get_usage_zone_radius() > 0:
|
||||
area = Area2D.new()
|
||||
var collision_shape = CollisionShape2D.new()
|
||||
@@ -429,11 +443,25 @@ class ActionZone:
|
||||
collision_shape.shape = circle_shape
|
||||
area.add_child(collision_shape)
|
||||
|
||||
circle = Circle.new(
|
||||
item.get_usage_zone_radius(),
|
||||
)
|
||||
circle.fill = preview
|
||||
circle.modulate.a = ZONE_OPACITY
|
||||
area.add_child(circle)
|
||||
circle.z_index = 100
|
||||
|
||||
func clear_preview_on_affected_area():
|
||||
for a in affected_areas:
|
||||
if a:
|
||||
a.affect_preview(false)
|
||||
|
||||
func update_preview(player : Player):
|
||||
update_preview_on_affected_area()
|
||||
if circle:
|
||||
circle.color = ZONE_ACTIVATED_COLOR if item.can_use(player, self) else ZONE_DEACTIVATED_COLOR
|
||||
|
||||
|
||||
func update_preview_on_affected_area():
|
||||
var detected_areas = get_affected_areas()
|
||||
clear_preview_on_affected_area()
|
||||
@@ -457,9 +485,13 @@ class ActionZone:
|
||||
return Vector2.ZERO if area == null else area.global_position
|
||||
|
||||
func move_to_position(pos : Vector2):
|
||||
if area:
|
||||
update_preview_on_affected_area()
|
||||
area.global_position = pos
|
||||
if area and plant_grid:
|
||||
if item and item.snap_usage_to_grid():
|
||||
area.global_position = plant_grid.get_point_for_tile(
|
||||
Math.get_tile_from_pos(pos)
|
||||
)
|
||||
else:
|
||||
area.global_position = pos
|
||||
|
||||
func get_tiles() -> Array[Vector2i]:
|
||||
return Math.get_tiles_in_circle(
|
||||
|
||||
@@ -39,10 +39,11 @@ func _ready():
|
||||
)
|
||||
|
||||
func _input(event):
|
||||
var sensivity = GameInfo.settings_data.mouse_sensivity / 100
|
||||
if controlling_player:
|
||||
if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
rotate_y(-event.relative.x * MOUSE_SENSIVITY)
|
||||
%Camera3D.rotate_x(-event.relative.y * MOUSE_SENSIVITY)
|
||||
rotate_y(-event.relative.x * sensivity)
|
||||
%Camera3D.rotate_x(-event.relative.y * sensivity)
|
||||
%Camera3D.rotation.x = clampf($Camera3D.rotation.x, -deg_to_rad(70), deg_to_rad(70))
|
||||
query_mouse = true
|
||||
if event.is_action_pressed("action") and action_hovered and action_hovered.interactable:
|
||||
|
||||
Reference in New Issue
Block a user