Ejemplo n.º 1
0
    //Coroutines
    public IEnumerator RedHit()
    {
        while (currentState == RED_STATE.HIT)
        {
            m_RedAnim.SetBool("Hit", true);

            m_RedAnim.SetBool("Idle", false);
            m_RedAnim.SetBool("Attack", false);
            m_RedAnim.SetBool("Chase", false);
            m_RedAnim.SetBool("Retreat", false);


            Vector3    targetPoint    = m_BlueTrans.transform.position;
            Quaternion targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
            m_RedTrans.rotation = Quaternion.Slerp(m_RedTrans.rotation, targetRotation, Time.time * 1.0f);

            //If hit again, retreat
            if (HitCount >= 1 & Health >= 90.0)
            {
                CurrentState = RED_STATE.ATTACK;
            }

            yield return(null);
        }

        yield break;
    }
Ejemplo n.º 2
0
    public IEnumerator RedIdle()
    {
        while (currentState == RED_STATE.IDLE)
        {
            m_RedAnim.SetBool("Idle", true);

            m_RedAnim.SetBool("Hit", false);
            m_RedAnim.SetBool("Attack", false);
            m_RedAnim.SetBool("Chase", false);
            m_RedAnim.SetBool("Retreat", false);


            Vector3    targetPoint    = m_BlueTrans.transform.position;
            Quaternion targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
            m_RedTrans.rotation = Quaternion.Slerp(m_RedTrans.rotation, targetRotation, Time.time * 1.0f);


            if (hit == true)
            {
                hit          = false;
                CurrentState = RED_STATE.HIT;
            }


            yield return(null);
        }

        yield break;
    }
Ejemplo n.º 3
0
    public IEnumerator Red_Move()
    {
        idle      = false;
        moving    = true;
        attacking = false;
        //m_Anim
        m_Agent.isStopped   = true;
        m_Agent.destination = m_Player.transform.position;
        m_Anim.SetBool("Idle", false);
        m_Anim.SetBool("Chase", true);
        m_Anim.SetBool("Attack", false);

        this.transform.rotation = Quaternion.Slerp(this.transform.rotation, Quaternion.LookRotation(direction), rotSpeed * Time.deltaTime);

        //Nav Mesh movement
        m_Agent.isStopped   = false;
        m_Agent.destination = m_Player.transform.position;

        //Check if Agent is at destination
        if (distance <= m_Agent.stoppingDistance)
        {
            m_Agent.isStopped = true;
            CurrentState      = RED_STATE.IDLE;
        }

        yield return(null);
    }
Ejemplo n.º 4
0
    public IEnumerator RedRetreat()
    {
        while (currentState == RED_STATE.RETREAT)
        {
            m_RedAnim.SetBool("Retreat", true);

            m_RedAnim.SetBool("Hit", false);
            m_RedAnim.SetBool("Idle", false);
            m_RedAnim.SetBool("Attack", false);
            m_RedAnim.SetBool("Chase", false);

            yield return(new WaitForSeconds(0.7f));

            CurrentState = RED_STATE.IDLE;

            yield break;
        }
    }
Ejemplo n.º 5
0
    public IEnumerator RedAttackCombo()
    {
        while (true)
        {
            //Rotation
            this.transform.rotation = Quaternion.Slerp(this.transform.rotation, Quaternion.LookRotation(direction), rotateSpeed * Time.deltaTime);

            m_Anim.SetBool("Idle", false);
            m_Anim.SetBool("Move", false);
            m_Anim.SetBool("AttackL", false);
            m_Anim.SetBool("AttackR", false);
            m_Anim.SetBool("AttackCombo", true);
            m_Anim.SetBool("Defend", false);

            yield return(new WaitForSeconds(0.5f));

            //isAttacking = false;
            CurrentState = RED_STATE.ATTACKING;

            yield return(null);
        }
    }
