Beispiel #1
0
        /// <summary>
        /// Activates a single target by running the links for that target
        /// </summary>
        /// <param name="rTarget"></param>
        protected virtual bool ActivateInstance(GameObject rTarget, object rData)
        {
            if (rTarget == null)
            {
                return(true);
            }

            IAttributeSource lAttributes = rTarget.GetComponent <IAttributeSource>();

            if (lAttributes == null)
            {
                return(true);
            }

            Type lType = lAttributes.GetAttributeType(_AttributeName);

            if (lType == typeof(int))
            {
                int lValue = 0;
                if (int.TryParse(_StringValue, out lValue))
                {
                    lAttributes.SetAttributeValue <int>(_AttributeName, lValue);
                }
            }
            else if (lType == typeof(float))
            {
                float lValue = 0f;
                if (float.TryParse(_StringValue, out lValue))
                {
                    lAttributes.SetAttributeValue <float>(_AttributeName, lValue);
                }
            }
            else if (lType == typeof(string))
            {
                lAttributes.SetAttributeValue <string>(_AttributeName, _StringValue);
            }

            return(true);
        }