level up
This commit is contained in:
parent
0e2b43760e
commit
48209c62ef
12 changed files with 135 additions and 21 deletions
|
|
@ -1,7 +1,6 @@
|
|||
extends Node2D
|
||||
class_name Battler
|
||||
|
||||
@export var sprite_texture : Texture
|
||||
@export var battler_stats : BattlerStats
|
||||
@export_enum("Plant", "Pollution") var side = 0
|
||||
|
||||
|
|
@ -9,10 +8,9 @@ class_name Battler
|
|||
|
||||
@onready var floating_text_packed : PackedScene = load("res://Objects/floating_text.tscn")
|
||||
|
||||
var life : int = 1 :
|
||||
var life : int = 1 :
|
||||
set(value):
|
||||
life = value
|
||||
print(name, " life : ", life)
|
||||
if life <= 0:
|
||||
death()
|
||||
|
||||
|
|
@ -27,12 +25,14 @@ var _attack_ready : bool = false
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
$Sprite2D.texture = sprite_texture
|
||||
set_side()
|
||||
set_battler_stats()
|
||||
_attack_ready = true
|
||||
printerr(name)
|
||||
|
||||
|
||||
#Fonction virtuelle
|
||||
func apply_progression() -> void:
|
||||
pass
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if target:
|
||||
|
|
|
|||
23
Objects/dump.gd
Normal file
23
Objects/dump.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
extends Node2D
|
||||
class_name Dump
|
||||
|
||||
var level = 0
|
||||
|
||||
@export var spawn_trash_wait_time := 3.0
|
||||
@onready var trash_packed : PackedScene = load("res://Objects/trash.tscn")
|
||||
var trash_battler : Battler
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if trash_battler == null && $SpawnCooldown.is_stopped():
|
||||
$SpawnCooldown.start(spawn_trash_wait_time)
|
||||
|
||||
|
||||
func spawn_trash() -> void:
|
||||
level += 1
|
||||
trash_battler = trash_packed.instantiate()
|
||||
trash_battler.level = level
|
||||
add_child(trash_battler)
|
||||
|
||||
func _on_spawn_cooldown_timeout() -> void:
|
||||
spawn_trash()
|
||||
1
Objects/dump.gd.uid
Normal file
1
Objects/dump.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c5dqyafu3h8xl
|
||||
11
Objects/dump.tscn
Normal file
11
Objects/dump.tscn
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[gd_scene format=3 uid="uid://c6vyscw4nhckx"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c5dqyafu3h8xl" path="res://Objects/dump.gd" id="1_yhoaw"]
|
||||
|
||||
[node name="Dump" type="Node2D" unique_id=1287085357]
|
||||
script = ExtResource("1_yhoaw")
|
||||
|
||||
[node name="SpawnCooldown" type="Timer" parent="." unique_id=262648708]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="timeout" from="SpawnCooldown" to="." method="_on_spawn_cooldown_timeout"]
|
||||
|
|
@ -3,7 +3,6 @@ var text : String = "-1" :
|
|||
set(value):
|
||||
text = str(value)
|
||||
$Label.text = text
|
||||
print("Text :", $Label.text)
|
||||
|
||||
func _ready() -> void:
|
||||
_animate()
|
||||
|
|
|
|||
33
Objects/plant.gd
Normal file
33
Objects/plant.gd
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
extends Battler
|
||||
class_name Plant
|
||||
|
||||
var level : int = 1:
|
||||
set(value):
|
||||
level = value
|
||||
apply_progression()
|
||||
|
||||
|
||||
@export var xp_curve : Curve
|
||||
var xp_points = 0 :
|
||||
set(value):
|
||||
xp_points = value
|
||||
print(xp_curve.sample(level))
|
||||
if xp_points >= xp_curve.sample(level):
|
||||
level +=1
|
||||
|
||||
|
||||
func get_new_target() -> void:
|
||||
super()
|
||||
if not target:
|
||||
return
|
||||
target = target as Trash
|
||||
target.trash_cleaned.connect(_on_Trash_trash_cleaned)
|
||||
|
||||
|
||||
func apply_progression() -> void:
|
||||
life += 10
|
||||
damage += 2
|
||||
|
||||
|
||||
func _on_Trash_trash_cleaned(xp_worth)-> void:
|
||||
xp_points += xp_worth
|
||||
1
Objects/plant.gd.uid
Normal file
1
Objects/plant.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://5l3g5qcjh5gy
|
||||
19
Objects/plant.tscn
Normal file
19
Objects/plant.tscn
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[gd_scene format=3 uid="uid://d1ivgsboj1got"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cndfpjgyfttdr" path="res://Objects/Battler.tscn" id="1_qws6r"]
|
||||
[ext_resource type="Script" uid="uid://5l3g5qcjh5gy" path="res://Objects/plant.gd" id="2_8p83i"]
|
||||
[ext_resource type="Texture2D" uid="uid://cs0k1ofdlayvr" path="res://Assets/Flowers/Flower 2/Flower 2 - TEAL.png" id="2_ms33i"]
|
||||
[ext_resource type="Resource" uid="uid://te1aq7i3mahk" path="res://Resources/plant_stats.tres" id="3_8p83i"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_ms33i"]
|
||||
_limits = [0.0, 100.0, 0.0, 10.0]
|
||||
_data = [Vector2(0, 0), 0.0, 10.0, 0, 1, Vector2(10, 100), 10.0, 0.0, 1, 0]
|
||||
point_count = 2
|
||||
|
||||
[node name="Plant" unique_id=1265041863 instance=ExtResource("1_qws6r")]
|
||||
script = ExtResource("2_8p83i")
|
||||
xp_curve = SubResource("Curve_ms33i")
|
||||
battler_stats = ExtResource("3_8p83i")
|
||||
|
||||
[node name="Sprite2D" parent="." index="0" unique_id=763052965]
|
||||
texture = ExtResource("2_ms33i")
|
||||
22
Objects/trash.gd
Normal file
22
Objects/trash.gd
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
extends Battler
|
||||
class_name Trash
|
||||
|
||||
signal trash_cleaned
|
||||
|
||||
|
||||
var level : int = 1
|
||||
var xp_worth = 10
|
||||
|
||||
func _ready() -> void:
|
||||
super()
|
||||
apply_progression()
|
||||
|
||||
func apply_progression() -> void:
|
||||
life *= level
|
||||
damage *= level
|
||||
armor *= level
|
||||
|
||||
|
||||
func death() -> void:
|
||||
super()
|
||||
trash_cleaned.emit(xp_worth)
|
||||
1
Objects/trash.gd.uid
Normal file
1
Objects/trash.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://5fptimht81p1
|
||||
14
Objects/trash.tscn
Normal file
14
Objects/trash.tscn
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[gd_scene format=3 uid="uid://3h0q7h8pdrt4"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cndfpjgyfttdr" path="res://Objects/Battler.tscn" id="1_6dsr2"]
|
||||
[ext_resource type="Script" uid="uid://5fptimht81p1" path="res://Objects/trash.gd" id="2_6dsr2"]
|
||||
[ext_resource type="Texture2D" uid="uid://cdhk55d5d05di" path="res://Assets/Trashes/recycling 2.png" id="2_ouqvo"]
|
||||
[ext_resource type="Resource" uid="uid://7rv28rbuxt2p" path="res://Resources/trash_stats.tres" id="3_tplsk"]
|
||||
|
||||
[node name="Trash" unique_id=1265041863 instance=ExtResource("1_6dsr2")]
|
||||
script = ExtResource("2_6dsr2")
|
||||
battler_stats = ExtResource("3_tplsk")
|
||||
side = 1
|
||||
|
||||
[node name="Sprite2D" parent="." index="0" unique_id=763052965]
|
||||
texture = ExtResource("2_ouqvo")
|
||||
20
game.tscn
20
game.tscn
|
|
@ -1,27 +1,17 @@
|
|||
[gd_scene format=3 uid="uid://vkh2dbrct7vh"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cndfpjgyfttdr" path="res://Objects/Battler.tscn" id="1_feb5d"]
|
||||
[ext_resource type="Texture2D" uid="uid://drwi73l0d04vj" path="res://Assets/Flowers/Flower Pot 5/Flower Pot 5 - LILAC.png" id="2_ryrav"]
|
||||
[ext_resource type="Resource" uid="uid://te1aq7i3mahk" path="res://Resources/plant_stats.tres" id="3_7jktm"]
|
||||
[ext_resource type="Texture2D" uid="uid://cdhk55d5d05di" path="res://Assets/Trashes/recycling 2.png" id="3_feb5d"]
|
||||
[ext_resource type="Resource" uid="uid://7rv28rbuxt2p" path="res://Resources/trash_stats.tres" id="5_ryrav"]
|
||||
[ext_resource type="PackedScene" uid="uid://d1ivgsboj1got" path="res://Objects/plant.tscn" id="1_feb5d"]
|
||||
[ext_resource type="PackedScene" uid="uid://c6vyscw4nhckx" path="res://Objects/dump.tscn" id="4_fc0e3"]
|
||||
|
||||
[node name="Game" type="Node2D" unique_id=2069582450]
|
||||
|
||||
[node name="Garden" type="Node2D" parent="." unique_id=491593255]
|
||||
position = Vector2(188, 171)
|
||||
|
||||
[node name="Plant" parent="Garden" unique_id=1265041863 instance=ExtResource("1_feb5d")]
|
||||
position = Vector2(189, 183)
|
||||
sprite_texture = ExtResource("2_ryrav")
|
||||
battler_stats = ExtResource("3_7jktm")
|
||||
|
||||
[node name="Dump" type="Node2D" parent="." unique_id=608611995]
|
||||
|
||||
[node name="Trash" parent="Dump" unique_id=1865311551 instance=ExtResource("1_feb5d")]
|
||||
position = Vector2(330, 181)
|
||||
sprite_texture = ExtResource("3_feb5d")
|
||||
battler_stats = ExtResource("5_ryrav")
|
||||
side = 1
|
||||
[node name="Dump" parent="." unique_id=1287085357 instance=ExtResource("4_fc0e3")]
|
||||
position = Vector2(341, 175)
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="." unique_id=1468251961]
|
||||
position = Vector2(259, 155)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue