diff --git a/assets/animations/slime_fire.tres b/assets/animations/slime_fire.tres new file mode 100644 index 0000000..dc807fd --- /dev/null +++ b/assets/animations/slime_fire.tres @@ -0,0 +1,22 @@ +[gd_resource type="SpriteFrames" load_steps=3 format=2] + +[ext_resource path="res://assets/prototipos/enemigos/enemy_slime_fire.png" type="Texture" id=1] +[ext_resource path="res://assets/prototipos/characters_sprites/skelet_idle_anim_f2.png" type="Texture" id=2] + +[resource] +animations = [ { +"frames": [ ExtResource( 1 ) ], +"loop": true, +"name": "idle", +"speed": 4.0 +}, { +"frames": [ ExtResource( 2 ) ], +"loop": false, +"name": "dead", +"speed": 5.0 +}, { +"frames": [ ExtResource( 1 ) ], +"loop": false, +"name": "attack", +"speed": 5.0 +} ] diff --git a/assets/animations/slime_normal.tres b/assets/animations/slime_normal.tres new file mode 100644 index 0000000..8aa7982 --- /dev/null +++ b/assets/animations/slime_normal.tres @@ -0,0 +1,22 @@ +[gd_resource type="SpriteFrames" load_steps=3 format=2] + +[ext_resource path="res://assets/prototipos/enemigos/enemy_slime_normal.png" type="Texture" id=1] +[ext_resource path="res://assets/prototipos/characters_sprites/skelet_idle_anim_f2.png" type="Texture" id=2] + +[resource] +animations = [ { +"frames": [ ExtResource( 1 ) ], +"loop": true, +"name": "idle", +"speed": 4.0 +}, { +"frames": [ ExtResource( 2 ) ], +"loop": false, +"name": "dead", +"speed": 5.0 +}, { +"frames": [ ExtResource( 1 ) ], +"loop": false, +"name": "attack", +"speed": 5.0 +} ] diff --git a/assets/animations/slime_original.tres b/assets/animations/slime_original.tres new file mode 100644 index 0000000..79ff5d4 --- /dev/null +++ b/assets/animations/slime_original.tres @@ -0,0 +1,31 @@ +[gd_resource type="SpriteFrames" load_steps=12 format=2] + +[ext_resource path="res://assets/prototipos/characters_sprites/swampy_idle_anim_f1.png" type="Texture" id=1] +[ext_resource path="res://assets/prototipos/characters_sprites/swampy_idle_anim_f3.png" type="Texture" id=2] +[ext_resource path="res://assets/prototipos/characters_sprites/skelet_idle_anim_f1.png" type="Texture" id=3] +[ext_resource path="res://assets/prototipos/characters_sprites/skelet_idle_anim_f0.png" type="Texture" id=4] +[ext_resource path="res://assets/prototipos/characters_sprites/skelet_idle_anim_f2.png" type="Texture" id=5] +[ext_resource path="res://assets/prototipos/characters_sprites/swampy_idle_anim_f2.png" type="Texture" id=6] +[ext_resource path="res://assets/prototipos/characters_sprites/swampy_idle_anim_f0.png" type="Texture" id=7] +[ext_resource path="res://assets/prototipos/characters_sprites/swampy_run_anim_f0.png" type="Texture" id=8] +[ext_resource path="res://assets/prototipos/characters_sprites/swampy_run_anim_f2.png" type="Texture" id=9] +[ext_resource path="res://assets/prototipos/characters_sprites/swampy_run_anim_f3.png" type="Texture" id=10] +[ext_resource path="res://assets/prototipos/characters_sprites/swampy_run_anim_f1.png" type="Texture" id=11] + +[resource] +animations = [ { +"frames": [ ExtResource( 7 ), ExtResource( 1 ), ExtResource( 6 ), ExtResource( 2 ), ExtResource( 8 ), ExtResource( 11 ), ExtResource( 9 ), ExtResource( 10 ) ], +"loop": true, +"name": "idle", +"speed": 4.0 +}, { +"frames": [ ExtResource( 4 ), ExtResource( 3 ), ExtResource( 5 ) ], +"loop": false, +"name": "dead", +"speed": 5.0 +}, { +"frames": [ ExtResource( 9 ), null, ExtResource( 9 ), null, ExtResource( 9 ) ], +"loop": false, +"name": "attack", +"speed": 5.0 +} ] diff --git a/assets/gris.png b/assets/gris.png new file mode 100644 index 0000000..1a19e61 Binary files /dev/null and b/assets/gris.png differ diff --git a/assets/rojo.png b/assets/rojo.png new file mode 100644 index 0000000..68c65fd Binary files /dev/null and b/assets/rojo.png differ diff --git a/project.godot b/project.godot index 902f8c1..86b4e13 100644 --- a/project.godot +++ b/project.godot @@ -39,10 +39,30 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://real_deal/scripts/exploration/actors/enemy_group.gd" }, { +"base": "Object", +"class": "Inventory", +"language": "GDScript", +"path": "res://real_deal/scripts/utils/player/inventory.gd" +}, { +"base": "Object", +"class": "Item", +"language": "GDScript", +"path": "res://real_deal/scripts/utils/player/item.gd" +}, { +"base": "Item", +"class": "Potion", +"language": "GDScript", +"path": "res://real_deal/scripts/utils/player/items/potion.gd" +}, { "base": "Node", "class": "Room", "language": "GDScript", "path": "res://real_deal/scripts/exploration/room.gd" +}, { +"base": "Item", +"class": "SlimeRemains", +"language": "GDScript", +"path": "res://real_deal/scripts/utils/player/items/slime_remains.gd" } ] _global_script_class_icons={ "Actor": "", @@ -51,7 +71,11 @@ _global_script_class_icons={ "Enemy": "", "EnemyA": "", "EnemyGroup": "", -"Room": "" +"Inventory": "", +"Item": "", +"Potion": "", +"Room": "", +"SlimeRemains": "" } [application] @@ -64,7 +88,7 @@ config/icon="res://icon.png" SceneManager="*res://real_deal/scripts/utils/SceneManager.gd" GameSaver="*res://real_deal/scripts/utils/GameSaver.gd" -PlayerManager="*res://real_deal/scripts/utils/player_manager.gd" +PlayerManager="*res://real_deal/scripts/utils/player/player_manager.gd" EnemiesDatabase="*res://real_deal/scripts/utils/enemies_database.gd" [display] diff --git a/real_deal/scenes/duel/DuelEnemy.tscn b/real_deal/scenes/duel/DuelEnemy.tscn index 6788e7d..3cc7091 100644 --- a/real_deal/scenes/duel/DuelEnemy.tscn +++ b/real_deal/scenes/duel/DuelEnemy.tscn @@ -1,50 +1,35 @@ -[gd_scene load_steps=15 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://real_deal/scripts/duel/DuelEnemy.gd" type="Script" id=1] -[ext_resource path="res://assets/prototipos/characters_sprites/swampy_idle_anim_f0.png" type="Texture" id=2] -[ext_resource path="res://assets/prototipos/characters_sprites/swampy_idle_anim_f2.png" type="Texture" id=3] -[ext_resource path="res://assets/prototipos/characters_sprites/swampy_run_anim_f0.png" type="Texture" id=4] -[ext_resource path="res://assets/prototipos/characters_sprites/swampy_idle_anim_f1.png" type="Texture" id=5] -[ext_resource path="res://assets/prototipos/characters_sprites/swampy_run_anim_f1.png" type="Texture" id=6] -[ext_resource path="res://assets/prototipos/characters_sprites/swampy_run_anim_f2.png" type="Texture" id=7] -[ext_resource path="res://assets/prototipos/characters_sprites/swampy_run_anim_f3.png" type="Texture" id=8] -[ext_resource path="res://assets/prototipos/characters_sprites/swampy_idle_anim_f3.png" type="Texture" id=9] -[ext_resource path="res://assets/prototipos/characters_sprites/skelet_idle_anim_f0.png" type="Texture" id=10] -[ext_resource path="res://assets/prototipos/characters_sprites/skelet_idle_anim_f1.png" type="Texture" id=11] -[ext_resource path="res://assets/prototipos/characters_sprites/skelet_idle_anim_f2.png" type="Texture" id=12] +[ext_resource path="res://assets/animations/slime_normal.tres" type="SpriteFrames" id=2] +[ext_resource path="res://assets/gris.png" type="Texture" id=3] +[ext_resource path="res://assets/rojo.png" type="Texture" id=4] -[sub_resource type="SpriteFrames" id=1] -animations = [ { -"frames": [ ExtResource( 2 ), ExtResource( 5 ), ExtResource( 3 ), ExtResource( 9 ), ExtResource( 4 ), ExtResource( 6 ), ExtResource( 7 ), ExtResource( 8 ) ], -"loop": true, -"name": "idle", -"speed": 4.0 -}, { -"frames": [ ExtResource( 10 ), ExtResource( 11 ), ExtResource( 12 ) ], -"loop": false, -"name": "dead", -"speed": 5.0 -}, { -"frames": [ ExtResource( 7 ), null, ExtResource( 7 ), null, ExtResource( 7 ) ], -"loop": false, -"name": "attack", -"speed": 5.0 -} ] - -[sub_resource type="RectangleShape2D" id=2] -extents = Vector2( 8.05047, 8.16186 ) +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 108.893, 93.6324 ) [node name="Battle_Enemy_Swampy" type="Area2D"] scale = Vector2( 2, 2 ) script = ExtResource( 1 ) [node name="Character" type="AnimatedSprite" parent="."] -frames = SubResource( 1 ) +frames = ExtResource( 2 ) animation = "idle" flip_h = true [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -shape = SubResource( 2 ) +shape = SubResource( 1 ) + +[node name="HealthBar" type="TextureProgress" parent="."] +margin_left = -108.505 +margin_top = 83.9132 +margin_right = 108.495 +margin_bottom = 98.9132 +texture_under = ExtResource( 3 ) +texture_progress = ExtResource( 4 ) +__meta__ = { +"_edit_use_anchors_": false +} [connection signal="card_target" from="." to="." method="_on_Battle_Enemy_Swampy_card_target"] [connection signal="not_card_target" from="." to="." method="_on_Battle_Enemy_Swampy_not_card_target"] [connection signal="playCard" from="." to="." method="_on_Battle_Enemy_Swampy_playCard"] diff --git a/real_deal/scripts/duel/DuelEnemy.gd b/real_deal/scripts/duel/DuelEnemy.gd index 2de5374..3dbf987 100644 --- a/real_deal/scripts/duel/DuelEnemy.gd +++ b/real_deal/scripts/duel/DuelEnemy.gd @@ -7,24 +7,68 @@ signal playCard var player = false # Comprobar si sobra var mouse_over = false +# Enemy Data +var enemy_name = "" +var enemy_class = "" +var type = "" +var level = "" +var strategy = "" +var skills = [] +var loot = [] + + func _ready(): add_to_group("enemies") # Se añaden al grupo de "targetebles" cuando se empieza a usar una carta # para evitar colisiones cuando no debe ## add_to_group("targeteable") +func set_data(enemy_data): + self._init_params( + enemy_data["deck"], + null, + enemy_data["max_hand_size"], + enemy_data["max_health"], + enemy_data["max_health"], + enemy_data["max_energy"], + enemy_data["max_energy"] + ) + $HealthBar.max_value = enemy_data["max_health"] + $HealthBar.value = $HealthBar.max_value + self.enemy_name = enemy_data["name"] + $Character.frames = load("res://assets/animations/{}.tres".format([enemy_data["animation"]], "{}")) + $Character.animation = "idle" + self.enemy_class = enemy_data["class"] + self.type = enemy_data["type"] + self.level = enemy_data["level"] + self.strategy = enemy_data["strategy"] + self.skills = enemy_data["skills"] + self.loot = self._generate_loot(enemy_data["loot"]) + +func modify_health(amount): + .modify_health(amount) + $HealthBar.value += amount +func _generate_loot(loot_posibilities): + var loot = [] + var dice = RandomNumberGenerator.new() + dice.randomize() + for loot_option in loot_posibilities: + if (dice.randf() < loot_option[1]): + loot.append((loot_option[0])) + return loot + func _on_Battle_Enemy_Swampy_card_target(): """ Start being a targeteable object """ get_tree().call_group("card", "get_target", self) - #print("Enable target") + print("Enable target") func _on_Battle_Enemy_Swampy_not_card_target(): self.mouse_over = false get_tree().call_group("card", "get_target", false) - #print("Disable target") + print("Disable target") func select_card(): diff --git a/real_deal/scripts/duel/DuelManager.gd b/real_deal/scripts/duel/DuelManager.gd index b6c8066..5747367 100644 --- a/real_deal/scripts/duel/DuelManager.gd +++ b/real_deal/scripts/duel/DuelManager.gd @@ -84,16 +84,9 @@ func _init_entities(enemy_datas): self.enemies.append(enemy) self.turn_sequence.append(enemy) get_node("Enemigos/Enemy_{i}".format({'i':enemies.size() - 1})).add_child(enemies[enemies.size() - 1]) - - enemy._init_params(#[], null) - enemy_data["deck"], - false, - enemy_data["max_hand_size"], - enemy_data["max_health"], - enemy_data["max_health"], - enemy_data["max_energy"], - enemy_data["max_energy"] - ) + enemy.set_data(enemy_data) + + func add_to_hand(card): @@ -179,6 +172,8 @@ func _player_lose_duel(): func _player_win_duel(): print("has ganado") + var reward = _get_reward() + PlayerManager.add_reward(reward) PlayerManager.health = self.player._health # TODO: Cambiar acceso a estas variables PlayerManager.energy = self.player._energy PlayerManager.save() @@ -193,6 +188,19 @@ func _are_enemies_dead(): return false return true +func _get_reward(): + """ + Al terminar el duelo se obtienen las posibles recompensas de los enemigos + y cargan en un diccionario que será incluido en el inventario del jugador. + Ese diccionario también se pasará al cambiar de escenar para mostrar las + recompensas obtenidas. + """ + var reward = [] + for enemy in self.enemies: + for item in enemy.loot: + reward.append(item) + print(reward) + return reward func update_data(data): var enemies_data = [] diff --git a/real_deal/scripts/exploration/actors/enemy_group.gd b/real_deal/scripts/exploration/actors/enemy_group.gd index c151095..60e79ed 100644 --- a/real_deal/scripts/exploration/actors/enemy_group.gd +++ b/real_deal/scripts/exploration/actors/enemy_group.gd @@ -8,7 +8,7 @@ class_name EnemyGroup # El grupo se define por los nombres de los enemigos que lo componen. # Todos sus datos son accesibles con el nombre en la base de datos. -export var enemies = ["normal_slime", "normal_slime"] +export var enemies = ["normal_slime"]#, "fire_slime"] # Called when the node enters the scene tree for the first time. diff --git a/real_deal/scripts/map/actors/Enemy.gd b/real_deal/scripts/map/actors/Enemy.gd index 3cf42df..3a4555c 100644 --- a/real_deal/scripts/map/actors/Enemy.gd +++ b/real_deal/scripts/map/actors/Enemy.gd @@ -5,7 +5,7 @@ class_name Enemy # Declare member variables here. Examples: # var a = 2 # var b = "text" -export var enemies = ["normal_slime", "normal_slime"] +export var enemies = ["normal_slime", "fire_slime", "fire_slime"] # Called when the node enters the scene tree for the first time. func _ready(): @@ -15,3 +15,5 @@ func _ready(): # Called every frame. 'delta' is the elapsed time since the previous frame. #func _process(delta): # pass + +# MIRAR PORQUE ESTE SCRIPT Y EL DE ENEMY GROUP ESTÁN DUPLICADOS diff --git a/real_deal/scripts/utils/enemies_database.gd b/real_deal/scripts/utils/enemies_database.gd index 19499b0..4f3d6e8 100644 --- a/real_deal/scripts/utils/enemies_database.gd +++ b/real_deal/scripts/utils/enemies_database.gd @@ -6,7 +6,8 @@ func _ready(): const DATA = { "normal_slime": { "name": "Slime", - "scene": preload("res://real_deal/scenes/duel/DuelEnemy.tscn"), + "scene": preload("res://real_deal/scenes/duel/DuelEnemy.tscn"), # Quizá ésta habría que quitarla + "animation": "slime_normal", "class": "slime", "type": "ordinary", "level": 1, # Algunas cosas podrías ser calculadas con funciones en el futuro @@ -27,13 +28,14 @@ const DATA = { "strategy": "basic", "skills": [], "loot": [ - ["Slime remains", 1.0], # Object and probability - ["Slime remains", 0.3] + [SlimeRemains, 1.0], # Object and probability + [SlimeRemains, 0.3] ] }, "fire_slime": { "name": "Fire Slime", "scene": preload("res://real_deal/scenes/duel/DuelEnemy.tscn"), + "animation": "slime_fire", "class": "slime", "type": "ordinary", "level": 2, # Algunas cosas podrías ser calculadas con funciones en el futuro diff --git a/real_deal/scripts/utils/player/inventory.gd b/real_deal/scripts/utils/player/inventory.gd new file mode 100644 index 0000000..4fb5efd --- /dev/null +++ b/real_deal/scripts/utils/player/inventory.gd @@ -0,0 +1,24 @@ +class_name Inventory +extends Object +""" +Esta clase está destinada a ser la estructura de datos que gestione +los ITEMS que posee el jugador en su inventario. +""" + +var _items = [] +# Deberíamos cambiarlo a un diccionario donde se guarden los objetos usando su referencia y el número de unidades + +func _init(): + print("jajaja") + +func add_item(item): + _items.append(item) + +func remove_item(item): + _items.remove(item) + +func get_item(item_type): + print("get_item IS NOT IMPLEMENTED") + +func get_items(): + return _items.duplicate() diff --git a/real_deal/scripts/utils/player/item.gd b/real_deal/scripts/utils/player/item.gd new file mode 100644 index 0000000..7159fef --- /dev/null +++ b/real_deal/scripts/utils/player/item.gd @@ -0,0 +1,4 @@ +class_name Item +extends Object + +var description = "" diff --git a/real_deal/scripts/utils/player/items/potion.gd b/real_deal/scripts/utils/player/items/potion.gd new file mode 100644 index 0000000..1aaf24d --- /dev/null +++ b/real_deal/scripts/utils/player/items/potion.gd @@ -0,0 +1,3 @@ +class_name Potion +extends Item + diff --git a/real_deal/scripts/utils/player/items/slime_remains.gd b/real_deal/scripts/utils/player/items/slime_remains.gd new file mode 100644 index 0000000..139011f --- /dev/null +++ b/real_deal/scripts/utils/player/items/slime_remains.gd @@ -0,0 +1,5 @@ +class_name SlimeRemains +extends Item + +func _ready(): + description = "Soy los restos de un slime" diff --git a/real_deal/scripts/utils/player_manager.gd b/real_deal/scripts/utils/player/player_manager.gd similarity index 91% rename from real_deal/scripts/utils/player_manager.gd rename to real_deal/scripts/utils/player/player_manager.gd index 69f23a8..a6e3dab 100644 --- a/real_deal/scripts/utils/player_manager.gd +++ b/real_deal/scripts/utils/player/player_manager.gd @@ -41,7 +41,7 @@ func _ready(): "fire", "fire" ] - inventory = [] + inventory = Inventory.new() func restore_player(): @@ -80,3 +80,10 @@ func load(): continue self.set(i, node_data[i]) save_game.close() + +func add_reward(reward): + for item in reward: + self.inventory.add_item(item) + +func _process(delta): + pass#print(self.inventory.get_items())