This commit is contained in:
parent
1f301815be
commit
9de869b7af
@ -8,5 +8,12 @@ func can_use(player : Player) -> bool:
|
||||
return true
|
||||
return false
|
||||
|
||||
func use(_player : Player) -> bool:
|
||||
return false
|
||||
func use(player : Player) -> bool:
|
||||
if not can_use(player):
|
||||
return false
|
||||
|
||||
var areas = player.action_area.get_overlapping_areas()
|
||||
for area in areas :
|
||||
if area is Plant:
|
||||
area.harvest()
|
||||
return true
|
||||
@ -4,8 +4,9 @@ class_name ItemObjectSprite
|
||||
@onready var iconSprite = $Icon
|
||||
|
||||
func apply_texture_to_sprite(texture, item_sprite_size = 50.):
|
||||
iconSprite.texture = texture
|
||||
iconSprite.scale = Vector2(
|
||||
1./(texture.get_width()/item_sprite_size),
|
||||
1./(texture.get_height()/item_sprite_size)
|
||||
)
|
||||
if texture:
|
||||
iconSprite.texture = texture
|
||||
iconSprite.scale = Vector2(
|
||||
1./(texture.get_width()/item_sprite_size),
|
||||
1./(texture.get_height()/item_sprite_size)
|
||||
)
|
||||
|
||||
BIN
entities/plants/assets/sprites/maias/growing.png
Normal file
BIN
entities/plants/assets/sprites/maias/growing.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
34
entities/plants/assets/sprites/maias/growing.png.import
Normal file
34
entities/plants/assets/sprites/maias/growing.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dwr3c6r6piwaa"
|
||||
path="res://.godot/imported/growing.png-7b76a9f596f5cec79fdd8685670b16b5.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/plants/assets/sprites/maias/growing.png"
|
||||
dest_files=["res://.godot/imported/growing.png-7b76a9f596f5cec79fdd8685670b16b5.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/maias/mature.png
Normal file
BIN
entities/plants/assets/sprites/maias/mature.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 193 KiB |
34
entities/plants/assets/sprites/maias/mature.png.import
Normal file
34
entities/plants/assets/sprites/maias/mature.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://d3apfwbqsg5ha"
|
||||
path="res://.godot/imported/mature.png-8766aea5da569488db27850c55c8418b.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/plants/assets/sprites/maias/mature.png"
|
||||
dest_files=["res://.godot/imported/mature.png-8766aea5da569488db27850c55c8418b.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/maias/planted.png
Normal file
BIN
entities/plants/assets/sprites/maias/planted.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
34
entities/plants/assets/sprites/maias/planted.png.import
Normal file
34
entities/plants/assets/sprites/maias/planted.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cpx7bkrvttasr"
|
||||
path="res://.godot/imported/planted.png-4bf3c8ff7d8aae08d7e3691f7e49cab2.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/plants/assets/sprites/maias/planted.png"
|
||||
dest_files=["res://.godot/imported/planted.png-4bf3c8ff7d8aae08d7e3691f7e49cab2.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
|
||||
130
entities/plants/plant_sprite.tscn
Normal file
130
entities/plants/plant_sprite.tscn
Normal file
@ -0,0 +1,130 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://2hrg6yjk0yt0"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bmjjpk4lvijws" path="res://entities/plants/scripts/plant_sprite.gd" id="1_pq8o7"]
|
||||
[ext_resource type="Texture2D" uid="uid://b3wom2xu26g43" path="res://entities/plants/assets/sprites/default_plant_glowing.png" id="2_hyinx"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_rbgiq"]
|
||||
resource_name = "harvest"
|
||||
length = 0.2
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:skew")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, -0.698132, 0.698132]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Sprite2D:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0.133333, 0.2),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_j6jm5"]
|
||||
resource_name = "bump"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:scale")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.233333, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0.15, 0.15), Vector2(0.15, 0.075), Vector2(0.15, 0.15)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Sprite2D:position")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.233333, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0), Vector2(0, 17.475), Vector2(0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_wyuub"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:scale")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0.15, 0.15)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Sprite2D:position")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Sprite2D:skew")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath("Sprite2D:modulate")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_8eofq"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_wyuub"),
|
||||
&"bump": SubResource("Animation_j6jm5"),
|
||||
&"harvest": SubResource("Animation_rbgiq")
|
||||
}
|
||||
|
||||
[node name="PlantSprite" type="Node2D"]
|
||||
script = ExtResource("1_pq8o7")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
scale = Vector2(0.15, 0.15)
|
||||
texture = ExtResource("2_hyinx")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_8eofq")
|
||||
}
|
||||
@ -26,4 +26,6 @@ planted_texture = ExtResource("4_2s6re")
|
||||
growing_texture = ExtResource("1_fp5j6")
|
||||
mature_texture = ExtResource("3_ffarr")
|
||||
mature_effect = SubResource("Resource_q68uy")
|
||||
harvest_types_path = Array[String]([])
|
||||
harvest_number = Array[int]([1, 2])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
|
||||
24
entities/plants/resources/plants/maias.tres
Normal file
24
entities/plants/resources/plants/maias.tres
Normal file
@ -0,0 +1,24 @@
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=7 format=3 uid="uid://dsctivn1vrem2"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="1_eqtut"]
|
||||
[ext_resource type="Texture2D" uid="uid://dwr3c6r6piwaa" path="res://entities/plants/assets/sprites/maias/growing.png" id="1_vyplc"]
|
||||
[ext_resource type="Texture2D" uid="uid://d3apfwbqsg5ha" path="res://entities/plants/assets/sprites/maias/mature.png" id="3_pi4ie"]
|
||||
[ext_resource type="Texture2D" uid="uid://cpx7bkrvttasr" path="res://entities/plants/assets/sprites/maias/planted.png" id="4_iqcy2"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_mwrj8"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_sri3b"]
|
||||
atlas = ExtResource("6_mwrj8")
|
||||
region = Rect2(1697, 331, 125, 158)
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_eqtut")
|
||||
name = "Maias"
|
||||
description = "This gorgeous flower has no effect, but produce a lot of seeds."
|
||||
growing_time = 2
|
||||
seed_texture = SubResource("AtlasTexture_sri3b")
|
||||
planted_texture = ExtResource("4_iqcy2")
|
||||
growing_texture = ExtResource("1_vyplc")
|
||||
mature_texture = ExtResource("3_pi4ie")
|
||||
harvest_types_path = Array[String](["uid://b04vho33bl52b", "uid://dsctivn1vrem2"])
|
||||
harvest_number = Array[int]([3, 4])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
@ -3,31 +3,37 @@ class_name Plant
|
||||
|
||||
const PLANT_AREA_WIDTH = 10
|
||||
const PLANT_SPRITE_SCALE = 0.15
|
||||
const HARVESTED_SEED_POSITION_RANGE = 100
|
||||
|
||||
const RANDOM_MAX_GROW_INTERVAL = 0.4
|
||||
|
||||
const SPRITE_SCENE : PackedScene = preload("res://entities/plants/plant_sprite.tscn")
|
||||
|
||||
enum State {PLANTED, GROWING, MATURE}
|
||||
|
||||
@export var plant_type : PlantType
|
||||
@export var planet : Planet
|
||||
@export var plant_type: PlantType
|
||||
@export var planet: Planet
|
||||
|
||||
var state : State = State.PLANTED : set = change_state
|
||||
var day : int = 0
|
||||
var state: State = State.PLANTED: set = change_state
|
||||
@export var day: int = 0 : set = set_day
|
||||
|
||||
@onready var plant_sprite : Sprite2D = generate_sprite()
|
||||
@onready var collision_shape : CollisionShape2D = generate_collision_shape()
|
||||
@onready var plant_sprite: PlantSprite = generate_sprite()
|
||||
@onready var collision_shape: CollisionShape2D = generate_collision_shape()
|
||||
|
||||
func _init(_plant_type = null, _planet = null):
|
||||
plant_type = _plant_type
|
||||
planet = _planet
|
||||
|
||||
func generate_sprite() -> Sprite2D:
|
||||
var sprite = Sprite2D.new()
|
||||
func generate_sprite() -> PlantSprite:
|
||||
var spriteObject : PlantSprite = SPRITE_SCENE.instantiate()
|
||||
|
||||
add_child(sprite)
|
||||
sprite.texture = get_state_texture(state)
|
||||
sprite.scale = Vector2.ONE * PLANT_SPRITE_SCALE
|
||||
sprite.offset
|
||||
add_child(spriteObject)
|
||||
spriteObject.apply_texture_to_sprite(
|
||||
get_state_texture(state),
|
||||
false
|
||||
)
|
||||
|
||||
return sprite
|
||||
return spriteObject
|
||||
|
||||
func generate_collision_shape() -> CollisionShape2D:
|
||||
var collision = CollisionShape2D.new()
|
||||
@ -40,20 +46,29 @@ func generate_collision_shape() -> CollisionShape2D:
|
||||
return collision
|
||||
|
||||
func pass_day():
|
||||
await get_tree().create_timer(randf_range(0., RANDOM_MAX_GROW_INTERVAL)).timeout
|
||||
day += 1
|
||||
|
||||
func set_day(d):
|
||||
day = d
|
||||
if day == 0:
|
||||
change_state(State.PLANTED)
|
||||
if day > plant_type.growing_time:
|
||||
change_state(State.MATURE)
|
||||
else:
|
||||
change_state(State.GROWING)
|
||||
|
||||
func change_state(_state : State):
|
||||
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:
|
||||
plant_sprite.apply_texture_to_sprite(
|
||||
get_state_texture(state)
|
||||
)
|
||||
|
||||
func get_state_texture(s: State) -> Texture2D:
|
||||
match s:
|
||||
State.PLANTED:
|
||||
return plant_type.planted_texture
|
||||
@ -64,8 +79,27 @@ func get_state_texture(s : State) -> Texture2D:
|
||||
return null
|
||||
|
||||
func harvest():
|
||||
day += 1
|
||||
if day > plant_type.growing_time:
|
||||
change_state(State.MATURE)
|
||||
else:
|
||||
change_state(State.GROWING)
|
||||
if state == State.MATURE:
|
||||
var seed_number = plant_type.harvest_number.pick_random()
|
||||
for i in range(seed_number):
|
||||
var seed_plant_type : PlantType = plant_type
|
||||
if len(plant_type.harvest_types_path):
|
||||
seed_plant_type = load(plant_type.harvest_types_path.pick_random())
|
||||
var item_object = planet.drop_item(
|
||||
Seed.new(seed_plant_type),
|
||||
global_position
|
||||
)
|
||||
var tween : Tween = get_tree().create_tween()
|
||||
tween.tween_property(
|
||||
item_object,
|
||||
"position",
|
||||
Vector2(
|
||||
item_object.position.x + randi()%HARVESTED_SEED_POSITION_RANGE,
|
||||
item_object.position.y + randi()%HARVESTED_SEED_POSITION_RANGE
|
||||
),
|
||||
0.2
|
||||
)
|
||||
|
||||
plant_sprite.start_harvest_animation()
|
||||
await plant_sprite.harvest_animation_finished
|
||||
queue_free()
|
||||
|
||||
17
entities/plants/scripts/plant_sprite.gd
Normal file
17
entities/plants/scripts/plant_sprite.gd
Normal file
@ -0,0 +1,17 @@
|
||||
extends Node2D
|
||||
class_name PlantSprite
|
||||
|
||||
signal harvest_animation_finished
|
||||
|
||||
@onready var sprite = $Sprite2D
|
||||
|
||||
func apply_texture_to_sprite(texture, with_animation = true):
|
||||
if with_animation:
|
||||
$AnimationPlayer.play("bump")
|
||||
await $AnimationPlayer.animation_finished
|
||||
sprite.texture = texture
|
||||
|
||||
func start_harvest_animation():
|
||||
$AnimationPlayer.play("harvest")
|
||||
await $AnimationPlayer.animation_finished
|
||||
harvest_animation_finished.emit()
|
||||
1
entities/plants/scripts/plant_sprite.gd.uid
Normal file
1
entities/plants/scripts/plant_sprite.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bmjjpk4lvijws
|
||||
@ -12,3 +12,6 @@ class_name PlantType
|
||||
@export var mature_texture : Texture
|
||||
|
||||
@export var mature_effect : PlantEffect
|
||||
|
||||
@export_file var harvest_types_path : Array[String] = []
|
||||
@export var harvest_number : Array[int] = [1,2]
|
||||
|
||||
@ -2,13 +2,14 @@ extends CharacterBody2D
|
||||
class_name Player
|
||||
|
||||
signal player_updated(player: Player)
|
||||
signal action_tried_without_energy
|
||||
|
||||
var planet : Planet # mis à jour par la classe Planet
|
||||
@export var speed = 400
|
||||
|
||||
@onready var inventory : Inventory = Inventory.new()
|
||||
|
||||
var max_energy : int = 10
|
||||
var max_energy : int = 5
|
||||
|
||||
var controlling_player : bool = true :
|
||||
set(v):
|
||||
@ -64,6 +65,8 @@ func calculate_direction():
|
||||
$Sprite.flip_h = (input_direction.x < 0)
|
||||
|
||||
func try_use_item():
|
||||
if energy == 0 and inventory.get_item():
|
||||
action_tried_without_energy.emit()
|
||||
if energy > 0 and can_use_item:
|
||||
use_item()
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=16 format=3 uid="uid://12nak7amd1uq"]
|
||||
[gd_scene load_steps=17 format=3 uid="uid://12nak7amd1uq"]
|
||||
|
||||
[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"]
|
||||
@ -46,6 +46,18 @@ tracks/1/keys = {
|
||||
"update": 1,
|
||||
"values": [false]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("MarginContainer/PlayerInfo/EnergyInfo:offset_left")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [-44.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_k4juk"]
|
||||
resource_name = "recharge_fade_in"
|
||||
@ -101,9 +113,26 @@ tracks/1/keys = {
|
||||
"values": [false]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_n4kem"]
|
||||
resource_name = "no_energy_left"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("MarginContainer/PlayerInfo/EnergyInfo:offset_left")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.0666667, 0.133333, 0.2, 0.266667, 0.333333, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [-44.0, -40.0, -44.0, -48.0, -44.0, -40.0, -44.0]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_n4kem"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_iyvkh"),
|
||||
&"no_energy_left": SubResource("Animation_n4kem"),
|
||||
&"recharge_fade_in": SubResource("Animation_k4juk"),
|
||||
&"recharge_fade_out": SubResource("Animation_fovlv")
|
||||
}
|
||||
@ -155,6 +184,7 @@ expand_mode = 2
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="EnergyInfo" type="HBoxContainer" parent="MarginContainer/PlayerInfo"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.281899
|
||||
|
||||
@ -8,6 +8,7 @@ signal day_pass_finished
|
||||
|
||||
func _on_player_updated(player:Player):
|
||||
%EnergyCount.text = str(player.energy)
|
||||
%EnergyInfo.modulate = Color.WHITE if player.energy > 0 else Color.RED
|
||||
|
||||
%AvailableActions/GetItem.visible = player.closest_interactable is ItemObject and player.inventory.get_item() == null
|
||||
%AvailableActions/SwapItem.visible = player.closest_interactable is ItemObject and player.inventory.get_item() != null
|
||||
@ -38,3 +39,7 @@ func _on_game_action_button_down():
|
||||
func _on_planet_updated(planet:Planet):
|
||||
$MarginContainer/DayCount.text = "Day " + str(planet.day)
|
||||
%DecontaminationCoverage.text = str(roundi(planet.decontamination_coverage * 100)) + "%"
|
||||
|
||||
|
||||
func _on_player_action_tried_without_energy():
|
||||
$AnimationPlayer.play("no_energy_left")
|
||||
|
||||
32
root.tscn
32
root.tscn
@ -1,10 +1,9 @@
|
||||
[gd_scene load_steps=18 format=3 uid="uid://c5bruelvqbm1k"]
|
||||
[gd_scene load_steps=20 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/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="Script" uid="uid://dedg615xudpoq" path="res://entities/interactables/item_object/script/item_object.gd" id="3_bf3um"]
|
||||
[ext_resource type="Resource" uid="uid://b04vho33bl52b" 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="Texture2D" uid="uid://bf6nw4onkhavr" path="res://common/inventory/assets/icons/shovel.svg" id="4_huihk"]
|
||||
[ext_resource type="Script" uid="uid://dya38x1h1uiyg" path="res://common/inventory/scripts/items/shovel.gd" id="5_qw60f"]
|
||||
@ -12,7 +11,8 @@
|
||||
[ext_resource type="Texture2D" uid="uid://bo3o2qf3i20ke" path="res://common/inventory/assets/icons/scuba-diving-tank.svg" id="6_gd4vy"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_tw3kd"]
|
||||
[ext_resource type="Script" uid="uid://bypjcvlc15gsm" path="res://common/inventory/scripts/items/seed.gd" id="9_gd4vy"]
|
||||
[ext_resource type="Script" uid="uid://cega715smavh3" path="res://entities/plants/scripts/plant.gd" id="11_eji0w"]
|
||||
[ext_resource type="Resource" uid="uid://b04vho33bl52b" path="res://entities/plants/resources/plants/default.tres" id="9_qw60f"]
|
||||
[ext_resource type="Resource" uid="uid://dsctivn1vrem2" path="res://entities/plants/resources/plants/maias.tres" id="11_eji0w"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_qt76e"]
|
||||
script = ExtResource("5_qw60f")
|
||||
@ -38,12 +38,24 @@ region = Rect2(1140, 345, 141, 128)
|
||||
|
||||
[sub_resource type="Resource" id="Resource_qwhpj"]
|
||||
script = ExtResource("9_gd4vy")
|
||||
plant_type = ExtResource("3_jnlp7")
|
||||
plant_type = ExtResource("9_qw60f")
|
||||
name = "Chardi"
|
||||
description = "This plant can grow without water, and reduce contamination around when it becomes mature."
|
||||
icon = SubResource("AtlasTexture_ffarr")
|
||||
metadata/_custom_type_script = "uid://bypjcvlc15gsm"
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_sri3b"]
|
||||
atlas = ExtResource("6_tw3kd")
|
||||
region = Rect2(1697, 331, 125, 158)
|
||||
|
||||
[sub_resource type="Resource" id="Resource_sq7yr"]
|
||||
script = ExtResource("9_gd4vy")
|
||||
plant_type = ExtResource("11_eji0w")
|
||||
name = "Maias"
|
||||
description = "This gorgeous flower has no effect, but produce a lot of seeds."
|
||||
icon = SubResource("AtlasTexture_sri3b")
|
||||
metadata/_custom_type_script = "uid://bypjcvlc15gsm"
|
||||
|
||||
[node name="Root" type="Node2D"]
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
@ -73,12 +85,11 @@ script = ExtResource("3_bf3um")
|
||||
item = SubResource("Resource_qwhpj")
|
||||
metadata/_custom_type_script = "uid://dedg615xudpoq"
|
||||
|
||||
[node name="Plant" type="Area2D" parent="Entities" node_paths=PackedStringArray("planet")]
|
||||
position = Vector2(-120, -38)
|
||||
script = ExtResource("11_eji0w")
|
||||
plant_type = ExtResource("3_jnlp7")
|
||||
planet = NodePath("../../Planet")
|
||||
metadata/_custom_type_script = "uid://cega715smavh3"
|
||||
[node name="ItemObject4" type="Area2D" parent="Entities"]
|
||||
position = Vector2(489, -84)
|
||||
script = ExtResource("3_bf3um")
|
||||
item = SubResource("Resource_sq7yr")
|
||||
metadata/_custom_type_script = "uid://dedg615xudpoq"
|
||||
|
||||
[node name="Planet" parent="." node_paths=PackedStringArray("import_entities_from_node") instance=ExtResource("1_pyidc")]
|
||||
import_entities_from_node = NodePath("../Entities")
|
||||
@ -92,5 +103,6 @@ following = NodePath("../Entities/Player")
|
||||
[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="action_tried_without_energy" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_action_tried_without_energy"]
|
||||
[connection signal="player_updated" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_updated"]
|
||||
[connection signal="planet_updated" from="Planet" to="CanvasLayer/RootGui" method="_on_planet_updated"]
|
||||
|
||||
@ -33,10 +33,11 @@ func create_entity_container() -> Node2D:
|
||||
|
||||
return container
|
||||
|
||||
func drop_item(item: Item, item_position : Vector2):
|
||||
func drop_item(item: Item, item_position : Vector2) -> ItemObject:
|
||||
var item_object = ItemObject.new(item)
|
||||
add_entity(item_object)
|
||||
item_object.global_position = item_position
|
||||
return item_object
|
||||
|
||||
func create_border_limit() -> StaticBody2D:
|
||||
var staticBody = StaticBody2D.new()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user