Exemplo n.º 1
0
 void FixedUpdate()
 {
     if (target != null)
     {
         //if (transform.position.y < target.transform.position.y)
         if (Vector3.Distance(transform.position, target.transform.position) < 3)
         {
             //finish
             EnemyParent ep = target.GetComponent <EnemyParent>();
             if (ep != null)
             {
                 ep.blood -= damage;
                 ep.BeAttack();
                 if (ep.blood <= 0)
                 {
                     ep.Die();
                 }
                 DestoryOwn();
             }
             return;
         }
         if (gameObject)
         {
             time += Time.deltaTime;
             float test = verticalSpeed - g * time;
             transform.Translate(moveDirection.normalized * speed * Time.deltaTime, Space.World);
             transform.Translate(Vector3.up * test * Time.deltaTime, Space.World);
             float testAngle = -angle + angleSpeed * time;
             transform.eulerAngles = new Vector3(testAngle, transform.eulerAngles.y, transform.eulerAngles.z);
         }
     }
 }
Exemplo n.º 2
0
    void HandleEnemy()
    {
        EnemyParent ep = target.GetComponent <EnemyParent>();

        if (ep != null)
        {
            ep.blood -= damage;
            ep.BeAttack();
            if (ep.blood <= 0)
            {
                ep.Die();
            }
            DestoryOwn();
        }
    }