Initial commit (1/2)
This commit is contained in:
commit
3411c5796d
66 changed files with 2261 additions and 0 deletions
44
scripts/MSShield.gd
Normal file
44
scripts/MSShield.gd
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
extends Node2D
|
||||
|
||||
class_name Shield
|
||||
|
||||
@export var MaxShieldCapacity : int = 8 #максимальный заряд щита
|
||||
@export var ShieldChargeRate : float = 1 #скорость зарядки щита
|
||||
@export var RechargeTimer : Timer
|
||||
@export var LaserTimer : Timer
|
||||
@export var LaserChargeRate : float = 20
|
||||
|
||||
@onready var Capacity : float = MaxShieldCapacity #текущий заряд щита
|
||||
var CanRecharge : bool = false
|
||||
var LaserRecharge : bool = true
|
||||
|
||||
func _ready():
|
||||
RechargeTimer.timeout.connect(recharging_timer)
|
||||
LaserTimer.timeout.connect(laser_timer)
|
||||
|
||||
func deal_damage(damage : float):
|
||||
Capacity -= damage
|
||||
if Capacity < 0:
|
||||
get_parent().Hull.HP += Capacity
|
||||
Capacity = 0
|
||||
CanRecharge = false
|
||||
RechargeTimer.start()
|
||||
LaserTimer.start()
|
||||
|
||||
func recharging_timer():
|
||||
CanRecharge = true
|
||||
|
||||
func _physics_process(delta):
|
||||
if CanRecharge:
|
||||
Capacity += ShieldChargeRate * delta
|
||||
if Capacity > MaxShieldCapacity:
|
||||
Capacity = MaxShieldCapacity
|
||||
CanRecharge = false
|
||||
if LaserRecharge:
|
||||
get_parent().Hull.Ammunition["Laser Energy"] += LaserChargeRate * delta
|
||||
if get_parent().Hull.Ammunition["Laser Energy"] > get_parent().Hull.MaxAmmunition["Laser Energy"]:
|
||||
get_parent().Hull.Ammunition["Laser Energy"] = get_parent().Hull.MaxAmmunition["Laser Energy"]
|
||||
LaserRecharge = false
|
||||
|
||||
func laser_timer():
|
||||
LaserRecharge = true
|
||||
Loading…
Add table
Add a link
Reference in a new issue