Ejemplo n.º 6
0
    //-------------------------------------------------------

    public IEnumerator Red_Idle()
    {
        idle      = true;
        moving    = false;
        attacking = false;
        //m_Anim
        m_Agent.isStopped   = true;
        m_Agent.destination = this.transform.position;
        m_Anim.SetBool("Idle", true);
        m_Anim.SetBool("Chase", false);
        m_Anim.SetBool("Attack", false);

        this.transform.rotation = Quaternion.Slerp(this.transform.rotation, Quaternion.LookRotation(direction), rotSpeed * Time.deltaTime);

        if (distance >= m_Agent.stoppingDistance && m_Agent.hasPath)
        {
            CurrentState = RED_STATE.MOVE;
            yield break;
        }

        yield return(null);
    }
Ejemplo n.º 7
0
    void Update()
    {
        //Rangefinder
        targetRange = Vector3.Distance(m_RedTrans.position, m_BlueTrans.position);
        //Debug.Log(targetRange);

        if (targetRange >= 1.0f)
        {
            CurrentState = RED_STATE.CHASE;
        }


        if (Health <= MaxHealth)
        {
            Health          += RegenAmt * Time.deltaTime;
            m_HealthUI.value = Health;
            Debug.Log(Health);
        }
        else if (Health > MaxHealth)
        {
            Health = MaxHealth;
        }
    }
Ejemplo n.º 8
0
    public IEnumerator RedAttack()
    {
        while (currentState == RED_STATE.ATTACK)
        {
            m_RedAnim.SetBool("Attack", true);

            m_RedAnim.SetBool("Idle", false);
            m_RedAnim.SetBool("Hit", false);
            m_RedAnim.SetBool("Chase", false);
            m_RedAnim.SetBool("Retreat", false);

            Vector3    targetPoint    = m_BlueTrans.transform.position;
            Quaternion targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
            m_RedTrans.rotation = Quaternion.Slerp(m_RedTrans.rotation, targetRotation, Time.time * 1.0f);

            if (HitCount >= 2 && Health <= 80.0f)
            {
                hit          = false;
                CurrentState = RED_STATE.RETREAT;
            }

            yield return(null);
        }
    }
Ejemplo n.º 9
0
    public IEnumerator RedChase()
    {
        while (currentState == RED_STATE.CHASE)
        {
            m_RedAnim.SetBool("Chase", true);

            m_RedAnim.SetBool("Idle", false);
            m_RedAnim.SetBool("Hit", false);
            m_RedAnim.SetBool("Attack", false);
            m_RedAnim.SetBool("Retreat", false);

            Vector3    targetPoint    = m_BlueTrans.transform.position;
            Quaternion targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
            m_RedTrans.rotation = Quaternion.Slerp(m_RedTrans.rotation, targetRotation, Time.time * 1.0f);
            m_RedTrans.position = Vector3.MoveTowards(m_RedTrans.position, m_BlueTrans.transform.position, 1.0f * Time.deltaTime);

            if (targetRange <= 1.0f)
            {
                CurrentState = RED_STATE.IDLE;
            }

            yield return(null);
        }
    }
Ejemplo n.º 10
0
    public IEnumerator RedAttacking()
    {
        while (true)
        {
            //Debug.Log("In Attacking");
            isAttacking = true;
            System.Random randomizer     = new System.Random();
            int           attackToChoose = randomizer.Next(3);

            switch (attackToChoose)
            {
            case 0:
                CurrentState = RED_STATE.ATTACKL;
                //Debug.Log("switch Attack L");
                break;

            case 1:
                CurrentState = RED_STATE.ATTACKR;
                //Debug.Log("switch Attack R");
                break;

            case 2:
                CurrentState = RED_STATE.ATTACKCOMBO;
                //Debug.Log("switch Attack R");
                break;
            }

            if (range > attackRange)
            {
                isAttacking  = false;
                CurrentState = RED_STATE.IDLE;
            }

            yield return(null);
        }
    }