Esempio n. 1
0
    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);
    }
Esempio n. 2
0
    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);
    }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        /// <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);
        }