mirror of
https://github.com/PfandBoss/SemesterGameJam2022.git
synced 2025-11-12 04:16:12 +01:00
start MapNodes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
extends Node
|
||||
class_name Game
|
||||
|
||||
#Signals
|
||||
signal ammo_pickup
|
||||
@@ -6,36 +7,22 @@ signal shoot
|
||||
|
||||
var t = 0.0
|
||||
|
||||
@onready var tween = create_tween() as Tween
|
||||
@onready var p1_train = $Player1 as Train
|
||||
@onready var p2_train = $Player2 as Train
|
||||
|
||||
@export var p1 : PathFollow3D
|
||||
@export var p2 : PathFollow3D
|
||||
|
||||
var speed_p1 = 10
|
||||
var speed_p2 = 10
|
||||
|
||||
func _ready():
|
||||
p1.get_node("root").test.connect(func(): print("player1"))
|
||||
p2.get_node("root").test.connect(func(): print("player2"))
|
||||
start_tween()
|
||||
|
||||
func start_tween():
|
||||
tween.stop()
|
||||
tween = create_tween()
|
||||
tween.set_parallel()
|
||||
tween.set_trans(Tween.TRANS_LINEAR)
|
||||
tween.tween_property(p1, "progress_ratio", 1, speed_p1)
|
||||
tween.tween_property(p2, "progress_ratio", -1, speed_p2)
|
||||
|
||||
p2_train.is_P1 = false
|
||||
p1_train.hit.connect(_on_hit_player)
|
||||
|
||||
|
||||
func _on_hit_player(player1,dmg):
|
||||
if not player1:
|
||||
p2_train.current_speed -= dmg
|
||||
else:
|
||||
p1_train.current_speed -= dmg
|
||||
|
||||
func _process(delta):
|
||||
if Input.is_action_pressed("test"):
|
||||
speed_p1 = 5
|
||||
start_tween()
|
||||
|
||||
if round(p1.position.distance_to(p2.position)) == 9:
|
||||
emit_signal("shoot")
|
||||
|
||||
|
||||
|
||||
|
||||
14
scripts/Logic/MapNode.gd
Normal file
14
scripts/Logic/MapNode.gd
Normal file
@@ -0,0 +1,14 @@
|
||||
extends Node
|
||||
class_name MapNode
|
||||
|
||||
const LENGTH = 10
|
||||
const PICKUP = 0
|
||||
var previous : MapNode
|
||||
|
||||
var current_trains = []
|
||||
|
||||
func _on_train_entered(train):
|
||||
current_trains.append(train)
|
||||
|
||||
func _on_train_exit(train):
|
||||
current_trains.erase(train)
|
||||
8
scripts/Logic/StraightMapNode.gd
Normal file
8
scripts/Logic/StraightMapNode.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
extends MapNode
|
||||
class_name StraightMapNode
|
||||
|
||||
var next : MapNode
|
||||
|
||||
func _on_train_exit(train):
|
||||
next._on_train_entered(train)
|
||||
super._on_train_exit(train)
|
||||
18
scripts/Logic/TurnMapNode.gd
Normal file
18
scripts/Logic/TurnMapNode.gd
Normal file
@@ -0,0 +1,18 @@
|
||||
extends StraightMapNode
|
||||
|
||||
signal turnEvent
|
||||
|
||||
var is_left_turn = false
|
||||
var turn = false
|
||||
var turn_node : MapNode
|
||||
|
||||
func _on_train_entered(train):
|
||||
super._on_train_entered(train)
|
||||
turnEvent.emit()
|
||||
|
||||
func _on_train_exit(train):
|
||||
if(turn):
|
||||
turn_node._on_train_entered(train)
|
||||
current_trains.erase(train)
|
||||
else:
|
||||
super._on_train_exit(train)
|
||||
Reference in New Issue
Block a user