Compare commits
8 Commits
e76e51b4e2
...
d2742231e6
| Author | SHA1 | Date | |
|---|---|---|---|
| d2742231e6 | |||
|
|
bca2300443 | ||
| b164141d00 | |||
| 25d81d57a5 | |||
| a0f17df7c6 | |||
| 23d062ab6d | |||
| c5c1d31a67 | |||
| 7c5c0de7b8 |
5
common/game_data/scripts/game_data.gd
Normal file
@ -0,0 +1,5 @@
|
||||
extends Resource
|
||||
class_name GameData
|
||||
|
||||
@export var currentTerrainData : TerrainData
|
||||
|
||||
1
common/game_data/scripts/game_data.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://73gftrlwnuhu
|
||||
70
common/game_data/scripts/terrain_data.gd
Normal file
@ -0,0 +1,70 @@
|
||||
extends Resource
|
||||
class_name TerrainData
|
||||
|
||||
const TERRAIN_IMAGE_GAME_FACTOR = 50
|
||||
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MAX_SIZE = 1000
|
||||
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MIN_SIZE = 200
|
||||
|
||||
signal terrain_updated
|
||||
|
||||
@export var terrainSize : Vector2 = Vector2(2000,2000)
|
||||
|
||||
@export var contamination : Image = null
|
||||
|
||||
func generate_default_contamination(
|
||||
central_zone_max_size : int = DEFAULT_CONTAMINATION_CENTRAL_ZONE_MAX_SIZE,
|
||||
central_zone_min_size : int = DEFAULT_CONTAMINATION_CENTRAL_ZONE_MIN_SIZE,
|
||||
):
|
||||
var noise: Noise = FastNoiseLite.new()
|
||||
noise.seed = randi()
|
||||
noise.noise_type = FastNoiseLite.TYPE_CELLULAR
|
||||
noise.frequency = 0.005 * TERRAIN_IMAGE_GAME_FACTOR
|
||||
|
||||
var imageSize = terrainSize / TERRAIN_IMAGE_GAME_FACTOR;
|
||||
|
||||
var noise_image = noise.get_image(
|
||||
imageSize.x,
|
||||
imageSize.y,
|
||||
1.0
|
||||
)
|
||||
|
||||
ImageTools.draw_gradient(
|
||||
noise_image,
|
||||
imageSize/2,
|
||||
central_zone_min_size / TERRAIN_IMAGE_GAME_FACTOR
|
||||
)
|
||||
|
||||
ImageTools.draw_gradient(
|
||||
noise_image,
|
||||
imageSize/2,
|
||||
central_zone_max_size / TERRAIN_IMAGE_GAME_FACTOR,
|
||||
Color.BLACK,
|
||||
true
|
||||
)
|
||||
|
||||
|
||||
ImageTools.flatten(noise_image, 0.5)
|
||||
|
||||
contamination = Image.create(
|
||||
imageSize.x,
|
||||
imageSize.y,
|
||||
false,
|
||||
Image.Format.FORMAT_L8
|
||||
)
|
||||
|
||||
contamination.copy_from(noise_image)
|
||||
|
||||
func impact_contamination(position : Vector2, impact_radius : int, to_value : float = 1.):
|
||||
ImageTools.draw_circle(
|
||||
contamination,
|
||||
position / TERRAIN_IMAGE_GAME_FACTOR,
|
||||
impact_radius / TERRAIN_IMAGE_GAME_FACTOR,
|
||||
Color(1., 1., 1., to_value)
|
||||
)
|
||||
|
||||
func get_contamination(point : Vector2) -> float:
|
||||
var pixel_point : Vector2 = Vector2(point) / float(TERRAIN_IMAGE_GAME_FACTOR)
|
||||
return contamination.get_pixel(
|
||||
int(round(pixel_point.x)),
|
||||
int(round(pixel_point.y))
|
||||
).r
|
||||
1
common/game_data/scripts/terrain_data.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://cx30nvq8b34lj
|
||||
@ -1 +0,0 @@
|
||||
uid://do1a37cqva05e
|
||||
@ -3,10 +3,10 @@ class_name Inventory
|
||||
|
||||
signal inventory_changed(inventory: Inventory)
|
||||
|
||||
@export var items: Array[GenericItem] = []
|
||||
@export var max_items: int = 10
|
||||
@export var items: Array[Item] = []
|
||||
@export var max_items: int = 1
|
||||
|
||||
func add_item(item: GenericItem):
|
||||
func add_item(item: Item):
|
||||
if items.size() < max_items:
|
||||
items.append(item)
|
||||
emit_signal("inventory_changed", self)
|
||||
@ -14,7 +14,7 @@ func add_item(item: GenericItem):
|
||||
else:
|
||||
return false
|
||||
|
||||
func add_items(items_to_add: Array[GenericItem], fillup: bool = false):
|
||||
func add_items(items_to_add: Array[Item], fillup: bool = false):
|
||||
if fillup:
|
||||
var has_changed := false
|
||||
for i in min(items_to_add.size(), max_items - items.size()):
|
||||
@ -33,11 +33,11 @@ func get_item(ind: int = 0):
|
||||
return items[ind]
|
||||
|
||||
func get_and_remove_item(ind: int = 0):
|
||||
var item_removed: GenericItem = items.pop_at(ind)
|
||||
var item_removed: Item = items.pop_at(ind)
|
||||
emit_signal("inventory_changed", self)
|
||||
return item_removed
|
||||
|
||||
func swap_items(item_to_add: GenericItem, ind_to_get: int = 0):
|
||||
func swap_items(item_to_add: Item, ind_to_get: int = 0):
|
||||
var item_to_get := items[ind_to_get]
|
||||
items[ind_to_get] = item_to_add
|
||||
emit_signal("inventory_changed", self)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
extends Resource
|
||||
class_name GenericItem
|
||||
class_name Item
|
||||
|
||||
@export var name: String
|
||||
@export var icon: Texture2D
|
||||
1
common/inventory/scripts/item.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bq7admu4ahs5r
|
||||
@ -1,4 +1,4 @@
|
||||
extends GenericItem
|
||||
extends Item
|
||||
class_name SeedItem
|
||||
|
||||
@export var plant_type: String
|
||||
|
||||
52
common/tools/scripts/image_tools.gd
Normal file
@ -0,0 +1,52 @@
|
||||
class_name ImageTools
|
||||
|
||||
static func draw_circle(image: Image, center: Vector2i, length: int, color: Color = Color.WHITE):
|
||||
for x in range(image.get_width()):
|
||||
for y in range(image.get_height()):
|
||||
var center_distance = Vector2i(x, y).distance_to(center)
|
||||
|
||||
if (center_distance <= length):
|
||||
image.set_pixel(x, y, color)
|
||||
|
||||
|
||||
static func draw_gradient(image: Image, center: Vector2i, length: int, color: Color = Color.WHITE, inverse := false):
|
||||
for x in range(image.get_width()):
|
||||
for y in range(image.get_height()):
|
||||
var original_pixel_color = image.get_pixel(x, y)
|
||||
var center_distance = Vector2i(x, y).distance_to(center)
|
||||
|
||||
if (center_distance == 0):
|
||||
if not inverse:
|
||||
image.set_pixel(x, y, original_pixel_color.blend(color))
|
||||
else:
|
||||
var color_to_add = Color(color, 1 / (center_distance / length)) if not inverse else Color(color, center_distance / length)
|
||||
image.set_pixel(
|
||||
x,
|
||||
y,
|
||||
original_pixel_color.blend(color_to_add)
|
||||
)
|
||||
|
||||
static func flatten(image: Image, threshold := 0.5):
|
||||
for x in range(image.get_width()):
|
||||
for y in range(image.get_height()):
|
||||
var original_pixel_color = image.get_pixel(x, y)
|
||||
|
||||
if original_pixel_color.r > threshold:
|
||||
image.set_pixel(
|
||||
x,
|
||||
y,
|
||||
Color.WHITE
|
||||
)
|
||||
else:
|
||||
image.set_pixel(
|
||||
x,
|
||||
y,
|
||||
Color.BLACK
|
||||
)
|
||||
|
||||
static func copy(from: Image, to : Image):
|
||||
for x in range(from.get_width()):
|
||||
for y in range(from.get_height()):
|
||||
to.set_pixel(x, y, from.get_pixel(x, y))
|
||||
|
||||
|
||||
1
common/tools/scripts/image_tools.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://b05d3may5qqtv
|
||||
@ -5,7 +5,10 @@ const LERP_WEIGHT = 0.9
|
||||
|
||||
@export var following : Node2D
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
func _ready():
|
||||
if following:
|
||||
global_position = following.global_position
|
||||
|
||||
func _process(_delta):
|
||||
if following:
|
||||
global_position = following.global_position.lerp(global_position, LERP_WEIGHT)
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
[gd_scene load_steps=10 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="Resource" uid="uid://lrl2okkhyxmx" path="res://common/inventory/resources/items/default_seed.tres" id="2_5foug"]
|
||||
[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="Resource" uid="uid://chmmu2jlo2eu0" path="res://entities/interactables/resources/actions/default_get_seed.tres" id="5_5foug"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_cdbrd"]
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_ocwgi"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("4_dq24f")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"default",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("5_2gcie")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"watered",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[node name="DefaultPlant" type="Area2D"]
|
||||
script = ExtResource("1_d8u7e")
|
||||
seed_item = ExtResource("2_5foug")
|
||||
actions = Array[ExtResource("2_rs46h")]([ExtResource("3_5foug"), ExtResource("5_5foug")])
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
scale = Vector2(4.01154, 4.01154)
|
||||
shape = SubResource("CircleShape2D_cdbrd")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
scale = Vector2(0.160462, 0.160462)
|
||||
sprite_frames = SubResource("SpriteFrames_ocwgi")
|
||||
@ -1,10 +0,0 @@
|
||||
extends Interactable
|
||||
class_name Plant
|
||||
|
||||
@export var seed_item : GenericItem
|
||||
|
||||
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]
|
||||
|
||||
@ -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,11 +3,15 @@ class_name Player
|
||||
|
||||
signal player_updated(player: Player)
|
||||
|
||||
var controlling_player : bool = true
|
||||
var planet : Planet # mis à jour par la classe Planet
|
||||
@export var speed = 400
|
||||
|
||||
@onready var inventory: Inventory = Inventory.new()
|
||||
@export var testPlantType : PlantType
|
||||
|
||||
var energy: int = 10:
|
||||
var max_energy : int = 10
|
||||
|
||||
var energy : int = max_energy :
|
||||
set(v):
|
||||
energy = v
|
||||
emit_signal("player_updated", self)
|
||||
@ -20,10 +24,11 @@ func _on_inventory_updated(_inventory: Inventory):
|
||||
emit_signal("player_updated", self)
|
||||
|
||||
func get_input():
|
||||
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")
|
||||
@ -31,24 +36,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)
|
||||
|
||||
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)
|
||||
func action():
|
||||
if planet:
|
||||
planet.plant(
|
||||
testPlantType,
|
||||
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()
|
||||
|
||||
BIN
entities/player/sounds/dig_1.wav
Normal file
24
entities/player/sounds/dig_1.wav.import
Normal file
@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://dfrp66a4isnt6"
|
||||
path="res://.godot/imported/dig_1.wav-7ad072dab09b362a7e8becc6a8e9d649.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/player/sounds/dig_1.wav"
|
||||
dest_files=["res://.godot/imported/dig_1.wav-7ad072dab09b362a7e8becc6a8e9d649.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
|
||||
BIN
entities/player/sounds/dig_2.wav
Normal file
24
entities/player/sounds/dig_2.wav.import
Normal file
@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://bdxkvaciw4mb3"
|
||||
path="res://.godot/imported/dig_2.wav-2f707145e043039106f8e3bee1ed8e77.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/player/sounds/dig_2.wav"
|
||||
dest_files=["res://.godot/imported/dig_2.wav-2f707145e043039106f8e3bee1ed8e77.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
|
||||
BIN
entities/player/sounds/dig_3.wav
Normal file
24
entities/player/sounds/dig_3.wav.import
Normal file
@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://llxrlwfccywb"
|
||||
path="res://.godot/imported/dig_3.wav-e440fc7357505855b3b56d72821d8a95.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/player/sounds/dig_3.wav"
|
||||
dest_files=["res://.godot/imported/dig_3.wav-e440fc7357505855b3b56d72821d8a95.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
|
||||
BIN
entities/player/sounds/harvest_1.wav
Normal file
24
entities/player/sounds/harvest_1.wav.import
Normal file
@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://6qmm1lmkft13"
|
||||
path="res://.godot/imported/harvest_1.wav-ba207989e74395ee730e7c4943696c32.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/player/sounds/harvest_1.wav"
|
||||
dest_files=["res://.godot/imported/harvest_1.wav-ba207989e74395ee730e7c4943696c32.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
|
||||
BIN
entities/player/sounds/harvest_2.wav
Normal file
24
entities/player/sounds/harvest_2.wav.import
Normal file
@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://cfwqjs2koxyi8"
|
||||
path="res://.godot/imported/harvest_2.wav-158fd873c16237044d07d7079edc5abf.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/player/sounds/harvest_2.wav"
|
||||
dest_files=["res://.godot/imported/harvest_2.wav-158fd873c16237044d07d7079edc5abf.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
|
||||
BIN
entities/player/sounds/harvest_3.wav
Normal file
24
entities/player/sounds/harvest_3.wav.import
Normal file
@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://xiif55xgsoxs"
|
||||
path="res://.godot/imported/harvest_3.wav-ba1f76ac9d83e08f35513c7dbeb090f5.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/player/sounds/harvest_3.wav"
|
||||
dest_files=["res://.godot/imported/harvest_3.wav-ba1f76ac9d83e08f35513c7dbeb090f5.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
|
||||
BIN
entities/player/sounds/harvest_4.wav
Normal file
24
entities/player/sounds/harvest_4.wav.import
Normal file
@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://bc803023sso65"
|
||||
path="res://.godot/imported/harvest_4.wav-35e3d63c56e7a1d73bee6cc87ace3be8.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/player/sounds/harvest_4.wav"
|
||||
dest_files=["res://.godot/imported/harvest_4.wav-35e3d63c56e7a1d73bee6cc87ace3be8.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
|
||||
BIN
entities/player/sounds/harvest_5.wav
Normal file
24
entities/player/sounds/harvest_5.wav.import
Normal file
@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://bv65uncyiu3dc"
|
||||
path="res://.godot/imported/harvest_5.wav-2a7c17a378f34ee56ecf2d841af1dcf5.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/player/sounds/harvest_5.wav"
|
||||
dest_files=["res://.godot/imported/harvest_5.wav-2a7c17a378f34ee56ecf2d841af1dcf5.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
|
||||
BIN
entities/player/sounds/harvest_6.wav
Normal file
24
entities/player/sounds/harvest_6.wav.import
Normal file
@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://b0hxscxlo241f"
|
||||
path="res://.godot/imported/harvest_6.wav-2836dc15776824ff43e7c447a4e48c92.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/player/sounds/harvest_6.wav"
|
||||
dest_files=["res://.godot/imported/harvest_6.wav-2836dc15776824ff43e7c447a4e48c92.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
|
||||
BIN
entities/player/sounds/pick_up_1.wav
Normal file
24
entities/player/sounds/pick_up_1.wav.import
Normal file
@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://bkitf5nhaa36p"
|
||||
path="res://.godot/imported/pick_up_1.wav-35d486c68a4148d6f225129804209371.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/player/sounds/pick_up_1.wav"
|
||||
dest_files=["res://.godot/imported/pick_up_1.wav-35d486c68a4148d6f225129804209371.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
|
||||
BIN
entities/player/sounds/pick_up_2.wav
Normal file
24
entities/player/sounds/pick_up_2.wav.import
Normal file
@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://dx58x1sg61mrv"
|
||||
path="res://.godot/imported/pick_up_2.wav-8b13148dd5bc8870c5578d85f90542eb.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/player/sounds/pick_up_2.wav"
|
||||
dest_files=["res://.godot/imported/pick_up_2.wav-8b13148dd5bc8870c5578d85f90542eb.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
|
||||
BIN
entities/player/sounds/pick_up_3.wav
Normal file
24
entities/player/sounds/pick_up_3.wav.import
Normal file
@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://c0fw77uiiwnfb"
|
||||
path="res://.godot/imported/pick_up_3.wav-4925e1a793c7954804fab43c81d2df3e.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/player/sounds/pick_up_3.wav"
|
||||
dest_files=["res://.godot/imported/pick_up_3.wav-4925e1a793c7954804fab43c81d2df3e.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
|
||||
@ -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,8 +53,9 @@ 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_updated" from="." to="PlayerInfo" method="_on_root_gui_player_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"]
|
||||
|
||||
@ -1,7 +1,27 @@
|
||||
extends Control
|
||||
class_name RootGui
|
||||
|
||||
signal player_updated(player: Player)
|
||||
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_updated(player: Player):
|
||||
emit_signal("player_updated", player)
|
||||
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()
|
||||
|
||||
@ -19,7 +19,7 @@ config/icon="res://icon.svg"
|
||||
|
||||
move_right={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":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":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, 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":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
@ -41,12 +41,13 @@ 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)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
environment/defaults/default_clear_color=Color(0.0617213, 0.0605653, 0.169189, 1)
|
||||
|
||||
45
root.tscn
@ -1,10 +1,10 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://c5bruelvqbm1k"]
|
||||
|
||||
[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/planet/planet.tscn" id="1_pyidc"]
|
||||
[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,41 +16,18 @@
|
||||
y_sort_enabled = true
|
||||
|
||||
[node name="Player" parent="Entities" instance=ExtResource("2_vvh5c")]
|
||||
testPlantType = ExtResource("3_jnlp7")
|
||||
|
||||
[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)
|
||||
|
||||
[node name="Planet" parent="." instance=ExtResource("1_pyidc")]
|
||||
[node name="Planet" parent="." node_paths=PackedStringArray("import_entities_from_node") instance=ExtResource("1_pyidc")]
|
||||
import_entities_from_node = NodePath("../Entities")
|
||||
|
||||
[node name="Camera" parent="." node_paths=PackedStringArray("following") instance=ExtResource("3_vvh5c")]
|
||||
position = Vector2(2.22, 0)
|
||||
following = NodePath("../Entities/Player")
|
||||
|
||||
[connection signal="player_updated" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_player_updated"]
|
||||
[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"]
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://tsi5j1uxppa4"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bnrjnvceprxfn" path="res://stages/planet/assets/textures/sol_gamejam_normal.png" id="1_wb4p4"]
|
||||
|
||||
[node name="Planet" type="Node2D"]
|
||||
|
||||
[node name="SolGamejamNormal" type="Sprite2D" parent="."]
|
||||
z_index = -1
|
||||
texture = ExtResource("1_wb4p4")
|
||||
|
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 114 KiB |
@ -3,15 +3,15 @@
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bnrjnvceprxfn"
|
||||
path="res://.godot/imported/sol_gamejam_normal.png-a56c3648b71b32f03d2bec4e03abf9bc.ctex"
|
||||
path="res://.godot/imported/sol_gamejam_normal.png-a8a63b9f57f727b96585445cbd74ba15.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://stages/planet/assets/textures/sol_gamejam_normal.png"
|
||||
dest_files=["res://.godot/imported/sol_gamejam_normal.png-a56c3648b71b32f03d2bec4e03abf9bc.ctex"]
|
||||
source_file="res://stages/terrain/planet/assets/textures/sol_gamejam_normal.png"
|
||||
dest_files=["res://.godot/imported/sol_gamejam_normal.png-a8a63b9f57f727b96585445cbd74ba15.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
10
stages/terrain/planet/planet.tscn
Normal file
@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://tsi5j1uxppa4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d1mp5sguc0b6u" path="res://stages/terrain/planet/scripts/planet.gd" id="1_y7d8a"]
|
||||
[ext_resource type="Material" uid="uid://ljvaj1vab53a" path="res://stages/terrain/planet/resources/materials/ground_contamination.tres" id="2_02xai"]
|
||||
[ext_resource type="Texture2D" uid="uid://bhs47ar83jfmr" path="res://stages/terrain/planet/resources/textures/sol_gamejam_normal.png" id="2_6qoee"]
|
||||
|
||||
[node name="Planet" type="Node2D"]
|
||||
script = ExtResource("1_y7d8a")
|
||||
background_texture = ExtResource("2_6qoee")
|
||||
contamination_material = ExtResource("2_02xai")
|
||||
@ -0,0 +1,26 @@
|
||||
[gd_resource type="ShaderMaterial" load_steps=7 format=3 uid="uid://ljvaj1vab53a"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://bglep64ppn74p" path="res://stages/terrain/planet/resources/materials/shaders/textures_data_filter.gdshader" id="1_ye8oh"]
|
||||
[ext_resource type="Texture2D" uid="uid://dcn4cq53h1qiy" path="res://stages/terrain/planet/resources/textures/sol_gamejam_fleurs_transp.png" id="3_j3avn"]
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_6hswu"]
|
||||
frequency = 0.0109
|
||||
|
||||
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_j3avn"]
|
||||
noise = SubResource("FastNoiseLite_6hswu")
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_r7pv0"]
|
||||
offsets = PackedFloat32Array(0)
|
||||
colors = PackedColorArray(0, 0, 0, 0.12549)
|
||||
|
||||
[sub_resource type="GradientTexture1D" id="GradientTexture1D_6hswu"]
|
||||
gradient = SubResource("Gradient_r7pv0")
|
||||
|
||||
[resource]
|
||||
shader = ExtResource("1_ye8oh")
|
||||
shader_parameter/data_texture = SubResource("NoiseTexture2D_j3avn")
|
||||
shader_parameter/data_texture_size = Vector2(1000, 1000)
|
||||
shader_parameter/data_texture_threshold = 0.5
|
||||
shader_parameter/texture_0 = SubResource("GradientTexture1D_6hswu")
|
||||
shader_parameter/texture_1 = ExtResource("3_j3avn")
|
||||
shader_parameter/texture_scale = 5.0
|
||||
@ -0,0 +1,35 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
#define pow2(x) (x * x)
|
||||
#define iResolution 1.0/SCREEN_PIXEL_SIZE
|
||||
|
||||
uniform sampler2D data_texture;
|
||||
uniform vec2 data_texture_size;
|
||||
uniform float data_texture_threshold = 0.5;
|
||||
uniform sampler2D texture_0 : filter_nearest, repeat_enable;
|
||||
uniform sampler2D texture_1 : filter_nearest, repeat_enable;
|
||||
|
||||
uniform float texture_scale = 10.;
|
||||
|
||||
//uniform float smooth_change_range = 0.15;
|
||||
|
||||
varying vec2 vert;
|
||||
|
||||
void vertex() {
|
||||
vert = 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);
|
||||
|
||||
COLOR = color;
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
uid://bglep64ppn74p
|
||||
|
After Width: | Height: | Size: 931 KiB |
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dcn4cq53h1qiy"
|
||||
path="res://.godot/imported/sol_gamejam_fleurs_transp.png-9f83431996765c9ee6ae75623dc9a6ca.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://stages/terrain/planet/resources/textures/sol_gamejam_fleurs_transp.png"
|
||||
dest_files=["res://.godot/imported/sol_gamejam_fleurs_transp.png-9f83431996765c9ee6ae75623dc9a6ca.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
stages/terrain/planet/resources/textures/sol_gamejam_normal.png
Normal file
|
After Width: | Height: | Size: 114 KiB |
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bhs47ar83jfmr"
|
||||
path="res://.godot/imported/sol_gamejam_normal.png-026e1b07759fe660eb66a9c8a302cb82.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://stages/terrain/planet/resources/textures/sol_gamejam_normal.png"
|
||||
dest_files=["res://.godot/imported/sol_gamejam_normal.png-026e1b07759fe660eb66a9c8a302cb82.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
|
||||
|
After Width: | Height: | Size: 653 KiB |
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://73topi3k4iia"
|
||||
path="res://.godot/imported/sol_gamejam_pollution_transparent.png-e0f6a469ee35256b6f08efb9025c9a38.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://stages/terrain/planet/resources/textures/sol_gamejam_pollution_transparent.png"
|
||||
dest_files=["res://.godot/imported/sol_gamejam_pollution_transparent.png-e0f6a469ee35256b6f08efb9025c9a38.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
|
||||
112
stages/terrain/planet/scripts/planet.gd
Normal file
@ -0,0 +1,112 @@
|
||||
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
|
||||
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)
|
||||
|
||||
if e is Player:
|
||||
e.planet = self
|
||||
|
||||
container.add_child(e)
|
||||
|
||||
|
||||
func generate_polygon_sprite(order : int = 0) -> Polygon2D:
|
||||
var sprite = Polygon2D.new()
|
||||
var size = terrainData.terrainSize
|
||||
sprite.polygon = PackedVector2Array([
|
||||
Vector2(0,0),
|
||||
Vector2(size.x, 0),
|
||||
Vector2(size.x, size.y),
|
||||
Vector2(0, size.y),
|
||||
])
|
||||
|
||||
sprite.z_index = -100 + order
|
||||
|
||||
add_child(sprite)
|
||||
|
||||
return sprite
|
||||
|
||||
func generate_background_sprite() -> Polygon2D:
|
||||
var sprite : Polygon2D = generate_polygon_sprite(0)
|
||||
|
||||
sprite.texture = background_texture
|
||||
sprite.texture_repeat = CanvasItem.TEXTURE_REPEAT_ENABLED
|
||||
sprite.texture_scale = Vector2.ONE * PLANET_TEXTURE_SCALE
|
||||
|
||||
return sprite
|
||||
|
||||
func generate_contamination_terrain_sprite() -> Polygon2D:
|
||||
if not terrainData.contamination:
|
||||
terrainData.generate_default_contamination()
|
||||
|
||||
var sprite :Polygon2D = generate_polygon_sprite(1)
|
||||
|
||||
contamination_texture = ImageTexture.create_from_image(terrainData.contamination)
|
||||
|
||||
contamination_material.set_shader_parameter("data_texture", contamination_texture)
|
||||
contamination_material.set_shader_parameter("data_texture_size", terrainData.terrainSize)
|
||||
contamination_material.set_shader_parameter("texture_scale", PLANET_TEXTURE_SCALE)
|
||||
|
||||
sprite.material = contamination_material
|
||||
|
||||
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
|
||||
|
||||
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()
|
||||
1
stages/terrain/planet/scripts/planet.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://d1mp5sguc0b6u
|
||||
57
stages/terrain/scripts/terrain.gd
Normal file
@ -0,0 +1,57 @@
|
||||
extends Node2D
|
||||
class_name Terrain
|
||||
|
||||
const BORDER_WIDTH = 100
|
||||
|
||||
@export var import_entities_from_node : Node2D = null
|
||||
|
||||
@export var terrainData : TerrainData
|
||||
|
||||
@onready var borderLimit : StaticBody2D = create_border_limit()
|
||||
@onready var entityContainer : Node2D = create_entity_container()
|
||||
|
||||
func _init():
|
||||
if not terrainData:
|
||||
terrainData = TerrainData.new()
|
||||
|
||||
func add_entity(e : Node2D, container : Node2D):
|
||||
if e.get_parent():
|
||||
e.get_parent().remove_child(e)
|
||||
|
||||
container.add_child(e)
|
||||
|
||||
func create_entity_container() -> Node2D:
|
||||
var container = Node2D.new()
|
||||
container.y_sort_enabled = true
|
||||
container.position = terrainData.terrainSize/2
|
||||
|
||||
add_child(container)
|
||||
|
||||
if import_entities_from_node:
|
||||
for child in import_entities_from_node.get_children():
|
||||
add_entity(child, container)
|
||||
|
||||
return container
|
||||
|
||||
func create_border_limit() -> StaticBody2D:
|
||||
var staticBody = StaticBody2D.new()
|
||||
var staticBodyCollision = CollisionPolygon2D.new()
|
||||
|
||||
add_child(staticBody)
|
||||
staticBody.add_child(staticBodyCollision)
|
||||
|
||||
var size = terrainData.terrainSize
|
||||
staticBodyCollision.polygon = PackedVector2Array([
|
||||
Vector2(0,0),
|
||||
Vector2(0, size.y),
|
||||
Vector2(size.x, size.y),
|
||||
Vector2(size.x, 0),
|
||||
Vector2(0,0),
|
||||
Vector2(-BORDER_WIDTH, -BORDER_WIDTH),
|
||||
Vector2(size.x + BORDER_WIDTH, -BORDER_WIDTH),
|
||||
Vector2(size.x + BORDER_WIDTH, size.y + BORDER_WIDTH),
|
||||
Vector2(- BORDER_WIDTH, size.y + BORDER_WIDTH),
|
||||
Vector2(-BORDER_WIDTH, -BORDER_WIDTH)
|
||||
])
|
||||
|
||||
return staticBody
|
||||
1
stages/terrain/scripts/terrain.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://dfl1ijmbmw57r
|
||||