private void Run()
    {
        float stamina   = GetComponent <PlayerStamina>().GetCurrentValue();
        float velocityX = PlayerMovementMathFunctions.GetVelocityByStamina(stamina, GameConfigRepository.LoadMovementEquationType());

        if (_player.GetState() == Player.State.Damaged)
        {
            velocityX += InGameParameters.PlayerMinusVelocityWhenDamaged;
        }
        velocityX = Mathf.Clamp(
            velocityX,
            InGameParameters.PlayerVelocityMin,
            InGameParameters.PlayerVelocityMax);
        Vector3 velocity = GetComponent <Rigidbody2D>().velocity;

        velocity.x = velocityX;
        GetComponent <Rigidbody2D>().velocity = velocity;
    }
Exemple #2
0
    void Start()
    {
        Debug.Assert(_dropdownMovementFunction != null);
        Debug.Assert(_dropdownStaminaHealAmount != null);
        Debug.Assert(_dropdownStaminaConsumeAmount != null);

        _movementFunctionOptions = new MovementFunctionOption[] {
            new MovementFunctionOption(
                PlayerMovementMathFunctions.Type.LinerEquation01,
                "1次方程式01"
                ),
            new MovementFunctionOption(
                PlayerMovementMathFunctions.Type.QuarticEquation01,
                "2次方程式01"
                ),
        };
        _staminaHealAmountOptions = Enumerable.Range((int)InGameParameters.StaminaHealAmountMin, (int)(InGameParameters.StaminaHealAmountMax - InGameParameters.StaminaHealAmountMin + 1))
                                    .Select((x) => (float)x)
                                    .ToArray();
        _staminaConsumeAmountOptions = Enumerable.Range((int)InGameParameters.StaminaConsumeAmountMin, (int)(InGameParameters.StaminaConsumeAmountMax - InGameParameters.StaminaConsumeAmountMin + 1))
                                       .Select((x) => (float)x)
                                       .ToArray();

        List <string> labels = _movementFunctionOptions.Select(x => x.Label).ToList();
        int           index  = System.Array.FindIndex(_movementFunctionOptions, x => x.Type == GameConfigRepository.LoadMovementEquationType());

        _dropdownMovementFunction.ClearOptions();
        _dropdownMovementFunction.AddOptions(labels);
        _dropdownMovementFunction.value = (index != -1) ? index : 0;


        labels = _staminaHealAmountOptions.Select(x => x.ToString("")).ToList();
        index  = System.Array.FindIndex(_staminaHealAmountOptions, x => x == GameConfigRepository.LoadStaminaHealAmount());
        _dropdownStaminaHealAmount.ClearOptions();
        _dropdownStaminaHealAmount.AddOptions(labels);
        _dropdownStaminaHealAmount.value = (index != -1) ? index : 0;


        labels = _staminaConsumeAmountOptions.Select(x => x.ToString("")).ToList();
        index  = System.Array.FindIndex(_staminaConsumeAmountOptions, x => x == GameConfigRepository.LoadStaminaConsumeAmount());
        _dropdownStaminaConsumeAmount.ClearOptions();
        _dropdownStaminaConsumeAmount.AddOptions(labels);
        _dropdownStaminaConsumeAmount.value = (index != -1) ? index : 0;
    }