You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
2.0 KiB
59 lines
2.0 KiB
4 years ago
|
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 火场信息中到场力量数据
|
||
|
/// </summary>
|
||
|
public class PowerPresentData
|
||
|
{
|
||
|
public static readonly PowerPresentData Instance = new PowerPresentData();
|
||
|
//按中队、车类型组织车辆数据(string:组织机构;List<KeyValuePair<FireCarEngine, int>:某类型车有多少辆)
|
||
|
private Dictionary<string, List<KeyValuePair<FireCarEngine, int>>> mOrgCars =
|
||
|
new Dictionary<string, List<KeyValuePair<FireCarEngine, int>>>();
|
||
|
|
||
|
public void AddPresentCar(KeyValuePair<string,List<KeyValuePair<FireCarEngine,int>>> presentCar)
|
||
|
{
|
||
|
List<KeyValuePair<FireCarEngine, int>> typePresentCars = new List<KeyValuePair<FireCarEngine, int>>();
|
||
|
if (mOrgCars.TryGetValue(presentCar.Key, out typePresentCars))
|
||
|
{
|
||
|
foreach (KeyValuePair<FireCarEngine,int> item in presentCar.Value)
|
||
|
{
|
||
|
AddCar(typePresentCars,item, presentCar.Key);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
mOrgCars.Add(presentCar.Key, presentCar.Value);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void AddCar(List<KeyValuePair<FireCarEngine,int>> typePresentCars, KeyValuePair<FireCarEngine,int> car, string orgName)
|
||
|
{
|
||
|
for (int i=0;i< typePresentCars.Count;i++)
|
||
|
{
|
||
|
if (typePresentCars[i].Key.TypeName == car.Key.TypeName)
|
||
|
{
|
||
|
typePresentCars[i] = new KeyValuePair<FireCarEngine, int>(typePresentCars[i].Key,typePresentCars[i].Value + car.Value);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
List<string> keys = new List<string>();
|
||
|
foreach (KeyValuePair<FireCarEngine,int> item in typePresentCars)
|
||
|
{
|
||
|
keys.Add(item.Key.TypeName);
|
||
|
}
|
||
|
if (!keys.Contains(car.Key.TypeName))
|
||
|
{
|
||
|
typePresentCars.Add(car);
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 得到所有到场力量
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
public Dictionary<string, List<KeyValuePair<FireCarEngine, int>>> GetAllPresentCar()
|
||
|
{
|
||
|
return mOrgCars;
|
||
|
}
|
||
|
}
|