public void RemoveComponent(LogicComponentType componentType)
 {
     if (this.m_components[(int)componentType] != null)
     {
         this.m_components[(int)componentType].Destruct();
         this.m_components[(int)componentType] = null;
     }
 }
        public void EnableComponent(LogicComponentType componentType, bool enable)
        {
            LogicComponent component = this.m_components[(int)componentType];

            if (component != null)
            {
                component.SetEnabled(enable);
            }
        }
        public LogicComponent GetComponent(LogicComponentType componentType)
        {
            LogicComponent component = this.m_components[(int)componentType];

            if (component != null && component.IsEnabled())
            {
                return(component);
            }

            return(null);
        }
Example #4
0
 public static void OpenWindow(LogicComponentType componentType, ComponentObjectBase components, LogicComponentBase value = null, string componetPathName = "")
 {
     instance            = GetWindow <SelectLogicObjectEditor>();
     instance.position   = new Rect(Screen.width / 2, Screen.height / 2, 500, 500);
     instance.value      = value;
     instance.components = components;
     if (value == null)
     {
         instance.isNew = true;
     }
     instance.Init(componentType, componetPathName);
 }
Example #5
0
 public static ComponentNameAttribute GetCompontNameAttribute(LogicComponentType componentType, string menuName)
 {
     Init();
     foreach (ComponentNameAttribute tn in nameList)
     {
         if (tn.menuName == menuName && tn.componentType == componentType)
         {
             return(tn);
         }
     }
     return(null);
 }
Example #6
0
        public static string[] GetCompontNameAttributeArray(LogicComponentType componentType, string logicFileUseType)
        {
            Init();
            List <string> tempList = new List <string>();

            foreach (ComponentNameAttribute tn in nameList)
            {
                if (tn.componentType == componentType && tn.CompareComponentUseTypes(logicFileUseType))
                {
                    tempList.Add(tn.menuName);
                }
            }
            return(tempList.ToArray());
        }
        public void AddComponent(LogicComponent component)
        {
            LogicComponentType componentType = component.GetComponentType();

            if (this.m_components[(int)componentType] == null)
            {
                this.m_level.GetComponentManagerAt(this.m_villageType).AddComponent(component);
                this.m_components[(int)componentType] = component;
            }
            else
            {
                Debugger.Error("LogicGameObject::addComponent - Component is already added.");
            }
        }
Example #8
0
 public void SetLogicConponetTypeEnable(LogicComponentType type, bool enable)
 {
     if (type == LogicComponentType.Event)
     {
         events.enable = enable;
     }
     else if (type == LogicComponentType.Condition)
     {
         conditions.enable = enable;
     }
     else
     {
         actions.enable = enable;
     }
 }
Example #9
0
        void Init(LogicComponentType componentType, string componetPathName)
        {
            logicComponetType = componentType;
            string logicFileUseType = "";

            if (StateMachineEditorWindow.Instance)
            {
                logicFileUseType = LogicSystemEditorWindow.logicFileUseType;
            }
            componetNameArr = CompontNameAttributeUtils.GetCompontNameAttributeArray(componentType, logicFileUseType);

            if (isNew == false)
            {
                for (int i = 0; i < componetNameArr.Length; i++)
                {
                    if (componetNameArr[i] == componetPathName)
                    {
                        selectInt0 = i;
                        return;
                    }
                }
            }
        }
        private void DrawNameAndClassListGUI(string name, ComponentObjectBase componentObject, LogicComponentType triggerType)
        {
            List <LogicComponentBase> dataList = componentObject.GetLogicComs();

            GUILayout.Space(6);
            GUIStyle style = "flow overlay header lower left";

            GUILayout.BeginHorizontal(style);
            GUILayout.Label(name);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("+", GUILayout.Width(30)))
            {
                SelectLogicObjectEditor.OpenWindow(triggerType, componentObject);
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginVertical("box");
            for (int i = 0; i < dataList.Count; i++)
            {
                LogicComponentBase value = dataList[i];
                GUILayout.BeginHorizontal();
                string menuName = "";


                ComponentNameAttribute cccc = CompontNameAttributeUtils.GetCompontNameAttributeByClassName(value.GetType().FullName);
                if (cccc != null)
                {
                    menuName = cccc.menuName;
                }
                GUILayout.Label("  " + menuName);
                GUILayout.Label(value.ToExplain());

                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Edit"))
                {
                    SelectLogicObjectEditor.OpenWindow(triggerType, componentObject, dataList[i], menuName);
                }
                if (GUILayout.Button("-", GUILayout.Width(55)))
                {
                    if (EditorUtility.DisplayDialog("提示", "你要删除当前组件吗?", "是", "否"))
                    {
                        dataList.RemoveAt(i);
                        componentObject.SaveComponentDataToClassValue();
                    }
                    return;
                }
                if (GUILayout.Button("▲", GUILayout.Width(55)))
                {
                    if (i - 1 >= 0)
                    {
                        LogicComponentBase temps = dataList[i];
                        dataList.RemoveAt(i);
                        dataList.Insert(i - 1, temps);
                    }
                    return;
                }
                if (GUILayout.Button("复制", GUILayout.Width(55)))
                {
                    if (copyDataDic.ContainsKey(triggerType))
                    {
                        copyDataDic[triggerType] = value;
                    }
                    else
                    {
                        copyDataDic.Add(triggerType, value);
                    }
                }
                if (copyDataDic.ContainsKey(triggerType))
                {
                    if (GUILayout.Button("粘贴", GUILayout.Width(55)))
                    {
                        dataList[i] = copyDataDic[triggerType];
                        copyDataDic.Remove(triggerType);
                    }
                }

                GUILayout.EndHorizontal();
                GUILayout.Space(6);
            }
            GUILayout.EndVertical();
        }
Example #11
0
 public LogicArrayList <LogicComponent> GetComponents(LogicComponentType componentType)
 {
     return(this.m_components[(int)componentType]);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="type"></param>
 /// <param name="menuName"></param>
 /// <param name="componentUseTypes">组件使用范围(地图逻辑,AI等),不填写为所有类型都可以使用</param>
 public ComponentNameAttribute(LogicComponentType type, string menuName, string[] componentUseTypes = null)
 {
     this.menuName          = menuName;
     componentType          = type;
     this.componentUseTypes = componentUseTypes;
 }
 public void SetComponentType(LogicComponentType type)
 {
     this.m_componentType = type;
 }