using UnityEngine; using System.Collections; using System.Collections.Generic; public class ThreatManager { private Dictionary threatDict; private List threatList; public ThreatManager() { threatDict = new Dictionary(); threatList = new List(); } public void AddThreat(int id, float value) { if(!threatDict.ContainsKey(id)) { Threat threat = new Threat(id, value); threatDict.Add(id, threat); threatList.Add(threat); } threatDict[id].SetValue(value); } public void RemoveThreat(int id) { if(threatDict.ContainsKey(id)) { Threat threat = threatDict[id]; threatDict.Remove(id); threatList.Remove(threat); } } public float GetThreat(int id) { if(threatDict.ContainsKey(id)) { return threatDict[id].GetValue(); } return 0; } public int GetMaxThreatId() { int id = -1; float maxThread = 0; for(int i=0; i maxThread) { id = threat.id; maxThread = threatValue; } } return id; } }