// Constructor (initialise values) public DecisionMachine(InvulTotem _totem, List <Decider> _deciders, PatternManager _patternManager, EnemyHealth _health) { this.localTotem = _totem; this.deciders = _deciders; this.pM = _patternManager; this.health = _health; }
public InvulTotem GetNearestTotem() { InvulTotem[] totemPoles = FindObjectsOfType <InvulTotem>(); float shortestDist = float.MaxValue; InvulTotem _totem = null;; foreach (InvulTotem tp in totemPoles) { float thisDist = Vector3.Distance(transform.position, tp.transform.position); if (thisDist < shortestDist) { shortestDist = thisDist; _totem = tp; } } return(_totem); }
void GetReferences() { totem = GetNearestTotem(); // get health healthRef = GetComponent <EnemyHealth>(); // Get sight detection fov = GetComponentInChildren <AI_FoV_Detection>(); // Get NavMeshAgent agent = GetComponent <NavMeshAgent>(); // Get weapon gun = GetComponentInChildren <AI_Weapon>(); // Get Object model model = transform.GetChild(0).transform; if (!isGuard) { col = GetComponent <SphereCollider>(); } }