void HandleNpcDtList(XKNpcSpawnListDt npcSpawnList) { if (npcSpawnList != null && NpcDtList.Contains(npcSpawnList)) { return; } NpcDtList.Add(npcSpawnList); }
void HandleRemoveNpcDtList(XKNpcSpawnListDt npcSpawnList) { //Debug.Log("Unity:"+"HandleRemoveNpcDtList**************"); if (npcSpawnList != null && !NpcDtList.Contains(npcSpawnList)) { return; } NpcDtList.Remove(npcSpawnList); Destroy(npcSpawnList.gameObject); }
public GameObject GetNpcObjFromNpcDtList(XKSpawnNpcPoint spawnCom, GameObject npcPrefab, Vector3 pos, Quaternion rot) { if (npcPrefab == null) { return(null); } GameObject npcObj = null; int max = NpcDtList.Count; if (max > 0) { for (int i = 0; i < max; i++) { if (NpcDtList[i] != null && NpcDtList[i].NpcPrefabName == npcPrefab.name) { npcObj = NpcDtList[i].FindNpcObjFromNpcList(spawnCom, npcPrefab); break; } } } if (npcObj == null) { //Debug.Log("Unity:"+"GetNpcObjFromNpcDtList -> npcPrefabName is "+npcPrefab.name); GameObject objNpcSpawnList = new GameObject("XKNpcSpawnListDt"); XKNpcSpawnListDt npcSpawnList = objNpcSpawnList.AddComponent <XKNpcSpawnListDt>(); HandleNpcDtList(npcSpawnList); Transform tran = objNpcSpawnList.transform; tran.parent = transform; npcObj = npcSpawnList.FindNpcObjFromNpcList(spawnCom, npcPrefab); if (npcObj == null) { HandleRemoveNpcDtList(npcSpawnList); } } if (npcObj != null) { //Transform npcTran = npcObj.transform; npcObj.transform.position = pos; npcObj.transform.rotation = rot; //Debug.Log("Unity:"+npcObj.name+", id "+npcObj.GetInstanceID()+", pos "+pos+", rot "+rot); } return(npcObj); }