コード例 #1
0
 public bool ReceiveImpact(AvatarBullet bullet)
 {
     //TODO: pasa el daño
     foreach (var enemyComp in GetComponents <Enemy>())
     {
         enemyComp.ReceiveAvatarBulletImpact(bullet);
     }
     return(true);
 }
コード例 #2
0
    public void ReceiveAvatarBulletImpact(AvatarBullet bullet)
    {
        if (!inmortal)
        {
            animator.SetTrigger("TakeDamage");

            life -= bullet.damage;
            if (life <= 0)
            {
                Die();
            }
        }

        //TODO: animacion de hit
    }
コード例 #3
0
    //llamado desde animacion
    public void SpawnBullet()
    {
        if (cosestTarget == null)
        {
            return;
        }


        AvatarBullet newBullet = Instantiate <AvatarBullet>(bulletPrefab);

        newBullet.transform.position = (bulletOrigin != null) ? bulletOrigin.position : transform.position;

        Vector3 targetPos = new Vector3(
            cosestTarget.transform.position.x,
            newBullet.transform.position.y,
            cosestTarget.transform.position.z);

        newBullet.transform.LookAt(targetPos, Vector3.up);

        Debug.DrawLine(transform.position, cosestTarget.transform.position, Color.red, 0.1f);

        cosestTarget = null;
    }