Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (!beginCarrotAttack)
        {
            attackTimeCounter += Time.deltaTime;

            if (attackTimeCounter >= attackWaitTime)
            {
                attackTimeCounter  = 0;
                myCollider.enabled = false;
            }
        }
        else
        {
            attackTimeCounter = 0;
        }

        if (beginCarrotAttack)
        {
            carrotTimeCounter += Time.deltaTime;
        }

        if (carrotTimeCounter >= carrotWaitTime)
        {
            if (myController.isBlocking)
            {
                myInfo.AddHealth(-10);
                myInfo.AddEnergy(-15);
            }
            else
            {
                myInfo.AddHealth(-15);
            }

            myCollider.enabled = false;
            myBody.velocity   += new Vector2(10, 20);
            //  myBody.AddForce(new Vector2(50, 25) * 1.0f, ForceMode2D.Impulse);
            carrotTimeCounter = 0;
            beginCarrotAttack = false;
        }
    }