Esempio n. 1
0
 private void OnSeen(VisionTarget target)
 {
     if (exclama_prefab)
     {
         Instantiate(exclama_prefab, transform);
     }
 }
Esempio n. 2
0
 void Awake()
 {
     rigid         = GetComponent <Rigidbody>();
     animator      = GetComponent <Animator>();
     collide       = GetComponentInChildren <Collider>();
     vision_target = GetComponent <VisionTarget>();
 }
Esempio n. 3
0
 public void DetectTouchTarget()
 {
     //Detect character touch
     foreach (VisionTarget character in VisionTarget.GetAll())
     {
         if (CanTouchObject(character.gameObject))
         {
             if (onTouchTarget != null)
             {
                 onTouchTarget.Invoke(seen_character);
             }
         }
     }
 }
        void Awake()
        {
            rigid         = GetComponent <Rigidbody2D>();
            animator      = GetComponent <Animator>();
            vision_target = GetComponent <VisionTarget>();
            collide       = GetComponentInChildren <Collider2D>();
            capsule_coll  = GetComponentInChildren <CapsuleCollider2D>();
            start_scale   = transform.localScale;

            contact_filter              = new ContactFilter2D();
            contact_filter.layerMask    = ground_mask;
            contact_filter.useLayerMask = true;
            contact_filter.useTriggers  = false;
        }
Esempio n. 5
0
        private void OnCollisionEnter2D(Collision2D other)
        {
            EnemyLOS2D enemy_other = other.gameObject.GetComponent <EnemyLOS2D>();

            if (enemy_other)
            {
                if (state == EnemyLOS2DState.Patrol && enemy_other.state == EnemyLOS2DState.Chase)
                {
                    VisionTarget target = enemy_other.seen_character;
                    if (target)
                    {
                        ChangeState(EnemyLOS2DState.Chase);
                        enemy_follow.target = target.gameObject;
                        seen_character      = target;
                    }
                }
            }
        }
Esempio n. 6
0
        public void ChangeState(EnemyLOS2DState state)
        {
            this.state  = state;
            state_timer = 0f;

            if (state == EnemyLOS2DState.Patrol)
            {
                seen_character = null;
            }

            if (enemy_patrol)
            {
                enemy_patrol.enabled = (state == EnemyLOS2DState.Patrol);
            }
            if (enemy_follow)
            {
                enemy_follow.enabled = (state == EnemyLOS2DState.Chase);
            }
        }
Esempio n. 7
0
        //Look for possible touch targets
        public void DetectTouchVisionTarget()
        {
            //Detect character touch
            foreach (VisionTarget character in VisionTarget.GetAll())
            {
                if (character == seen_character)
                {
                    continue;
                }

                if (character.CanBeSeen() && CanTouchObject(character.gameObject))
                {
                    seen_character = character;
                    ChangeState(EnemyLOS2DState.Alert);

                    if (onSeeTarget != null)
                    {
                        onSeeTarget.Invoke(seen_character);
                    }
                }
            }
        }
Esempio n. 8
0
        //Look for possible seen targets
        public void DetectVisionTarget()
        {
            //Detect character
            foreach (VisionTarget character in VisionTarget.GetAll())
            {
                if (character == seen_character)
                {
                    continue;
                }

                if (CanSeeVisionTarget(character))
                {
                    seen_character = character;
                    ChangeState(EnemyLOS2DState.Alert);

                    if (onSeeTarget != null)
                    {
                        onSeeTarget.Invoke(seen_character);
                    }
                }
            }
        }
Esempio n. 9
0
 //Can the enemy see a vision target?
 public bool CanSeeVisionTarget(VisionTarget target, float range_offset = 0f, float angle_offset = 0f)
 {
     return(target != null && target.CanBeSeen() && CanSeeObject(target.gameObject, range_offset, angle_offset));
 }
Esempio n. 10
0
 private void OnTouch(VisionTarget target)
 {
     //Add code for when you get caught
 }