All magic done
This commit is contained in:
parent
c77e5f9dcb
commit
ee24fa5352
|
@ -8,7 +8,7 @@ onready var Hurtbox = $Area2D
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
speed = 50
|
speed = 50
|
||||||
health = 3.5
|
health = 3
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
Player.current_scene = "res://levels/World.tscn"
|
Player.current_scene = "res://levels/World.tscn"
|
||||||
|
|
|
@ -19,7 +19,7 @@ func on_impact(collision):
|
||||||
func explode():
|
func explode():
|
||||||
for body in $Area2D.get_overlapping_bodies():
|
for body in $Area2D.get_overlapping_bodies():
|
||||||
if body.get("health") != null and body.get_type() != "player":
|
if body.get("health") != null and body.get_type() != "player":
|
||||||
body.health -= damage
|
body.health -= damage * damage_mod
|
||||||
if body.has_method("play_hit"):
|
if body.has_method("play_hit"):
|
||||||
body.play_hit()
|
body.play_hit()
|
||||||
$Explosion.play(0.0)
|
$Explosion.play(0.0)
|
||||||
|
|
|
@ -15,6 +15,8 @@ var is_charge = false
|
||||||
var is_prism = false
|
var is_prism = false
|
||||||
var is_triple = false
|
var is_triple = false
|
||||||
|
|
||||||
|
onready var Spr: Sprite = $Sprite
|
||||||
|
|
||||||
func get_wand_type(wand_id):
|
func get_wand_type(wand_id):
|
||||||
match wand_id:
|
match wand_id:
|
||||||
Globals.Conduit1:
|
Globals.Conduit1:
|
||||||
|
@ -37,8 +39,11 @@ func _physics_process(delta):
|
||||||
if collision != null:
|
if collision != null:
|
||||||
on_impact(collision)
|
on_impact(collision)
|
||||||
|
|
||||||
func launch(wand):
|
func launch(wand, mod = 1):
|
||||||
velocity = (Vector2(speed, 0)).rotated(rotation)
|
velocity = (Vector2(speed, 0)).rotated(rotation)
|
||||||
|
damage_mod = mod
|
||||||
|
scale = Vector2(1, 1)
|
||||||
|
Spr.scale = Vector2(mod, mod)
|
||||||
get_wand_type(wand)
|
get_wand_type(wand)
|
||||||
return energy_cost * energy_mod
|
return energy_cost * energy_mod
|
||||||
|
|
||||||
|
|
|
@ -1 +1,31 @@
|
||||||
extends Wand
|
extends Wand
|
||||||
|
|
||||||
|
var charge_level = 0
|
||||||
|
var max_charge = 3
|
||||||
|
var projectile = null
|
||||||
|
|
||||||
|
onready var ChargeTimer: Timer = $ChargeTimer
|
||||||
|
|
||||||
|
func fire(p):
|
||||||
|
projectile = p
|
||||||
|
if ChargeTimer.is_stopped():
|
||||||
|
ChargeTimer.start()
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
print(charge_level)
|
||||||
|
scale = Vector2(charge_level / 2 + 1, charge_level / 2 + 1)
|
||||||
|
|
||||||
|
func _on_ChargeTimer_timeout():
|
||||||
|
charge_level = clamp(charge_level + 0.5, 0, max_charge)
|
||||||
|
|
||||||
|
func _input(event):
|
||||||
|
if event.is_action_released("shoot"):
|
||||||
|
ChargeTimer.stop()
|
||||||
|
if charge_level <= 0:
|
||||||
|
charge_level = 0
|
||||||
|
return
|
||||||
|
var temp = projectile.instance()
|
||||||
|
get_tree().current_scene.add_child(temp)
|
||||||
|
temp.global_transform = $ProjectileSpawn.global_transform
|
||||||
|
var energy_cost = temp.launch(wand_type, charge_level)
|
||||||
|
charge_level = 0
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
[gd_scene load_steps=3 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://magic/Wands/ChargedWand.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://art/Wand.png" type="Texture" id=2]
|
[ext_resource path="res://art/Wand.png" type="Texture" id=2]
|
||||||
|
|
||||||
[node name="ChargedWand" type="Sprite"]
|
[node name="ChargedWand" type="Sprite"]
|
||||||
position = Vector2( 9, 0 )
|
position = Vector2( 11, 0 )
|
||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
texture = ExtResource( 2 )
|
texture = ExtResource( 2 )
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
@ -16,3 +16,8 @@ rotation = -1.5708
|
||||||
[node name="ShootDelay" type="Timer" parent="."]
|
[node name="ShootDelay" type="Timer" parent="."]
|
||||||
wait_time = 0.3
|
wait_time = 0.3
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="ChargeTimer" type="Timer" parent="."]
|
||||||
|
wait_time = 0.4
|
||||||
|
one_shot = true
|
||||||
|
[connection signal="timeout" from="ChargeTimer" to="." method="_on_ChargeTimer_timeout"]
|
||||||
|
|
Loading…
Reference in a new issue