ajout des particules de roche et changement de l'écran de chargement
This commit is contained in:
3
entities/player/assets/sprites/robot.tres
Normal file
3
entities/player/assets/sprites/robot.tres
Normal file
@@ -0,0 +1,3 @@
|
||||
[gd_resource type="SpriteFrames" format=3 uid="uid://b62q2fakkopmu"]
|
||||
|
||||
[resource]
|
||||
@@ -1,6 +1,7 @@
|
||||
extends Fork
|
||||
class_name Shovel
|
||||
|
||||
const DIG_PARTICLES := preload("res://entities/player/inventory/scripts/items/utils/dig_particles.tscn")
|
||||
const SHOVEL_ZONE_RADIUS = 50
|
||||
|
||||
func get_item_name() -> String:
|
||||
@@ -33,7 +34,7 @@ func can_use(_player : Player, zone : Player.ActionZone) -> bool:
|
||||
return false
|
||||
|
||||
func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
AudioManager.play_sfx("Dig")
|
||||
AudioManager.play_sfx("Rocks")
|
||||
for area in zone.get_affected_areas():
|
||||
if area and area is Plant:
|
||||
harvest(area, player)
|
||||
@@ -45,5 +46,10 @@ func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
var rock_layer : RockLayer = bodies[rock_layer_id]
|
||||
|
||||
rock_layer.dig_rocks(zone.get_tiles())
|
||||
|
||||
|
||||
var particles := (DIG_PARTICLES.instantiate() as Node2D)
|
||||
player.region.add_child(particles)
|
||||
particles.global_position = zone.get_global_position()
|
||||
|
||||
return true
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
[gd_scene format=3 uid="uid://d4bokthua8vum"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://rjpuk6wfusk0" path="res://entities/player/inventory/scripts/items/utils/scripts/dig_particles.gd" id="1_80bhs"]
|
||||
[ext_resource type="PackedScene" uid="uid://drf23tyb65cpc" path="res://common/vfx/particles/explosion_particles.tscn" id="1_c4ts5"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_7foqj"]
|
||||
offsets = PackedFloat32Array(0, 0.73362446, 1)
|
||||
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0.84705883, 1, 1, 1, 0)
|
||||
|
||||
[sub_resource type="Curve" id="Curve_w1iqb"]
|
||||
_limits = [-1.0, 1.0, 0.0, 1.0]
|
||||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[node name="DigParticles" type="Node2D" unique_id=358042179]
|
||||
script = ExtResource("1_80bhs")
|
||||
|
||||
[node name="ExplosionParticles" parent="." unique_id=1558673457 instance=ExtResource("1_c4ts5")]
|
||||
unique_name_in_owner = true
|
||||
amount = 10
|
||||
lifetime = 1.0
|
||||
speed_scale = 3.0
|
||||
spread = 50.0
|
||||
gravity = Vector2(0, 400)
|
||||
initial_velocity_min = 150.0
|
||||
initial_velocity_max = 200.0
|
||||
scale_amount_min = 0.2
|
||||
scale_amount_max = 0.3
|
||||
color = Color(0.5372549, 0.54901963, 0.5137255, 1)
|
||||
color_ramp = SubResource("Gradient_7foqj")
|
||||
hue_variation_min = -0.05
|
||||
hue_variation_max = 0.05
|
||||
hue_variation_curve = SubResource("Curve_w1iqb")
|
||||
@@ -0,0 +1,9 @@
|
||||
extends Node2D
|
||||
|
||||
func _ready():
|
||||
print("Emitting !")
|
||||
%ExplosionParticles.emitting = true
|
||||
%ExplosionParticles.finished.connect(
|
||||
queue_free
|
||||
)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://rjpuk6wfusk0
|
||||
@@ -4,6 +4,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://dompaj451gklw" path="res://entities/player/assets/sprites/movement_particles.png" id="2_bls4j"]
|
||||
[ext_resource type="Texture2D" uid="uid://ys5fis3gsnoy" path="res://entities/player/assets/sprites/shadow.png" id="2_fkugw"]
|
||||
[ext_resource type="Texture2D" uid="uid://c7ff87jniga5m" path="res://entities/player/assets/sprites/robot.png" id="4_bls4j"]
|
||||
[ext_resource type="Script" uid="uid://b1mmtgmi5oq86" path="res://entities/player/scripts/player_sprite.gd" id="5_fkugw"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_sglur"]
|
||||
radius = 27.0
|
||||
@@ -118,11 +119,43 @@ animations = [{
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_bls4j"]
|
||||
[sub_resource type="Animation" id="Animation_fkugw"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("PlayerSprite:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0.99999994, -17)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_fkugw"]
|
||||
states/StateMachine/node = SubResource("AnimationNodeStateMachine_bls4j")
|
||||
states/StateMachine/position = Vector2(386, 91)
|
||||
[sub_resource type="Animation" id="Animation_8fjmc"]
|
||||
resource_name = "float"
|
||||
length = 4.0
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("PlayerSprite:position")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 1.9666667, 4),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0.99999994, -17), Vector2(1, -12), Vector2(0.99999994, -17)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_qiwj3"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_fkugw"),
|
||||
&"float": SubResource("Animation_8fjmc")
|
||||
}
|
||||
|
||||
[node name="Player" type="CharacterBody2D" unique_id=447849413]
|
||||
script = ExtResource("1_abrql")
|
||||
@@ -132,9 +165,9 @@ position = Vector2(0, -17)
|
||||
shape = SubResource("CircleShape2D_sglur")
|
||||
|
||||
[node name="Shadow" type="Sprite2D" parent="." unique_id=875064259]
|
||||
modulate = Color(0, 0, 0, 0.60784316)
|
||||
modulate = Color(0, 0, 0, 0.41568628)
|
||||
position = Vector2(-1, 13)
|
||||
scale = Vector2(0.35897446, 0.3589744)
|
||||
scale = Vector2(0.41025653, 0.41025642)
|
||||
texture = ExtResource("2_fkugw")
|
||||
|
||||
[node name="InteractArea2D" type="Area2D" parent="." unique_id=1048722411]
|
||||
@@ -153,14 +186,16 @@ gravity = Vector2(0, 100)
|
||||
scale_amount_curve = SubResource("Curve_fkugw")
|
||||
color_ramp = SubResource("Gradient_bls4j")
|
||||
|
||||
[node name="Sprite" type="AnimatedSprite2D" parent="." unique_id=638545037]
|
||||
[node name="PlayerSprite" type="AnimatedSprite2D" parent="." unique_id=638545037]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2(0.99999994, -17)
|
||||
scale = Vector2(0.0656168, 0.065616846)
|
||||
sprite_frames = SubResource("SpriteFrames_a1qjk")
|
||||
animation = &"back"
|
||||
animation = &"front_right"
|
||||
frame_progress = 0.46771586
|
||||
script = ExtResource("5_fkugw")
|
||||
wanted_orientation = 2
|
||||
|
||||
[node name="FloatAnimationPlayer" type="AnimationPlayer" parent="." unique_id=929823261]
|
||||
|
||||
[node name="AnimationTree" type="AnimationTree" parent="." unique_id=563415659]
|
||||
tree_root = SubResource("AnimationNodeStateMachine_fkugw")
|
||||
[node name="FloatAnimationPlayer" type="AnimationPlayer" parent="." unique_id=793749564]
|
||||
libraries/ = SubResource("AnimationLibrary_qiwj3")
|
||||
autoplay = &"float"
|
||||
|
||||
@@ -99,25 +99,23 @@ func calculate_direction():
|
||||
func turn_animate(input_direction):
|
||||
if input_direction.x > TURN_ANIMATION_MINIMUM_THRESHOLD:
|
||||
if input_direction.y > TURN_ANIMATION_MINIMUM_THRESHOLD:
|
||||
%Sprite.play("front_right")
|
||||
%PlayerSprite.wanted_orientation = PlayerSprite.ROrient.FRONT_RIGHT
|
||||
elif input_direction.y < -TURN_ANIMATION_MINIMUM_THRESHOLD:
|
||||
%Sprite.play("back_right")
|
||||
%PlayerSprite.wanted_orientation = PlayerSprite.ROrient.BACK_RIGHT
|
||||
else:
|
||||
%Sprite.play("right")
|
||||
%PlayerSprite.wanted_orientation = PlayerSprite.ROrient.RIGHT
|
||||
elif input_direction.x < -TURN_ANIMATION_MINIMUM_THRESHOLD:
|
||||
if input_direction.y > TURN_ANIMATION_MINIMUM_THRESHOLD:
|
||||
%Sprite.play("front_left")
|
||||
%PlayerSprite.wanted_orientation = PlayerSprite.ROrient.FRONT_LEFT
|
||||
elif input_direction.y < -TURN_ANIMATION_MINIMUM_THRESHOLD:
|
||||
%Sprite.play("back_left")
|
||||
%PlayerSprite.wanted_orientation = PlayerSprite.ROrient.BACK_LEFT
|
||||
else:
|
||||
%Sprite.play("left")
|
||||
%PlayerSprite.wanted_orientation = PlayerSprite.ROrient.LEFT
|
||||
else:
|
||||
if input_direction.y > TURN_ANIMATION_MINIMUM_THRESHOLD:
|
||||
%Sprite.play("front")
|
||||
%PlayerSprite.wanted_orientation = PlayerSprite.ROrient.FRONT
|
||||
elif input_direction.y < -TURN_ANIMATION_MINIMUM_THRESHOLD:
|
||||
%Sprite.play("back")
|
||||
else:
|
||||
%Sprite.play("front")
|
||||
%PlayerSprite.wanted_orientation = PlayerSprite.ROrient.BACK
|
||||
|
||||
func can_interact(interactable : Interactable):
|
||||
return interactable.can_interact(self)
|
||||
|
||||
113
entities/player/scripts/player_sprite.gd
Normal file
113
entities/player/scripts/player_sprite.gd
Normal file
@@ -0,0 +1,113 @@
|
||||
@tool
|
||||
extends AnimatedSprite2D
|
||||
class_name PlayerSprite
|
||||
|
||||
const ORIENTATION_TIME = 0.1
|
||||
|
||||
enum ROrient {
|
||||
FRONT,
|
||||
FRONT_RIGHT,
|
||||
FRONT_LEFT,
|
||||
BACK,
|
||||
BACK_RIGHT,
|
||||
BACK_LEFT,
|
||||
RIGHT,
|
||||
LEFT,
|
||||
}
|
||||
|
||||
@export var wanted_orientation : ROrient
|
||||
var orientation : ROrient : set = set_orientation
|
||||
|
||||
var time_since_last_orientation = 10.
|
||||
|
||||
func _process(delta):
|
||||
time_since_last_orientation += delta
|
||||
|
||||
if time_since_last_orientation > ORIENTATION_TIME and wanted_orientation != orientation:
|
||||
time_since_last_orientation = 0.
|
||||
if is_closest_clockwise(orientation, wanted_orientation):
|
||||
orientation = clock_wise(orientation)
|
||||
else :
|
||||
orientation = counter_clock_wise(orientation)
|
||||
|
||||
|
||||
func set_orientation(o : ROrient = orientation):
|
||||
orientation = o
|
||||
if is_node_ready() and animation != orientation_to_str(o):
|
||||
play(orientation_to_str(o))
|
||||
|
||||
|
||||
static func orientation_to_str(o : ROrient) -> String:
|
||||
match o:
|
||||
ROrient.FRONT:
|
||||
return "front"
|
||||
ROrient.FRONT_RIGHT:
|
||||
return "front_right"
|
||||
ROrient.FRONT_LEFT:
|
||||
return "front_left"
|
||||
ROrient.BACK:
|
||||
return "back"
|
||||
ROrient.BACK_RIGHT:
|
||||
return "back_right"
|
||||
ROrient.BACK_LEFT:
|
||||
return "back_left"
|
||||
ROrient.RIGHT:
|
||||
return "right"
|
||||
ROrient.LEFT:
|
||||
return "left"
|
||||
_:
|
||||
return "front"
|
||||
|
||||
static func clock_wise(o : ROrient) -> ROrient:
|
||||
match o:
|
||||
ROrient.FRONT:
|
||||
return ROrient.FRONT_LEFT
|
||||
ROrient.FRONT_LEFT:
|
||||
return ROrient.LEFT
|
||||
ROrient.LEFT:
|
||||
return ROrient.BACK_LEFT
|
||||
ROrient.BACK_LEFT:
|
||||
return ROrient.BACK
|
||||
ROrient.BACK:
|
||||
return ROrient.BACK_RIGHT
|
||||
ROrient.BACK_RIGHT:
|
||||
return ROrient.RIGHT
|
||||
ROrient.RIGHT:
|
||||
return ROrient.FRONT_RIGHT
|
||||
ROrient.FRONT_RIGHT:
|
||||
return ROrient.FRONT
|
||||
_:
|
||||
return ROrient.FRONT
|
||||
|
||||
static func counter_clock_wise(o : ROrient) -> ROrient:
|
||||
match o:
|
||||
ROrient.FRONT:
|
||||
return ROrient.FRONT_RIGHT
|
||||
ROrient.FRONT_RIGHT:
|
||||
return ROrient.RIGHT
|
||||
ROrient.RIGHT:
|
||||
return ROrient.BACK_RIGHT
|
||||
ROrient.BACK_RIGHT:
|
||||
return ROrient.BACK
|
||||
ROrient.BACK:
|
||||
return ROrient.BACK_LEFT
|
||||
ROrient.BACK_LEFT:
|
||||
return ROrient.LEFT
|
||||
ROrient.LEFT:
|
||||
return ROrient.FRONT_LEFT
|
||||
ROrient.FRONT_LEFT:
|
||||
return ROrient.FRONT
|
||||
_:
|
||||
return ROrient.FRONT
|
||||
|
||||
static func is_closest_clockwise(
|
||||
current : ROrient,
|
||||
wanted : ROrient,
|
||||
):
|
||||
var move := current
|
||||
var step := 0
|
||||
while move != wanted:
|
||||
step += 1
|
||||
move = clock_wise(move)
|
||||
return step < 4
|
||||
|
||||
1
entities/player/scripts/player_sprite.gd.uid
Normal file
1
entities/player/scripts/player_sprite.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b1mmtgmi5oq86
|
||||
Reference in New Issue
Block a user