예제 #1
0
        /**
         * <summary>Updates a List of parameter values to be used at runtime.</summary>
         * <param name="newParameters">The new parameter values.  Parameters will be updated by matchind ID value, not by index.  Parameters that are not included in the list will not be updated.</param>
         */
        public void AssignParameterValues(List <ActionParameter> newParameters)
        {
            if (useParameters && parameters != null)
            {
                if (runtimeParameters == null)
                {
                    runtimeParameters = new List <ActionParameter> ();
                }

                foreach (ActionParameter newParameter in newParameters)
                {
                    ActionParameter matchingParameter = GetParameter(newParameter.ID);
                    if (matchingParameter != null)
                    {
                        matchingParameter.CopyValues(newParameter);
                    }
                }
            }
        }
        override public float Run()
        {
            if (_parameter == null)
            {
                ACDebug.LogWarning("Cannot set parameter value since it cannot be found!");
                return(0f);
            }

            if (setParamMethod == SetParamMethod.CopiedFromGlobalVariable)
            {
                GVar gVar = GlobalVariables.GetVariable(globalVariableID);
                if (gVar != null)
                {
                    if (_parameter.parameterType == ParameterType.Boolean ||
                        _parameter.parameterType == ParameterType.Integer)
                    {
                        _parameter.intValue = gVar.val;
                    }
                    else if (_parameter.parameterType == ParameterType.Float)
                    {
                        _parameter.floatValue = gVar.floatVal;
                    }
                    else if (_parameter.parameterType == ParameterType.Vector3)
                    {
                        _parameter.vector3Value = gVar.vector3Val;
                    }
                    else if (_parameter.parameterType == ParameterType.String)
                    {
                        _parameter.stringValue = GlobalVariables.GetStringValue(globalVariableID, true, Options.GetLanguage());
                    }
                }
            }
            else if (setParamMethod == SetParamMethod.EnteredHere)
            {
                if (_parameter.parameterType == ParameterType.Boolean ||
                    _parameter.parameterType == ParameterType.Integer ||
                    _parameter.parameterType == ParameterType.GlobalVariable ||
                    _parameter.parameterType == ParameterType.LocalVariable ||
                    _parameter.parameterType == ParameterType.InventoryItem)
                {
                    _parameter.intValue = intValue;
                }
                else if (_parameter.parameterType == ParameterType.Float)
                {
                    _parameter.floatValue = floatValue;
                }
                else if (_parameter.parameterType == ParameterType.String)
                {
                    _parameter.stringValue = stringValue;
                }
                else if (_parameter.parameterType == ParameterType.GameObject)
                {
                    _parameter.gameObject = gameobjectValue;
                    _parameter.intValue   = gameObjectConstantID;
                }
                else if (_parameter.parameterType == ParameterType.UnityObject)
                {
                    _parameter.objectValue = unityObjectValue;
                }
                else if (_parameter.parameterType == ParameterType.Vector3)
                {
                    _parameter.vector3Value = vector3Value;
                }
            }
            else if (setParamMethod == SetParamMethod.Random)
            {
                if (_parameter.parameterType == ParameterType.Boolean)
                {
                    _parameter.intValue = Random.Range(0, 2);
                }
                else if (_parameter.parameterType == ParameterType.Integer)
                {
                    _parameter.intValue = Random.Range(intValue, intValueMax + 1);
                }
                else if (_parameter.parameterType == ParameterType.Float)
                {
                    _parameter.floatValue = Random.Range(floatValue, floatValueMax);
                }
                else
                {
                    ACDebug.LogWarning("Parameters of type '" + _parameter.parameterType + "' cannot be set randomly.");
                }
            }
            else if (setParamMethod == SetParamMethod.CopiedFromParameter)
            {
                if (_parameterToCopy == null)
                {
                    ACDebug.LogWarning("Cannot copy parameter value since it cannot be found!");
                    return(0f);
                }

                _parameter.CopyValues(_parameterToCopy);
            }

            return(0f);
        }