Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/guluc3m/morgana
Browse files Browse the repository at this point in the history
  • Loading branch information
Patataman committed Jun 12, 2021
2 parents 7a8a9e2 + 2dd2b3e commit 742f6d4
Show file tree
Hide file tree
Showing 17 changed files with 237 additions and 54 deletions.
22 changes: 22 additions & 0 deletions assets/animations/slime_fire.tres
Original file line number Diff line number Diff line change
@@ -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
} ]
22 changes: 22 additions & 0 deletions assets/animations/slime_normal.tres
Original file line number Diff line number Diff line change
@@ -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
} ]
31 changes: 31 additions & 0 deletions assets/animations/slime_original.tres
Original file line number Diff line number Diff line change
@@ -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
} ]
Binary file added assets/gris.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/rojo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 26 additions & 2 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand All @@ -51,7 +71,11 @@ _global_script_class_icons={
"Enemy": "",
"EnemyA": "",
"EnemyGroup": "",
"Room": ""
"Inventory": "",
"Item": "",
"Potion": "",
"Room": "",
"SlimeRemains": ""
}

[application]
Expand All @@ -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]
Expand Down
53 changes: 19 additions & 34 deletions real_deal/scenes/duel/DuelEnemy.tscn
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
48 changes: 46 additions & 2 deletions real_deal/scripts/duel/DuelEnemy.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
28 changes: 18 additions & 10 deletions real_deal/scripts/duel/DuelManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand All @@ -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 = []
Expand Down
2 changes: 1 addition & 1 deletion real_deal/scripts/exploration/actors/enemy_group.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion real_deal/scripts/map/actors/Enemy.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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
8 changes: 5 additions & 3 deletions real_deal/scripts/utils/enemies_database.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
24 changes: 24 additions & 0 deletions real_deal/scripts/utils/player/inventory.gd
Original file line number Diff line number Diff line change
@@ -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()
Loading

0 comments on commit 742f6d4

Please sign in to comment.