//--------------------- // CALLED FROM ENEMY WHEN IT COMES CLOSER TO THE PLAYER - EXCHANGES FOR NEW 'NEARLIST' SPRITE public void Attach_Near_TargetID_Sprite(Transform t) { foreach (GameObject g in nearList) { if (!g.activeSelf) { g.SetActive(true); targetIDScript = g.GetComponent <ScriptTargetID>(); targetIDScript.targetFocus = t; targetIDScript.spinTrigger = true; activeList.Add(g); // Quicker for A_SceneManager Script to call and loop through shorter list if target object goes out of view break; } } }
//--------------------- // CALLED FROM ENEMY WHEN IT GETS DESTROYED OR IS TOO FAR..can be called by SceneManager too. public void Free_TargetID_Sprite(Transform t) { foreach (GameObject g in activeList) { targetIDScript = g.GetComponent <ScriptTargetID>(); if (targetIDScript.targetFocus == t) { targetIDScript.targetFocus = null; targetIDScript.spinTrigger = false; g.transform.rotation = Quaternion.identity; g.SetActive(false); activeList.Remove(g); // Quicker for A_SceneManager Script to call and loop through shorter list if target object goes out of view break; } } }
//--------------------- // CALLED FROM ENEMY WHEN IT COMES WITHIN RANGE public void Attach_Far_TargetID_Sprite(Transform t) { foreach (GameObject g in farList) { if (!g.activeSelf) { g.SetActive(true); targetIDScript = g.GetComponent <ScriptTargetID>(); targetIDScript.targetFocus = t; targetIDScript.spinTrigger = false; activeList.Add(g); // Quicker for A_SceneManager Script to call and loop through shorter list if target object goes out of view sfx.PlaySound(4, Vector3.zero); // FAR BLEEP break; } } }