74 lines
1.9 KiB
C#
74 lines
1.9 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;
|
|
}
|
|
|
|
public List<NormalVehicle> SearchEnemies(int troopId)
|
|
{
|
|
foreach (var team in _troopVehicles)
|
|
{
|
|
if (Level.Level.IsEnemy(team.Key, troopId))
|
|
{
|
|
return team.Value;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public List<NormalVehicle> SearchFriend(int troopId)
|
|
{
|
|
foreach (var team in _troopVehicles)
|
|
{
|
|
if (!Level.Level.IsEnemy(team.Key, troopId))
|
|
{
|
|
return team.Value;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
}
|
|
}
|