Wands sorta work
This commit is contained in:
parent
8fc51732d8
commit
a2107b0583
|
@ -1,5 +0,0 @@
|
|||
extends Sprite
|
||||
class_name Wand
|
||||
|
||||
func fire(projectile, effect):
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
[ext_resource path="res://script/PlayerStateMachine.gd" type="Script" id=4]
|
||||
[ext_resource path="res://ui/Inventory.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://art/WizardM.png" type="Texture" id=6]
|
||||
[ext_resource path="res://script/WandManager.gd" type="Script" id=7]
|
||||
[ext_resource path="res://script/WandPosition.gd" type="Script" id=7]
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=1]
|
||||
polygon = PoolVector2Array( -7, 0, -7, -2, -6, -2, -6, -3, -5, -3, -5, -5, -6, -5, -6, -10, -7, -10, -7, -12, -6, -12, -6, -19, -4, -19, -4, -18, -3, -18, -3, -17, 1, -17, 1, -16, 3, -16, 3, -15, 4, -15, 4, -14, 5, -14, 5, -13, 6, -13, 6, -12, 7, -12, 7, -10, 6, -10, 6, -9, 5, -9, 5, -8, 6, -8, 6, -4, 5, -4, 5, 0, -7, 0 )
|
||||
|
@ -84,8 +84,8 @@ drag_margin_bottom = 0.0
|
|||
[node name="PlayerStateMachine" type="Node" parent="."]
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="WandManager" type="Position2D" parent="."]
|
||||
position = Vector2( 0, -8 )
|
||||
[node name="WandPosition" type="Position2D" parent="."]
|
||||
position = Vector2( 0, -7 )
|
||||
script = ExtResource( 7 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
|
|
16
magic/Projectiles/EcoProjectile.tscn
Normal file
16
magic/Projectiles/EcoProjectile.tscn
Normal file
|
@ -0,0 +1,16 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://art/ecoprojectile.png" type="Texture" id=1]
|
||||
[ext_resource path="res://magic/Projectiles/Projectile.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
radius = 5.0
|
||||
|
||||
[node name="EcoProjectile" type="KinematicBody2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
16
magic/Projectiles/ExplosiveProjectile.tscn
Normal file
16
magic/Projectiles/ExplosiveProjectile.tscn
Normal file
|
@ -0,0 +1,16 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://art/MineProjectile.png" type="Texture" id=1]
|
||||
[ext_resource path="res://magic/Projectiles/Projectile.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
radius = 6.0
|
||||
|
||||
[node name="ExplosiveProjectile" type="KinematicBody2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
18
magic/Projectiles/PhantomProjectile.tscn
Normal file
18
magic/Projectiles/PhantomProjectile.tscn
Normal file
|
@ -0,0 +1,18 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://art/PhantomProjectile.png" type="Texture" id=1]
|
||||
[ext_resource path="res://magic/Projectiles/Projectile.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 5.0
|
||||
height = 2.0
|
||||
|
||||
[node name="PhantomProjectile" type="KinematicBody2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
rotation = 1.5708
|
||||
shape = SubResource( 1 )
|
|
@ -11,7 +11,7 @@ func _physics_process(delta):
|
|||
if collision != null:
|
||||
on_impact(collision)
|
||||
|
||||
func launch():
|
||||
func launch(wand, effect):
|
||||
velocity = (Vector2(speed, 0)).rotated(rotation)
|
||||
|
||||
func on_impact(collision):
|
17
magic/Projectiles/WaveProjectile.tscn
Normal file
17
magic/Projectiles/WaveProjectile.tscn
Normal file
|
@ -0,0 +1,17 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://art/WaveProjectile.png" type="Texture" id=1]
|
||||
[ext_resource path="res://magic/Projectiles/Projectile.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 4.0
|
||||
height = 4.0
|
||||
|
||||
[node name="WaveProjectile" type="KinematicBody2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
|
@ -1,13 +1,16 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://art/BouncingWand.png" type="Texture" id=1]
|
||||
[ext_resource path="res://magic/Wands/WandClass.gd" type="Script" id=2]
|
||||
|
||||
[node name="BouncyWand" type="Sprite"]
|
||||
rotation = 1.5708
|
||||
texture = ExtResource( 1 )
|
||||
offset = Vector2( 0, -11 )
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Position2D" type="Position2D" parent="."]
|
||||
position = Vector2( -7.86805e-07, -18 )
|
||||
[node name="ProjectileSpawn" type="Position2D" parent="."]
|
||||
position = Vector2( -8.01086e-05, -22 )
|
||||
rotation = -1.5708
|
||||
|
||||
[node name="ShootDelay" type="Timer" parent="."]
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://magic/Wands/WandClass.gd" type="Script" id=1]
|
||||
[ext_resource path="res://art/Wand.png" type="Texture" id=2]
|
||||
|
||||
[node name="ChargedWand" type="Sprite"]
|
||||
position = Vector2( 9, 0 )
|
||||
rotation = 1.5708
|
||||
texture = ExtResource( 2 )
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="ProjectileSpawn" type="Position2D" parent="."]
|
||||
position = Vector2( -6.11959e-07, -7 )
|
||||
rotation = -1.5708
|
||||
|
||||
[node name="ShootDelay" type="Timer" parent="."]
|
||||
wait_time = 0.3
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://art/PrismaticWand.png" type="Texture" id=1]
|
||||
|
||||
[ext_resource path="res://magic/Wands/WandClass.gd" type="Script" id=2]
|
||||
|
||||
[node name="PrismWand" type="Sprite"]
|
||||
rotation = 1.5708
|
||||
texture = ExtResource( 1 )
|
||||
offset = Vector2( 0, -10 )
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Position2D" type="Position2D" parent="."]
|
||||
[node name="ProjectileSpawn" type="Position2D" parent="."]
|
||||
position = Vector2( 0, -20 )
|
||||
rotation = -1.5708
|
||||
|
||||
[node name="ShootDelay" type="Timer" parent="."]
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://art/TripleWand.png" type="Texture" id=1]
|
||||
[ext_resource path="res://magic/Wands/WandClass.gd" type="Script" id=2]
|
||||
|
||||
[node name="TripleWand" type="Sprite"]
|
||||
rotation = 1.5708
|
||||
texture = ExtResource( 1 )
|
||||
offset = Vector2( 0, -11 )
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="ProjectileSpawn" type="Position2D" parent="."]
|
||||
[node name="ProjectileSpawn1" type="Position2D" parent="."]
|
||||
position = Vector2( -5.00007, -20 )
|
||||
|
||||
[node name="ProjectileSpawn2" type="Position2D" parent="."]
|
||||
position = Vector2( -8.01086e-05, -22 )
|
||||
|
||||
[node name="ProjectileSpawn3" type="Position2D" parent="."]
|
||||
position = Vector2( 4.99993, -20 )
|
||||
|
||||
[node name="ShootDelay" type="Timer" parent="."]
|
||||
|
|
11
magic/Wands/WandClass.gd
Normal file
11
magic/Wands/WandClass.gd
Normal file
|
@ -0,0 +1,11 @@
|
|||
extends Sprite
|
||||
class_name Wands
|
||||
|
||||
func fire(projectile, effect):
|
||||
if $ShootDelay.is_stopped() and projectile != null:
|
||||
print("fire")
|
||||
var temp = projectile.instance()
|
||||
get_tree().current_scene.add_child(temp)
|
||||
temp.global_transform = $ProjectileSpawn.global_transform
|
||||
temp.launch(null, null)
|
||||
$ShootDelay.start()
|
|
@ -22,7 +22,7 @@ _global_script_classes=[ {
|
|||
"base": "KinematicBody2D",
|
||||
"class": "Projectile",
|
||||
"language": "GDScript",
|
||||
"path": "res://script/Projectile.gd"
|
||||
"path": "res://magic/Projectiles/Projectile.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"class": "StateMachine",
|
||||
|
@ -30,16 +30,16 @@ _global_script_classes=[ {
|
|||
"path": "res://script/StateMachine.gd"
|
||||
}, {
|
||||
"base": "Sprite",
|
||||
"class": "Wand",
|
||||
"class": "Wands",
|
||||
"language": "GDScript",
|
||||
"path": "res://WandClass.gd"
|
||||
"path": "res://magic/Wands/WandClass.gd"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"Collectable": "",
|
||||
"Enemy": "",
|
||||
"Projectile": "",
|
||||
"StateMachine": "",
|
||||
"Wand": ""
|
||||
"Wands": ""
|
||||
}
|
||||
|
||||
[application]
|
||||
|
|
|
@ -74,19 +74,39 @@ func add_item(index):
|
|||
func _on_Conduit1_toggled():
|
||||
if Conduit1.is_visible() and active_conduit != Globals.Magic[Globals.Conduit1]:
|
||||
active_conduit = Globals.Magic[Globals.Conduit1]
|
||||
parent.WandManager.set_current_conduit(active_conduit)
|
||||
parent.WandPosition.set_current_conduit(active_conduit)
|
||||
|
||||
func _on_Conduit2_toggled():
|
||||
if Conduit2.is_visible() and active_conduit != Globals.Magic[Globals.Conduit2]:
|
||||
active_conduit = Globals.Magic[Globals.Conduit2]
|
||||
parent.WandManager.set_current_conduit(active_conduit)
|
||||
parent.WandPosition.set_current_conduit(active_conduit)
|
||||
|
||||
func _on_Conduit3_toggled():
|
||||
if Conduit3.is_visible() and active_conduit != Globals.Magic[Globals.Conduit3]:
|
||||
active_conduit = Globals.Magic[Globals.Conduit3]
|
||||
parent.WandManager.set_current_conduit(active_conduit)
|
||||
parent.WandPosition.set_current_conduit(active_conduit)
|
||||
|
||||
func _on_Conduit4_toggled():
|
||||
if Conduit4.is_visible() and active_conduit != Globals.Magic[Globals.Conduit4]:
|
||||
active_conduit = Globals.Magic[Globals.Conduit4]
|
||||
parent.WandManager.set_current_conduit(active_conduit)
|
||||
parent.WandPosition.set_current_conduit(active_conduit)
|
||||
|
||||
|
||||
func _on_Projectile1_pressed():
|
||||
if Projectile1.is_visible() and active_projectile != Globals.Magic[Globals.Projectile1]:
|
||||
active_projectile = Globals.Magic[Globals.Projectile1]
|
||||
|
||||
|
||||
func _on_Projectile2_pressed():
|
||||
if Projectile2.is_visible() and active_projectile != Globals.Magic[Globals.Projectile2]:
|
||||
active_projectile = Globals.Magic[Globals.Projectile2]
|
||||
|
||||
|
||||
func _on_Projectile3_pressed():
|
||||
if Projectile3.is_visible() and active_projectile != Globals.Magic[Globals.Projectile3]:
|
||||
active_projectile = Globals.Magic[Globals.Projectile3]
|
||||
|
||||
|
||||
func _on_Projectile4_pressed():
|
||||
if Projectile4.is_visible() and active_projectile != Globals.Magic[Globals.Projectile4]:
|
||||
active_projectile = Globals.Magic[Globals.Projectile4]
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
extends Position2D
|
||||
|
||||
onready var parent = get_parent()
|
||||
onready var inv = parent.Inventory
|
||||
|
||||
func clear_conduit():
|
||||
for c in get_children():
|
||||
c.queue_free()
|
||||
|
@ -10,3 +7,7 @@ func clear_conduit():
|
|||
func set_current_conduit(conduit):
|
||||
clear_conduit()
|
||||
add_child(conduit.instance())
|
||||
|
||||
func _process(delta):
|
||||
if Input.is_action_pressed("shoot") and get_child_count() != 0:
|
||||
get_children()[0].fire(get_parent().Inventory.active_projectile, null)
|
|
@ -1,8 +1,8 @@
|
|||
extends Node
|
||||
|
||||
enum {Conduit1, Conduit2, Conduit3, Conduit4, }
|
||||
enum {Projectile1, Projectile2, Projectile3, Projectile4}
|
||||
enum {Effect1, Effect2, Effect3, Effect4}
|
||||
enum {Conduit1, Conduit2, Conduit3, Conduit4,
|
||||
Projectile1, Projectile2, Projectile3, Projectile4,
|
||||
Effect1, Effect2, Effect3, Effect4}
|
||||
|
||||
const TILE_SIZE = 16
|
||||
|
||||
|
@ -12,10 +12,10 @@ var conduit2_ps = preload("res://magic/Wands/TripleWand.tscn")
|
|||
var conduit3_ps = preload("res://magic/Wands/BouncyWand.tscn")
|
||||
var conduit4_ps = preload("res://magic/Wands/PrismWand.tscn")
|
||||
|
||||
var projectile1_ps
|
||||
var projectile2_ps
|
||||
var projectile3_ps
|
||||
var projectile4_ps
|
||||
var projectile1_ps = preload("res://magic/Projectiles/EcoProjectile.tscn")
|
||||
var projectile2_ps = preload("res://magic/Projectiles/PhantomProjectile.tscn")
|
||||
var projectile3_ps = preload("res://magic/Projectiles/WaveProjectile.tscn")
|
||||
var projectile4_ps = preload("res://magic/Projectiles/ExplosiveProjectile.tscn")
|
||||
|
||||
var effect1_ps
|
||||
var effect2_ps
|
||||
|
|
|
@ -24,15 +24,20 @@ onready var Anim: AnimationPlayer = $AnimationPlayer
|
|||
onready var CoyoteTimer: Timer = $CoyoteTimer
|
||||
onready var ShootDelay: Timer = $ShootDelay
|
||||
onready var StateMachine: Node = $PlayerStateMachine
|
||||
onready var WandManager: Node2D = $WandManager
|
||||
onready var WandPosition: Node2D = $WandPosition
|
||||
onready var ProjectileSpawn: Node2D = $HoldPosition/ProjectileSpawn
|
||||
onready var Inventory: CanvasLayer = $Inventory
|
||||
onready var Wand
|
||||
onready var Stats = $Stats
|
||||
|
||||
onready var health = Stats.health setget set_health, get_health
|
||||
onready var energy = Stats.energy setget set_energy, get_energy
|
||||
|
||||
func get_current_conduit():
|
||||
return Inventory.active_conduit
|
||||
|
||||
func get_current_projectile():
|
||||
return Inventory.active_projectile
|
||||
|
||||
func get_type():
|
||||
return "player"
|
||||
|
||||
|
@ -65,10 +70,7 @@ func _physics_process(delta):
|
|||
func handle_move_input():
|
||||
input_direction = int(Input.is_action_pressed("right")) - int(Input.is_action_pressed("left"))
|
||||
velocity.x = lerp(velocity.x, speed * input_direction, get_movement_weight())
|
||||
WandManager.look_at(get_global_mouse_position())
|
||||
|
||||
if Input.is_action_pressed("shoot") and Wand != null:
|
||||
Wand.fire_projectile(WandManager.rotation_degrees)
|
||||
WandPosition.look_at(get_global_mouse_position())
|
||||
|
||||
if input_direction > 0:
|
||||
Spr.flip_h = false
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=9 format=2]
|
||||
[gd_scene load_steps=13 format=2]
|
||||
|
||||
[ext_resource path="res://ui/Inventory.png" type="Texture" id=1]
|
||||
[ext_resource path="res://script/Inventory.gd" type="Script" id=2]
|
||||
|
@ -6,6 +6,10 @@
|
|||
[ext_resource path="res://art/TripleWand.png" type="Texture" id=4]
|
||||
[ext_resource path="res://art/BouncingWand.png" type="Texture" id=5]
|
||||
[ext_resource path="res://art/PrismaticWand.png" type="Texture" id=6]
|
||||
[ext_resource path="res://art/PhantomProjectile.png" type="Texture" id=7]
|
||||
[ext_resource path="res://art/ecoprojectile.png" type="Texture" id=8]
|
||||
[ext_resource path="res://art/WaveProjectile.png" type="Texture" id=9]
|
||||
[ext_resource path="res://art/MineProjectile.png" type="Texture" id=10]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "SlideIn"
|
||||
|
@ -109,7 +113,58 @@ __meta__ = {
|
|||
}
|
||||
|
||||
[node name="Projectiles" type="Node2D" parent="Inventory"]
|
||||
visible = false
|
||||
|
||||
[node name="Projectile1" type="TextureButton" parent="Inventory/Projectiles"]
|
||||
margin_left = -28.0
|
||||
margin_top = -19.0
|
||||
margin_right = -12.0
|
||||
margin_bottom = -5.0
|
||||
action_mode = 0
|
||||
texture_normal = ExtResource( 8 )
|
||||
expand = true
|
||||
stretch_mode = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Projectile2" type="TextureButton" parent="Inventory/Projectiles"]
|
||||
margin_left = 7.0
|
||||
margin_top = -19.0
|
||||
margin_right = 23.0
|
||||
margin_bottom = -5.0
|
||||
action_mode = 0
|
||||
texture_normal = ExtResource( 7 )
|
||||
expand = true
|
||||
stretch_mode = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Projectile3" type="TextureButton" parent="Inventory/Projectiles"]
|
||||
margin_left = -28.0
|
||||
margin_top = 1.0
|
||||
margin_right = -12.0
|
||||
margin_bottom = 15.0
|
||||
action_mode = 0
|
||||
texture_normal = ExtResource( 9 )
|
||||
expand = true
|
||||
stretch_mode = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Projectile4" type="TextureButton" parent="Inventory/Projectiles"]
|
||||
margin_left = 7.0
|
||||
margin_top = 1.0
|
||||
margin_right = 23.0
|
||||
margin_bottom = 15.0
|
||||
action_mode = 0
|
||||
texture_normal = ExtResource( 10 )
|
||||
expand = true
|
||||
stretch_mode = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Effects" type="Node2D" parent="Inventory"]
|
||||
visible = false
|
||||
|
@ -117,3 +172,7 @@ visible = false
|
|||
[connection signal="pressed" from="Inventory/Conduits/Conduit2" to="." method="_on_Conduit2_toggled"]
|
||||
[connection signal="pressed" from="Inventory/Conduits/Conduit3" to="." method="_on_Conduit3_toggled"]
|
||||
[connection signal="pressed" from="Inventory/Conduits/Conduit4" to="." method="_on_Conduit4_toggled"]
|
||||
[connection signal="pressed" from="Inventory/Projectiles/Projectile1" to="." method="_on_Projectile1_pressed"]
|
||||
[connection signal="pressed" from="Inventory/Projectiles/Projectile2" to="." method="_on_Projectile2_pressed"]
|
||||
[connection signal="pressed" from="Inventory/Projectiles/Projectile3" to="." method="_on_Projectile3_pressed"]
|
||||
[connection signal="pressed" from="Inventory/Projectiles/Projectile4" to="." method="_on_Projectile4_pressed"]
|
||||
|
|
Loading…
Reference in a new issue