Пример #1
0
    public void Enter(BurinkeruInputManager inputManager, BurinkeruCharacterController parent, CharacterComponents components)
    {
        this.inputManager = inputManager;
        this.components   = components;

        base.Enter(parent);
    }
Пример #2
0
    void switchToSlideIfNeeded()
    {
        BurinkeruCharacterController characterController = (BurinkeruCharacterController)this.characterController;

        if (characterController == null)
        {
            return;
        }

        if (characterController.IsCrouching)
        {
            float enterTime   = characterController.CrouchState.EnterTime;
            float currentTime = Time.unscaledTime;
            float timeDiff    = currentTime - enterTime;

            Vector3 currentVelocity = characterController.DeltaPosition;
            currentVelocity.Scale(BurinkeruCharacterController.MovementAxes);
            currentVelocity /= Time.deltaTime;

            if (currentVelocity.sqrMagnitude > 10 && timeDiff < 0.5f)
            {
                slide();
            }
        }
    }
Пример #3
0
    public override void UpdateMovement()
    {
        BurinkeruCharacterController characterController = (BurinkeruCharacterController)this.characterController;

        if (characterController == null)
        {
            return;
        }

        if (groundedInternalState != null && groundedInternalState is PlayerSlideState)
        {
            groundedInternalState.UpdateMovement();
        }
        else
        {
            updateDefaultGroundMovement();
        }

        if (inputManager.IsCommandDown(BurinkeruInputManager.InputCommand.CROUCH))
        {
            switchCrouch();
        }
        else if (inputManager.IsCommandDown(BurinkeruInputManager.InputCommand.JUMP))
        {
            onJumpButtonClicked();
        }
        else if (inputManager.IsCommandDown(BurinkeruInputManager.InputCommand.RUN) && !characterController.IsBlinking)
        {
            switchRun();
        }
    }
Пример #4
0
    public virtual void Init(RigManager rigManager, BurinkeruCharacterController characterController, ParticlesManager particleManager)
    {
        this.rigManager          = rigManager;
        this.characterController = characterController;
        this.particleManager     = particleManager;
        CanAttack = true;

        initActionsDefinitions();
    }
Пример #5
0
    public override void Init(RigManager rigManager, BurinkeruCharacterController characterController, ParticlesManager particlesManager)
    {
        base.Init(rigManager, characterController, particlesManager);

        rigAnmationController = rigManager.RigWithKatana;
        rigAnmationController.OnAttackEnded   += onAttackEnded;
        rigAnmationController.OnAttackStarted += onAttackStarted;
        rigAnmationController.OnCustomEvent   += onCustomEventOccured;
    }
Пример #6
0
    public override void Init(RigManager rigManager, BurinkeruCharacterController characterController, ParticlesManager particlesManager)
    {
        base.Init(rigManager, characterController, particlesManager);

        rigAnmationController = rigManager.RigWithRevolver;
        rigAnmationController.OnAttackEnded += onAttackEnded;
        rigAnmationController.OnCustomEvent += onCustomEvent;

        Bullets   = MAX_BULLETS;
        CanAttack = true;
    }
Пример #7
0
    protected virtual void switchCrouch()
    {
        BurinkeruCharacterController burinkeruCharacterController = (BurinkeruCharacterController)characterController;

        if (burinkeruCharacterController.IsCrouching)
        {
            burinkeruCharacterController.ExitCrouch();
        }
        else
        {
            burinkeruCharacterController.EnterCrouch();
        }
    }
Пример #8
0
    void applyGravity()
    {
        BurinkeruCharacterController characterController = (BurinkeruCharacterController)this.characterController;

        if (characterController == null)
        {
            return;
        }

        if (!characterController.IsBlinking && wallRunState == null)
        {
            float gravity = -CharacterControllerParameters.Instance.Gravity * Time.deltaTime;
            addVelocity(new Vector3(0f, gravity, 0));
        }
    }
Пример #9
0
    protected override void onEnter()
    {
        BurinkeruCharacterController characterController = (BurinkeruCharacterController)this.characterController;

        if (characterController == null)
        {
            return;
        }

        Vector3 currentVelocity = characterController.Velocity;

        currentVelocity.y = 0;
        setVelocity(currentVelocity);

        switchToSlideIfNeeded();
    }
