示例#1
0
    public float TryModifyParameter(GameParameter gameParameter, float value)
    {
        ChangingParameter changingParameter = null;

        try
        {
            changingParameter = changingParameters.Single(s => s.gameParameter == gameParameter);
        }
        catch (System.InvalidOperationException)
        {
        }

        if (changingParameter != null)
        {
            Debug.Log("Нашел параметр в предмете " + changingParameter.gameParameter);
            if (changingParameter.useAsPercent)
            {
                return(value *= changingParameter.value);
            }
            else
            {
                return(value += changingParameter.value);
            }
        }
        else
        {
            return(value);
        }
    }
示例#2
0
    private void TryAddBonusToParameter(ChangingParameter changingParameter)
    {
        switch (changingParameter.gameParameter)
        {
        case GameParameter.AccelerationDuration: if (changingParameter.useAsPercent)
            {
                _accelerationDuration *= changingParameter.value;
            }
            else
            {
                _accelerationDuration += changingParameter.value;
            } break;

        case GameParameter.PlayerDetectionDistance: if (changingParameter.useAsPercent)
            {
                _playerRadar.radius *= changingParameter.value;
            }
            else
            {
                _playerRadar.radius += changingParameter.value;
            } break;

        case GameParameter.SlowdownDuration: if (changingParameter.useAsPercent)
            {
                _slowdownDuration *= changingParameter.value;
            }
            else
            {
                _slowdownDuration += changingParameter.value;
            } break;

        case GameParameter.SoulDetectionDistance: if (changingParameter.useAsPercent)
            {
                _soulRadar.radius *= changingParameter.value;
            }
            else
            {
                _soulRadar.radius += changingParameter.value;
            } break;

        case GameParameter.SoulSpeed: if (changingParameter.useAsPercent)
            {
                _maxSpeed *= changingParameter.value;
            }
            else
            {
                _maxSpeed += changingParameter.value;
            } break;

        case GameParameter.SoulWalkingSpeed: if (changingParameter.useAsPercent)
            {
                navMeshAgent.speed *= changingParameter.value;
            }
            else
            {
                navMeshAgent.speed += changingParameter.value;
            } break;
        }
    }
示例#3
0
    public ChangingParameter GetParameterByEnum(GameParameter gameParameter)
    {
        ChangingParameter changingParameter = null;

        try
        {
            changingParameter = changingParameters.Single(s => s.gameParameter == gameParameter);
        }
        catch (System.InvalidOperationException)
        {
        }

        return(changingParameter);
    }