Пример #1
0
 public ActionProperty(ActionProperty actionProp, BComponent newParent = null)
 {
     this.parent          = newParent;
     this.actionName      = actionProp.actionName;
     this.componentName   = actionProp.componentName;
     this.action          = actionProp.action;
     this.behaviorManager = actionProp.behaviorManager;
 }
Пример #2
0
        public static BComponent Build(XmlNode xmlDoc, BComponent parent, Behaviors behaviorManager)
        {
            System.Func <bool> action = null;
            string             actionName;
            string             componentName;
            bool   isError      = false;
            string messageError = "";

            FindAttributes(xmlDoc, out actionName, out componentName);
            if (actionName == null)
            {
                isError      = true;
                messageError = "ActionProperty: don't have action attribute";
                throw new NullReferenceException(messageError);
            }
            else
            {
                MonoBehaviour mono = GetRightMono(componentName, behaviorManager.components);
                if (mono != null)
                {
                    action = FindProperty <System.Func <bool> >(actionName, mono);

                    if (action == null)
                    {
                        isError      = true;
                        messageError = string.Format("ActionProperty: I can't find property [{0}]", actionName);
                    }
                }
                else
                {
                    isError      = true;
                    messageError = string.Format("ActionProperty: wrong component name [{1}] for menthod: [{0}]", actionName, componentName);
                    Debug.LogError(messageError);
                }
            }

            ActionProperty result = new ActionProperty(parent, action, actionName, componentName, behaviorManager);

            result.isError      = isError;
            result.messageError = messageError;
            return(result);
        }