added Graphics and sound Effects and more overhauls

This commit is contained in:
Exobyt 2025-08-03 20:56:32 +02:00
parent c887a2168c
commit b9d4288900
214 changed files with 3378 additions and 198 deletions

View file

@ -5,9 +5,21 @@ class_name Spaceship extends CharacterBody2D
@onready var weaponNode = $weaponNode
@onready var invincibleTimer = $invincibleTimer
@onready var MINIGUN = preload("res://scenes/weapon/minigun/minigun.tscn")
@onready var RAILGUN = preload("res://scenes/weapon/railgun/railgun.tscn")
@onready var SHOTGUN = preload("res://scenes/weapon/shotgun/shotgun.tscn")
@onready var radiationDamageTimer = $radiationDamageTimer
@onready var radiationDamage = $radiationDamage
@export var shotgunTexture: Texture2D
@export var minigunTexture: Texture2D
@export var railgunTexture: Texture2D
@export var minHealth: int = 0
@export var maxHealth: int = 100
@export var health: int = maxHealth
@onready var health: int = maxHealth
@export var speed: int = 800
@export var acceleration: float = 0.8
@ -16,23 +28,31 @@ class_name Spaceship extends CharacterBody2D
@export var timeGhost: TimeGhost = null
@export var weapon: Weapon = null
var currentWeapon: PackedScene
@export var invincible: bool = false
var currentRadiationDamage: int = 1
signal destroyed
func _init() -> void:
health = maxHealth
func _ready() -> void:
invincibleTimer.wait_time = Globals.currentDelay * 3
shortInvincibility()
func damage(amount: int):
if not invincible:
if health - amount <= minHealth:
if timeGhost == null:
emit_signal("destroyed")
if self.is_in_group("enemy"):
Globals.enemyDestroyed()
destroy()
health = minHealth
shortInvincibility()
health = maxHealth
else:
health -= amount
@ -44,6 +64,7 @@ func heal(amount: int):
func destroy():
if timeGhost == null:
destroyed.emit()
queue_free()
else:
timeGhost.destroy()
@ -63,19 +84,36 @@ func moveTimeGhost(_position: Vector2, _rotation: float):
timeGhost.moveTimeGhost(_position, _rotation)
func changeWeapon(_weapon: PackedScene):
currentWeapon = _weapon
var newWeapon = _weapon.instantiate()
for i in weaponNode.get_children():
i.queue_free()
weaponNode.add_child(newWeapon)
weapon = newWeapon
if newWeapon is Shotgun:
sprite.texture = shotgunTexture
elif newWeapon is Minigun:
sprite.texture = minigunTexture
elif newWeapon is Railgun:
sprite.texture = railgunTexture
await get_tree().create_timer(Globals.currentDelay).timeout
if timeGhost != null:
timeGhost.changeWeapon(_weapon)
#match newWeapon:
#Shotgun:
#sprite.texture = shotgunTexture
#Minigun:
#sprite.texture = minigunTexture
#Railgun:
#sprite.texture = railgunTexture
#
func addTimeGhost(_timeGhost: TimeGhost):
if timeGhost == null:
timeGhost = _timeGhost
timeGhost.setSpaceship(self)
timeGhost.changeWeapon(currentWeapon)
else:
timeGhost.addTimeGhost(_timeGhost)
@ -91,5 +129,19 @@ func _on_invincible_timer_timeout() -> void:
func _on_hurt_area_area_entered(area: Area2D) -> void:
if area.get_parent().is_in_group("obstacle"):
velocity = Vector2.UP.rotated(rotation) * -pushback
velocity = Vector2.UP.rotated(rad_to_deg(global_position.angle_to(area.global_position))) * -pushback
area.get_parent().queue_free()
func inceraseMaxhealth(increase: int):
maxHealth += increase
health += increase
func applyRadiation(amount: int):
if radiationDamageTimer.is_stopped():
currentRadiationDamage = amount
radiationDamageTimer.start()
func _on_radiation_damge_timer_timeout() -> void:
radiationDamage.play()
damage(currentRadiationDamage)