示例#1
0
 private void OnTriggerStay(Collider other)
 {
     if (other.tag == "Player")
     {
         Vector3 newTarget = new Vector3(other.transform.position.x + 0.3f,
                                         other.transform.position.y + 1,
                                         other.transform.position.z);
         target = other.transform;
         float distance = Vector3.Distance(transform.position, target.position);
         if (distance > shotDistance)
         {
             transform.LookAt(newTarget);
             FollowTarget();
         }
         else if (distance <= shotDistance)
         {
             transform.LookAt(newTarget);
             if (isAttacking == false)
             {
                 GameObject           GO  = Instantiate(atkPrefab, atkOrigin.position, atkOrigin.rotation);
                 EnemyShootController esc = GO.GetComponent <EnemyShootController>();
                 esc.SetStart(atkDamage, atkSpeed);
                 isAttacking = true;
             }
         }
     }
 }
示例#2
0
 void Start()
 {
     body           = GetComponent <Rigidbody> ();
     shootComponent = GetComponentInChildren <EnemyShootController> ();
     PatternSwitch();
 }
示例#3
0
 void OnShoot(EnemyShootController ctrl)
 {
     state = (int)State.Attack;
 }