43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using Code.Example.Race.Track;
|
|
using Code.Infrastructure.EventBus;
|
|
using Reflex.Attributes;
|
|
using UnityEngine;
|
|
|
|
namespace Code.Example.Race.Racer.Player
|
|
{
|
|
public class PlayerRacer : Racer
|
|
{
|
|
[Inject] private EventBus _eventBus;
|
|
|
|
public Transform CameraPosition;
|
|
public override void SetData(RacerData data)
|
|
{
|
|
Data = data;
|
|
}
|
|
|
|
public override void Initialize(List<Transform> waypoints)
|
|
{
|
|
Waypoints = waypoints;
|
|
}
|
|
|
|
public override void NextWaypoint()
|
|
{
|
|
if (++CurrentWaypointIndex < Waypoints.Count) return;
|
|
|
|
CurrentWaypointIndex = 0;
|
|
_eventBus.RaiseEvent<IPlayerPassedCheckpointHandler>(x=> x.OnPlayerLapPassed(this));
|
|
_eventBus.RaiseEvent<IRacerPassedCheckpointHandler>(x=> x.LapPassed(this));
|
|
}
|
|
public bool RaceStarted { get; set; }
|
|
public override void StartRacer()
|
|
{
|
|
RaceStarted = true;
|
|
}
|
|
|
|
public override void StopRacer()
|
|
{
|
|
RaceStarted = false;
|
|
}
|
|
}
|
|
} |