All magic done

This commit is contained in:
Logan 2020-07-21 19:50:43 -05:00
parent c77e5f9dcb
commit ee24fa5352
5 changed files with 45 additions and 5 deletions

View file

@ -8,7 +8,7 @@ onready var Hurtbox = $Area2D
func _ready():
speed = 50
health = 3.5
health = 3
func _physics_process(delta):
Player.current_scene = "res://levels/World.tscn"

View file

@ -19,7 +19,7 @@ func on_impact(collision):
func explode():
for body in $Area2D.get_overlapping_bodies():
if body.get("health") != null and body.get_type() != "player":
body.health -= damage
body.health -= damage * damage_mod
if body.has_method("play_hit"):
body.play_hit()
$Explosion.play(0.0)

View file

@ -15,6 +15,8 @@ var is_charge = false
var is_prism = false
var is_triple = false
onready var Spr: Sprite = $Sprite
func get_wand_type(wand_id):
match wand_id:
Globals.Conduit1:
@ -37,8 +39,11 @@ func _physics_process(delta):
if collision != null:
on_impact(collision)
func launch(wand):
func launch(wand, mod = 1):
velocity = (Vector2(speed, 0)).rotated(rotation)
damage_mod = mod
scale = Vector2(1, 1)
Spr.scale = Vector2(mod, mod)
get_wand_type(wand)
return energy_cost * energy_mod

View file

@ -1 +1,31 @@
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

View file

@ -1,10 +1,10 @@
[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]
[node name="ChargedWand" type="Sprite"]
position = Vector2( 9, 0 )
position = Vector2( 11, 0 )
rotation = 1.5708
texture = ExtResource( 2 )
script = ExtResource( 1 )
@ -16,3 +16,8 @@ rotation = -1.5708
[node name="ShootDelay" type="Timer" parent="."]
wait_time = 0.3
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"]