fix round display when custom map rounds
This commit is contained in:
parent
37e0c0470d
commit
0fad385344
3 changed files with 7 additions and 1 deletions
|
@ -4,6 +4,9 @@ extends Node2D
|
||||||
|
|
||||||
var reference_gamestateplayer
|
var reference_gamestateplayer
|
||||||
|
|
||||||
|
func setMapRounds(r:int):
|
||||||
|
$CharacterBody_Car/label_round.map_rounds=r
|
||||||
|
|
||||||
func getSpeed() -> float:
|
func getSpeed() -> float:
|
||||||
return cbcar.velocity.length()
|
return cbcar.velocity.length()
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ func _ready() -> void:
|
||||||
|
|
||||||
if (mapsceneinstance.override_rounds_number>0): #if set to 0, do not override
|
if (mapsceneinstance.override_rounds_number>0): #if set to 0, do not override
|
||||||
map_rounds=mapsceneinstance.override_rounds_number
|
map_rounds=mapsceneinstance.override_rounds_number
|
||||||
|
|
||||||
|
|
||||||
print(str(checkpoints.size())+" Checkpoints found")
|
print(str(checkpoints.size())+" Checkpoints found")
|
||||||
|
|
||||||
|
@ -84,6 +85,7 @@ func _ready() -> void:
|
||||||
newcarinstance.setCheckpoints(checkpoints,map_rounds)
|
newcarinstance.setCheckpoints(checkpoints,map_rounds)
|
||||||
newcarinstance.getCharacterBody().car_finished.connect(_on_car_finished)
|
newcarinstance.getCharacterBody().car_finished.connect(_on_car_finished)
|
||||||
newcarinstance.getCharacterBody().car_on_checkpoint.connect(_on_car_on_checkpoint)
|
newcarinstance.getCharacterBody().car_on_checkpoint.connect(_on_car_on_checkpoint)
|
||||||
|
newcarinstance.setMapRounds(map_rounds) #give information to each car (to show correct rounds number)
|
||||||
|
|
||||||
var startmarker:Sprite2D=mapsceneinstance.get_node("startmarker")
|
var startmarker:Sprite2D=mapsceneinstance.get_node("startmarker")
|
||||||
if startmarker != null:
|
if startmarker != null:
|
||||||
|
|
|
@ -2,6 +2,7 @@ extends Label
|
||||||
|
|
||||||
@onready var animation_player: AnimationPlayer = $"../AnimationPlayer"
|
@onready var animation_player: AnimationPlayer = $"../AnimationPlayer"
|
||||||
|
|
||||||
|
var map_rounds=0
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
@ -13,7 +14,7 @@ func _process(delta: float) -> void:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func showRounds(round):
|
func showRounds(round):
|
||||||
var rounds=Gamestate.getRounds()
|
var rounds=map_rounds
|
||||||
if (round==-1): #finished
|
if (round==-1): #finished
|
||||||
round=rounds
|
round=rounds
|
||||||
text=str(round)+"/"+str(rounds)
|
text=str(round)+"/"+str(rounds)
|
||||||
|
|
Loading…
Add table
Reference in a new issue