Example #1
0
    IEnumerator Move()
    {
        while (true)
        {
            if (isDetect || ZC.isDead || ZC.isAttack)
            {
                yield return(null);
            }

            if (!isMove)
            {
                moveType = Random.Range(0, 100);

                transform.parent.rotation = Quaternion.Euler(new Vector3(0, transform.parent.rotation.y + Random.Range(-20, 21), 0));
            }

            if (moveType > 0 && moveType < 50) // 멈춰있는 상태
            {
                ZC.zombieAnimator.SetBool("isWalk", false);
            }
            else
            {
                isMove = true;
                timer += Time.deltaTime;

                transform.parent.Translate(Vector3.forward * ZC.GetAttackInfo(2) * Time.deltaTime, Space.Self);
                ZC.zombieAnimator.SetBool("isWalk", true);

                if (timer > 7.0f)
                {
                    timer  = 0;
                    isMove = false;
                }
            }

            if (!isMove)
            {
                yield return(new WaitForSeconds(7.0f));
            }
            else
            {
                yield return(null);
            }
        }
    }
    IEnumerator Attack()
    {
        while (true)
        {
            ParentRd.velocity = Vector3.zero;
            ZC.zombieAnimator.SetBool("isAttack", true);

            if (ZC.isDead)
            {
                StopCoroutine(co_Attack);
            }
            else
            {
                PlayerMover.instance.Attacked(ZC.GetAttackInfo(1));
            }

            yield return(null);
        }
    }