48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using Gameplay.Vehicle.Impl;
|
|
namespace Gameplay.Vehicle
|
|
{
|
|
public class VehicleManager
|
|
{
|
|
|
|
private Dictionary<int, List<NormalVehicle>> _troopVehicles = new Dictionary<int, List<NormalVehicle>>();
|
|
|
|
public VehicleManager()
|
|
{
|
|
|
|
}
|
|
|
|
public void AddVehicle(NormalVehicle vehicle)
|
|
{
|
|
var troopId = vehicle.commonData.troopId;
|
|
if (!_troopVehicles.ContainsKey(troopId))
|
|
{
|
|
_troopVehicles.Add(troopId, new List<NormalVehicle>());
|
|
}
|
|
_troopVehicles[troopId].Add(vehicle);
|
|
}
|
|
|
|
public void RemoveVehicle(NormalVehicle vehicle)
|
|
{
|
|
var troopId = vehicle.commonData.troopId;
|
|
if (_troopVehicles.ContainsKey(troopId))
|
|
{
|
|
_troopVehicles[troopId].Remove(vehicle);
|
|
}
|
|
}
|
|
|
|
public NormalVehicle GetVehicleByTroop(int troopId)
|
|
{
|
|
if (_troopVehicles.TryGetValue(troopId, out var vehicle))
|
|
{
|
|
if (vehicle.Count > 0)
|
|
{
|
|
return vehicle[0];
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|
|
}
|