Example #1
0
        public void DoAttack()
        {
            PlaySound(Sound);
            var direction = new Vector2(GetComponent <CharacterFlip>().FlippedAsUnit, 0f);
            var hit       = PsxExt.RayCastWithDebug(transform.position + new Vector3(Offset.x, Offset.y, 0f), direction, Reach, HitMask, ShowDebug);

            if (hit.collider != null)
            {
                var health = hit.collider.gameObject.GetComponent <Health>();
                if (health != null)
                {
                    PlaySound(HitSound);
                    health.Deal(Damage);
                }
            }
        }
Example #2
0
        private bool CanSeePlayer()
        {
            if (_player == null)
            {
                return(false);
            }

            var direction = new Vector2(_flip.FlippedAsUnit, 0f);

            var hit = PsxExt.RayCastWithDebug(transform.position + _surroundings.GetMiddleAsVector3(), direction, SeeDistance, SeeMask, DrawDebug);

            if (hit.collider == null)
            {
                return(false);
            }
            if (hit.collider.gameObject.name != "Player")
            {
                return(false);
            }
            return(hit.collider.gameObject.GetComponent <Health>().Alive);
        }