Player stores scene
This commit is contained in:
parent
6c3432ab13
commit
8cc87c4b14
|
@ -1,13 +1,15 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
var position: Vector2 = Vector2()
|
var position: Vector2 = Vector2()
|
||||||
var health: float = -1
|
var health = null
|
||||||
var energy: float = -1
|
var energy = null
|
||||||
var unlocked: Array = [Globals.Conduit2]
|
var unlocked: Array = [Globals.Conduit2]
|
||||||
|
var current_scene: PackedScene
|
||||||
|
|
||||||
func respawn():
|
func respawn():
|
||||||
health = -1
|
health = null
|
||||||
energy = -1
|
energy = null
|
||||||
|
|
||||||
func reset_magic():
|
func reset_magic():
|
||||||
unlocked = []
|
unlocked = []
|
||||||
|
|
||||||
|
|
16
magic/Beams/Beam.gd
Normal file
16
magic/Beams/Beam.gd
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
extends Node2D
|
||||||
|
class_name Beam
|
||||||
|
|
||||||
|
var max_cast = Vector2(400, 0)
|
||||||
|
|
||||||
|
onready var Beam: Sprite = $Beam
|
||||||
|
onready var Begin: Sprite = $Begin
|
||||||
|
onready var Ray: RayCast2D = $Raycast2D
|
||||||
|
onready var End: Position2D = $End
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
Ray.cast_to = max_cast
|
||||||
|
if Ray.is_colliding():
|
||||||
|
End.global_position = Ray.get_collision_point()
|
||||||
|
else:
|
||||||
|
End.position = max_cast
|
|
@ -17,6 +17,6 @@ region_rect = Rect2( 0, 0, 8, 8 )
|
||||||
|
|
||||||
[node name="RayCast2D" type="RayCast2D" parent="."]
|
[node name="RayCast2D" type="RayCast2D" parent="."]
|
||||||
enabled = true
|
enabled = true
|
||||||
cast_to = Vector2( 100, 0 )
|
cast_to = Vector2( 400, 0 )
|
||||||
|
|
||||||
[node name="End" type="Position2D" parent="."]
|
[node name="End" type="Position2D" parent="."]
|
||||||
|
|
|
@ -9,6 +9,11 @@
|
||||||
config_version=4
|
config_version=4
|
||||||
|
|
||||||
_global_script_classes=[ {
|
_global_script_classes=[ {
|
||||||
|
"base": "Node2D",
|
||||||
|
"class": "Beam",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://magic/Beams/Beam.gd"
|
||||||
|
}, {
|
||||||
"base": "Area2D",
|
"base": "Area2D",
|
||||||
"class": "Collectable",
|
"class": "Collectable",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
|
@ -40,6 +45,7 @@ _global_script_classes=[ {
|
||||||
"path": "res://magic/Wands/WandClass.gd"
|
"path": "res://magic/Wands/WandClass.gd"
|
||||||
} ]
|
} ]
|
||||||
_global_script_class_icons={
|
_global_script_class_icons={
|
||||||
|
"Beam": "",
|
||||||
"Collectable": "",
|
"Collectable": "",
|
||||||
"Enemy": "",
|
"Enemy": "",
|
||||||
"EnemyProjectile": "",
|
"EnemyProjectile": "",
|
||||||
|
|
|
@ -10,10 +10,9 @@ var energy = 5 setget set_energy, get_energy
|
||||||
var is_burnout = false
|
var is_burnout = false
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
print(Player.energy)
|
if Player.health == null:
|
||||||
if Player.health == -1:
|
|
||||||
Player.health = Hearts.max_value
|
Player.health = Hearts.max_value
|
||||||
if Player.energy == -1:
|
if Player.energy == null:
|
||||||
Player.energy = Energybar.max_value
|
Player.energy = Energybar.max_value
|
||||||
print("max")
|
print("max")
|
||||||
set_health(Player.health)
|
set_health(Player.health)
|
||||||
|
@ -25,6 +24,10 @@ func _on_Regen_timeout():
|
||||||
is_burnout = false
|
is_burnout = false
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
|
if Player.health == null:
|
||||||
|
Player.health = Hearts.max_value
|
||||||
|
if Player.energy == null:
|
||||||
|
Player.energy = Energybar.max_value
|
||||||
if get_accurate_energy() < Energybar.max_value and Regen.is_stopped():
|
if get_accurate_energy() < Energybar.max_value and Regen.is_stopped():
|
||||||
Regen.start()
|
Regen.start()
|
||||||
BurnoutSprite.visible = is_burnout
|
BurnoutSprite.visible = is_burnout
|
||||||
|
|
Loading…
Reference in a new issue