Initial commit (1/2)

This commit is contained in:
Алкесей Мирнеков 2023-11-05 16:23:18 +03:00 committed by GitHub
commit 3411c5796d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 2261 additions and 0 deletions

44
scripts/MSShield.gd Normal file
View 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