void OnTriggerEnter(Collider p_other) { Transform __root = p_other.transform.root; if (__root.tag != "Mirah") { return; } Mirah __mirahScript = __root.gameObject.GetComponent <Mirah>(); __mirahScript.SetDistraction(this.transform.position); }
private void ManageTarget() { if (_currentTarget == null) { SearchAndDetect(); } else if (Vector3.Distance(_position, _currentTarget.transform.position) > detectionAreaRadius) { _currentTarget = null; if (onTargetLost != null) { onTargetLost(); } } }
public static void RegisterCharacter(Character p_toRegister) { if (_singleton == null) { Debug.LogError("GameplayManager singleton was null!"); return; } switch (p_toRegister.type) { case Character.Type.ENEMY: Enemy __enemy = p_toRegister.GetComponent <Enemy>(); if (__enemy == null) { return; } if (_singleton.enemies.Contains(__enemy) == false) { _singleton.enemies.Add(__enemy); } break; case Character.Type.GUARDIAN: Guardian __guardian = p_toRegister.GetComponent <Guardian>(); if (__guardian == null) { return; } _singleton.guardian = __guardian; break; case Character.Type.MIRAH: Mirah __mirah = p_toRegister.GetComponent <Mirah>(); if (__mirah == null) { return; } _singleton.mirah = __mirah; break; } }
private void SearchAndDetect() { var __detectedObjects = Physics.OverlapSphere(_position, detectionAreaRadius); foreach (Collider objCollider in __detectedObjects) { if (objCollider.gameObject.layer != LayerMask.NameToLayer("EnemyDetectable")) { continue; } Transform __rootObj = objCollider.transform.root; Mirah __mirahScript = __rootObj.GetComponent <Mirah>(); if (__mirahScript != null) { _currentTarget = __mirahScript; if (onTargetFound != null) { onTargetFound(_currentTarget); } } } }