TUBES NOW SHOOT UP, A BASKED NOW CATCHES YOU
This commit is contained in:
@@ -1,8 +1,25 @@
|
||||
extends Area3D
|
||||
class_name LevelBounds
|
||||
|
||||
var level_collision_shapes : Array[CollisionShape3D]
|
||||
var check_collision = true
|
||||
|
||||
func _ready() -> void:
|
||||
for i in get_children():
|
||||
if i is CollisionShape3D:
|
||||
level_collision_shapes.append(i)
|
||||
|
||||
func _on_body_exited(body: Node3D) -> void:
|
||||
var level_control = get_tree().current_scene
|
||||
if level_control.gamemode.die_on_leaving_bounds == true:
|
||||
get_tree().current_scene.die()
|
||||
else:
|
||||
body.global_position = body.last_ground_pos + Vector3(0,10,0)
|
||||
if check_collision == true:
|
||||
var level_control = get_tree().current_scene
|
||||
if level_control.gamemode.die_on_leaving_bounds == true:
|
||||
get_tree().current_scene.die()
|
||||
else:
|
||||
body.global_position = body.last_ground_pos + Vector3(0,10,0)
|
||||
|
||||
func toggle_collision(collision_state):
|
||||
print("COLLISION STATE: ",collision_state)
|
||||
check_collision = collision_state
|
||||
if level_collision_shapes != null and level_collision_shapes != []:
|
||||
for i in level_collision_shapes:
|
||||
i.disabled = collision_state
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
extends CharacterBody3D
|
||||
class_name Player
|
||||
|
||||
const JUMP_WEAPON_DIP = Vector3(0,-5,0)
|
||||
const AIR_TRANSITION_SPEED = 7
|
||||
|
||||
@@ -3,32 +3,30 @@ class_name Portal
|
||||
|
||||
var level_info = {}
|
||||
|
||||
|
||||
var timer_active = false
|
||||
var active = true
|
||||
var entered = false
|
||||
var index : int
|
||||
|
||||
@onready var timer: Timer = $Timer
|
||||
@onready var scene_holder: Node3D = $Scene_Holder
|
||||
|
||||
const SCENE_SPAWN_OFFSET = Vector3(0,400,0)
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_body_entered(body: Node3D) -> void:
|
||||
if body.is_in_group("player"):
|
||||
if active and timer_active:
|
||||
if body is Player:
|
||||
if active and !entered:
|
||||
active = false
|
||||
timer.start(1)
|
||||
var scene = load(level_info["level_path"]).instantiate()
|
||||
|
||||
get_tree().current_scene.add_child(scene)
|
||||
scene_holder.add_child(scene)
|
||||
scene.global_position = global_position + SCENE_SPAWN_OFFSET
|
||||
|
||||
entered = true
|
||||
if active and entered:
|
||||
var spawned_stuff = scene_holder.get_children()
|
||||
for i in spawned_stuff:
|
||||
i.queue_free()
|
||||
|
||||
|
||||
func _on_start_activation_timeout() -> void:
|
||||
timer_active = true
|
||||
active = true
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
extends Node
|
||||
class_name SwitchBasic
|
||||
|
||||
signal switch_changed
|
||||
|
||||
@export var switch_override : bool = false
|
||||
@export var start_on : bool = false
|
||||
@export var toggle_enabled : bool = false
|
||||
@export var bullet_enabled : bool = true
|
||||
@export var timer_enabled : bool = false
|
||||
@export var timer_duration : float = 2.0
|
||||
@export var anim_player : AnimationPlayer
|
||||
|
||||
var switched_on : bool
|
||||
|
||||
@@ -18,23 +21,31 @@ func _ready() -> void:
|
||||
switched_on = start_on
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func switch():
|
||||
if toggle_enabled:
|
||||
if switched_on == true:
|
||||
switched_on = false
|
||||
SignalBus.emit_signal("switch_changed")
|
||||
switch_changed.emit()
|
||||
|
||||
if anim_player != null:
|
||||
anim_player.play("off")
|
||||
|
||||
else:
|
||||
switched_on = true
|
||||
SignalBus.emit_signal("switch_changed")
|
||||
switch_changed.emit()
|
||||
|
||||
if anim_player != null:
|
||||
anim_player.play("on")
|
||||
|
||||
if timer_enabled:
|
||||
start_timer()
|
||||
else:
|
||||
switched_on = true
|
||||
SignalBus.emit_signal("switch_changed")
|
||||
switch_changed.emit()
|
||||
|
||||
if anim_player != null:
|
||||
anim_player.play("on")
|
||||
|
||||
if timer_enabled:
|
||||
start_timer()
|
||||
|
||||
@@ -44,4 +55,4 @@ func start_timer():
|
||||
|
||||
func _on_timer_timeout():
|
||||
switched_on = false
|
||||
SignalBus.emit_signal("switch_changed")
|
||||
switch_changed.emit()
|
||||
|
||||
26
scripts/tube_top.gd
Normal file
26
scripts/tube_top.gd
Normal file
@@ -0,0 +1,26 @@
|
||||
extends Node3D
|
||||
|
||||
@export var level_bounds : LevelBounds
|
||||
|
||||
var open = true
|
||||
var active = true
|
||||
|
||||
@onready var anim_player: AnimationPlayer = $AnimationPlayer
|
||||
|
||||
|
||||
func _on_player_detect_body_entered(body: Node3D) -> void:
|
||||
if body is Player:
|
||||
if open and active:
|
||||
anim_player.play("close")
|
||||
open = false
|
||||
|
||||
func _on_switch_1_switch_changed() -> void:
|
||||
if open:
|
||||
anim_player.play("close")
|
||||
open = false
|
||||
else:
|
||||
anim_player.play("open")
|
||||
open = true
|
||||
|
||||
if level_bounds != null:
|
||||
level_bounds.toggle_collision(!open)
|
||||
1
scripts/tube_top.gd.uid
Normal file
1
scripts/tube_top.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b420xwtc2odnk
|
||||
Reference in New Issue
Block a user