Exemplo n.º 1
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        nangkuriBase = animator.GetComponent <Base_Nangkuri>();
        rBody        = animator.GetComponent <Rigidbody2D>();

        if (Random.Range(0, 1) == 0)
        {
            nangkuriBase.SwitchDirection();
        }
    }
Exemplo n.º 2
0
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        nangkuriBase.UpdateRays();

        if (nangkuriBase.detactChangeDir)
        {
            nangkuriBase.SwitchDirection();
        }

        if (Mathf.Abs(rBody.velocity.x) < nangkuriBase.WalkSpeed)
        {
            rBody.velocity += new Vector2(nangkuriBase.MoveAcc * nangkuriBase.headingTo.x, 0.0f);
        }
    }
Exemplo n.º 3
0
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (nangkuriBase.playerDetacted || nangkuriBase.PlayerLostTime < 0.2f)
        {
            nangkuriBase.SwitchDirToPlayer();
        }
        else
        {
            nangkuriBase.UpdateRays();
            if (nangkuriBase.detactChangeDir)
            {
                nangkuriBase.SwitchDirection();
            }
            else if (nangkuriBase.detactForward)
            {
                nangkuriBase.SwitchDirection();
            }
        }

        if (Mathf.Abs(rBody.velocity.x) < nangkuriBase.RunSpeed)
        {
            rBody.velocity += new Vector2(nangkuriBase.MoveAcc * nangkuriBase.headingTo.x, 0.0f);
        }
    }