#22 développement du pourcentage de contamination
This commit is contained in:
parent
f5be43767a
commit
b0efeff809
@ -2,12 +2,12 @@ extends Resource
|
|||||||
class_name TerrainData
|
class_name TerrainData
|
||||||
|
|
||||||
const TERRAIN_IMAGE_GAME_FACTOR = 50
|
const TERRAIN_IMAGE_GAME_FACTOR = 50
|
||||||
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MAX_SIZE = 1000
|
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MAX_SIZE = 500
|
||||||
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MIN_SIZE = 200
|
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MIN_SIZE = 100
|
||||||
|
|
||||||
signal terrain_updated
|
signal terrain_updated
|
||||||
|
|
||||||
@export var terrainSize : Vector2 = Vector2(2000,2000)
|
@export var terrainSize : Vector2 = Vector2(1500,1500)
|
||||||
|
|
||||||
@export var contamination : Image = null
|
@export var contamination : Image = null
|
||||||
|
|
||||||
@ -67,4 +67,7 @@ func get_contamination(point : Vector2) -> float:
|
|||||||
return contamination.get_pixel(
|
return contamination.get_pixel(
|
||||||
int(round(pixel_point.x)),
|
int(round(pixel_point.x)),
|
||||||
int(round(pixel_point.y))
|
int(round(pixel_point.y))
|
||||||
).r
|
).r
|
||||||
|
|
||||||
|
func get_decontamination_coverage() -> float:
|
||||||
|
return ImageTools.get_color_coverage(contamination)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[gd_resource type="Resource" script_class="SeedItem" load_steps=3 format=3 uid="uid://lrl2okkhyxmx"]
|
[gd_resource type="Resource" script_class="SeedItem" load_steps=3 format=3 uid="uid://lrl2okkhyxmx"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://gui/player_info/assets/icons/bolt.svg" id="1_dy25s"]
|
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://gui/assets/icons/bolt.svg" id="1_dy25s"]
|
||||||
[ext_resource type="Script" uid="uid://bypjcvlc15gsm" path="res://common/inventory/scripts/items/seed_item.gd" id="2_mgcdi"]
|
[ext_resource type="Script" uid="uid://bypjcvlc15gsm" path="res://common/inventory/scripts/items/seed_item.gd" id="2_mgcdi"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
|
|||||||
@ -1,5 +1,14 @@
|
|||||||
class_name ImageTools
|
class_name ImageTools
|
||||||
|
|
||||||
|
static func get_color_coverage(image: Image, color: Color = Color.WHITE):
|
||||||
|
var pixel_color_count = 0.
|
||||||
|
for x in range(image.get_width()):
|
||||||
|
for y in range(image.get_height()):
|
||||||
|
if image.get_pixel(x, y) == color:
|
||||||
|
pixel_color_count += 1.
|
||||||
|
return pixel_color_count/(image.get_width()*image.get_height())
|
||||||
|
|
||||||
|
|
||||||
static func draw_circle(image: Image, center: Vector2i, length: int, color: Color = Color.WHITE):
|
static func draw_circle(image: Image, center: Vector2i, length: int, color: Color = Color.WHITE):
|
||||||
for x in range(image.get_width()):
|
for x in range(image.get_width()):
|
||||||
for y in range(image.get_height()):
|
for y in range(image.get_height()):
|
||||||
|
|||||||
@ -20,7 +20,7 @@ region = Rect2(1140, 345, 141, 128)
|
|||||||
script = ExtResource("1_moyj3")
|
script = ExtResource("1_moyj3")
|
||||||
name = "Chardi"
|
name = "Chardi"
|
||||||
description = "This plant can grow without water, and reduce contamination around when it becomes mature."
|
description = "This plant can grow without water, and reduce contamination around when it becomes mature."
|
||||||
growing_time = 2
|
growing_time = 1
|
||||||
seed_texture = SubResource("AtlasTexture_ffarr")
|
seed_texture = SubResource("AtlasTexture_ffarr")
|
||||||
planted_texture = ExtResource("4_2s6re")
|
planted_texture = ExtResource("4_2s6re")
|
||||||
growing_texture = ExtResource("1_fp5j6")
|
growing_texture = ExtResource("1_fp5j6")
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 887 B After Width: | Height: | Size: 887 B |
@ -3,15 +3,15 @@
|
|||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://dcgnamu7sb3ov"
|
uid="uid://dcgnamu7sb3ov"
|
||||||
path="res://.godot/imported/bolt.svg-346ec638bad7861a6c0a47abfe0480f6.ctex"
|
path="res://.godot/imported/bolt.svg-99699818681b1e0e18f4836dfd772b8c.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://gui/player_info/assets/icons/bolt.svg"
|
source_file="res://gui/assets/icons/bolt.svg"
|
||||||
dest_files=["res://.godot/imported/bolt.svg-346ec638bad7861a6c0a47abfe0480f6.ctex"]
|
dest_files=["res://.godot/imported/bolt.svg-99699818681b1e0e18f4836dfd772b8c.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 294 KiB After Width: | Height: | Size: 294 KiB |
@ -3,15 +3,15 @@
|
|||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://cm3ehinvvj52i"
|
uid="uid://cm3ehinvvj52i"
|
||||||
path="res://.godot/imported/Interface sans boutons.png-6f58a6b9570fde0ac2945334970770a8.ctex"
|
path="res://.godot/imported/Interface sans boutons.png-84e848a01e86bdad058d81d09d7731ba.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://gui/player_info/assets/texture/Interface sans boutons.png"
|
source_file="res://gui/assets/texture/Interface sans boutons.png"
|
||||||
dest_files=["res://.godot/imported/Interface sans boutons.png-6f58a6b9570fde0ac2945334970770a8.ctex"]
|
dest_files=["res://.godot/imported/Interface sans boutons.png-84e848a01e86bdad058d81d09d7731ba.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
@ -1,68 +0,0 @@
|
|||||||
[gd_scene load_steps=6 format=3 uid="uid://baqrmhsgqda6v"]
|
|
||||||
|
|
||||||
[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="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)
|
|
||||||
layout_mode = 3
|
|
||||||
anchor_right = 0.293
|
|
||||||
anchor_bottom = 0.247
|
|
||||||
offset_right = -0.536011
|
|
||||||
offset_bottom = -0.0559998
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
size_flags_horizontal = 0
|
|
||||||
size_flags_vertical = 0
|
|
||||||
script = ExtResource("1_ghu0s")
|
|
||||||
|
|
||||||
[node name="Background" type="TextureRect" parent="."]
|
|
||||||
layout_mode = 1
|
|
||||||
anchors_preset = 15
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
texture = ExtResource("2_cgy6f")
|
|
||||||
expand_mode = 2
|
|
||||||
stretch_mode = 5
|
|
||||||
|
|
||||||
[node name="EnergyInfo" type="HBoxContainer" parent="."]
|
|
||||||
layout_mode = 1
|
|
||||||
anchors_preset = -1
|
|
||||||
anchor_left = 0.281899
|
|
||||||
anchor_top = 0.384375
|
|
||||||
anchor_right = 0.281899
|
|
||||||
anchor_bottom = 0.584375
|
|
||||||
offset_left = -44.0
|
|
||||||
offset_top = -12.5
|
|
||||||
offset_right = 44.0
|
|
||||||
offset_bottom = 12.5
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
metadata/_edit_use_anchors_ = true
|
|
||||||
|
|
||||||
[node name="Icon" type="TextureRect" parent="EnergyInfo"]
|
|
||||||
custom_minimum_size = Vector2(36.64, 0)
|
|
||||||
layout_mode = 2
|
|
||||||
texture = ExtResource("3_s4ggy")
|
|
||||||
stretch_mode = 5
|
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="EnergyInfo"]
|
|
||||||
layout_mode = 2
|
|
||||||
theme = ExtResource("4_cgy6f")
|
|
||||||
text = "0"
|
|
||||||
label_settings = ExtResource("5_s4ggy")
|
|
||||||
horizontal_alignment = 1
|
|
||||||
vertical_alignment = 1
|
|
||||||
|
|
||||||
[node name="Inventory" type="HBoxContainer" parent="."]
|
|
||||||
layout_mode = 0
|
|
||||||
offset_left = 157.0
|
|
||||||
offset_top = 86.0
|
|
||||||
offset_right = 291.0
|
|
||||||
offset_bottom = 126.0
|
|
||||||
alignment = 1
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
extends Control
|
|
||||||
|
|
||||||
func player_update(player: Player):
|
|
||||||
$EnergyInfo/Label.text = str(player.energy)
|
|
||||||
@ -1 +0,0 @@
|
|||||||
uid://bpqh8n0lbluf8
|
|
||||||
@ -1,9 +1,9 @@
|
|||||||
[gd_scene load_steps=16 format=3 uid="uid://12nak7amd1uq"]
|
[gd_scene load_steps=16 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="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="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="Texture2D" uid="uid://cm3ehinvvj52i" path="res://gui/assets/texture/Interface sans boutons.png" id="3_n4kem"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://gui/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"]
|
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/default_label_settings.tres" id="4_ujg5r"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c2pgaklnj5w3d" path="res://gui/assets/texture/Tablette info.png" id="6_fovlv"]
|
[ext_resource type="Texture2D" uid="uid://c2pgaklnj5w3d" path="res://gui/assets/texture/Tablette info.png" id="6_fovlv"]
|
||||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="7_n4kem"]
|
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="7_n4kem"]
|
||||||
@ -137,8 +137,64 @@ grow_vertical = 2
|
|||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
theme = ExtResource("2_nq5i2")
|
theme = ExtResource("2_nq5i2")
|
||||||
|
|
||||||
[node name="PlayerInfo" parent="MarginContainer" instance=ExtResource("1_8kw6x")]
|
[node name="PlayerInfo" type="Control" parent="MarginContainer"]
|
||||||
|
custom_minimum_size = Vector2(337, 160)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 0
|
||||||
|
size_flags_vertical = 0
|
||||||
|
|
||||||
|
[node name="Background" type="TextureRect" parent="MarginContainer/PlayerInfo"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
texture = ExtResource("3_n4kem")
|
||||||
|
expand_mode = 2
|
||||||
|
stretch_mode = 5
|
||||||
|
|
||||||
|
[node name="EnergyInfo" type="HBoxContainer" parent="MarginContainer/PlayerInfo"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = -1
|
||||||
|
anchor_left = 0.281899
|
||||||
|
anchor_top = 0.384375
|
||||||
|
anchor_right = 0.281899
|
||||||
|
anchor_bottom = 0.584375
|
||||||
|
offset_left = -44.0
|
||||||
|
offset_top = -12.5
|
||||||
|
offset_right = 44.0
|
||||||
|
offset_bottom = 12.5
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
metadata/_edit_use_anchors_ = true
|
||||||
|
|
||||||
|
[node name="Icon" type="TextureRect" parent="MarginContainer/PlayerInfo/EnergyInfo"]
|
||||||
|
custom_minimum_size = Vector2(36.64, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
texture = ExtResource("4_k4juk")
|
||||||
|
stretch_mode = 5
|
||||||
|
|
||||||
|
[node name="EnergyCount" type="Label" parent="MarginContainer/PlayerInfo/EnergyInfo"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
theme = ExtResource("2_nq5i2")
|
||||||
|
text = "0"
|
||||||
|
label_settings = ExtResource("4_ujg5r")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="DecontaminationCoverage" type="Label" parent="MarginContainer/PlayerInfo"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 157.0
|
||||||
|
offset_top = 86.0
|
||||||
|
offset_right = 291.0
|
||||||
|
offset_bottom = 126.0
|
||||||
|
text = "100%"
|
||||||
|
label_settings = ExtResource("4_ujg5r")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
[node name="DayPass" type="Button" parent="MarginContainer"]
|
[node name="DayPass" type="Button" parent="MarginContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|||||||
@ -7,7 +7,7 @@ signal day_pass_proceed
|
|||||||
signal day_pass_finished
|
signal day_pass_finished
|
||||||
|
|
||||||
func _on_player_updated(player:Player):
|
func _on_player_updated(player:Player):
|
||||||
$MarginContainer/PlayerInfo.player_update(player)
|
%EnergyCount.text = str(player.energy)
|
||||||
|
|
||||||
%AvailableActions/GetItem.visible = player.closest_interactable is ItemObject and player.inventory.lenght() == 0
|
%AvailableActions/GetItem.visible = player.closest_interactable is ItemObject and player.inventory.lenght() == 0
|
||||||
%AvailableActions/SwapItem.visible = player.closest_interactable is ItemObject and player.inventory.lenght() > 0
|
%AvailableActions/SwapItem.visible = player.closest_interactable is ItemObject and player.inventory.lenght() > 0
|
||||||
@ -23,9 +23,6 @@ func _on_player_updated(player:Player):
|
|||||||
%ItemName.text = item.name
|
%ItemName.text = item.name
|
||||||
%ItemDesc.text = item.description
|
%ItemDesc.text = item.description
|
||||||
|
|
||||||
func _on_planet_planet_stats_updated(day:int):
|
|
||||||
$MarginContainer/DayCount.text = "Day " + str(day)
|
|
||||||
|
|
||||||
func _on_day_pass_pressed():
|
func _on_day_pass_pressed():
|
||||||
day_pass_pressed.emit()
|
day_pass_pressed.emit()
|
||||||
$AnimationPlayer.play("recharge_fade_in")
|
$AnimationPlayer.play("recharge_fade_in")
|
||||||
@ -37,3 +34,7 @@ func _on_day_pass_pressed():
|
|||||||
|
|
||||||
func _on_game_action_button_down():
|
func _on_game_action_button_down():
|
||||||
game_click.emit()
|
game_click.emit()
|
||||||
|
|
||||||
|
func _on_planet_updated(planet:Planet):
|
||||||
|
$MarginContainer/DayCount.text = "Day " + str(planet.day)
|
||||||
|
%DecontaminationCoverage.text = str(roundi(planet.decontamination_coverage * 100)) + "%"
|
||||||
|
|||||||
@ -54,8 +54,9 @@ position = Vector2(2.22, 0)
|
|||||||
following = NodePath("../Entities/Player")
|
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_finished" from="CanvasLayer/RootGui" to="Entities/Player" method="_on_root_gui_day_pass_finished"]
|
||||||
|
[connection signal="day_pass_finished" from="CanvasLayer/RootGui" to="Planet" 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_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="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="game_click" from="CanvasLayer/RootGui" to="Entities/Player" method="_on_root_gui_game_click"]
|
||||||
[connection signal="player_updated" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_updated"]
|
[connection signal="player_updated" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_updated"]
|
||||||
[connection signal="planet_stats_updated" from="Planet" to="CanvasLayer/RootGui" method="_on_planet_planet_stats_updated"]
|
[connection signal="planet_updated" from="Planet" to="CanvasLayer/RootGui" method="_on_planet_updated"]
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
extends Terrain
|
extends Terrain
|
||||||
class_name Planet
|
class_name Planet
|
||||||
|
|
||||||
signal planet_stats_updated(day : int)
|
signal planet_updated(planet : Planet)
|
||||||
|
|
||||||
const PLANET_TEXTURE_SCALE : float = 5.0
|
const PLANET_TEXTURE_SCALE : float = 5.0
|
||||||
|
|
||||||
@ -10,15 +10,19 @@ const PLANET_TEXTURE_SCALE : float = 5.0
|
|||||||
|
|
||||||
@onready var background_sprite : Polygon2D = generate_background_sprite()
|
@onready var background_sprite : Polygon2D = generate_background_sprite()
|
||||||
@onready var contamination_sprite : Polygon2D = generate_contamination_terrain_sprite()
|
@onready var contamination_sprite : Polygon2D = generate_contamination_terrain_sprite()
|
||||||
|
@onready var decontamination_coverage : float = terrainData.get_decontamination_coverage() :
|
||||||
|
set(v):
|
||||||
|
decontamination_coverage = v
|
||||||
|
planet_updated.emit(self)
|
||||||
|
|
||||||
var contamination_texture : ImageTexture
|
var contamination_texture : ImageTexture
|
||||||
var day : int = 0 :
|
var day : int = 0 :
|
||||||
set(v):
|
set(v):
|
||||||
emit_signal("planet_stats_updated", v)
|
|
||||||
day = v
|
day = v
|
||||||
|
planet_updated.emit(self)
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
emit_signal("planet_stats_updated", day)
|
planet_updated.emit(self)
|
||||||
|
|
||||||
#region ------------------ Generation ------------------
|
#region ------------------ Generation ------------------
|
||||||
|
|
||||||
@ -109,4 +113,7 @@ func pass_day():
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
func _on_root_gui_day_pass_proceed():
|
func _on_root_gui_day_pass_proceed():
|
||||||
pass_day()
|
pass_day()
|
||||||
|
|
||||||
|
func _on_root_gui_day_pass_finished():
|
||||||
|
decontamination_coverage = terrainData.get_decontamination_coverage()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user