87 lines
2.2 KiB
C#
87 lines
2.2 KiB
C#
using System.Collections.Generic;
|
|
using Gameplay.Skill;
|
|
using Gameplay.Vehicle.Impl;
|
|
namespace Gameplay.Vehicle
|
|
{
|
|
public class VehicleManager
|
|
{
|
|
|
|
private static VehicleManager _instance;
|
|
|
|
public static VehicleManager Inst
|
|
{
|
|
get
|
|
{
|
|
return _instance;
|
|
}
|
|
}
|
|
|
|
public static VehicleManager CreateInstance()
|
|
{
|
|
if (_instance != null)
|
|
{
|
|
DebugUtil.LogError("请勿重复创建VehicleManager");
|
|
return _instance;
|
|
}
|
|
_instance = new VehicleManager();
|
|
return _instance;
|
|
}
|
|
|
|
private readonly List<PreviewVehicle> _preCreateVehicles = new List<PreviewVehicle>();
|
|
private readonly List<NormalVehicle> _vehicles = new List<NormalVehicle>();
|
|
|
|
private VehicleManager()
|
|
{
|
|
|
|
}
|
|
|
|
private void _AddVehicle(NormalVehicle vehicle)
|
|
{
|
|
_vehicles.Add(vehicle);
|
|
}
|
|
|
|
public void UpdateTargets()
|
|
{
|
|
for (int i = 0; i < _vehicles.Count; i++)
|
|
{
|
|
var vehicle = _vehicles[i];
|
|
if (SkillManager.instance.needSkillPaused && SkillManager.instance.skillingUnit != vehicle)
|
|
{
|
|
continue;
|
|
}
|
|
vehicle.UpdateTargets();
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_instance = null;
|
|
}
|
|
|
|
public void PreviewUpdate(float dt)
|
|
{
|
|
for (int i = 0; i < _preCreateVehicles.Count; i++)
|
|
{
|
|
var vehicle = _preCreateVehicles[i];
|
|
vehicle.PreviewUpdate(dt);
|
|
}
|
|
}
|
|
|
|
public void LogicUpdate(float dt)
|
|
{
|
|
for (int i = 0; i < _vehicles.Count; i++)
|
|
{
|
|
var vehicle = _vehicles[i];
|
|
|
|
if (SkillManager.instance.needSkillPaused && SkillManager.instance.skillingUnit != vehicle)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
vehicle.LogicUpdate(dt);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|