Exemplo n.º 1
0
    //jump
    IEnumerator doJump()
    {
        //set jump state
        jumpInProgress = true;
        playerState.SetState(UNITSTATE.JUMPING);

        //play animation
        animator.SetAnimatorBool("JumpInProgress", true);
        animator.SetAnimatorTrigger("JumpUp");
        animator.ShowDustEffectJump();

        //play sfx
        if (jumpUpVoice != "")
        {
            GlobalAudioPlayer.PlaySFXAtPosition(jumpUpVoice, transform.position);
        }

        //set state
        yield return(new WaitForFixedUpdate());

        //start jump
        while (isGrounded)
        {
            SetVelocity(Vector3.up * JumpForce);
            yield return(new WaitForFixedUpdate());
        }

        //continue until we hit the ground
        while (!isGrounded)
        {
            yield return(new WaitForFixedUpdate());
        }

        //land
        playerState.SetState(UNITSTATE.LAND);
        SetVelocity(Vector3.zero);

        animator.SetAnimatorFloat("MovementSpeed", 0f);
        animator.SetAnimatorBool("JumpInProgress", false);
        animator.SetAnimatorBool("JumpKickActive", false);
        animator.SetAnimatorBool("JumpPunchActive", false); //LETHAL FORCES - Adding Jump Punch
        animator.ShowDustEffectLand();

        //sfx
        GlobalAudioPlayer.PlaySFX("FootStep");
        if (jumpLandVoice != "")
        {
            GlobalAudioPlayer.PlaySFXAtPosition(jumpLandVoice, transform.position);
        }

        jumpInProgress = false;

        if (playerState.currentState == UNITSTATE.LAND)
        {
            yield return(new WaitForSeconds(landRecoveryTime));

            setPlayerState(UNITSTATE.IDLE);
        }
    }
Exemplo n.º 2
0
    //player has landed after a jump
    void HasLanded()
    {
        jumpInProgress = false;
        playerState.SetState(UNITSTATE.LAND);
        rb.velocity = Vector2.zero;
        landTime    = Time.time;

        //set animator properties
        animator.SetAnimatorFloat("MovementSpeed", 0f);
        animator.SetAnimatorBool("JumpInProgress", false);
        animator.SetAnimatorBool("JumpKickActive", false);
        animator.SetAnimatorBool("Falling", false);
        animator.ShowDustEffectLand();

        //sfx
        GlobalAudioPlayer.PlaySFX("FootStep");
        if (jumpLandVoice != "")
        {
            GlobalAudioPlayer.PlaySFXAtPosition(jumpLandVoice, transform.position);
        }
    }
Exemplo n.º 3
0
    //knockDown sequence
    public IEnumerator KnockDownSequence(GameObject inflictor)
    {
        playerState.SetState(UNITSTATE.KNOCKDOWN);
        animator.StopAllCoroutines();
        yield return(new WaitForFixedUpdate());

        //look towards the direction of the incoming attack
        int dir = inflictor.transform.position.x > transform.position.x ? 1 : -1;

        currentDirection = (DIRECTION)dir;
        TurnToDir(currentDirection);

        //update playermovement
        var pm = GetComponent <PlayerMovement>();

        if (pm != null)
        {
            pm.CancelJump();
            pm.SetDirection(currentDirection);
        }

        //add knockback force
        animator.SetAnimatorTrigger("KnockDown_Up");
        while (IsGrounded())
        {
            SetVelocity(new Vector3(KnockbackForce * -dir, KnockdownUpForce, 0));
            yield return(new WaitForFixedUpdate());
        }

        //going up...
        while (rb.velocity.y >= 0)
        {
            yield return(new WaitForFixedUpdate());
        }

        //going down
        animator.SetAnimatorTrigger("KnockDown_Down");
        while (!IsGrounded())
        {
            yield return(new WaitForFixedUpdate());
        }

        //hit ground
        animator.SetAnimatorTrigger("KnockDown_End");
        CamShake camShake = Camera.main.GetComponent <CamShake>();

        if (camShake != null)
        {
            camShake.Shake(.3f);
        }
        animator.ShowDustEffectLand();

        //sfx
        GlobalAudioPlayer.PlaySFXAtPosition("Drop", transform.position);

        //ground slide
        float   t            = 0;
        float   speed        = 2;
        Vector3 fromVelocity = rb.velocity;

        while (t < 1)
        {
            SetVelocity(Vector3.Lerp(new Vector3(fromVelocity.x, rb.velocity.y + Physics.gravity.y * Time.fixedDeltaTime, fromVelocity.z), new Vector3(0, rb.velocity.y, 0), t));
            t += Time.deltaTime * speed;
            yield return(null);
        }

        //knockDown Timeout
        SetVelocity(Vector3.zero);
        yield return(new WaitForSeconds(KnockdownTimeout));

        //stand up
        animator.SetAnimatorTrigger("StandUp");
        playerState.currentState = UNITSTATE.STANDUP;

        yield return(new WaitForSeconds(KnockdownStandUpTime));

        playerState.currentState = UNITSTATE.IDLE;
    }
Exemplo n.º 4
0
    //knockDown sequence
    IEnumerator KnockDownSequence(GameObject inflictor)
    {
        enemyState = UNITSTATE.KNOCKDOWN;
        yield return(new WaitForFixedUpdate());

        //look towards the direction of the incoming attack
        int dir = 1;

        if (inflictor != null)
        {
            dir = inflictor.transform.position.x > transform.position.x? 1 : -1;
        }
        currentDirection = (DIRECTION)dir;
        animator.SetDirection(currentDirection);
        TurnToDir(currentDirection);

        //add knockback force
        animator.SetAnimatorTrigger("KnockDown_Up");
        while (IsGrounded())
        {
            SetVelocity(new Vector3(KnockbackForce * -dir, KnockdownUpForce, 0));
            yield return(new WaitForFixedUpdate());
        }

        //going up...
        while (rb.velocity.y >= 0)
        {
            yield return(new WaitForFixedUpdate());
        }

        //going down
        animator.SetAnimatorTrigger("KnockDown_Down");
        while (!IsGrounded())
        {
            yield return(new WaitForFixedUpdate());
        }

        //hit ground
        animator.SetAnimatorTrigger("KnockDown_End");
        GlobalAudioPlayer.PlaySFXAtPosition("Drop", transform.position);
        animator.SetAnimatorFloat("MovementSpeed", 0f);
        animator.ShowDustEffectLand();
        enemyState = UNITSTATE.KNOCKDOWNGROUNDED;
        Move(Vector3.zero, 0f);

        //cam shake
        CamShake camShake = Camera.main.GetComponent <CamShake>();

        if (camShake != null)
        {
            camShake.Shake(.3f);
        }

        //dust effect
        animator.ShowDustEffectLand();

        //stop sliding
        float   t            = 0;
        float   speed        = 2;
        Vector3 fromVelocity = rb.velocity;

        while (t < 1)
        {
            SetVelocity(Vector3.Lerp(new Vector3(fromVelocity.x, rb.velocity.y + Physics.gravity.y * Time.fixedDeltaTime, fromVelocity.z), new Vector3(0, rb.velocity.y, 0), t));
            t += Time.deltaTime * speed;
            yield return(new WaitForFixedUpdate());
        }

        //knockDown Timeout
        Move(Vector3.zero, 0f);
        yield return(new WaitForSeconds(KnockdownTimeout));

        //stand up
        enemyState = UNITSTATE.STANDUP;
        animator.SetAnimatorTrigger("StandUp");
        Invoke("Ready", standUpTime);
    }