public override void Up()
    {
        //Set the position and velocity.
        Owner.transform.position += new Vector3(0, -Owner.PlayerProps.CeilingPushOffOffset, 0);
        Owner.Velocity            = new Vector3(Owner.Velocity.x, -Owner.PlayerProps.WallSlidePushOff.y, 0);

        //Set the state.
        InAirState state = ScriptableObject.CreateInstance <InAirState>();

        state.DimAcceleration();
        Owner.ChangeState(state, true);

        //Play the right noise.
        WorldConstants.PlayPhysNoises.PlayNoise(PlayerPhysicsNoises.Events.SlidePushOff);
        WorldConstants.PlayPhysNoises.PlayNoise(PlayerPhysicsNoises.Events.GroundPound);
    }
 private void OnDisable()
 {
     IdleState.Dispose();
     MoveState.Dispose();
     JumpState.Dispose();
     InAirState.Dispose();
     LandState.Dispose();
     WallSlideState.Dispose();
     LedgeClimbState.Dispose();
     CrouchIdleState.Dispose();
     CrouchMoveState.Dispose();
     SwordAttackState.Dispose();
     HandAttackState.Dispose();
     AirAttackState.Dispose();
     SlideState.Dispose();
 }
        void onStateChanged(CharacterStateBase newState, CharacterStateBase prevState)
        {
            if (typeof(InAirState).IsAssignableFrom(prevState.GetType()) && typeof(GroundState).IsAssignableFrom(newState.GetType()))
            {
                InAirState inAirState = (InAirState)prevState;

                if (Mathf.Abs(inAirState.LastInAirVelocity.y) > minYVelocityToAnimateLanding)
                {
                    headAnimationController.AnimateLand();
                }
            }

            if (typeof(WallRunState).IsAssignableFrom(newState.GetType()))
            {
                WallRunState wallRunState = (WallRunState)newState;

                switch (wallRunState.WallRunSide)
                {
                case WallRunState.WallRunType.LEFT:

                    spineAnimationController.AnimateWallRunLeft();

                    break;

                case WallRunState.WallRunType.RIGH:

                    spineAnimationController.AnimateWallRunRight();

                    break;
                }
            }

            if (typeof(WallRunState).IsAssignableFrom(prevState.GetType()))
            {
                spineAnimationController.AnimateToDefaultPosition();
            }
            else if (typeof(GroundState).IsAssignableFrom(newState.GetType()))
            {
                GroundState groundState = (GroundState)newState;
                onGroundStateInternalStateChaged(groundState.InternalState);
            }
            else if (typeof(SlideState).IsAssignableFrom(newState.GetType()))
            {
                headAnimationController.SetCrouch(true);
            }
        }
Exemplo n.º 4
0
    public PlayerControllerData(PlayerController player)
    {
        Player               = player;
        PlayerRB             = Player.GetComponent <Rigidbody2D>();
        MainCollider         = Player.GetComponent <CapsuleCollider2D>();
        PlayerSpriteRenderer = Player.GetComponent <SpriteRenderer>();
        PlayerCam            = Camera.main;
        PlayerAnimator       = Player.GetComponent <Animator>();
        PlayerHUD            = GameObject.Find("HUD_Base_Panel").GetComponent <HUD>();
        PlayerBoomerang      = Player.GetComponentInChildren <BoomerangObj>();

        PlatformLayer = LayerMask.GetMask("World");

        Idle     = new IdleState(this);
        Movement = new MoveState(this);
        Jump     = new JumpState(this);
        InAir    = new InAirState(this);
        Aim      = new AimState(this);
        Throw    = new ThrowState(this);
        WallJump = new WallJumpState(this);
        SetState(Idle);

        AnimStates = new Dictionary <State, string>()
        {
            { Idle, idleAnim },
            { Movement, moveAnim },
            { Jump, idleAnim },
            { InAir, inAirAnim },
            { Aim, null },
            { Throw, null },
            { WallJump, onWallAnim }
        };

        maxPlayerHealth = 100.0f;
        playerHealth    = maxPlayerHealth;
        maxPlayerPotion = 50.0f;
        playerPotion    = maxPlayerPotion;
    }