En este paso, crearás un objetivo especial que otorga tiempo adicional cuando un jugador lo alcanza. El objetivo aparece aleatoriamente cuando se alcanzan objetivos con puntuación positiva, y las probabilidades de que aparezca aumentan hasta que lo hace.
Cómo modificar tu isla
Selecciona Objetivo de combo en el visor.
Pulsa la tecla Alt, luego haz clic con el botón izquierdo del ratón en el widget de eje y arrastra un objetivo duplicado al frente de tu galería de tiro. Este es el objetivo de tiempo adicional.
En el panel Detalles, establece TargetType en Bailando.
Cómo escribir código de Verse
En esta página encontrarás instrucciones paso a paso sobre los cambios que debes realizar en el código. No obstante, si deseas revisar tu trabajo, consulta la sección Código completo para ver el resultado final.
Abre el archivo
shooting_range_manager_device.verse.Añade la siguiente biblioteca para permitir la generación de números aleatorios.
Verseusing { /Verse.org/Random }Añade las siguientes variables para almacenar la referencia del dispositivo objetivo y las propiedades relacionadas. Las variables de duración y recompensa se expresan en segundos.
Verse@editable InitialTimerDuration:float = 30.0 @editable MaxTimerDuration:float = 60.0 @editable BonusTimeTarget:shooting_range_target_track_device = shooting_range_target_track_device{} @editableAñade el método de devolución de llamada
OnBonusTimeTargetHitque incrementa el cronómetro.Verse# A hit callback that adds bonus time and disables the BonusTimeTarget. OnBonusTimeTargetHit():void= CurrentDuration:float = Timer.GetActiveDuration() Timer.SetActiveDuration(CurrentDuration + BonusTimeReward) BonusTimeTarget.PopDown() BonusTimeTarget.Disable()Modifica el método
OnBeginpara configurar la suscripción al evento de objetivo de tiempo adicional y deshabilitarlo.Verse# Runs when the device is started in a running game. OnBegin<override>()<suspends>:void= # Subscribing to the GoodTarget HitEvents. GoodTarget1.HitEvent.Subscribe(OnGoodTarget1Hit) GoodTarget2.HitEvent.Subscribe(OnGoodTarget2Hit) GoodTarget3.HitEvent.Subscribe(OnGoodTarget3Hit) # Subscribing to the BadTarget HitEvents. BadTarget1.HitEvent.Subscribe(OnBadTarget1Hit) BadTarget2.HitEvent.Subscribe(OnBadTarget2Hit)Modifica el método
StartTimerpara establecer la duración máxima y activa del cronómetro.Verse# Setup and start the timer. StartTimer():void= # Set the event subscription to call OnTimerSuccess when the timer finishes. Timer.SuccessEvent.Subscribe(OnTimerSuccess) <# --- New Code Start --- #> # Set the max and active duration based on the set property values. Timer.SetMaxDuration(MaxTimerDuration) Timer.SetActiveDuration(InitialTimerDuration)Modifica el método
AdjustScorepara que el objetivo de tiempo adicional aparezca aleatoriamente en función del número de objetivos correctos que hayas alcanzado.Verse# Adjusts the player's score by the provided value. AdjustScore(Value:int):void= # Start the timer if it hasn't started yet. if (not IsTimerStarted?): StartTimer() # Sets the score award to the base value of the target. ScoreManager.SetScoreAward(Value) # Gets the first player in the playspace.Guarda y compila tu código de Verse.
Código completo
using { /Fortnite.com/Devices }
using { /Verse.org/Random }
using { /Verse.org/Simulation }
# A device that manages shooting range gameplay.
shooting_range_manager_device := class(creative_device):
@editable
ScoreManager:score_manager_device = score_manager_device{}
Cómo juntarlo todo
Selecciona shooting_range_manager_device en el visor o en el panel Esquematizador.
En el panel Detalles, establece BonusTimeTarget según el objetivo de tiempo adicional.
Aplica los cambios y prueba tu isla.
Comprueba que el objetivo de tiempo adicional aparece después de disparar a objetivos que dan puntuación positiva.