void UpdateInstances() { List <UnitInfoTag> remains = new List <UnitInfoTag>(); for (int i = 0; i < instances.Count; i++) { if (GetUnit(instances[i].uuid) == null) { if (instances[i].basicUnit != null && !instances[i].basicUnit.isDead) { instances[i].basicUnit.isDead = true; } Destroy(instances[i].gameObject); UpdateUnitNumberText(); } else { remains.Add(instances[i]); } } instances = remains; for (int i = 0; i < units.Count; i++) { bool found = false; for (int j = 0; j < instances.Count; j++) { if (units[i].uuid == instances[j].uuid) { instances[j].Apply(units[i]); found = true; //Schin update CD ready emotion //this process has moved to inside Update() of BasicUnit break; } } if (!found) { var prefab = (GameObject)Resources.Load(UnitTypeIndexMapper.map[units[i].type]); GameObject g = Instantiate(prefab); units[i].HP = g.GetComponent <UnitSpec>().MaxHP; units[i].MP = g.GetComponent <UnitSpec>().MaxMP; UnitInfoTag tag = g.GetComponent <UnitInfoTag>(); tag.sim = this; tag.Apply(units[i]); tag.InitializeBasicUnit(units[i]); tag.SetOwned(units[i].owner == isClient); instances.Add(tag); } } }
void UpdateInstances() { for (int i = 0; i < units.Count; i++) { bool found = false; for (int j = 0; j < instances.Count; j++) { if (units[i].uuid == instances[j].uuid) { instances[j].Apply(units[i]); found = true; break; } } if (!found) { GameObject g = Instantiate(prefabs[0]); UnitInfoTag tag = g.GetComponent <UnitInfoTag>(); tag.Apply(units[i]); tag.SetOwned(units[i].owner == isClient); instances.Add(tag); } } }