#39 ajout d'un compost plus des ajouts mineurs de qualité de vie
This commit is contained in:
73
entities/interactables/compost/assets/sprites/compost.svg
Normal file
73
entities/interactables/compost/assets/sprites/compost.svg
Normal file
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="54.516888mm"
|
||||
height="71.574326mm"
|
||||
viewBox="0 0 54.516888 71.574326"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
inkscape:export-filename="compost.svg"
|
||||
inkscape:export-xdpi="51.66227"
|
||||
inkscape:export-ydpi="51.66227"
|
||||
xml:space="preserve"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#505050"
|
||||
bordercolor="#ffffff"
|
||||
borderopacity="1"
|
||||
inkscape:showpageshadow="0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="1"
|
||||
inkscape:deskcolor="#505050"
|
||||
inkscape:document-units="mm" /><defs
|
||||
id="defs1" /><g
|
||||
inkscape:label="Calque 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-20.067568,-29.766889)"><rect
|
||||
style="fill:#c9c9c9;fill-opacity:1;stroke-width:0.264583;stroke-linecap:square"
|
||||
id="rect5"
|
||||
width="10.702703"
|
||||
height="54.532818"
|
||||
x="25.418919"
|
||||
y="29.76689"
|
||||
ry="4.1948323" /><rect
|
||||
style="fill:#c9c9c9;fill-opacity:1;stroke-width:0.264583;stroke-linecap:square"
|
||||
id="rect8"
|
||||
width="43.814186"
|
||||
height="44.307919"
|
||||
x="25.418921"
|
||||
y="39.991791"
|
||||
ry="4.1948323" /><rect
|
||||
style="fill:#ffffff;fill-opacity:1;stroke-width:0.264583;stroke-linecap:square"
|
||||
id="rect3"
|
||||
width="10.702703"
|
||||
height="54.532818"
|
||||
x="20.067568"
|
||||
y="46.808395"
|
||||
ry="4.1948323" /><rect
|
||||
style="fill:#c9c9c9;fill-opacity:1;stroke-width:0.264583;stroke-linecap:square"
|
||||
id="rect6"
|
||||
width="10.702703"
|
||||
height="54.532818"
|
||||
x="58.530403"
|
||||
y="29.76689"
|
||||
ry="4.1948323" /><rect
|
||||
style="fill:#ffffff;fill-opacity:1;stroke-width:0.264583;stroke-linecap:square"
|
||||
id="rect4"
|
||||
width="10.702703"
|
||||
height="54.532818"
|
||||
x="63.881756"
|
||||
y="46.808395"
|
||||
ry="4.1948323" /><rect
|
||||
style="fill:#ffffff;fill-opacity:1;stroke-width:0.264583;stroke-linecap:square"
|
||||
id="rect7"
|
||||
width="43.814186"
|
||||
height="44.307919"
|
||||
x="25.418919"
|
||||
y="57.033298"
|
||||
ry="0" /></g></svg>
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1,37 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://f2rte5jc0psp"
|
||||
path="res://.godot/imported/compost.svg-503fc2423ba701b15edd51da5ab01164.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/interactables/compost/assets/sprites/compost.svg"
|
||||
dest_files=["res://.godot/imported/compost.svg-503fc2423ba701b15edd51da5ab01164.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
129
entities/interactables/compost/compost.tscn
Normal file
129
entities/interactables/compost/compost.tscn
Normal file
@@ -0,0 +1,129 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://bkwh1ntvgkkrt"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dw6jgsasb2fe1" path="res://entities/interactables/compost/scripts/compost.gd" id="1_1758a"]
|
||||
[ext_resource type="Texture2D" uid="uid://f2rte5jc0psp" path="res://entities/interactables/compost/assets/sprites/compost.svg" id="2_r6435"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_etofw"]
|
||||
bg_color = Color(0.260098, 0.11665, 0.0419712, 0.231373)
|
||||
corner_radius_top_left = 5
|
||||
corner_radius_top_right = 5
|
||||
corner_radius_bottom_right = 5
|
||||
corner_radius_bottom_left = 5
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3ao1n"]
|
||||
bg_color = Color(0.270222, 0.270222, 0.270222, 1)
|
||||
corner_radius_top_left = 5
|
||||
corner_radius_top_right = 5
|
||||
corner_radius_bottom_right = 5
|
||||
corner_radius_bottom_left = 5
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_coj8m"]
|
||||
size = Vector2(77, 92)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_1758a"]
|
||||
resource_name = "empty"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Compost:position")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0), Vector2(0, 12.605), Vector2(0, -24.56), Vector2(0, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Compost:scale")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0.291262, 0.291262), Vector2(0.291, 0.191), Vector2(0.291, 0.366), Vector2(0.291262, 0.291262)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_r6435"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Compost:scale")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0.291262, 0.291262)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Compost:position")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_etofw"]
|
||||
resource_name = "fill"
|
||||
length = 0.3
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Compost:scale")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0.291262, 0.291262), Vector2(0.291, 0.231), Vector2(0.291262, 0.291262)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_etofw"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_r6435"),
|
||||
&"empty": SubResource("Animation_1758a"),
|
||||
&"fill": SubResource("Animation_etofw")
|
||||
}
|
||||
|
||||
[node name="Compost" type="Area2D"]
|
||||
script = ExtResource("1_1758a")
|
||||
|
||||
[node name="Compost" type="Sprite2D" parent="."]
|
||||
modulate = Color(0.615686, 0.501961, 0.270588, 1)
|
||||
scale = Vector2(0.291262, 0.291262)
|
||||
texture = ExtResource("2_r6435")
|
||||
|
||||
[node name="ProgressBar" type="ProgressBar" parent="Compost"]
|
||||
unique_name_in_owner = true
|
||||
offset_left = -62.0
|
||||
offset_top = -7.0
|
||||
offset_right = 62.0
|
||||
offset_bottom = 120.0
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_etofw")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_3ao1n")
|
||||
value = 20.0
|
||||
fill_mode = 3
|
||||
show_percentage = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
visible = false
|
||||
position = Vector2(-0.5, 2)
|
||||
shape = SubResource("RectangleShape2D_coj8m")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_etofw")
|
||||
}
|
||||
34
entities/interactables/compost/scripts/compost.gd
Normal file
34
entities/interactables/compost/scripts/compost.gd
Normal file
@@ -0,0 +1,34 @@
|
||||
extends Interactable
|
||||
class_name Compost
|
||||
|
||||
|
||||
@export var value_per_seed : float = 0.5
|
||||
|
||||
var fill_value : float = 0.
|
||||
|
||||
func _process(_delta):
|
||||
%ProgressBar.value = lerp(%ProgressBar.value, fill_value * 100, 0.5)
|
||||
|
||||
func _ready():
|
||||
fill_value = 0.
|
||||
|
||||
func can_interact(p : Player) -> bool:
|
||||
return p.inventory.get_item() and p.inventory.get_item() is Seed
|
||||
|
||||
func requirement_text() -> String:
|
||||
return "You must have a seed in hand"
|
||||
|
||||
func interact(p : Player) -> bool:
|
||||
if not can_interact(p):
|
||||
return false
|
||||
|
||||
p.delete_item()
|
||||
fill_value += value_per_seed
|
||||
if fill_value >= 1.:
|
||||
$AnimationPlayer.play("empty")
|
||||
fill_value = 0
|
||||
p.upgrade()
|
||||
value_per_seed /= 1.5
|
||||
else:
|
||||
$AnimationPlayer.play("fill")
|
||||
return true
|
||||
1
entities/interactables/compost/scripts/compost.gd.uid
Normal file
1
entities/interactables/compost/scripts/compost.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dw6jgsasb2fe1
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://b0ecjfdnvhjjf"]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://c3uusrlts538q"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dedg615xudpoq" path="res://entities/interactables/item_object/script/item_object.gd" id="1_hxea8"]
|
||||
|
||||
|
||||
@@ -6,6 +6,12 @@ var available : bool = true
|
||||
func _ready():
|
||||
printerr("Abstract Interactable class used")
|
||||
|
||||
func can_interact(_p : Player) -> bool:
|
||||
return true
|
||||
|
||||
func interact_requirement_text() -> String:
|
||||
return ""
|
||||
|
||||
func interact(_p : Player) -> bool:
|
||||
printerr("Interact function called on abstract Interactable class")
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user