public override void SetUpInput()
    {
        DashComponent     = GetComponent <DashComponent>();
        AttackComponent   = GetComponent <EHAttackComponent>();
        MovementComponent = GetComponent <EHCharacterMovementComponent>();
        CharacterWallJump = GetComponent <WallJump>();
        ParryComponent    = GetComponent <EHParry>();

        BindActionToInput(JUMP_COMMAND, ButtonInputType.Button_Pressed, Jump);
        BindActionToInput(JUMP_COMMAND, ButtonInputType.Button_Buffer, JumpBufferEnded);
        BindActionToInput(JUMP_COMMAND, ButtonInputType.Button_Released, MovementComponent.EndJump);
        BindActionToInput(DASH_COMMAND, ButtonInputType.Button_Pressed, DashComponent.InputDash);
        BindActionToInput(DASH_COMMAND, ButtonInputType.Button_Buffer, DashComponent.CancelDash);
        BindActionToInput(SHOOT_COMMAND, ButtonInputType.Button_Pressed, Shoot);
        BindActionToInput(SHOOT_COMMAND, ButtonInputType.Button_Buffer, ShootBufferEnd);
        BindActionToInput(ATTACK_COMMAND, ButtonInputType.Button_Pressed, Attack);
        BindActionToInput(ATTACK_COMMAND, ButtonInputType.Button_Buffer, AttackBufferEnded);
        BindActionToInput(JUMP_COMMAND, ButtonInputType.Button_Pressed, CharacterWallJump.InputWallJump);
        BindActionToInput(JUMP_COMMAND, ButtonInputType.Button_Buffer, CharacterWallJump.InputCancelWallJump);
        BindActionToInput(PARRY_COMMAND, ButtonInputType.Button_Pressed, ParryComponent.ParryInputDown);
        BindActionToInput(PARRY_COMMAND, ButtonInputType.Button_Buffer, ParryComponent.ParryInputReleased);

        BindActionToAxis(HORIZONTAL_AXIS, MovementComponent.SetHorizontalInput);
        BindActionToAxis(VERTICAL_AXIS, MovementComponent.SetVerticalInput);
    }
Example #2
0
    protected override void Start()
    {
        base.Start();

        // By possessing, the controller's pawn is defined as this pawn
        controller = GetComponent <PlayerController>();
        controller.Possess(this);

        dash  = GetComponent <DashComponent>();
        combo = GetComponent <ComboComponent>();
    }
    protected override void OnUpdate()
    {
        float dt = Time.DeltaTime;

        //Get Entities
        Entity playerEntity = GameVariables.Player.Entity;

        //Get Components
        DirectionData  direction = EntityManager.GetComponentData <DirectionData>(playerEntity);
        DashComponent  dash      = EntityManager.GetComponentData <DashComponent>(playerEntity);
        InputComponent inputs    = EntityManager.GetComponentData <InputComponent>(playerEntity);
        Rotation       rotation  = EntityManager.GetComponentData <Rotation>(playerEntity);

        //Is Player currently dashing? -> Keep moving
        if (dash.IsDashing)
        {
            dash.CurrentDashTime -= dt;

            direction.Value = GetVelocity(dash);
            EntityManager.SetComponentData(playerEntity, direction);

            EventsHolder.StateEvents.Add(new StateInfo
            {
                Entity       = GameVariables.Player.Entity,
                DesiredState = State.Dashing,
                Action       = StateInfo.ActionType.TryChange
            });
        }
        //Is dash finished? -> Unlock inputs...
        else if (dash.WasDashingPreviousFrame)
        {
            OnDashEnd(ref dash);
        }

        if (!dash.IsAvailable)
        {
            dash.CurrentCooldownTime -= dt;
        }

        if (TryDash(dash, inputs))
        {
            //Dash
            Dash(ref dash, inputs, rotation);
            //Set Player invincibility
            GlobalEvents.PlayerEvents.SetInvincibility(InvincibilityType.Dash);
            SoundEventSystem.PlayDashSound();
        }

        EntityManager.SetComponentData(playerEntity, dash);
    }