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.
51 lines
1.6 KiB
51 lines
1.6 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
public class ArrivedForceContent : MonoBehaviour { |
|
public GameObject itemPre; |
|
/// <summary> |
|
/// 创建到场力量显示条目 |
|
/// </summary> |
|
/// <param name="arrivedCars"></param> |
|
public void CreateItems(Dictionary<string, List<KeyValuePair<FireCarEngine, int>>> arrivedCars) |
|
{ |
|
for (int i = 0; i < transform.childCount; i++) |
|
{ |
|
Destroy(transform.GetChild(i).gameObject); |
|
} |
|
if (itemPre == null) |
|
{ |
|
itemPre = Resources.Load("ArrivedForce/ArrivedForceItem") as GameObject; |
|
} |
|
foreach(string team in arrivedCars.Keys) |
|
{ |
|
List<KeyValuePair<FireCarEngine, int>> list = arrivedCars[team]; |
|
foreach(KeyValuePair<FireCarEngine,int> pair in list) |
|
{ |
|
for(int j = 0; j < pair.Value; j++) |
|
{ |
|
GameObject item = Instantiate(itemPre, transform); |
|
item.GetComponent<ArrivedForceItem>().Set(team,pair.Key, j); |
|
} |
|
} |
|
} |
|
} |
|
public void CreateItems(List<TruckMessage> trucks) |
|
{ |
|
for(int i = 0; i < transform.childCount; i++) |
|
{ |
|
Destroy(transform.GetChild(i).gameObject); |
|
} |
|
if (itemPre == null) |
|
{ |
|
itemPre = Resources.Load("ArrivedForce/ArrivedForceItem") as GameObject; |
|
} |
|
foreach(TruckMessage msg in trucks) |
|
{ |
|
GameObject item = Instantiate(itemPre, transform); |
|
item.GetComponent<ArrivedForceItem>().Set(msg); |
|
} |
|
} |
|
}
|
|
|