예제 #1
0
    // Update is called once per frame
    void Update()
    {
        ////Check if character just landed on the ground
        //if (!m_grounded && m_groundSensor.State())
        //{
        //    m_grounded = true;
        //    m_animator.SetBool("Grounded", m_grounded);
        //}

        ////Check if character just started falling
        //if (m_grounded && !m_groundSensor.State())
        //{
        //    m_grounded = false;
        //    m_animator.SetBool("Grounded", m_grounded);
        //}

        EhealthBar.SetHealth(EnemyHealth);

        // Move
        float distance = Vector2.Distance(target.position, transform.position);

        if (distance <= lookRadius)
        {
            TargetInRange = true;
            //  Debug.Log("in radius");
            GetComponent <EnemyAI>().enabled = true;
        }
        else
        {
            TargetInRange = false;

            GetComponent <EnemyAI>().enabled = false;
        }


        // -- Handle Animations --
        //Death
        if (EnemyHealth <= 0)
        {
            HealthIsNull = true;
            scoreLogic.KilledEnemy();
            DestroyGameObject();
            return;
        }
        else
        {
            HealthIsNull = false;
        }



        if (distance <= AttackRange)
        {
            InattackRange = true;

            GameObject E_sword = Instantiate(EnemySowrd, E_SowrdPoint.position, Quaternion.identity);
            Destroy(E_sword, 0.1f);
            //return;
        }
        else
        {
            InattackRange = false;
        }
    }