Пример #1
0
    public void SetActionState(ActionState newActionState)
    {
        switch (currentActionState)
        {
        case ActionState.Free:
            lastSavePosition = transform.position;
            break;

        case ActionState.Falling:
            timeFalling = 0.0f;
            fallingSave.gameObject.SetActive(false);
            break;

        case ActionState.Hooked:
            lastSavePosition = transform.position;
            break;
        }

        switch (newActionState)
        {
        case ActionState.Free:
            gameObject.layer = LayerList.Player;
            player.hook.ResetAnchorPoints();
            canDash = true;
            break;

        case ActionState.Falling:
            player.hook.ResetAnchorPoints();
            gameObject.layer     = LayerList.PlayerFalling;
            rigidbody2D.velocity = Vector2.zero;
            fallingSave.gameObject.SetActive(true);
            break;

        case ActionState.Dashing:
            gameObject.layer = LayerList.PlayerDashing;
            canDash          = false;
            timeDashing      = 0.0f;
            Vector2 dashDirection = (Vector2)crosshair.transform.localPosition - boxCollider2D.offset;
            dashTime         = dashDirection.magnitude / dashSpeed;
            dashingDirection = dashDirection.normalized;
            Trailer.AddTrailer(spriteRenderer, dashTime, 0.05f, 1.0f, 10.0f, 0.1f);
            break;

        case ActionState.Swinging:
            gameObject.layer = LayerList.PlayerDashing;
            break;

        case ActionState.Pulling:
            gameObject.layer = LayerList.PlayerDashing;
            break;

        case ActionState.Repositioning:
            gameObject.layer  = LayerList.PlayerDashing;
            canDash           = false;
            timeRepositioning = 0.0f;
            break;
        }

        currentActionState = newActionState;
    }