Adds missing data
This commit is contained in:
parent
e6391d9fdd
commit
53cdcc3433
620 changed files with 47293 additions and 151 deletions
|
|
@ -8,6 +8,9 @@ const MOVEMENT_SPEED = 1
|
|||
@onready var enemyAi: EnemyAI = $BTPlayer
|
||||
@onready var health: Health = $Health
|
||||
@onready var origin: Node3D = $"enemies/Vert/Shoot Marker"
|
||||
@onready var enemyVisual: Node3D = $enemies/Vert
|
||||
@onready var shootSound: AudioStreamPlayer3D = $"enemies/Vert/Shoot Marker/ShootSound"
|
||||
@onready var deathSound: AudioStreamPlayer = $DeathSound
|
||||
|
||||
const SPEED = 5.0
|
||||
const JUMP_VELOCITY = 4.5
|
||||
|
|
@ -18,13 +21,19 @@ func _ready() -> void:
|
|||
health.death.connect(died)
|
||||
|
||||
func died() -> void:
|
||||
deathSound.play()
|
||||
|
||||
process_mode = Node.PROCESS_MODE_DISABLED
|
||||
|
||||
await deathSound.finished
|
||||
|
||||
queue_free()
|
||||
|
||||
func updateMovementBlend(delta: float, to: float) -> void:
|
||||
movementBlend = move_toward(movementBlend, to, delta * 2);
|
||||
|
||||
func rotateTo(delta: float, targetDirection: Vector3) -> void:
|
||||
self.global_basis.z = lerp(self.global_basis.z, targetDirection, delta * 10);
|
||||
self.global_basis.z = targetDirection;
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if agent.is_navigation_finished():
|
||||
|
|
@ -50,11 +59,10 @@ func _physics_process(delta: float) -> void:
|
|||
self.animationtree['parameters/Movement/blend_position'] = movementBlend
|
||||
|
||||
func fireWeapon() -> void:
|
||||
var fireDirection = (Player.Instance.enemyTarget.global_position - origin.global_position).normalized()
|
||||
fireDirection = fireDirection.rotated(Vector3.UP, randf_range(-.3, .3))
|
||||
shootSound.play()
|
||||
|
||||
DebugDraw3D.draw_arrow(origin.global_position, origin.global_position + Vector3.UP * 1, Color.RED, 0.5, true, 10)
|
||||
DebugDraw3D.draw_arrow(origin.global_position, origin.global_position + fireDirection * 10, Color.WHITE, 0.5, true, 10)
|
||||
var fireDirection = (Player.Instance.enemyTarget.global_position - origin.global_position).normalized()
|
||||
fireDirection = fireDirection.rotated(Vector3.UP, randf_range(-0.1, 0.1))
|
||||
|
||||
var query = PhysicsRayQueryParameters3D.create(origin.global_position, origin.global_position + fireDirection * 200)
|
||||
var result = get_world_3d().direct_space_state.intersect_ray(query)
|
||||
|
|
@ -67,4 +75,4 @@ func fireWeapon() -> void:
|
|||
if not health:
|
||||
return
|
||||
|
||||
result.collider.health.take_damage(1, Vector2(0,0))
|
||||
result.collider.health.take_damage(1, Vector2(0,0), self.origin)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const DISTANCE_TO_PLAYER: float = 10.0
|
|||
@export var character: Enemy
|
||||
|
||||
@export_category("Sprite")
|
||||
@export var sprite:Sprite3D;
|
||||
@export var visual: GeometryInstance3D;
|
||||
@export var idleTexture: Texture2D;
|
||||
@export var aggressiveTexture: Texture2D;
|
||||
|
||||
|
|
@ -25,12 +25,23 @@ var aggressive = false
|
|||
func _physics_process(_delta: float) -> void:
|
||||
self.blackboard.set_var('PlayerDistance', character.global_position.distance_to(Player.Instance.global_position))
|
||||
self.blackboard.set_var('LookingAngleToPlayer', (-character.global_basis.z).dot((character.global_position - Player.Instance.global_position).normalized()))
|
||||
|
||||
self.blackboard.set_var('PlayerVisible', getPlayerVisible())
|
||||
|
||||
func getPlayerVisible() -> bool:
|
||||
var query = PhysicsRayQueryParameters3D.create(Origin.global_position, Player.Instance.global_position);
|
||||
var result = character.get_world_3d().direct_space_state.intersect_ray(query)
|
||||
|
||||
if !result:
|
||||
return false
|
||||
|
||||
return result.collider is Player
|
||||
|
||||
func setAggressive(value: bool) -> void:
|
||||
if not aggressive && value:
|
||||
agent.target_position = character.global_position;
|
||||
|
||||
sprite.texture = aggressiveTexture if value else idleTexture
|
||||
(visual.material_overlay as StandardMaterial3D).albedo_texture = aggressiveTexture if value else idleTexture
|
||||
aggressive = value
|
||||
|
||||
|
||||
|
|
@ -44,7 +55,7 @@ func moveToPlayer() -> void:
|
|||
|
||||
func Fire() -> void:
|
||||
self.animationTree['parameters/playback'].travel('Fire')
|
||||
var instance = MuzzleFlash.instantiate(PackedScene.GEN_EDIT_STATE_INSTANCE)
|
||||
var instance = MuzzleFlash.instantiate()
|
||||
Origin.add_child(instance)
|
||||
character.fireWeapon()
|
||||
|
||||
|
|
|
|||
24
scripts/level_secret_handler.gd
Normal file
24
scripts/level_secret_handler.gd
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
extends Node
|
||||
class_name SecretHandler
|
||||
|
||||
var totalTriggers: int = 0
|
||||
var triggers: Array[String] = []
|
||||
|
||||
signal SecretTriggered
|
||||
|
||||
func registerTrigger(id: String) -> void:
|
||||
if triggers.count(id) > 0:
|
||||
return
|
||||
|
||||
totalTriggers = totalTriggers + 1
|
||||
triggers.append(id)
|
||||
|
||||
func triggered(id: String) -> void:
|
||||
if triggers.count(id) < 1:
|
||||
return
|
||||
|
||||
triggers.erase(id)
|
||||
print("Triggered ", id)
|
||||
SecretTriggered.emit()
|
||||
|
||||
Player.Instance.ui.displaySecret()
|
||||
|
|
@ -1,16 +1,25 @@
|
|||
extends Camera3D
|
||||
|
||||
class_name CameraController
|
||||
|
||||
@export var PlayerNode: Node3D;
|
||||
|
||||
@export var turnSpeed: float = 0.25;
|
||||
@export var XRotationClamp: Vector2 = Vector2(-90, 90)
|
||||
|
||||
var currentRotation: Vector2 = Vector2(0,0);
|
||||
var enabled: bool = true
|
||||
|
||||
func _ready() -> void:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED;
|
||||
|
||||
func disableInput():
|
||||
enabled = false
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not enabled:
|
||||
return
|
||||
|
||||
if event is InputEventKey && event.key_label == KEY_ESCAPE:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,15 @@ static var Instance: Player;
|
|||
@onready var collisionShape: CollisionShape3D = $CollisionShape3D
|
||||
@onready var health: Health = $Health
|
||||
@onready var enemyTarget: Node3D = $"Enemy Target"
|
||||
@onready var deathHandler: DeathHandler = $DeathHandler
|
||||
@onready var cameraController: CameraController = $CollisionShape3D/Camera3D
|
||||
@onready var ui: UI = $Ui
|
||||
@onready var weapon: Node3D = $CollisionShape3D/Camera3D/Weapon
|
||||
|
||||
@onready var walkingSound = $Walking
|
||||
@onready var sprintingSound = $Sprinting
|
||||
@onready var startupSound = $Startup
|
||||
@onready var hitSound = $HitSound
|
||||
|
||||
const CROUCHED_SPEED: float = 2.5
|
||||
const SPEED: float = 5.0
|
||||
|
|
@ -23,13 +32,25 @@ const JUMP_VELOCITY: float = 4.5
|
|||
|
||||
var lastDirection = Vector2(0,0)
|
||||
@export var PlayerState: PlayerStates = PlayerStates.STANDING
|
||||
var controls = true
|
||||
|
||||
# Get the gravity from the project settings to be synced with RigidBody nodes.
|
||||
var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity")
|
||||
|
||||
func _ready() -> void:
|
||||
weapon.process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
|
||||
get_tree().paused = true
|
||||
ui.setFade(0)
|
||||
get_tree().create_timer(1).timeout.connect(readying)
|
||||
weapon.process_mode = Node.PROCESS_MODE_PAUSABLE
|
||||
|
||||
Instance = self
|
||||
health.damaged.connect(self.damaged)
|
||||
health.death.connect(self.onDeath)
|
||||
|
||||
func readying():
|
||||
get_tree().paused = false;
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
# Add the gravity.
|
||||
|
|
@ -53,8 +74,12 @@ func _physics_process(delta: float) -> void:
|
|||
self.handleCrouching()
|
||||
if PlayerState == PlayerStates.STANDING && Input.is_action_pressed('player_sprint'):
|
||||
self.PlayerState = PlayerStates.SPRINTING
|
||||
walkingSound.process_mode = Node.PROCESS_MODE_DISABLED
|
||||
sprintingSound.process_mode = Node.PROCESS_MODE_INHERIT
|
||||
if PlayerState == PlayerStates.SPRINTING && Input.is_action_just_released('player_sprint'):
|
||||
self.PlayerState = PlayerStates.STANDING
|
||||
walkingSound.process_mode = Node.PROCESS_MODE_INHERIT
|
||||
sprintingSound.process_mode = Node.PROCESS_MODE_DISABLED
|
||||
|
||||
if PlayerState == PlayerStates.SPRINTING:
|
||||
speed = SPRINT_SPEED
|
||||
|
|
@ -96,3 +121,17 @@ func handleCrouching():
|
|||
|
||||
func damaged():
|
||||
print("Damage")
|
||||
|
||||
func onDeath(from):
|
||||
hitSound.play()
|
||||
deathHandler.died(from)
|
||||
cameraController.disableInput()
|
||||
ui.displayYouDied()
|
||||
|
||||
get_tree().paused = true
|
||||
|
||||
await get_tree().create_timer(2.5).timeout
|
||||
ui.setFade(1)
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
|
||||
get_tree().reload_current_scene()
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ extends Node3D
|
|||
|
||||
@onready var animationtree: AnimationTree = $AnimationPlayer/AnimationTree
|
||||
@onready var timer: Timer = $CooldownTimer
|
||||
@onready var shootSound: AudioStreamPlayer3D = $ShootSound
|
||||
|
||||
@export_category("Firing")
|
||||
@export var MuzzleFlash: PackedScene
|
||||
|
|
@ -33,25 +34,23 @@ func _input(event: InputEvent) -> void:
|
|||
|
||||
self.animationtree.set('parameters/' + travelTarget + '/blend_position', randf_range(0, 2))
|
||||
self.statemachine.travel(travelTarget)
|
||||
shootSound.play()
|
||||
|
||||
fireBullet()
|
||||
|
||||
self.timer.start()
|
||||
|
||||
func fireBullet() -> void:
|
||||
var instance = self.MuzzleFlash.instantiate(PackedScene.GEN_EDIT_STATE_INSTANCE)
|
||||
var instance = self.MuzzleFlash.instantiate()
|
||||
Origin.add_child(instance)
|
||||
|
||||
var query = PhysicsRayQueryParameters3D.create(BulletOrigin.global_position, BulletOrigin.global_position + BulletOrigin.global_basis.z * -200)
|
||||
var result = get_world_3d().direct_space_state.intersect_ray(query)
|
||||
|
||||
if not result:
|
||||
print('No result')
|
||||
return
|
||||
|
||||
var health = result.collider.get_node_or_null('Health')
|
||||
if health:
|
||||
print("Dealing Damage")
|
||||
result.collider.health.take_damage(1, Vector2(0,0))
|
||||
result.collider.health.take_damage(1, Vector2(0,0), BulletOrigin)
|
||||
return
|
||||
print('No Health Element')
|
||||
|
|
|
|||
10
scripts/secret_label.gd
Normal file
10
scripts/secret_label.gd
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
extends Label3D
|
||||
|
||||
@export var secretHandler: SecretHandler;
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
secretHandler.SecretTriggered.connect(self.secretTriggered)
|
||||
|
||||
func secretTriggered() -> void:
|
||||
text = 'Secrets found: \n {0} / {1}'.format([secretHandler.totalTriggers - secretHandler.triggers.size(), secretHandler.totalTriggers])
|
||||
Loading…
Add table
Add a link
Reference in a new issue