Пример #1
0
    // Update is called once per frame
    void Update()
    {
        healthBar.localScale = new Vector3(health / maxHealth * healthBarLocalScale.x, healthBarLocalScale.y, healthBarLocalScale.z);

        if (health <= 0.0f)
        {
            Level_Controller.RemoveEnemy("Mole");
            deathRemains.transform.position = transform.position;
            Instantiate(deathRemains);
            Destroy(gameObject);
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        healthBar.localScale = new Vector3(health / maxHealth * healthBarLocalScale.x, healthBarLocalScale.y, healthBarLocalScale.z);

        if (moving == false)
        {
            StartCoroutine(RandomMovement());
        }

        if (Vector2.Distance(player.transform.position, transform.position) < 1.5f && attackCooldown == false)
        {
            StartCoroutine(AttackPlayer());
        }

        if (health <= 0.0f)
        {
            Level_Controller.RemoveEnemy("Slime");
            deathRemains.transform.position = transform.position;
            Instantiate(deathRemains);
            Destroy(gameObject);
        }
    }