Пример #10
0
    void enterCrouch()
    {
        BurinkeruCharacterController characterController = (BurinkeruCharacterController)this.characterController;

        if (characterController == null)
        {
            return;
        }

        if (groundedInternalState != null && groundedInternalState is PlayerRunState)
        {
            slide();
        }

        characterController.EnterCrouch();
    }
Пример #11
0
    protected override void switchCrouch()
    {
        BurinkeruCharacterController characterController = (BurinkeruCharacterController)this.characterController;

        if (characterController == null)
        {
            return;
        }
        if (characterController.IsCrouching)
        {
            exitCrouch();
        }
        else
        {
            enterCrouch();
        }
    }
Пример #12
0
    void exitCrouch()
    {
        BurinkeruCharacterController characterController = (BurinkeruCharacterController)this.characterController;

        if (characterController == null)
        {
            return;
        }

        if (groundedInternalState != null && groundedInternalState is PlayerSlideState)
        {
            groundedInternalState.Exit();
            groundedInternalState = null;
        }

        characterController.ExitCrouch();
    }
Пример #13
0
    void switchRun()
    {
        BurinkeruCharacterController characterController = (BurinkeruCharacterController)this.characterController;

        if (characterController == null)
        {
            return;
        }

        if (groundedInternalState == null)
        {
            if (characterController.IsCrouching)
            {
                exitCrouch();
            }

            setNewInternalState(new PlayerRunState());
        }
    }
Пример #14
0
    void slide()
    {
        BurinkeruCharacterController characterController = (BurinkeruCharacterController)this.characterController;

        if (characterController == null)
        {
            return;
        }

        if (groundedInternalState != null)
        {
            groundedInternalState.Exit();
        }

        PlayerSlideState slideState = new PlayerSlideState();

        slideState.OnExitSlideStateRequested += onExitSlideStateRequested;
        slideState.Enter(inputManager, characterController, components);
        groundedInternalState = slideState;
    }
Пример #15
0
    void setNewInternalState(PlayerState newState)
    {
        BurinkeruCharacterController characterController = (BurinkeruCharacterController)this.characterController;

        if (characterController == null)
        {
            return;
        }

        if (groundedInternalState == null || newState.GetType() != groundedInternalState.GetType())
        {
            if (groundedInternalState != null)
            {
                groundedInternalState.Exit();
            }

            newState.Enter(inputManager, characterController, components);
            groundedInternalState = newState;
        }
    }
Пример #16
0
    bool tryToWallRun()
    {
        bool success = false;
        BurinkeruCharacterController characterController = (BurinkeruCharacterController)this.characterController;

        if (characterController == null)
        {
            return(false);
        }

        PlayerWallRunState.WallRunRaycastResult result = PlayerWallRunState.RaycastWalls(characterController.transform);

        if (result.Success)
        {
            if (lastWallRunCollider == null ||
                (lastWallRunCollider != result.Hit.collider) ||
                (lastWallRunCollider == result.Hit.collider && wallRunToLastColliderAllowed))
            {
                lastWallRunCollider = result.Hit.collider;

                Vector3 lookDirection = characterController.GetLookDirection();
                float   dot           = Vector3.Dot(lookDirection, result.Direction);
                success = true;
                Vector3 v   = characterController.GetLookDirection();
                Vector3 n   = result.Hit.normal;
                Vector3 vtn = Vector3.Cross(v, n);
                Vector3 res = Vector3.Cross(n, vtn);
                res.y *= 0.1f;

                result.RunDirection = res;

                wallRunState = new PlayerWallRunState(result);
                wallRunState.Enter(inputManager, characterController, components);
                wallRunState.RequestExit += onExitRequested;

                Debug.DrawRay(result.Hit.point, res * 10, Color.magenta, 1f);
            }
        }

        return(success);
    }
Пример #17
0
    void onJumpButtonClicked()
    {
        BurinkeruCharacterController characterController = (BurinkeruCharacterController)this.characterController;

        if (characterController == null)
        {
            return;
        }

        if (characterController.IsCrouching)
        {
            if (groundedInternalState != null && groundedInternalState is PlayerSlideState)
            {
                jump();
            }

            characterController.ExitCrouch();
        }
        else
        {
            jump();
        }
    }