Skip to content

Commit

Permalink
attack button
Browse files Browse the repository at this point in the history
  • Loading branch information
Patataman committed Nov 1, 2020
1 parent 810bc3e commit 76f9ea9
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 113 deletions.

This file was deleted.

34 changes: 0 additions & 34 deletions assets/sprites/cards_marks/mark_placeholder.png.import

This file was deleted.

27 changes: 24 additions & 3 deletions dani_sandbox/scenes/BattleCard.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
[gd_scene format=2]
[gd_scene load_steps=2 format=2]

[node name="Area2D" type="Area2D"]
[ext_resource path="res://dani_sandbox/scripts/BattleCard.gd" type="Script" id=1]

[node name="Card" type="Control"]
anchor_right = 0.039
anchor_bottom = 0.08
margin_right = 0.0639992
rect_min_size = Vector2( 40, 48 )
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Button" type="Button" parent="."]
margin_right = 12.0
margin_right = 40.0
margin_bottom = 48.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Label" type="Label" parent="."]
margin_left = 6.0
margin_top = 6.0
margin_right = 33.0
margin_bottom = 20.0
text = "card"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"]
18 changes: 17 additions & 1 deletion dani_sandbox/scenes/BattleGrid.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=4 format=2]

[ext_resource path="res://dani_sandbox/scripts/BattleGrid.gd" type="Script" id=1]
[ext_resource path="res://dani_sandbox/scenes/BattleHand.tscn" type="PackedScene" id=2]
[ext_resource path="res://assets/prototipos/albertoV_dungeon_background.png" type="Texture" id=4]

[node name="Main" type="Node2D"]
Expand Down Expand Up @@ -55,3 +56,18 @@ margin_bottom = 137.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="hand_location" type="HBoxContainer" parent="."]
margin_right = 288.0
margin_bottom = 24.0
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Hand" parent="hand_location" instance=ExtResource( 2 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 144.0
margin_right = 144.0
margin_bottom = 24.0
45 changes: 45 additions & 0 deletions dani_sandbox/scenes/BattleHand.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[gd_scene load_steps=3 format=2]

[ext_resource path="res://dani_sandbox/scenes/BattleCard.tscn" type="PackedScene" id=1]
[ext_resource path="res://dani_sandbox/scripts/BattleHand.gd" type="Script" id=2]

[node name="Hand" type="Control"]
anchor_right = 0.086
anchor_bottom = 0.093
margin_right = -0.064003
margin_bottom = 0.199997
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="testing_background" type="ColorRect" parent="."]
visible = false
margin_left = 32.0
margin_right = 48.0
margin_bottom = 48.0

[node name="HBoxContainer" type="HBoxContainer" parent="."]
margin_right = 84.0
margin_bottom = 56.0
grow_horizontal = 0
grow_vertical = 0
size_flags_horizontal = 2
custom_constants/separation = 4
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Card" parent="HBoxContainer" instance=ExtResource( 1 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 40.0
margin_bottom = 56.0

[node name="Card2" parent="HBoxContainer" instance=ExtResource( 1 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 44.0
margin_right = 84.0
margin_bottom = 56.0
15 changes: 8 additions & 7 deletions dani_sandbox/scenes/BattlePlayer.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ animations = [ {
"speed": 5.0
}, {
"frames": [ ExtResource( 3 ) ],
"loop": true,
"loop": false,
"name": "attack",
"speed": 5.0
} ]
Expand All @@ -39,18 +39,18 @@ animations = [ {

[sub_resource type="Animation" id=4]
resource_name = "attack"
length = 0.5
length = 0.4
tracks/0/type = "value"
tracks/0/path = NodePath(".:rotation_degrees")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.2 ),
"transitions": PoolRealArray( 1, 1 ),
"times": PoolRealArray( 0, 0.2, 0.4 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"update": 0,
"values": [ 0.0, 120.0 ]
"values": [ 0.0, 120.0, 0.0 ]
}

[node name="Battle_Player" type="Area2D"]
Expand All @@ -60,8 +60,6 @@ script = ExtResource( 1 )
[node name="Character" type="AnimatedSprite" parent="."]
frames = SubResource( 1 )
animation = "idle"
frame = 1
playing = true

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( -0.520279, 3.19599 )
Expand All @@ -75,3 +73,6 @@ offset = Vector2( 0, -2.125 )

[node name="AnimationPlayer" type="AnimationPlayer" parent="Weapon"]
anims/attack = SubResource( 4 )
[connection signal="playerAttack" from="." to="." method="_on_Battle_Player_playerAttack"]
[connection signal="animation_finished" from="Character" to="." method="_on_Character_animation_finished"]
[connection signal="animation_finished" from="Weapon" to="." method="_on_Weapon_animation_finished"]
17 changes: 17 additions & 0 deletions dani_sandbox/scripts/BattleCard.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
extends Control

signal playerAttack

var player = ""
var target = ""
var type = ""

# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.


func _on_Button_pressed():
player.get_node("Character").animation = type
player.emit_signal("playerAttack")
player.get_node("Character").play()
5 changes: 5 additions & 0 deletions dani_sandbox/scripts/BattleGrid.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ var enemies = []
# Called when the node enters the scene tree for the first time.
func _ready():
player = load("res://dani_sandbox/scenes/BattlePlayer.tscn").instance()

for card in $hand_location/Hand/HBoxContainer.get_children():
card.player = player
card.type = "attack"

for i in range(3):
enemies.append(load("res://dani_sandbox/scenes/BattleEnemy.tscn").instance())
get_node("Player").add_child(player)
Expand Down
17 changes: 17 additions & 0 deletions dani_sandbox/scripts/BattleHand.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
extends Control


# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var player = ""

# Called when the node enters the scene tree for the first time.
func _ready():
var cards = $HBoxContainer.get_child_count()
set_custom_minimum_size(Vector2(40*cards, 48))
_set_size(Vector2(40*cards, 48))

# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
19 changes: 19 additions & 0 deletions dani_sandbox/scripts/BattlePlayer.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
extends "res://dani_sandbox/scripts/BattleCharacter.gd"

signal playerAttack

func _ready():
play_idle()


func _process(delta):
pass


func _on_Character_animation_finished():
if $Character.animation == "attack":
play_idle()


func play_idle():
$Character.animation = "idle"
$Character.play()


func _on_Battle_Player_playerAttack():
$Weapon/AnimationPlayer.play("attack")
22 changes: 22 additions & 0 deletions dani_sandbox/scripts/Button.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
extends Button

signal playCard


export var anim = ""
export var player = ""
export var target = ""

# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass


func _on_Button_pressed():
player.animation = anim
player.play()
34 changes: 0 additions & 34 deletions icon.png.import

This file was deleted.

0 comments on commit 76f9ea9

Please sign in to comment.