#24 et #21 ajout d'une plante générique, et d'un cycle de recharge du robot avec croissance des plantes
@ -1,8 +0,0 @@
|
||||
extends Interactable
|
||||
class_name Plant
|
||||
|
||||
var watered : bool = false : set = set_watered
|
||||
|
||||
func set_watered(_watered):
|
||||
watered = _watered
|
||||
$AnimatedSprite2D.play("watered" if watered else "default")
|
||||
BIN
entities/plants/assets/sprites/default/growing.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
34
entities/plants/assets/sprites/default/growing.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c7mp7tkkkk6o5"
|
||||
path="res://.godot/imported/growing.png-3f6fb3171589f3a22ebfeda1a4575199.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/plants/assets/sprites/default/growing.png"
|
||||
dest_files=["res://.godot/imported/growing.png-3f6fb3171589f3a22ebfeda1a4575199.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
|
||||
BIN
entities/plants/assets/sprites/default/mature.png
Normal file
|
After Width: | Height: | Size: 149 KiB |
34
entities/plants/assets/sprites/default/mature.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bupl1y0cfj21q"
|
||||
path="res://.godot/imported/mature.png-f8b2b72a84e90cfc6bf925d1d48f7f7e.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/plants/assets/sprites/default/mature.png"
|
||||
dest_files=["res://.godot/imported/mature.png-f8b2b72a84e90cfc6bf925d1d48f7f7e.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
|
||||
BIN
entities/plants/assets/sprites/default/planted.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
34
entities/plants/assets/sprites/default/planted.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ba413oun7ry78"
|
||||
path="res://.godot/imported/planted.png-2c23372e71d0997d310374f47bb48594.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/plants/assets/sprites/default/planted.png"
|
||||
dest_files=["res://.godot/imported/planted.png-2c23372e71d0997d310374f47bb48594.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
|
||||
|
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 96 KiB |
@ -3,15 +3,15 @@
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c6vby5r0pfni2"
|
||||
path="res://.godot/imported/default_plant.png-bbc4a8928e27ae5fc30489a97257bdb9.ctex"
|
||||
path="res://.godot/imported/default_plant.png-0e29f01fe7666058a9a8c53076d3ea4d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/interactables/plants/assets/sprites/default_plant.png"
|
||||
dest_files=["res://.godot/imported/default_plant.png-bbc4a8928e27ae5fc30489a97257bdb9.ctex"]
|
||||
source_file="res://entities/plants/assets/sprites/default_plant.png"
|
||||
dest_files=["res://.godot/imported/default_plant.png-0e29f01fe7666058a9a8c53076d3ea4d.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
Before Width: | Height: | Size: 169 KiB After Width: | Height: | Size: 169 KiB |
@ -3,15 +3,15 @@
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b3wom2xu26g43"
|
||||
path="res://.godot/imported/default_plant_glowing.png-09ba534646a860193c36fa40d5f83142.ctex"
|
||||
path="res://.godot/imported/default_plant_glowing.png-1922303555901146cff9778bc5fe2dcb.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/interactables/plants/assets/sprites/default_plant_glowing.png"
|
||||
dest_files=["res://.godot/imported/default_plant_glowing.png-09ba534646a860193c36fa40d5f83142.ctex"]
|
||||
source_file="res://entities/plants/assets/sprites/default_plant_glowing.png"
|
||||
dest_files=["res://.godot/imported/default_plant_glowing.png-1922303555901146cff9778bc5fe2dcb.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://clpcqkdlj3d8e"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://clpcqkdlj3d8e"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cega715smavh3" path="res://entities/interactables/plants/scripts/plant.gd" id="1_d8u7e"]
|
||||
[ext_resource type="Script" uid="uid://yutflvdgdk04" path="res://entities/interactables/scripts/interactable_action.gd" id="2_rs46h"]
|
||||
[ext_resource type="Resource" uid="uid://bk0kop0m75pjy" path="res://entities/interactables/resources/actions/default_water_plant.tres" id="3_5foug"]
|
||||
[ext_resource type="Texture2D" uid="uid://c6vby5r0pfni2" path="res://entities/interactables/plants/assets/sprites/default_plant.png" id="4_dq24f"]
|
||||
[ext_resource type="Texture2D" uid="uid://b3wom2xu26g43" path="res://entities/interactables/plants/assets/sprites/default_plant_glowing.png" id="5_2gcie"]
|
||||
[ext_resource type="Script" uid="uid://cega715smavh3" path="res://entities/plants/scripts/plant.gd" id="1_d8u7e"]
|
||||
[ext_resource type="Texture2D" uid="uid://c6vby5r0pfni2" path="res://entities/plants/assets/sprites/default_plant.png" id="4_dq24f"]
|
||||
[ext_resource type="Texture2D" uid="uid://b3wom2xu26g43" path="res://entities/plants/assets/sprites/default_plant_glowing.png" id="5_2gcie"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_cdbrd"]
|
||||
|
||||
@ -29,7 +27,6 @@ animations = [{
|
||||
|
||||
[node name="DefaultPlant" type="Area2D"]
|
||||
script = ExtResource("1_d8u7e")
|
||||
actions = Array[ExtResource("2_rs46h")]([ExtResource("3_5foug")])
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
scale = Vector2(4.01154, 4.01154)
|
||||
@ -0,0 +1,8 @@
|
||||
[gd_resource type="Resource" script_class="DecontaminateTerrainEffect" load_steps=2 format=3 uid="uid://bdddlia6qxgf2"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cgscbuxe4dawb" path="res://entities/plants/scripts/plant_effects/decontaminate_terrain_effect.gd" id="1_8l07v"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_8l07v")
|
||||
impact_radius = 50
|
||||
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
|
||||
21
entities/plants/resources/plants/default.tres
Normal file
@ -0,0 +1,21 @@
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=7 format=3 uid="uid://dmbu538b3utec"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://c7mp7tkkkk6o5" path="res://entities/plants/assets/sprites/default/growing.png" id="1_fp5j6"]
|
||||
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="1_moyj3"]
|
||||
[ext_resource type="Script" uid="uid://cgscbuxe4dawb" path="res://entities/plants/scripts/plant_effects/decontaminate_terrain_effect.gd" id="2_cky1j"]
|
||||
[ext_resource type="Texture2D" uid="uid://bupl1y0cfj21q" path="res://entities/plants/assets/sprites/default/mature.png" id="3_ffarr"]
|
||||
[ext_resource type="Texture2D" uid="uid://ba413oun7ry78" path="res://entities/plants/assets/sprites/default/planted.png" id="4_2s6re"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_q68uy"]
|
||||
script = ExtResource("2_cky1j")
|
||||
impact_radius = 100
|
||||
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_moyj3")
|
||||
growing_time = 2
|
||||
planted_texture = ExtResource("4_2s6re")
|
||||
growing_texture = ExtResource("1_fp5j6")
|
||||
mature_texture = ExtResource("3_ffarr")
|
||||
mature_effect = SubResource("Resource_q68uy")
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
66
entities/plants/scripts/plant.gd
Normal file
@ -0,0 +1,66 @@
|
||||
extends Node2D
|
||||
class_name Plant
|
||||
|
||||
const PLANT_AREA_WIDTH = 10
|
||||
const PLANT_SPRITE_SCALE = 0.15
|
||||
|
||||
enum State {PLANTED, GROWING, MATURE}
|
||||
|
||||
var plant_type : PlantType
|
||||
var planet : Planet
|
||||
|
||||
var state : State = State.PLANTED : set = change_state
|
||||
var day : int = 0
|
||||
|
||||
@onready var plant_sprite : Sprite2D = generate_sprite()
|
||||
@onready var plant_area : Area2D = generate_area()
|
||||
|
||||
func _init(_plant_type, _planet):
|
||||
plant_type = _plant_type
|
||||
planet = _planet
|
||||
|
||||
func generate_sprite() -> Sprite2D:
|
||||
var sprite = Sprite2D.new()
|
||||
|
||||
add_child(sprite)
|
||||
sprite.texture = get_state_texture(state)
|
||||
sprite.scale = Vector2.ONE * PLANT_SPRITE_SCALE
|
||||
sprite.offset
|
||||
|
||||
return sprite
|
||||
|
||||
func generate_area() -> Area2D:
|
||||
var area = Area2D.new()
|
||||
var collision = CollisionShape2D.new()
|
||||
var collision_shape = CircleShape2D.new()
|
||||
collision_shape.radius = PLANT_AREA_WIDTH
|
||||
|
||||
collision.shape = collision_shape
|
||||
area.add_child(collision)
|
||||
add_child(area)
|
||||
|
||||
return area
|
||||
|
||||
func pass_day():
|
||||
day += 1
|
||||
if day > plant_type.growing_time:
|
||||
change_state(State.MATURE)
|
||||
else:
|
||||
change_state(State.GROWING)
|
||||
|
||||
func change_state(_state : State):
|
||||
state = _state
|
||||
plant_sprite.texture = get_state_texture(state)
|
||||
|
||||
if state == State.MATURE and plant_type.mature_effect:
|
||||
plant_type.mature_effect.effect(self)
|
||||
|
||||
func get_state_texture(s : State) -> Texture2D:
|
||||
match s:
|
||||
State.PLANTED:
|
||||
return plant_type.planted_texture
|
||||
State.GROWING:
|
||||
return plant_type.growing_texture
|
||||
State.MATURE:
|
||||
return plant_type.mature_texture
|
||||
return null
|
||||
7
entities/plants/scripts/plant_effect.gd
Normal file
@ -0,0 +1,7 @@
|
||||
# Classe abstraite permettant de développer divers effets de plantes
|
||||
extends Resource
|
||||
class_name PlantEffect
|
||||
|
||||
func effect(plant):
|
||||
printerr("Classe abstraite PlantEffect appelée")
|
||||
|
||||
1
entities/plants/scripts/plant_effect.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bpycohqas4hff
|
||||
@ -0,0 +1,10 @@
|
||||
extends PlantEffect
|
||||
class_name DecontaminateTerrainEffect
|
||||
|
||||
@export var impact_radius = 50
|
||||
|
||||
func effect(plant):
|
||||
plant.planet.impact_contamination(
|
||||
plant.global_position,
|
||||
impact_radius
|
||||
)
|
||||
@ -0,0 +1 @@
|
||||
uid://cgscbuxe4dawb
|
||||
11
entities/plants/scripts/plant_type.gd
Normal file
@ -0,0 +1,11 @@
|
||||
extends Resource
|
||||
class_name PlantType
|
||||
|
||||
@export var growing_time : int
|
||||
|
||||
@export var seed_texture : Texture
|
||||
@export var planted_texture : Texture
|
||||
@export var growing_texture : Texture
|
||||
@export var mature_texture : Texture
|
||||
|
||||
@export var mature_effect : PlantEffect
|
||||
1
entities/plants/scripts/plant_type.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://jnye5pe1bgqw
|
||||
@ -3,10 +3,15 @@ class_name Player
|
||||
|
||||
signal player_stats_updated(player : Player)
|
||||
|
||||
var controlling_player : bool = true
|
||||
var planet : Planet # mis à jour par la classe Planet
|
||||
@export var speed = 400
|
||||
|
||||
var energy : int = 10 :
|
||||
@export var testPlantType : PlantType
|
||||
|
||||
var max_energy : int = 10
|
||||
|
||||
var energy : int = max_energy :
|
||||
set(v):
|
||||
energy = v
|
||||
emit_signal("player_stats_updated", self)
|
||||
@ -15,10 +20,11 @@ func _ready():
|
||||
emit_signal("player_stats_updated", self)
|
||||
|
||||
func get_input():
|
||||
calculate_direction()
|
||||
if controlling_player:
|
||||
calculate_direction()
|
||||
|
||||
if Input.is_action_just_pressed("interact") and energy > 0:
|
||||
try_interact()
|
||||
if Input.is_action_just_pressed("action") and energy > 0:
|
||||
action()
|
||||
|
||||
func calculate_direction():
|
||||
var input_direction : Vector2 = Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||
@ -26,24 +32,25 @@ func calculate_direction():
|
||||
if input_direction.x:
|
||||
$Sprite.flip_h = (input_direction.x < 0)
|
||||
|
||||
func try_interact():
|
||||
var interactables : Array[Interactable]
|
||||
|
||||
for area2D in $InteractArea2D.get_overlapping_areas():
|
||||
if area2D is Interactable:
|
||||
interactables.push_front(area2D)
|
||||
func action():
|
||||
if planet:
|
||||
planet.plant(
|
||||
testPlantType,
|
||||
global_position
|
||||
)
|
||||
|
||||
if len(interactables):
|
||||
if len(interactables) > 1:
|
||||
# Sort them to the closer
|
||||
interactables.sort_custom(
|
||||
func (el1 : Interactable, el2 : Interactable):
|
||||
return el1.global_position.distance_to(global_position) > el2.global_position.distance_to(global_position)
|
||||
)
|
||||
|
||||
interactables[0].interact(self)
|
||||
energy -= 1
|
||||
func pass_day():
|
||||
energy = max_energy
|
||||
|
||||
func _physics_process(_delta):
|
||||
get_input()
|
||||
move_and_slide()
|
||||
|
||||
func _on_root_gui_day_pass_pressed():
|
||||
controlling_player = false
|
||||
|
||||
func _on_root_gui_day_pass_finished():
|
||||
controlling_player = true
|
||||
|
||||
func _on_root_gui_game_click():
|
||||
action()
|
||||
|
||||
@ -3,11 +3,8 @@
|
||||
[ext_resource type="Script" uid="uid://bpqh8n0lbluf8" path="res://gui/player_info/scripts/player_info.gd" id="1_ghu0s"]
|
||||
[ext_resource type="Texture2D" uid="uid://cm3ehinvvj52i" path="res://gui/player_info/assets/texture/Interface sans boutons.png" id="2_cgy6f"]
|
||||
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://gui/player_info/assets/icons/bolt.svg" id="3_s4ggy"]
|
||||
[ext_resource type="FontFile" uid="uid://byyfovm1ha5ya" path="res://gui/ressources/fonts/AtomicMd-3zXDZ.ttf" id="4_5y5ny"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_bye71"]
|
||||
font = ExtResource("4_5y5ny")
|
||||
font_size = 25
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="4_cgy6f"]
|
||||
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/default_label_settings.tres" id="5_s4ggy"]
|
||||
|
||||
[node name="PlayerInfo" type="Control"]
|
||||
custom_minimum_size = Vector2(337, 160)
|
||||
@ -56,7 +53,8 @@ stretch_mode = 5
|
||||
|
||||
[node name="Label" type="Label" parent="EnergyInfo"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("4_cgy6f")
|
||||
text = "0"
|
||||
label_settings = SubResource("LabelSettings_bye71")
|
||||
label_settings = ExtResource("5_s4ggy")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
7
gui/ressources/default_label_settings.tres
Normal file
@ -0,0 +1,7 @@
|
||||
[gd_resource type="LabelSettings" load_steps=2 format=3 uid="uid://dqwayi8yjwau2"]
|
||||
|
||||
[ext_resource type="FontFile" uid="uid://byyfovm1ha5ya" path="res://gui/ressources/fonts/AtomicMd-3zXDZ.ttf" id="1_w0wva"]
|
||||
|
||||
[resource]
|
||||
font = ExtResource("1_w0wva")
|
||||
font_size = 25
|
||||
50
gui/ressources/default_theme.tres
Normal file
@ -0,0 +1,50 @@
|
||||
[gd_resource type="Theme" load_steps=5 format=3 uid="uid://bgcmd213j6gk1"]
|
||||
|
||||
[ext_resource type="FontFile" uid="uid://byyfovm1ha5ya" path="res://gui/ressources/fonts/AtomicMd-3zXDZ.ttf" id="1_hv6r3"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hv6r3"]
|
||||
bg_color = Color(0.976471, 0.741176, 0.4, 1)
|
||||
border_width_left = 10
|
||||
border_width_top = 10
|
||||
border_width_right = 10
|
||||
border_width_bottom = 10
|
||||
border_color = Color(0.975367, 0.740445, 0.401877, 1)
|
||||
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_y48f0"]
|
||||
bg_color = Color(0.886275, 0.623529, 0.196078, 1)
|
||||
border_width_left = 10
|
||||
border_width_top = 10
|
||||
border_width_right = 10
|
||||
border_width_bottom = 10
|
||||
border_color = Color(0.886275, 0.623529, 0.196078, 1)
|
||||
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_st1o2"]
|
||||
bg_color = Color(0.692349, 0.477218, 0.112321, 1)
|
||||
border_width_left = 10
|
||||
border_width_top = 10
|
||||
border_width_right = 10
|
||||
border_width_bottom = 10
|
||||
border_color = Color(0.694118, 0.478431, 0.113725, 1)
|
||||
corner_radius_top_left = 5
|
||||
corner_radius_top_right = 5
|
||||
corner_radius_bottom_right = 5
|
||||
corner_radius_bottom_left = 5
|
||||
|
||||
[resource]
|
||||
Button/font_sizes/font_size = 25
|
||||
Button/fonts/font = ExtResource("1_hv6r3")
|
||||
Button/styles/hover = SubResource("StyleBoxFlat_hv6r3")
|
||||
Button/styles/normal = SubResource("StyleBoxFlat_y48f0")
|
||||
Button/styles/pressed = SubResource("StyleBoxFlat_st1o2")
|
||||
MarginContainer/constants/margin_bottom = 10
|
||||
MarginContainer/constants/margin_left = 10
|
||||
MarginContainer/constants/margin_right = 10
|
||||
MarginContainer/constants/margin_top = 10
|
||||
@ -1,7 +1,62 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://12nak7amd1uq"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://12nak7amd1uq"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://baqrmhsgqda6v" path="res://gui/player_info/player_info.tscn" id="1_8kw6x"]
|
||||
[ext_resource type="Script" uid="uid://cqao7n800qy40" path="res://gui/scripts/root_gui.gd" id="1_udau0"]
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="2_nq5i2"]
|
||||
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://gui/player_info/assets/icons/bolt.svg" id="4_k4juk"]
|
||||
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/default_label_settings.tres" id="4_ujg5r"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_k4juk"]
|
||||
resource_name = "recharge_fade_in"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("RechargeFade:color")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_iyvkh"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("RechargeFade:color")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(0, 0, 0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_fovlv"]
|
||||
resource_name = "recharge_fade_out"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("RechargeFade:color")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0.166667, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0, 0, 0, 1), Color(0, 0, 0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_n4kem"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_iyvkh"),
|
||||
&"recharge_fade_in": SubResource("Animation_k4juk"),
|
||||
&"recharge_fade_out": SubResource("Animation_fovlv")
|
||||
}
|
||||
|
||||
[node name="RootGui" type="Control"]
|
||||
layout_mode = 3
|
||||
@ -14,14 +69,59 @@ size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource("1_udau0")
|
||||
|
||||
[node name="PlayerInfo" parent="." instance=ExtResource("1_8kw6x")]
|
||||
[node name="GameAction" type="TextureButton" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
offset_right = 337.0
|
||||
offset_bottom = 160.0
|
||||
grow_horizontal = 1
|
||||
grow_vertical = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[connection signal="player_stats_updated" from="." to="PlayerInfo" method="_on_root_gui_player_stats_updated"]
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
theme = ExtResource("2_nq5i2")
|
||||
|
||||
[node name="PlayerInfo" parent="MarginContainer" instance=ExtResource("1_8kw6x")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="DayPass" type="Button" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
size_flags_vertical = 8
|
||||
focus_mode = 0
|
||||
theme = ExtResource("2_nq5i2")
|
||||
text = "Recharge"
|
||||
icon = ExtResource("4_k4juk")
|
||||
|
||||
[node name="DayCount" type="Label" parent="MarginContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
size_flags_vertical = 0
|
||||
label_settings = ExtResource("4_ujg5r")
|
||||
|
||||
[node name="RechargeFade" type="ColorRect" parent="."]
|
||||
physics_interpolation_mode = 0
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
color = Color(0, 0, 0, 0)
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_n4kem")
|
||||
}
|
||||
|
||||
[connection signal="player_stats_updated" from="." to="MarginContainer/PlayerInfo" method="_on_root_gui_player_stats_updated"]
|
||||
[connection signal="button_down" from="GameAction" to="." method="_on_game_action_button_down"]
|
||||
[connection signal="pressed" from="MarginContainer/DayPass" to="." method="_on_day_pass_pressed"]
|
||||
|
||||
@ -2,6 +2,26 @@ extends Control
|
||||
class_name RootGui
|
||||
|
||||
signal player_stats_updated(player : Player)
|
||||
signal game_click
|
||||
signal day_pass_pressed
|
||||
signal day_pass_proceed
|
||||
signal day_pass_finished
|
||||
|
||||
func _on_player_player_stats_updated(player:Player):
|
||||
emit_signal("player_stats_updated", player)
|
||||
|
||||
|
||||
func _on_planet_planet_stats_updated(day:int):
|
||||
$MarginContainer/DayCount.text = "Day " + str(day)
|
||||
|
||||
func _on_day_pass_pressed():
|
||||
day_pass_pressed.emit()
|
||||
$AnimationPlayer.play("recharge_fade_in")
|
||||
await $AnimationPlayer.animation_finished
|
||||
day_pass_proceed.emit()
|
||||
$AnimationPlayer.play("recharge_fade_out")
|
||||
await $AnimationPlayer.animation_finished
|
||||
day_pass_finished.emit()
|
||||
|
||||
func _on_game_action_button_down():
|
||||
game_click.emit()
|
||||
|
||||
@ -41,9 +41,9 @@ move_down={
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
interact={
|
||||
action={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(222, 14),"global_position":Vector2(231, 62),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
38
root.tscn
@ -3,8 +3,8 @@
|
||||
[ext_resource type="PackedScene" uid="uid://12nak7amd1uq" path="res://gui/root_gui.tscn" id="1_jnlp7"]
|
||||
[ext_resource type="PackedScene" uid="uid://tsi5j1uxppa4" path="res://stages/terrain/planet/planet.tscn" id="1_pyidc"]
|
||||
[ext_resource type="PackedScene" uid="uid://bgvbgeq46wee2" path="res://entities/player/player.tscn" id="2_vvh5c"]
|
||||
[ext_resource type="Resource" uid="uid://dmbu538b3utec" path="res://entities/plants/resources/plants/default.tres" id="3_jnlp7"]
|
||||
[ext_resource type="PackedScene" uid="uid://dj7gp3crtg2yt" path="res://entities/camera/camera.tscn" id="3_vvh5c"]
|
||||
[ext_resource type="PackedScene" uid="uid://clpcqkdlj3d8e" path="res://entities/interactables/plants/default_plant.tscn" id="4_28aoi"]
|
||||
|
||||
[node name="Root" type="Node2D"]
|
||||
|
||||
@ -16,36 +16,7 @@
|
||||
y_sort_enabled = true
|
||||
|
||||
[node name="Player" parent="Entities" instance=ExtResource("2_vvh5c")]
|
||||
|
||||
[node name="DefaultPlant" parent="Entities" instance=ExtResource("4_28aoi")]
|
||||
position = Vector2(195, 37)
|
||||
|
||||
[node name="DefaultPlant2" parent="Entities" instance=ExtResource("4_28aoi")]
|
||||
position = Vector2(114, -40)
|
||||
|
||||
[node name="DefaultPlant3" parent="Entities" instance=ExtResource("4_28aoi")]
|
||||
position = Vector2(-222, 138)
|
||||
|
||||
[node name="DefaultPlant4" parent="Entities" instance=ExtResource("4_28aoi")]
|
||||
position = Vector2(-186, -96)
|
||||
|
||||
[node name="DefaultPlant5" parent="Entities" instance=ExtResource("4_28aoi")]
|
||||
position = Vector2(-7, 150)
|
||||
|
||||
[node name="DefaultPlant6" parent="Entities" instance=ExtResource("4_28aoi")]
|
||||
position = Vector2(-19, -102)
|
||||
|
||||
[node name="DefaultPlant7" parent="Entities" instance=ExtResource("4_28aoi")]
|
||||
position = Vector2(-115, 50)
|
||||
|
||||
[node name="DefaultPlant8" parent="Entities" instance=ExtResource("4_28aoi")]
|
||||
position = Vector2(147, -173)
|
||||
|
||||
[node name="DefaultPlant9" parent="Entities" instance=ExtResource("4_28aoi")]
|
||||
position = Vector2(98, 90)
|
||||
|
||||
[node name="DefaultPlant10" parent="Entities" instance=ExtResource("4_28aoi")]
|
||||
position = Vector2(-269, 1)
|
||||
testPlantType = ExtResource("3_jnlp7")
|
||||
|
||||
[node name="Planet" parent="." node_paths=PackedStringArray("import_entities_from_node") instance=ExtResource("1_pyidc")]
|
||||
import_entities_from_node = NodePath("../Entities")
|
||||
@ -54,4 +25,9 @@ import_entities_from_node = NodePath("../Entities")
|
||||
position = Vector2(2.22, 0)
|
||||
following = NodePath("../Entities/Player")
|
||||
|
||||
[connection signal="day_pass_finished" from="CanvasLayer/RootGui" to="Entities/Player" method="_on_root_gui_day_pass_finished"]
|
||||
[connection signal="day_pass_pressed" from="CanvasLayer/RootGui" to="Entities/Player" method="_on_root_gui_day_pass_pressed"]
|
||||
[connection signal="day_pass_proceed" from="CanvasLayer/RootGui" to="Planet" method="_on_root_gui_day_pass_proceed"]
|
||||
[connection signal="game_click" from="CanvasLayer/RootGui" to="Entities/Player" method="_on_root_gui_game_click"]
|
||||
[connection signal="player_stats_updated" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_player_stats_updated"]
|
||||
[connection signal="planet_stats_updated" from="Planet" to="CanvasLayer/RootGui" method="_on_planet_planet_stats_updated"]
|
||||
|
||||
@ -22,12 +22,12 @@ void vertex() {
|
||||
void fragment() {
|
||||
vec4 pixel_color = texture(data_texture, vert/data_texture_size);
|
||||
float value = pixel_color.x;
|
||||
|
||||
|
||||
vec2 texture_0_size = vec2(float(textureSize(texture_0, 0).x), float(textureSize(texture_0, 0).y)) / texture_scale;
|
||||
vec2 texture_1_size = vec2(float(textureSize(texture_1, 0).x), float(textureSize(texture_1, 0).y)) / texture_scale;
|
||||
|
||||
|
||||
vec4 color = texture(texture_0, vert/texture_0_size);
|
||||
|
||||
|
||||
if (value > data_texture_threshold)
|
||||
color = texture(texture_1, vert / texture_1_size);
|
||||
|
||||
|
||||
@ -1,17 +1,28 @@
|
||||
extends Terrain
|
||||
class_name Planet
|
||||
|
||||
signal planet_stats_updated(day : int)
|
||||
|
||||
const PLANET_TEXTURE_SCALE : float = 5.0
|
||||
|
||||
@export var background_texture : Texture2D
|
||||
@export var contamination_material : ShaderMaterial
|
||||
|
||||
|
||||
@onready var background_sprite : Polygon2D = generate_background_sprite()
|
||||
@onready var contamination_sprite : Polygon2D = generate_contamination_terrain_sprite()
|
||||
var contamination_texture : ImageTexture
|
||||
|
||||
func add_entity(e : Node2D, container : Node2D):
|
||||
var contamination_texture : ImageTexture
|
||||
var day : int = 0 :
|
||||
set(v):
|
||||
emit_signal("planet_stats_updated", v)
|
||||
day = v
|
||||
|
||||
func _ready():
|
||||
emit_signal("planet_stats_updated", day)
|
||||
|
||||
#region ------------------ Generation ------------------
|
||||
|
||||
func add_entity(e : Node2D, container : Node2D = entityContainer):
|
||||
if e.get_parent():
|
||||
e.get_parent().remove_child(e)
|
||||
|
||||
@ -20,6 +31,7 @@ func add_entity(e : Node2D, container : Node2D):
|
||||
|
||||
container.add_child(e)
|
||||
|
||||
|
||||
func generate_polygon_sprite(order : int = 0) -> Polygon2D:
|
||||
var sprite = Polygon2D.new()
|
||||
var size = terrainData.terrainSize
|
||||
@ -61,10 +73,40 @@ func generate_contamination_terrain_sprite() -> Polygon2D:
|
||||
|
||||
return sprite
|
||||
|
||||
#endregion
|
||||
|
||||
#region ------------------ Usage ------------------
|
||||
|
||||
func plant(
|
||||
type : PlantType,
|
||||
plant_position : Vector2,
|
||||
) -> bool:
|
||||
if is_there_contamination(plant_position):
|
||||
return false
|
||||
|
||||
var new_plant = Plant.new(
|
||||
type,
|
||||
self
|
||||
)
|
||||
add_entity(new_plant)
|
||||
new_plant.global_position = plant_position
|
||||
return true
|
||||
|
||||
func impact_contamination(impact_position : Vector2, impact_radius : int, contamination : bool = false):
|
||||
terrainData.impact_contamination(impact_position, impact_radius, 0. if contamination else 1.)
|
||||
if contamination_texture:
|
||||
contamination_texture.update(terrainData.contamination)
|
||||
|
||||
func is_there_contamination(point : Vector2) -> bool:
|
||||
return terrainData.get_contamination(point) < 0.5
|
||||
return terrainData.get_contamination(point) < 0.5
|
||||
|
||||
func pass_day():
|
||||
for e : Node2D in entityContainer.get_children():
|
||||
if e.has_method("pass_day"):
|
||||
e.pass_day()
|
||||
day += 1
|
||||
|
||||
#endregion
|
||||
|
||||
func _on_root_gui_day_pass_proceed():
|
||||
pass_day()
|
||||