예제 #1
0
    //Currently only does air attack freeze ADD ONE FOR GROUND
    IEnumerator AttackFreeze(Fighter enemyRef)
    {
        _fighterRef.InHitstunFreeze = true;
        enemyRef.InHitstunFreeze = true;
        //
        enemyRef.EnterHitstun();
        //Freeze both player and target for x time
        Vector2 thisVelocity = _fighterRef.GetComponent<Rigidbody2D>().velocity;
        Vector2 otherVelocity = enemyRef.GetComponent<Rigidbody2D>().velocity;
        thisVelocity.y += 3;
        if (_slamSpeed != 0)
        {
            otherVelocity.y = _slamSpeed;
            thisVelocity.y = 4;
            if (otherVelocity.x > 0)
                otherVelocity.x += 4;
            else
                otherVelocity.x -= 4;
        }
        else
        {
            otherVelocity.y += 4f;
        }
        float thisGravity = _fighterRef.GetComponent<Rigidbody2D>().gravityScale;
        float otherGravity = enemyRef.GetComponent<Rigidbody2D>().gravityScale;
        _anim.speed = 0;
        _fighterRef.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
        _fighterRef.GetComponent<Rigidbody2D>().gravityScale = 0;
        enemyRef.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
        enemyRef.GetComponent<Rigidbody2D>().gravityScale = 0;

        yield return new WaitForSeconds(_hitstunFreezeTime);

        _anim.speed = 1;
        _fighterRef.GetComponent<Rigidbody2D>().velocity = thisVelocity;
        enemyRef.GetComponent<Rigidbody2D>().velocity = otherVelocity;
        _fighterRef.GetComponent<Rigidbody2D>().gravityScale = thisGravity;
        enemyRef.GetComponent<Rigidbody2D>().gravityScale = otherGravity;
        enemyRef.StartHitstunTimer(_hitstunTime);
        _fighterRef.InHitstunFreeze = false;
        enemyRef.InHitstunFreeze = false;
    }