Exemple #1
0
    void Jump()
    {
        isJump = true;
        anim.SetTrigger("JumpWall");
        Flip.FlipIfCanFlip(inputDirection * -1);
        //   Flip.transform.localPosition = new Vector3(OffSetSpriteX * inputDirection.x * -1, Flip.transform.localPosition.y, Flip.transform.localPosition.z);
        Flip.transform.localPosition = new Vector3(OffSetSpriteX * 1 * -1, Flip.transform.localPosition.y, Flip.transform.localPosition.z);

        if (isChange)
        {
            StopCoroutine("ChangeStateMove");
            isChange = false;
        }
        canInputCheckWallJump = false;
        StartCoroutine(timerVar.StartTime(SetInputAgainTrue, InputForWallAgain));

        int dir = 0;

        if (isLeftSide)
        {
            dir = 1;
        }
        else
        {
            dir = -1;
        }
        if (useJump)
        {
            move.FirstJump(TimeNoInput, dir);
        }
        else
        {
            float multiplyX = 1.0f;
            if ((isLeftSide && inputDirection.x > 0) ||
                (isRigthSide && inputDirection.x < 0))
            {
                //  multiplyX = MultyplyForceOtherDireccion;
            }
            Vector2 normalFactorSpeed = FactorForNormalSpeed;
            if (move.canRun)
            {
                normalFactorSpeed = FactorForRunSpeed;
            }

            move.ApplyForce(new Vector2(dir, 1).normalized, force.x * multiplyX * normalFactorSpeed.x, force.y * normalFactorSpeed.y, true, TimeNoInput);

            move.SetIsNONWhenJump();
        }

        FX.Spawn(move.groundCheck.position);
        //Klvo
        jumpSFX.Play();
        fsm.PerformTransition(Transition.Move_WallJump);
    }
Exemple #2
0
    public override void DoBeforeEntering()
    {
        // SI hay suscriptores a este evento, NO lanzar ataque
        if (LaunchPunchAction != null)
        {
            LaunchPunchAction();
            fsm.PerformTransition(Transition.CrushToMove);
            return;
        }

        //rigidbody2D.isKinematic = true;
        rigidBody2D.velocity     = Vector2.zero;
        store_GravityScale       = rigidBody2D.gravityScale;
        rigidBody2D.gravityScale = 0;
        anim.SetBool("isCrushing", true);
        anim.SetTrigger("CrushTrigger");

        ManagerPause.SubscribeOnPauseGame(OnPauseGame);
        ManagerPause.SubscribeOnResumeGame(OnResumeGame);

        anim.SetFloat("CrushDir", directionAxis);

        //Defino al direccion del golpe:
        if (directionAxis > inputOffset && canPuchUp)//arriba
        {
            typeC       = TypeCrush.Upper;
            useForceUp  = true;
            canPuchUp   = false;
            timerPuchUp = false;
            moveState.SetIsNONWhenJump();
            StartCoroutine("StartCrush", TimeToCrushUp);
            StartCoroutine(timerVar.StartTime(SetTimerPushUp, TimeToPushUp + TimeToCrushUp));
            highHitSFX.Spawn(transform.position, transform.rotation);
        }
        else if (directionAxis < -1 * inputOffset)//abajo
        {
            typeC  = TypeCrush.Down;
            isDown = true;
            moveState.RemoveLayerToWhatisGround("Obstacle");
            StartCoroutine("StartCrush", TimeToCrushDown);
            lowHitSFX.Spawn(transform.position, transform.rotation);
        }
        else//middle
        {
            typeC                = TypeCrush.Middle;
            puno.enabled         = true;
            punoRenderer.enabled = true;

            StartCoroutine("StartCrush", TimeToCrush);
            anim.SetFloat("CrushDir", 0);
            middleHitSFX.Spawn(transform.position, transform.rotation);
        }
    }