GameObject SearchForTarget() { var hits = coneOfSight.GetObjectsInSight(hitMask, dirSprites.CurrentFacingDirection, 10f, 20); if (hits.Count == 0) { return(null); } //lets find a target: foreach (Collider2D coll in hits) { if (coll.gameObject.layer == playersLayer) { return(coll.gameObject); } } return(null); }
MouseAI AnyMiceNearby() { var hits = coneOfSight.GetObjectsInSight(mobMask, dirSprites.CurrentFacingDirection, 10f, 20); foreach (Collider2D coll in hits) { if (coll.gameObject != gameObject && coll.gameObject.GetComponent <MouseAI>() != null && !coll.gameObject.GetComponent <LivingHealthBehaviour>().IsDead) { return(coll.gameObject.GetComponent <MouseAI>()); } } return(null); }
CatAI AnyCatsNearby() { var hits = coneOfSight.GetObjectsInSight(mobMask, LayerTypeSelection.Walls, directional.CurrentDirection.Vector, 10f, 5); foreach (var coll in hits) { if (coll.GameObject == null) { continue; } if (coll.GameObject != gameObject && coll.GameObject.GetComponent <CatAI>() != null && !coll.GameObject.GetComponent <LivingHealthBehaviour>().IsDead) { return(coll.GameObject.GetComponent <CatAI>()); } } return(null); }
private MouseAI AnyMiceNearby() { var hits = coneOfSight.GetObjectsInSight(mobMask, LayerTypeSelection.Walls, rotatable.CurrentDirection.ToLocalVector3(), 10f); foreach (var coll in hits) { if (coll == null) { continue; } if (coll != gameObject && coll.GetComponent <MouseAI>() != null && !coll.GetComponent <LivingHealthBehaviour>().IsDead) { return(coll.GetComponent <MouseAI>()); } } return(null); }
/// <summary> /// Looks around and tries to find players to target /// </summary> /// <returns>Gameobject of the first player it found</returns> protected virtual GameObject SearchForTarget() { var hits = coneOfSight.GetObjectsInSight(hitMask, LayerTypeSelection.Walls, directional.CurrentDirection.Vector, 10f, 20); if (hits.Count == 0) { return(null); } foreach (var coll in hits) { if (coll.GameObject == null) { continue; } if (coll.GameObject.layer == playersLayer) { return(coll.GameObject); } } return(null); }