ajout des actions demandant un clic long et dev des region modifier
This commit is contained in:
BIN
gui/pointer/assets/sounds/action_press_time.wav
Normal file
BIN
gui/pointer/assets/sounds/action_press_time.wav
Normal file
Binary file not shown.
24
gui/pointer/assets/sounds/action_press_time.wav.import
Normal file
24
gui/pointer/assets/sounds/action_press_time.wav.import
Normal file
@@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://bhsew2amu3ydx"
|
||||
path="res://.godot/imported/action_press_time.wav-94144a74154abd8dae9e5128d23613dc.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://gui/pointer/assets/sounds/action_press_time.wav"
|
||||
dest_files=["res://.godot/imported/action_press_time.wav-94144a74154abd8dae9e5128d23613dc.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=2
|
||||
@@ -4,6 +4,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://bspffyprdywgc" path="res://gui/pointer/assets/cursors/pointer.svg" id="2_q4bvb"]
|
||||
[ext_resource type="AudioStream" uid="uid://bym03qp4n6vep" path="res://gui/pointer/assets/sounds/click.wav" id="3_kj0cm"]
|
||||
[ext_resource type="Texture2D" uid="uid://djb52fosgmv4j" path="res://common/icons/left_click.svg" id="3_pshoq"]
|
||||
[ext_resource type="AudioStream" uid="uid://bhsew2amu3ydx" path="res://gui/pointer/assets/sounds/action_press_time.wav" id="3_tof6i"]
|
||||
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="4_b4uwv"]
|
||||
[ext_resource type="Script" uid="uid://c60a1bjcuj4hd" path="res://common/vfx/circle/scripts/circle.gd" id="5_b4uwv"]
|
||||
[ext_resource type="PackedScene" uid="uid://3ss8pvhsackj" path="res://gui/game/card/card_visualiser.tscn" id="6_7j4mj"]
|
||||
@@ -18,6 +19,19 @@
|
||||
[ext_resource type="Texture2D" uid="uid://bt3g5bmar0icf" path="res://common/icons/growth.svg" id="14_efnoc"]
|
||||
[ext_resource type="Texture2D" uid="uid://df0y0s666ui4h" path="res://icon.png" id="15_dtmaq"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_tdpeg"]
|
||||
interpolation_mode = 1
|
||||
offsets = PackedFloat32Array(0.018099548, 0.40723982, 0.7058824, 0.97737557)
|
||||
colors = PackedColorArray(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_tof6i"]
|
||||
gradient = SubResource("Gradient_tdpeg")
|
||||
width = 50
|
||||
height = 50
|
||||
fill = 1
|
||||
fill_from = Vector2(0.5, 0.5)
|
||||
fill_to = Vector2(1, 0.5)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_6eft6"]
|
||||
shader = ExtResource("7_wgcdp")
|
||||
shader_parameter/fov = 90.0
|
||||
@@ -67,10 +81,34 @@ layer = 128
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="ActionProgressPlayer" type="AudioStreamPlayer" parent="InspectorCanvasLayer/Inspector" unique_id=276634191]
|
||||
unique_name_in_owner = true
|
||||
stream = ExtResource("3_tof6i")
|
||||
volume_db = -5.0
|
||||
pitch_scale = 4.0
|
||||
bus = &"Sfx"
|
||||
|
||||
[node name="ActionProgressBar" type="TextureProgressBar" parent="InspectorCanvasLayer/Inspector" unique_id=55992280]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -19.0
|
||||
offset_top = -17.0
|
||||
offset_right = 41.0
|
||||
offset_bottom = 43.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
value = 66.0
|
||||
fill_mode = 4
|
||||
texture_progress = SubResource("GradientTexture2D_tof6i")
|
||||
|
||||
[node name="Container" type="VBoxContainer" parent="InspectorCanvasLayer/Inspector" unique_id=319962477]
|
||||
layout_mode = 0
|
||||
offset_left = 28.0
|
||||
|
||||
@@ -9,7 +9,7 @@ const ZONE_DEACTIVATED_COLOR = Color.REBECCA_PURPLE
|
||||
|
||||
const CARD_VISUALISATION_TIME = 0.3
|
||||
const CARD_UP_PADDING = 50
|
||||
|
||||
|
||||
@export var default_cursor : Texture2D
|
||||
|
||||
var current_inspect : Node = null
|
||||
@@ -22,58 +22,23 @@ var current_selected_item : Item = null
|
||||
var have_energy_to_use_item : bool = false
|
||||
var could_use_item : bool = false
|
||||
var can_use_item : bool = false
|
||||
var press_time := 0.
|
||||
var press_action_done := false
|
||||
|
||||
func _ready():
|
||||
Input.set_custom_mouse_cursor(default_cursor)
|
||||
%Action.visible = false
|
||||
|
||||
func _input(_event):
|
||||
if player:
|
||||
if Input.is_action_just_pressed("move_pointer"):
|
||||
player.try_move(
|
||||
player.get_global_mouse_position()
|
||||
)
|
||||
if Input.is_action_just_pressed("drop"):
|
||||
player.drop_item()
|
||||
|
||||
if Input.is_action_just_pressed("action"):
|
||||
if current_inspect is InventoryGuiItemMouseDetector:
|
||||
GameInfo.game_data.player_data.inventory.set_current_item(inspected.index)
|
||||
elif can_interact:
|
||||
var interactable = current_inspect as Interactable
|
||||
player.try_interact(interactable)
|
||||
elif can_use_item:
|
||||
player.try_use_item(
|
||||
player.data.inventory.get_item(),
|
||||
player.get_global_mouse_position()
|
||||
)
|
||||
|
||||
func _process(delta):
|
||||
if player:
|
||||
process_player_actions(delta)
|
||||
else :
|
||||
%ActionProgressBar.value = 0.
|
||||
|
||||
if current_inspect != inspected:
|
||||
time_last_inspected += delta
|
||||
%Inspector.position = get_viewport().get_mouse_position()
|
||||
|
||||
if player:
|
||||
can_interact = (
|
||||
current_inspect
|
||||
and current_inspect is Interactable
|
||||
and player.can_interact(current_inspect)
|
||||
)
|
||||
|
||||
current_selected_item = player.data.inventory.get_item()
|
||||
|
||||
could_use_item = (
|
||||
current_selected_item
|
||||
and player.preview_could_use_item(current_selected_item)
|
||||
)
|
||||
|
||||
have_energy_to_use_item = (
|
||||
current_selected_item
|
||||
and player.has_energy_to_use_item(current_selected_item)
|
||||
)
|
||||
|
||||
can_use_item = could_use_item and have_energy_to_use_item
|
||||
|
||||
if current_selected_item and SceneManager.actual_scene.scene_id == "REGION":
|
||||
%ActionZone.radius = current_selected_item.usage_zone_radius
|
||||
%ActionZone.color = ZONE_ACTIVATED_COLOR if can_use_item else ZONE_DEACTIVATED_COLOR
|
||||
@@ -86,6 +51,75 @@ func _process(delta):
|
||||
|
||||
update_inspector()
|
||||
|
||||
func process_player_actions(delta : float):
|
||||
can_interact = (
|
||||
current_inspect
|
||||
and current_inspect is Interactable
|
||||
and player.can_interact(current_inspect)
|
||||
)
|
||||
|
||||
current_selected_item = player.data.inventory.get_item()
|
||||
|
||||
could_use_item = (
|
||||
current_selected_item
|
||||
and player.preview_could_use_item(current_selected_item)
|
||||
)
|
||||
|
||||
have_energy_to_use_item = (
|
||||
current_selected_item
|
||||
and player.has_energy_to_use_item(current_selected_item)
|
||||
)
|
||||
|
||||
can_use_item = could_use_item and have_energy_to_use_item
|
||||
|
||||
if Input.is_action_pressed("move_pointer"):
|
||||
player.try_move(
|
||||
player.get_global_mouse_position()
|
||||
)
|
||||
if Input.is_action_just_pressed("drop"):
|
||||
player.drop_item()
|
||||
|
||||
|
||||
if (
|
||||
Input.is_action_pressed("action")
|
||||
):
|
||||
if (
|
||||
can_use_item
|
||||
and current_selected_item.is_action_need_press_time()
|
||||
and not press_action_done
|
||||
and not can_interact
|
||||
and not current_inspect is InventoryGuiItemMouseDetector
|
||||
):
|
||||
press_time += delta
|
||||
%ActionProgressBar.value = press_time/current_selected_item.get_action_press_time() * 100
|
||||
if not %ActionProgressPlayer.playing:
|
||||
%ActionProgressPlayer.play()
|
||||
%ActionProgressPlayer.pitch_scale = 1. / (current_selected_item.get_action_press_time() / %ActionProgressPlayer.stream.get_length())
|
||||
|
||||
if press_time > current_selected_item.get_action_press_time():
|
||||
player.try_use_item(
|
||||
current_selected_item,
|
||||
player.get_global_mouse_position()
|
||||
)
|
||||
press_action_done = true
|
||||
else:
|
||||
press_action_done = false
|
||||
press_time = 0
|
||||
%ActionProgressPlayer.playing = false
|
||||
%ActionProgressBar.value = 0.
|
||||
|
||||
if Input.is_action_just_pressed("action"):
|
||||
if current_inspect is InventoryGuiItemMouseDetector:
|
||||
GameInfo.game_data.player_data.inventory.set_current_item(inspected.index)
|
||||
elif can_interact:
|
||||
var interactable = current_inspect as Interactable
|
||||
player.try_interact(interactable)
|
||||
elif can_use_item and not current_selected_item.is_action_need_press_time():
|
||||
player.try_use_item(
|
||||
current_selected_item,
|
||||
player.get_global_mouse_position()
|
||||
)
|
||||
|
||||
func inspect(node: Node):
|
||||
if current_inspect and current_inspect != node and current_inspect.has_method("inspect"):
|
||||
current_inspect.inspect(false)
|
||||
@@ -131,7 +165,7 @@ func update_card():
|
||||
|
||||
|
||||
func update_inspector():
|
||||
if player:
|
||||
if player and not get_tree().paused:
|
||||
if can_interact and current_inspect and current_inspect is Interactable:
|
||||
%Action.visible = true
|
||||
%ActionText.text = current_inspect.interact_text()
|
||||
|
||||
Reference in New Issue
Block a user