Развитие гоночек
This commit is contained in:
1 parent
ec60c47652
commit
b54083521f
532 files changed
+16091
-28231
No files matched your search
@@ -4,7 +4,7 @@ using UnityEngine.AI;
|
||||
|
||||
namespace Code.Example.Race.Racer.AI
|
||||
{
|
||||
public class AIDebugRacer : MonoBehaviour
|
||||
public class AIDebugRacer : Racer
|
||||
{
|
||||
[SerializeField] private NavMeshAgent navMeshAgent;
|
||||
[SerializeField] private List<Transform> waypoints;
|
||||
@@ -15,11 +15,31 @@ namespace Code.Example.Race.Racer.AI
|
||||
_currentWaypointIndex++;
|
||||
}
|
||||
|
||||
public void NextWaypoint()
|
||||
public override void NextWaypoint()
|
||||
{
|
||||
if(_currentWaypointIndex >= waypoints.Count) _currentWaypointIndex = 0;
|
||||
|
||||
navMeshAgent.destination = waypoints[_currentWaypointIndex++].position;
|
||||
}
|
||||
|
||||
public override void StartRacer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void StopRacer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void SetData(RacerData data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Initialize(List<Transform> waypoints)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
namespace Code.Example.Race.Racer.AI
|
||||
{
|
||||
public class AIRacer : Racer
|
||||
{
|
||||
[SerializeField] private NavMeshAgent navMeshAgent;
|
||||
|
||||
public override void SetData(RacerData data)
|
||||
{
|
||||
Data = data;
|
||||
navMeshAgent.angularSpeed = data.angularSpeed;
|
||||
navMeshAgent.speed = data.speed;
|
||||
}
|
||||
|
||||
public override void Initialize(List<Transform> waypoints)
|
||||
{
|
||||
navMeshAgent.isStopped = true;
|
||||
|
||||
Waypoints = waypoints;
|
||||
navMeshAgent.destination = Waypoints[CurrentWaypointIndex].position;
|
||||
|
||||
CurrentWaypointIndex++;
|
||||
}
|
||||
public override void StartRacer() => navMeshAgent.isStopped = false;
|
||||
public override void StopRacer() => navMeshAgent.isStopped = true;
|
||||
public override void NextWaypoint()
|
||||
{
|
||||
if(CurrentWaypointIndex >= Waypoints.Count) CurrentWaypointIndex = 0;
|
||||
|
||||
navMeshAgent.destination = Waypoints[CurrentWaypointIndex++].position;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05f30660967e40209aa88719fa498c78
|
||||
timeCreated: 1769694590
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Example.Race.Racer.AI
|
||||
{
|
||||
public class PlayerRacer : Racer
|
||||
{
|
||||
public override void SetData(RacerData data)
|
||||
{
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public override void Initialize(List<Transform> waypoints)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void NextWaypoint()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void StartRacer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void StopRacer()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d3497d41c87415eab67cfc865262b79
|
||||
timeCreated: 1769619757
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Example.Race.Racer.AI
|
||||
{
|
||||
public abstract class Racer : MonoBehaviour
|
||||
{
|
||||
protected List<Transform> Waypoints;
|
||||
protected int CurrentWaypointIndex;
|
||||
public RacerData Data { get; protected set; }
|
||||
public int Id { get; set; }
|
||||
public abstract void SetData(RacerData data);
|
||||
public abstract void Initialize(List<Transform> waypoints);
|
||||
public abstract void NextWaypoint();
|
||||
public abstract void StartRacer();
|
||||
public abstract void StopRacer();
|
||||
|
||||
[SerializeField] protected Rigidbody carRigidbody;
|
||||
public Rigidbody CarRigidbody => GetComponent<Rigidbody>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f87ed38713d4b779df9e46c83b03fb7
|
||||
timeCreated: 1769619306
|
||||
Reference in new issue
Block a user