added Graphics and sound Effects and more overhauls
This commit is contained in:
parent
c887a2168c
commit
b9d4288900
214 changed files with 3378 additions and 198 deletions
|
|
@ -1,22 +1,67 @@
|
|||
class_name Enemy extends "res://scenes/spaceShip/spaceShip.gd"
|
||||
|
||||
@onready var visionArea: VisionArea = $VisionAreas/VisionArea
|
||||
@onready var visionAreaStop: VisionArea = $VisionAreas/VisionAreaStop
|
||||
@onready var visionAreaEnemy: VisionArea = $VisionAreas/VisionAreaEnemy
|
||||
@onready var raycast: RayCast2D = $RayCast2D
|
||||
|
||||
@onready var hit = $hit
|
||||
|
||||
@export var range: int = 800
|
||||
|
||||
func _ready() -> void:
|
||||
setVision()
|
||||
|
||||
func setVision():
|
||||
visionArea.changeViewSize(range)
|
||||
visionAreaStop.changeViewSize(range-50)
|
||||
visionAreaEnemy.changeViewSize(200)
|
||||
raycast.target_position.y = -range
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
#print(name, " velocity: ", velocity," velocityMedian: ", getVelocityMedian(), " radius: ", $VisionAreas/VisionAreaStop/CollisionShape2D.shape.radius)
|
||||
#if Globals.getPlayer() != null:
|
||||
#if getVelocityMedian()*8 > range:
|
||||
#visionAreaStop.changeViewSize(getVelocityMedian()*8)
|
||||
#global_position.distance_to(Globals.getPlayer().global_position)
|
||||
|
||||
if Globals.getPlayer() != null:
|
||||
look_at(Globals.getPlayer().global_position)
|
||||
var direction = Vector2.RIGHT.rotated(rotation)
|
||||
rotation += PI / 2
|
||||
if Globals.getPlayer() != null:
|
||||
rotation += PI / 2
|
||||
|
||||
if visionArea.has_overlapping_bodies():
|
||||
if not raycast.is_colliding():
|
||||
attack()
|
||||
#if getEnemyList() != []:
|
||||
#for i in getEnemyList():
|
||||
##print(global_position.distance_to(i.global_position))
|
||||
#direction -= Vector2.UP.rotated(rad_to_deg(global_position.angle_to(i.global_position))) * -10
|
||||
#break
|
||||
#print(self)
|
||||
#print(visionAreaEnemy.get_overlapping_bodies())
|
||||
#print(getEnemyList())
|
||||
if not visionAreaStop.has_overlapping_bodies():
|
||||
velocity = velocity.lerp(direction * speed, acceleration * delta)
|
||||
else:
|
||||
if not raycast.is_colliding():
|
||||
attack()
|
||||
velocity = velocity.lerp(Vector2.ZERO, acceleration * delta)
|
||||
|
||||
move_and_slide()
|
||||
|
||||
func _on_hurt_area_hurt(amount: int) -> void:
|
||||
hit.play()
|
||||
damage(amount)
|
||||
|
||||
func getVelocityMedian() -> float:
|
||||
var _velocity = velocity
|
||||
if _velocity.x < 0:
|
||||
_velocity.x *= -1
|
||||
if _velocity.y < 0:
|
||||
_velocity.y *= -1
|
||||
return (_velocity.x + _velocity.y) / 2
|
||||
|
||||
func getEnemyList() -> Array:
|
||||
var enemies = visionAreaEnemy.get_overlapping_bodies()
|
||||
enemies.erase(self)
|
||||
return enemies
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://bodpgjdjhfn4w"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://bodpgjdjhfn4w"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://csacin2gx2tum" path="res://scenes/spaceShip/spaceShip.tscn" id="1_5w6ng"]
|
||||
[ext_resource type="Script" uid="uid://djlqf2g8ho05r" path="res://scenes/spaceShip/enemy/enemy.gd" id="2_2erf0"]
|
||||
[ext_resource type="Texture2D" uid="uid://cfwyw1sr6x2np" path="res://icon.svg" id="2_u13ds"]
|
||||
[ext_resource type="Texture2D" uid="uid://dansb0wnm00vb" path="res://assets/enemy/shotgunEnemy.png" id="3_7vnn2"]
|
||||
[ext_resource type="Texture2D" uid="uid://bkc8av1vbis4r" path="res://assets/enemy/enemy.png" id="3_hybmu"]
|
||||
[ext_resource type="PackedScene" uid="uid://k5fr6bfn6kkd" path="res://scenes/spaceShip/enemy/visionArea/visionArea.tscn" id="4_hybmu"]
|
||||
[ext_resource type="Texture2D" uid="uid://mftd7366eymt" path="res://assets/enemy/minigunEnemy.png" id="4_ibucj"]
|
||||
[ext_resource type="Texture2D" uid="uid://iddqk6g00rku" path="res://assets/enemy/RailgunEnemy.png" id="5_fmf0p"]
|
||||
[ext_resource type="AudioStream" uid="uid://vjxm7ay4t2ju" path="res://assets/sound/hit2.wav" id="5_gid86"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2erf0"]
|
||||
size = Vector2(112, 112)
|
||||
|
|
@ -11,15 +15,16 @@ size = Vector2(112, 112)
|
|||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_u13ds"]
|
||||
size = Vector2(112, 112)
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_hybmu"]
|
||||
radius = 448.071
|
||||
|
||||
[node name="Enemy" groups=["enemy"] instance=ExtResource("1_5w6ng")]
|
||||
modulate = Color(1, 0, 1, 1)
|
||||
collision_layer = 36
|
||||
collision_mask = 35
|
||||
collision_mask = 67
|
||||
script = ExtResource("2_2erf0")
|
||||
speed = 700
|
||||
range = 800
|
||||
shotgunTexture = ExtResource("3_7vnn2")
|
||||
minigunTexture = ExtResource("4_ibucj")
|
||||
railgunTexture = ExtResource("5_fmf0p")
|
||||
maxHealth = 10
|
||||
speed = 1000
|
||||
|
||||
[node name="CollisionShape2D" parent="." index="0"]
|
||||
shape = SubResource("RectangleShape2D_2erf0")
|
||||
|
|
@ -28,19 +33,29 @@ shape = SubResource("RectangleShape2D_2erf0")
|
|||
shape = SubResource("RectangleShape2D_u13ds")
|
||||
|
||||
[node name="Sprite2D" parent="." index="2"]
|
||||
texture = ExtResource("2_u13ds")
|
||||
position = Vector2(0, -24)
|
||||
texture = ExtResource("3_hybmu")
|
||||
|
||||
[node name="VisionAreas" type="Node2D" parent="." index="5"]
|
||||
|
||||
[node name="VisionAreaStop" parent="VisionAreas" index="0" instance=ExtResource("4_hybmu")]
|
||||
[node name="VisionArea" parent="VisionAreas" index="0" instance=ExtResource("4_hybmu")]
|
||||
|
||||
[node name="CollisionShape2D" parent="VisionAreas/VisionAreaStop" index="0"]
|
||||
shape = SubResource("CircleShape2D_hybmu")
|
||||
[node name="VisionAreaStop" parent="VisionAreas" index="1" instance=ExtResource("4_hybmu")]
|
||||
|
||||
[node name="VisionAreaEnemy" parent="VisionAreas" index="2" instance=ExtResource("4_hybmu")]
|
||||
collision_mask = 32
|
||||
|
||||
[node name="RayCast2D" type="RayCast2D" parent="." index="6"]
|
||||
target_position = Vector2(0, -448)
|
||||
collision_mask = 32
|
||||
hit_from_inside = true
|
||||
|
||||
[node name="hit" type="AudioStreamPlayer2D" parent="." index="7"]
|
||||
stream = ExtResource("5_gid86")
|
||||
|
||||
[connection signal="hurt" from="hurtArea" to="." method="_on_hurt_area_hurt"]
|
||||
|
||||
[editable path="hurtArea"]
|
||||
[editable path="VisionAreas/VisionArea"]
|
||||
[editable path="VisionAreas/VisionAreaStop"]
|
||||
[editable path="VisionAreas/VisionAreaEnemy"]
|
||||
|
|
|
|||
5
scenes/spaceShip/enemy/minigunEnemy/minigunEnemy.gd
Normal file
5
scenes/spaceShip/enemy/minigunEnemy/minigunEnemy.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class_name MinigunEnemy extends "res://scenes/spaceShip/enemy/enemy.gd"
|
||||
|
||||
func _ready() -> void:
|
||||
changeWeapon(MINIGUN)
|
||||
setVision()
|
||||
1
scenes/spaceShip/enemy/minigunEnemy/minigunEnemy.gd.uid
Normal file
1
scenes/spaceShip/enemy/minigunEnemy/minigunEnemy.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dbxjdkvkkv5cm
|
||||
16
scenes/spaceShip/enemy/minigunEnemy/minigunEnemy.tscn
Normal file
16
scenes/spaceShip/enemy/minigunEnemy/minigunEnemy.tscn
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bydt20jefk35d"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bodpgjdjhfn4w" path="res://scenes/spaceShip/enemy/enemy.tscn" id="1_h0ios"]
|
||||
[ext_resource type="Script" uid="uid://dbxjdkvkkv5cm" path="res://scenes/spaceShip/enemy/minigunEnemy/minigunEnemy.gd" id="2_ltdg3"]
|
||||
[ext_resource type="Texture2D" uid="uid://mftd7366eymt" path="res://assets/enemy/minigunEnemy.png" id="3_ltdg3"]
|
||||
|
||||
[node name="MinigunEnemy" instance=ExtResource("1_h0ios")]
|
||||
script = ExtResource("2_ltdg3")
|
||||
|
||||
[node name="Sprite2D" parent="." index="2"]
|
||||
texture = ExtResource("3_ltdg3")
|
||||
|
||||
[editable path="hurtArea"]
|
||||
[editable path="VisionAreas/VisionArea"]
|
||||
[editable path="VisionAreas/VisionAreaStop"]
|
||||
[editable path="VisionAreas/VisionAreaEnemy"]
|
||||
5
scenes/spaceShip/enemy/railgunEnemy/railgunEnemy.gd
Normal file
5
scenes/spaceShip/enemy/railgunEnemy/railgunEnemy.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class_name RailgunEnemy extends "res://scenes/spaceShip/enemy/enemy.gd"
|
||||
|
||||
func _ready() -> void:
|
||||
changeWeapon(RAILGUN)
|
||||
setVision()
|
||||
1
scenes/spaceShip/enemy/railgunEnemy/railgunEnemy.gd.uid
Normal file
1
scenes/spaceShip/enemy/railgunEnemy/railgunEnemy.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cjge3ovdfjmdn
|
||||
18
scenes/spaceShip/enemy/railgunEnemy/railgunEnemy.tscn
Normal file
18
scenes/spaceShip/enemy/railgunEnemy/railgunEnemy.tscn
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://tvds0d2gclgg"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bodpgjdjhfn4w" path="res://scenes/spaceShip/enemy/enemy.tscn" id="1_0ankw"]
|
||||
[ext_resource type="Script" uid="uid://cjge3ovdfjmdn" path="res://scenes/spaceShip/enemy/railgunEnemy/railgunEnemy.gd" id="2_s6fkk"]
|
||||
[ext_resource type="Texture2D" uid="uid://iddqk6g00rku" path="res://assets/enemy/RailgunEnemy.png" id="3_k5wkg"]
|
||||
|
||||
[node name="RailgunEnemy" instance=ExtResource("1_0ankw")]
|
||||
script = ExtResource("2_s6fkk")
|
||||
range = 1200
|
||||
speed = 500
|
||||
|
||||
[node name="Sprite2D" parent="." index="2"]
|
||||
texture = ExtResource("3_k5wkg")
|
||||
|
||||
[editable path="hurtArea"]
|
||||
[editable path="VisionAreas/VisionArea"]
|
||||
[editable path="VisionAreas/VisionAreaStop"]
|
||||
[editable path="VisionAreas/VisionAreaEnemy"]
|
||||
6
scenes/spaceShip/enemy/shotgunEnemy/shotgunEnemy.gd
Normal file
6
scenes/spaceShip/enemy/shotgunEnemy/shotgunEnemy.gd
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class_name ShotgunEnemy extends "res://scenes/spaceShip/enemy/enemy.gd"
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
changeWeapon(SHOTGUN)
|
||||
setVision()
|
||||
1
scenes/spaceShip/enemy/shotgunEnemy/shotgunEnemy.gd.uid
Normal file
1
scenes/spaceShip/enemy/shotgunEnemy/shotgunEnemy.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bxd6hh53c3h4p
|
||||
18
scenes/spaceShip/enemy/shotgunEnemy/shotgunEnemy.tscn
Normal file
18
scenes/spaceShip/enemy/shotgunEnemy/shotgunEnemy.tscn
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://dcmfud0437rkx"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bodpgjdjhfn4w" path="res://scenes/spaceShip/enemy/enemy.tscn" id="1_lma5b"]
|
||||
[ext_resource type="Script" uid="uid://bxd6hh53c3h4p" path="res://scenes/spaceShip/enemy/shotgunEnemy/shotgunEnemy.gd" id="2_3bd2j"]
|
||||
[ext_resource type="Texture2D" uid="uid://dansb0wnm00vb" path="res://assets/enemy/shotgunEnemy.png" id="3_5lm6h"]
|
||||
|
||||
[node name="ShotgunEnemy" instance=ExtResource("1_lma5b")]
|
||||
script = ExtResource("2_3bd2j")
|
||||
range = 400
|
||||
speed = 1200
|
||||
|
||||
[node name="Sprite2D" parent="." index="2"]
|
||||
texture = ExtResource("3_5lm6h")
|
||||
|
||||
[editable path="hurtArea"]
|
||||
[editable path="VisionAreas/VisionArea"]
|
||||
[editable path="VisionAreas/VisionAreaStop"]
|
||||
[editable path="VisionAreas/VisionAreaEnemy"]
|
||||
|
|
@ -1 +1,9 @@
|
|||
class_name VisionArea extends Area2D
|
||||
|
||||
@onready var collisionShape = $CollisionShape2D
|
||||
|
||||
func _ready() -> void:
|
||||
collisionShape.shape = CircleShape2D.new()
|
||||
|
||||
func changeViewSize(size: int):
|
||||
collisionShape.shape.radius = size
|
||||
|
|
|
|||
8
scenes/spaceShip/player/Interface.gd
Normal file
8
scenes/spaceShip/player/Interface.gd
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
extends Control
|
||||
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
progressBarHealth.max_value = Globals.getPlayer().maxHealthh
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
1
scenes/spaceShip/player/Interface.gd.uid
Normal file
1
scenes/spaceShip/player/Interface.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bgf71jqib5ck4
|
||||
22
scenes/spaceShip/player/camera2d.gd
Normal file
22
scenes/spaceShip/player/camera2d.gd
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
extends Camera2D
|
||||
|
||||
var shake_duration: float = 0.5
|
||||
var shake_magnitude: float = 10.0
|
||||
var shake_timer: float = 0.0
|
||||
var original_position: Vector2
|
||||
|
||||
func _ready():
|
||||
original_position = position
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if shake_timer > 0:
|
||||
shake_timer -= delta
|
||||
var offset = Vector2(randf_range(-shake_magnitude, shake_magnitude), randf_range(-shake_magnitude, shake_magnitude))
|
||||
position = original_position + offset
|
||||
else:
|
||||
position = original_position
|
||||
|
||||
func shake(duration: float, magnitude: float) -> void:
|
||||
shake_duration = duration
|
||||
shake_magnitude = magnitude
|
||||
shake_timer = shake_duration
|
||||
1
scenes/spaceShip/player/camera2d.gd.uid
Normal file
1
scenes/spaceShip/player/camera2d.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cb4i45ekmd2is
|
||||
10
scenes/spaceShip/player/input.gd
Normal file
10
scenes/spaceShip/player/input.gd
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
extends Control
|
||||
|
||||
@onready var moveButton = $MoveButton
|
||||
@onready var shootButton = $ShootButton
|
||||
@onready var shootButtonCorner = $ShootButtonCorner
|
||||
@onready var moveButtonCorner = $MoveButtonCorner
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
shootButton.global_position = shootButtonCorner.global_position
|
||||
moveButton.global_position = moveButtonCorner.global_position
|
||||
1
scenes/spaceShip/player/input.gd.uid
Normal file
1
scenes/spaceShip/player/input.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ds2moov3l1dyk
|
||||
|
|
@ -1,42 +1,178 @@
|
|||
class_name Player extends "res://scenes/spaceShip/spaceShip.gd"
|
||||
|
||||
@onready var dashCooldown = $dashCooldown
|
||||
@onready var spawnPointPool = $spawnPointPool
|
||||
@onready var timeGhostScene = preload("res://scenes/spaceShip/timeGhost/timeghost.tscn")
|
||||
|
||||
@onready var dashCooldown = $dashCooldown
|
||||
@onready var selfHealTimer = $selfHealTimer
|
||||
@onready var selfHealCountdownTimer = $selfHealCountdownTimer
|
||||
|
||||
@onready var progressBarHealth = $Camera2D/CanvasLayer/Control/VBoxContainer/HealthUi/ProgressBarHealth
|
||||
@onready var progressBarSpeed = $Camera2D/CanvasLayer/Control/VBoxContainer/SpeedUi/ProgressBarSpeed
|
||||
@onready var progressBarDashCooldown = $Camera2D/CanvasLayer/Control/VBoxContainer/DashCooldownUi/ProgressBarDashCooldown
|
||||
@onready var progressBarWeaponCooldown = $Camera2D/CanvasLayer/Control/VBoxContainer/WeaponCooldown/ProgressBarWeaponCooldown
|
||||
@onready var labelWaveInfo = $Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer/LabelWaveInfo
|
||||
@onready var labelWaveEnemiesInfo = $Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer2/LabelWaveEnemiesInfo
|
||||
@onready var labelWaveDestroyedInfo = $Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer3/LabelWaveDestroyedInfo
|
||||
@onready var upgradeChooser = $Camera2D/CanvasLayer/Control/UpgradeChooser
|
||||
|
||||
@onready var hit = $hit
|
||||
@onready var input = $Camera2D/CanvasLayer/Control/Input
|
||||
|
||||
@export var spawnDistance: int = 5000
|
||||
|
||||
var maxSpeedMult: float = 3
|
||||
var maxAcceleration: float = 1
|
||||
var speedMult: float = 1
|
||||
var damageMult: float = 1
|
||||
var dashUnlocked: bool = false
|
||||
var strifeUnlocked: bool = false
|
||||
var selfHealUnlocked: bool = false
|
||||
|
||||
@export var spawnDistance: int = 1000
|
||||
|
||||
func _ready() -> void:
|
||||
if Globals.touchscreen:
|
||||
input.show()
|
||||
progressBarHealth.max_value = maxHealth
|
||||
progressBarSpeed.max_value = speed / 2
|
||||
progressBarDashCooldown.max_value = dashCooldown.wait_time
|
||||
randomize()
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
pass
|
||||
changeWeapon(SHOTGUN)
|
||||
progressBarWeaponCooldown.max_value = weapon.cooldown
|
||||
shortInvincibility()
|
||||
await get_tree().create_timer(Globals.currentDelay).timeout
|
||||
addGhost()
|
||||
newUpgrade()
|
||||
Globals.waveComplete.connect(newUpgrade)
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
#if Input.is_action_pressed("attack"):
|
||||
#attack()
|
||||
#
|
||||
#look_at(get_global_mouse_position())
|
||||
#rotation += PI / 2
|
||||
#var direction = Vector2.UP.normalized().rotated(rotation) * Input.get_action_strength("moveForward")
|
||||
##Input.get_vector("moveForward", "moveBackward").normalized().rotated(rotation)
|
||||
#if Input.is_action_just_pressed("dash") and dashCooldown.is_stopped():
|
||||
#dash()
|
||||
#velocity = velocity.lerp(direction * speed, acceleration * delta)
|
||||
#move_and_slide()
|
||||
#if timeGhost != null:
|
||||
#moveTimeGhost(global_position, rotation)
|
||||
|
||||
if Input.is_action_pressed("attack"):
|
||||
attack()
|
||||
|
||||
look_at(get_global_mouse_position())
|
||||
var controllerDirection = Input.get_vector("lookLeft", "lookRight", "lookForward", "lookDown")
|
||||
controllerDirection
|
||||
if controllerDirection == Vector2.ZERO:
|
||||
look_at(get_global_mouse_position())
|
||||
else:
|
||||
look_at(global_position+controllerDirection)
|
||||
rotation += PI / 2
|
||||
var direction = Input.get_vector("moveLeft", "moveRight", "moveForward", "moveBackward").normalized().rotated(rotation)
|
||||
if Input.is_action_just_pressed("dash") and dashCooldown.is_stopped():
|
||||
var direction: Vector2
|
||||
#if strifeUnlocked:
|
||||
#direction = Input.get_vector("moveLeft", "moveRight", "moveForward", "moveBackward").normalized().rotated(rotation)
|
||||
if Globals.touchscreen:
|
||||
if Input.is_action_pressed("touchscreenForward"):
|
||||
direction = Vector2.UP.normalized().rotated(rotation) * Input.get_action_strength("touchscreenForward")
|
||||
else:
|
||||
direction = Vector2.UP.normalized().rotated(rotation) * Input.get_action_strength("moveForward")
|
||||
if Input.is_action_just_pressed("dash") and dashCooldown.is_stopped() and dashUnlocked:
|
||||
dash()
|
||||
velocity = velocity.lerp(direction * speed, acceleration * delta)
|
||||
#if Input.is_action_pressed("moveForward") or Input.is_action_pressed("moveLeft") or Input.is_action_pressed("moveRight"):
|
||||
if Input.is_action_pressed("moveForward") or Input.is_action_pressed("touchscreenForward"):
|
||||
velocity = velocity.lerp(direction * speed * speedMult, 1 * delta)
|
||||
move_and_slide()
|
||||
if timeGhost != null:
|
||||
moveTimeGhost(global_position, rotation)
|
||||
|
||||
|
||||
setInterface()
|
||||
|
||||
func _on_hurt_area_hurt(amount: int) -> void:
|
||||
damage(amount)
|
||||
hit.play()
|
||||
$Camera2D.shake(0.5, 5.0)
|
||||
if selfHealUnlocked:
|
||||
selfHealTimer.stop()
|
||||
selfHealCountdownTimer.start()
|
||||
|
||||
func dash():
|
||||
shortInvincibility()
|
||||
dashCooldown.start()
|
||||
global_position += Vector2.UP.rotated(rotation) * 1000
|
||||
|
||||
func getRandomSpawnPointPosition() -> Vector2:
|
||||
var rng = RandomNumberGenerator.new()
|
||||
print(deg_to_rad(rng.randi_range(0, 360)))
|
||||
print(Vector2.UP.rotated(deg_to_rad(rng.randi_range(0, 360))) * spawnDistance)
|
||||
return global_position + Vector2.UP.rotated(deg_to_rad(rng.randi_range(0, 360))) * spawnDistance
|
||||
#return spawnPointPool.get_children()[rng.randi_range(0, spawnPointPool.get_children().size()-1)].global_position
|
||||
|
||||
func addGhost():
|
||||
var _timeGhost = timeGhostScene.instantiate()
|
||||
get_tree().get_first_node_in_group("timeGhostPool").add_child(_timeGhost)
|
||||
addTimeGhost(_timeGhost)
|
||||
|
||||
func unlockDash():
|
||||
dashUnlocked = true
|
||||
|
||||
func unlockStrife():
|
||||
strifeUnlocked = true
|
||||
|
||||
|
||||
|
||||
func _on_self_heal_countdown_timeout() -> void:
|
||||
selfHealTimer.start()
|
||||
|
||||
func _on_self_heal_timer_timeout() -> void:
|
||||
if health >= maxHealth:
|
||||
selfHealTimer.stop()
|
||||
else:
|
||||
heal(1)
|
||||
selfHealTimer.start()
|
||||
|
||||
|
||||
func setInterface():
|
||||
if dashUnlocked:
|
||||
$Camera2D/CanvasLayer/Control/VBoxContainer/DashCooldownUi.visible = true
|
||||
progressBarHealth.value = Globals.getPlayer().health
|
||||
progressBarSpeed.value = getVelocityMedian()
|
||||
if dashCooldown.is_stopped():
|
||||
progressBarDashCooldown.value = 0
|
||||
else:
|
||||
progressBarDashCooldown.value = dashCooldown.wait_time - dashCooldown.time_left
|
||||
|
||||
if weapon != null:
|
||||
progressBarWeaponCooldown.value = weapon.cooldownTimer.wait_time - weapon.cooldownTimer.time_left
|
||||
labelWaveInfo.text = str(Globals.currentWave)
|
||||
labelWaveEnemiesInfo.text = str(Globals.enemyCount)
|
||||
labelWaveDestroyedInfo.text = str(Globals.destroyedShips)
|
||||
|
||||
func getVelocityMedian() -> float:
|
||||
var _velocity = velocity
|
||||
if _velocity.x < 0:
|
||||
_velocity.x *= -1
|
||||
if _velocity.y < 0:
|
||||
_velocity.y *= -1
|
||||
return (_velocity.x + _velocity.y) / 2
|
||||
|
||||
func newUpgrade():
|
||||
get_tree().paused = true
|
||||
upgradeChooser.showUpgrades()
|
||||
|
||||
func addSpeedMult(mult: float):
|
||||
if speedMult * mult > maxSpeedMult:
|
||||
speedMult = maxSpeedMult
|
||||
Globals.removeSpeedUPgrade()
|
||||
else:
|
||||
speedMult *= mult
|
||||
|
||||
|
||||
func switchToMinigun():
|
||||
changeWeapon(MINIGUN)
|
||||
progressBarWeaponCooldown.max_value = weapon.cooldown
|
||||
|
||||
func switchToShotgun():
|
||||
changeWeapon(SHOTGUN)
|
||||
progressBarWeaponCooldown.max_value = weapon.cooldown
|
||||
|
||||
func switchToRailgun():
|
||||
changeWeapon(RAILGUN)
|
||||
progressBarWeaponCooldown.max_value = weapon.cooldown
|
||||
|
|
|
|||
|
|
@ -1,8 +1,21 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://bmc2exqutt6vu"]
|
||||
[gd_scene load_steps=19 format=3 uid="uid://bmc2exqutt6vu"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://csacin2gx2tum" path="res://scenes/spaceShip/spaceShip.tscn" id="1_nnn47"]
|
||||
[ext_resource type="Script" uid="uid://0i8gdbb8f6ic" path="res://scenes/spaceShip/player/player.gd" id="2_acneu"]
|
||||
[ext_resource type="Texture2D" uid="uid://cfwyw1sr6x2np" path="res://icon.svg" id="3_0gv45"]
|
||||
[ext_resource type="Texture2D" uid="uid://cd5anydes4tv3" path="res://assets/player/shotgunShip.png" id="3_ah1lv"]
|
||||
[ext_resource type="Texture2D" uid="uid://dlahm782n0awk" path="res://assets/player/minigunShip.png" id="4_1o0bm"]
|
||||
[ext_resource type="Theme" uid="uid://bcbicfiflkrja" path="res://theme/interface.tres" id="4_o6j0d"]
|
||||
[ext_resource type="Script" uid="uid://cb4i45ekmd2is" path="res://scenes/spaceShip/player/camera2d.gd" id="4_sk4ix"]
|
||||
[ext_resource type="Texture2D" uid="uid://dhbn4acw1a6eu" path="res://assets/player/railgunShip.png" id="5_5sy6u"]
|
||||
[ext_resource type="PackedScene" uid="uid://ha8undpo7d4d" path="res://scenes/upgradeChooser/upgradeChooser.tscn" id="5_nno2o"]
|
||||
[ext_resource type="Texture2D" uid="uid://bwtb3m00d1gu2" path="res://assets/symbols/heart.png" id="6_sytd6"]
|
||||
[ext_resource type="Texture2D" uid="uid://cmb78bi27e2jl" path="res://assets/ui/dash.png" id="7_qoa7h"]
|
||||
[ext_resource type="AudioStream" uid="uid://xldfu6srikfp" path="res://assets/sound/hit.wav" id="7_sma6c"]
|
||||
[ext_resource type="Script" uid="uid://ds2moov3l1dyk" path="res://scenes/spaceShip/player/input.gd" id="8_5l1u7"]
|
||||
[ext_resource type="Texture2D" uid="uid://vxl26x3xc8ms" path="res://assets/ui/reload.png" id="8_48lx4"]
|
||||
[ext_resource type="Texture2D" uid="uid://c0qub1plvyt4x" path="res://assets/ui/move.png" id="10_5l1u7"]
|
||||
[ext_resource type="Texture2D" uid="uid://bgqfuj6p3h5ad" path="res://assets/ui/attack.png" id="11_5l1u7"]
|
||||
[ext_resource type="Script" uid="uid://bqykrbwxdktxk" path="res://addons/virtual_joystick/virtual_joystick_instantiator.gd" id="13_1o0bm"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_0gv45"]
|
||||
radius = 56.5685
|
||||
|
|
@ -15,7 +28,11 @@ collision_layer = 12
|
|||
collision_mask = 3
|
||||
motion_mode = 1
|
||||
script = ExtResource("2_acneu")
|
||||
spawnDistance = 1000
|
||||
spawnDistance = 5000
|
||||
shotgunTexture = ExtResource("3_ah1lv")
|
||||
minigunTexture = ExtResource("4_1o0bm")
|
||||
railgunTexture = ExtResource("5_5sy6u")
|
||||
invincible = true
|
||||
|
||||
[node name="CollisionShape2D" parent="." index="0"]
|
||||
shape = SubResource("CircleShape2D_0gv45")
|
||||
|
|
@ -24,30 +41,234 @@ shape = SubResource("CircleShape2D_0gv45")
|
|||
shape = SubResource("RectangleShape2D_0gv45")
|
||||
|
||||
[node name="Sprite2D" parent="." index="2"]
|
||||
texture = ExtResource("3_0gv45")
|
||||
position = Vector2(0, -24)
|
||||
|
||||
[node name="dashCooldown" type="Timer" parent="." index="5"]
|
||||
wait_time = 10.0
|
||||
one_shot = true
|
||||
autostart = true
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="." index="6"]
|
||||
[node name="selfHealTimer" type="Timer" parent="." index="6"]
|
||||
one_shot = true
|
||||
|
||||
[node name="spawnPointPool" type="Node2D" parent="." index="7"]
|
||||
[node name="selfHealCountdownTimer" type="Timer" parent="." index="7"]
|
||||
wait_time = 10.0
|
||||
one_shot = true
|
||||
|
||||
[node name="spawnPoint" type="Marker2D" parent="spawnPointPool" index="0"]
|
||||
position = Vector2(360, -176)
|
||||
[node name="Camera2D" type="Camera2D" parent="." index="8"]
|
||||
script = ExtResource("4_sk4ix")
|
||||
|
||||
[node name="spawnPoint2" type="Marker2D" parent="spawnPointPool" index="1"]
|
||||
position = Vector2(392, 256)
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="Camera2D" index="0"]
|
||||
|
||||
[node name="spawnPoint3" type="Marker2D" parent="spawnPointPool" index="2"]
|
||||
position = Vector2(-416, 224)
|
||||
[node name="Control" type="Control" parent="Camera2D/CanvasLayer" index="0"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("4_o6j0d")
|
||||
|
||||
[node name="spawnPoint4" type="Marker2D" parent="spawnPointPool" index="3"]
|
||||
position = Vector2(-408, -168)
|
||||
[node name="Input" type="Control" parent="Camera2D/CanvasLayer/Control" index="0"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("8_5l1u7")
|
||||
|
||||
[node name="Virtual Joystick" type="Control" parent="Camera2D/CanvasLayer/Control/Input" index="0"]
|
||||
modulate = Color(1, 1, 1, 0.588235)
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -40.0
|
||||
offset_right = 40.0
|
||||
grow_vertical = 0
|
||||
scale = Vector2(2.5, 2.5)
|
||||
script = ExtResource("13_1o0bm")
|
||||
metadata/_custom_type_script = "uid://bqykrbwxdktxk"
|
||||
|
||||
[node name="MoveButton" type="TouchScreenButton" parent="Camera2D/CanvasLayer/Control/Input" index="1"]
|
||||
modulate = Color(1, 1, 1, 0.588235)
|
||||
position = Vector2(1408, 576)
|
||||
scale = Vector2(14, 14)
|
||||
texture_normal = ExtResource("10_5l1u7")
|
||||
action = "touchscreenForward"
|
||||
|
||||
[node name="ShootButton" type="TouchScreenButton" parent="Camera2D/CanvasLayer/Control/Input" index="2"]
|
||||
modulate = Color(1, 1, 1, 0.588235)
|
||||
position = Vector2(896, 560)
|
||||
scale = Vector2(14, 14)
|
||||
texture_normal = ExtResource("11_5l1u7")
|
||||
action = "attack"
|
||||
|
||||
[node name="ShootButtonCorner" type="Control" parent="Camera2D/CanvasLayer/Control/Input" index="3"]
|
||||
layout_mode = 1
|
||||
anchor_left = 0.992
|
||||
anchor_top = 0.985
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -1016.64
|
||||
offset_top = -495.8
|
||||
offset_right = -1024.0
|
||||
offset_bottom = -504.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="MoveButtonCorner" type="Control" parent="Camera2D/CanvasLayer/Control/Input" index="4"]
|
||||
layout_mode = 1
|
||||
anchor_left = 0.992
|
||||
anchor_top = 0.985
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -504.64
|
||||
offset_top = -495.8
|
||||
offset_right = -512.0
|
||||
offset_bottom = -504.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Camera2D/CanvasLayer/Control" index="1"]
|
||||
layout_mode = 1
|
||||
offset_left = 64.0
|
||||
offset_top = 64.0
|
||||
offset_right = 1096.0
|
||||
offset_bottom = 238.0
|
||||
|
||||
[node name="Weapon" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/VBoxContainer" index="0"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Camera2D/CanvasLayer/Control/VBoxContainer/Weapon" index="0"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HealthUi" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/VBoxContainer" index="1"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Camera2D/CanvasLayer/Control/VBoxContainer/HealthUi" index="0"]
|
||||
layout_mode = 2
|
||||
texture = ExtResource("6_sytd6")
|
||||
expand_mode = 2
|
||||
|
||||
[node name="LabelHealth" type="Label" parent="Camera2D/CanvasLayer/Control/VBoxContainer/HealthUi" index="1"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ProgressBarHealth" type="ProgressBar" parent="Camera2D/CanvasLayer/Control/VBoxContainer/HealthUi" index="2"]
|
||||
modulate = Color(1, 0, 0, 1)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
theme_override_font_sizes/font_size = 0
|
||||
show_percentage = false
|
||||
|
||||
[node name="SpeedUi" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/VBoxContainer" index="2"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="LabelSpeed" type="Label" parent="Camera2D/CanvasLayer/Control/VBoxContainer/SpeedUi" index="0"]
|
||||
layout_mode = 2
|
||||
text = "S"
|
||||
|
||||
[node name="ProgressBarSpeed" type="ProgressBar" parent="Camera2D/CanvasLayer/Control/VBoxContainer/SpeedUi" index="1"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
step = 1.0
|
||||
|
||||
[node name="DashCooldownUi" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/VBoxContainer" index="3"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Camera2D/CanvasLayer/Control/VBoxContainer/DashCooldownUi" index="0"]
|
||||
layout_mode = 2
|
||||
texture = ExtResource("7_qoa7h")
|
||||
expand_mode = 2
|
||||
|
||||
[node name="LabelDashCooldown" type="Label" parent="Camera2D/CanvasLayer/Control/VBoxContainer/DashCooldownUi" index="1"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ProgressBarDashCooldown" type="ProgressBar" parent="Camera2D/CanvasLayer/Control/VBoxContainer/DashCooldownUi" index="2"]
|
||||
modulate = Color(0, 0.172549, 1, 1)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
show_percentage = false
|
||||
|
||||
[node name="WeaponCooldown" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/VBoxContainer" index="4"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Camera2D/CanvasLayer/Control/VBoxContainer/WeaponCooldown" index="0"]
|
||||
layout_mode = 2
|
||||
texture = ExtResource("8_48lx4")
|
||||
expand_mode = 2
|
||||
|
||||
[node name="LabelWeaponCooldown" type="Label" parent="Camera2D/CanvasLayer/Control/VBoxContainer/WeaponCooldown" index="1"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ProgressBarWeaponCooldown" type="ProgressBar" parent="Camera2D/CanvasLayer/Control/VBoxContainer/WeaponCooldown" index="2"]
|
||||
modulate = Color(0.870588, 1, 0, 1)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
show_percentage = false
|
||||
|
||||
[node name="HBoxContainer" type="VBoxContainer" parent="Camera2D/CanvasLayer/Control" index="2"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -560.0
|
||||
offset_top = 64.0
|
||||
offset_right = -61.0
|
||||
offset_bottom = 321.0
|
||||
grow_horizontal = 0
|
||||
alignment = 1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/HBoxContainer" index="0"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="LabelWave" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer" index="0"]
|
||||
layout_mode = 2
|
||||
text = "WAVE: "
|
||||
|
||||
[node name="LabelWaveInfo" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer" index="1"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/HBoxContainer" index="1"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="LabelWaveEnemies" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer2" index="0"]
|
||||
layout_mode = 2
|
||||
text = "Enemies: "
|
||||
|
||||
[node name="LabelWaveEnemiesInfo" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer2" index="1"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer3" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control/HBoxContainer" index="2"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="LabelWaveDestroyed" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer3" index="0"]
|
||||
layout_mode = 2
|
||||
text = "Destroyed: "
|
||||
|
||||
[node name="LabelWaveDestroyedInfo" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer/HBoxContainer3" index="1"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="UpgradeChooser" parent="Camera2D/CanvasLayer/Control" index="3" instance=ExtResource("5_nno2o")]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
||||
[node name="hit" type="AudioStreamPlayer2D" parent="." index="9"]
|
||||
stream = ExtResource("7_sma6c")
|
||||
|
||||
[connection signal="hurt" from="hurtArea" to="." method="_on_hurt_area_hurt"]
|
||||
[connection signal="timeout" from="dashCooldown" to="." method="_on_dash_cooldown_timeout"]
|
||||
[connection signal="timeout" from="selfHealTimer" to="." method="_on_self_heal_timer_timeout"]
|
||||
[connection signal="timeout" from="selfHealCountdownTimer" to="." method="_on_self_heal_countdown_timeout"]
|
||||
|
||||
[editable path="hurtArea"]
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://csacin2gx2tum"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://csacin2gx2tum"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://quxft75411y7" path="res://scenes/spaceShip/spaceShip.gd" id="1_a2e5l"]
|
||||
[ext_resource type="PackedScene" uid="uid://cglnd1ekr5u6r" path="res://scenes/areas/hurtArea/hurtArea.tscn" id="2_b8guf"]
|
||||
[ext_resource type="AudioStream" uid="uid://decf2fp3ve2v8" path="res://assets/sound/radiation.wav" id="3_6p3ob"]
|
||||
|
||||
[node name="Spaceship" type="CharacterBody2D" groups=["spaceShip"]]
|
||||
collision_layer = 4
|
||||
|
|
@ -19,5 +20,12 @@ script = ExtResource("1_a2e5l")
|
|||
one_shot = true
|
||||
autostart = true
|
||||
|
||||
[node name="radiationDamageTimer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="radiationDamage" type="AudioStreamPlayer2D" parent="."]
|
||||
stream = ExtResource("3_6p3ob")
|
||||
|
||||
[connection signal="area_entered" from="hurtArea" to="." method="_on_hurt_area_area_entered"]
|
||||
[connection signal="timeout" from="invincibleTimer" to="." method="_on_invincible_timer_timeout"]
|
||||
[connection signal="timeout" from="radiationDamageTimer" to="." method="_on_radiation_damge_timer_timeout"]
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
class_name TimeGhost extends "res://scenes/spaceShip/spaceShip.gd"
|
||||
|
||||
@onready var damageArea = $DamageArea
|
||||
|
||||
@export var spaceShip: Spaceship = null
|
||||
|
||||
|
||||
#func _init(_speed: int, _acceleration: float) -> void:
|
||||
# speed = _speed
|
||||
#acceleration = _acceleration
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
move_and_slide()
|
||||
|
||||
|
|
@ -15,3 +19,8 @@ func setSpaceship(_spaceShip: Spaceship):
|
|||
acceleration = spaceShip.acceleration
|
||||
global_position = spaceShip.global_position
|
||||
sprite.texture = spaceShip.sprite.texture
|
||||
|
||||
|
||||
func _on_damage_area_area_entered(area: Area2D) -> void:
|
||||
if area.get_parent().is_in_group("player"):
|
||||
damageArea.damageHurtArea(area, Globals.getPlayer().maxHealth)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://dms0cw7opfd64"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://dms0cw7opfd64"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://csacin2gx2tum" path="res://scenes/spaceShip/spaceShip.tscn" id="1_bm7fr"]
|
||||
[ext_resource type="Script" uid="uid://m3hn5tl2nidk" path="res://scenes/spaceShip/timeGhost/timeghost.gd" id="2_57067"]
|
||||
[ext_resource type="PackedScene" uid="uid://eqo7k2ronf8k" path="res://scenes/areas/damageArea/damageArea.tscn" id="3_5nmba"]
|
||||
[ext_resource type="Texture2D" uid="uid://cd5anydes4tv3" path="res://assets/player/shotgunShip.png" id="3_37yrs"]
|
||||
[ext_resource type="Texture2D" uid="uid://dlahm782n0awk" path="res://assets/player/minigunShip.png" id="4_s1boh"]
|
||||
[ext_resource type="Texture2D" uid="uid://dhbn4acw1a6eu" path="res://assets/player/railgunShip.png" id="5_1tvm6"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5nmba"]
|
||||
size = Vector2(50, 50)
|
||||
|
|
@ -11,23 +14,24 @@ size = Vector2(50, 50)
|
|||
size = Vector2(50, 50)
|
||||
|
||||
[node name="Timeghost" groups=["timeGhost"] instance=ExtResource("1_bm7fr")]
|
||||
modulate = Color(0, 1, 1, 1)
|
||||
modulate = Color(0.54902, 1, 1, 0.588235)
|
||||
collision_layer = 20
|
||||
script = ExtResource("2_57067")
|
||||
shotgunTexture = ExtResource("3_37yrs")
|
||||
minigunTexture = ExtResource("4_s1boh")
|
||||
railgunTexture = ExtResource("5_1tvm6")
|
||||
invincible = true
|
||||
|
||||
[node name="CollisionShape2D" parent="." index="0"]
|
||||
shape = SubResource("RectangleShape2D_5nmba")
|
||||
disabled = true
|
||||
|
||||
[node name="hurtArea" parent="." index="1"]
|
||||
visible = false
|
||||
|
||||
[node name="DamageArea" parent="." index="4" instance=ExtResource("3_5nmba")]
|
||||
damage = 10
|
||||
|
||||
[node name="CollisionShape2D" parent="DamageArea" index="0"]
|
||||
shape = SubResource("RectangleShape2D_m3s7j")
|
||||
disabled = true
|
||||
|
||||
[connection signal="area_entered" from="DamageArea" to="." method="_on_damage_area_area_entered"]
|
||||
|
||||
[editable path="hurtArea"]
|
||||
[editable path="DamageArea"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue