Пример #1
0
    public Enemy_Sphere_L(string prefabName, string name, Transform parent, float health, float maxHealth)
    {
        _body        = SetForm(prefabName);
        _name        = name;
        _hitpoint    = health;
        _hitpointMax = maxHealth;
        _isAlive     = true;

        CreateAvatar(parent);

        // Assign behavior class
        //......
        damageMonitor              = Avatar.AddComponent <DamageMonitor>();
        simplePatrol               = Avatar.AddComponent <SimplePatrol>();
        damageMonitor.OnBulletHit += TakeDamage;
        OnDestroy += DestroySelf;
    }
Пример #2
0
    private void Awake()
    {
        patrol   = transform.parent.GetComponent <SimplePatrol>();
        ddol     = GameObject.Find("Manager").GetComponent <DDOL>();
        player   = GameObject.Find("Player");
        rb2D     = transform.parent.gameObject;
        rb       = rb2D.GetComponent <Rigidbody2D>();
        playerHp = player.GetComponent <HPmanager>();
        source   = GetComponent <AudioSource>();


        enemy       = GetComponent <GameObject>();
        anim        = GetComponent <Animator>();
        constraints = GetComponent <ScaleConstraint>();

        foreach (GameObject obj in ddol._ddolObjects)
        {
            if (obj.name == rb2D.name)
            {
                Debug.Log("ovo");
                Destroy(rb2D);
            }
        }
    }
Пример #3
0
 private void Start()
 {
     simplePatrol = transform.parent.GetComponent <SimplePatrol>();
 }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        if (ActualHP <= 0 && Counter == 0)
        {
            ddol._ddolObjects.Add(rb2D);

            Counter++;
        }


        Healthbar.fillAmount = ActualHP / 100;
        timer += Time.deltaTime;

        if (timer >= timeBetweenAttacks && playerInRange && (rb2D.transform.position.x > player.transform.position.x) && transform.rotation.y >= 0)
        {
            Attack();
        }
        if (timer >= timeBetweenAttacks && playerInRange && (rb2D.transform.position.x < player.transform.position.x) && transform.rotation.y < 0)
        {
            Attack();
        }
        if (grande == true)
        {
            constraints.constraintActive = true;
        }

        if (anim.GetCurrentAnimatorStateInfo(0).IsName("agrandar"))
        {
            anim.SetBool("running", false);


            if (anim.GetCurrentAnimatorStateInfo(0).normalizedTime >= 0.9f)
            {
                anim.SetBool("activar", false);
                grande = true;
            }
        }
        if (anim.GetCurrentAnimatorStateInfo(0).IsName("attack"))
        {
            if (anim.GetCurrentAnimatorStateInfo(0).normalizedTime >= 0.9f)
            {
                anim.SetBool("attacking", false);
            }
        }


        if (ActualHP <= 0)
        {
            patrol         = rb2D.GetComponent <SimplePatrol>();
            patrol.enabled = false;
            anim.SetBool("dead", true);
            if (anim.GetCurrentAnimatorStateInfo(0).IsName("death"))
            {
                if (anim.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1f)
                {
                    Destroy(col);
                    rb.constraints = RigidbodyConstraints2D.FreezePositionY;
                }
            }
        }
    }