private void InitTypeItems()
        {
            NodeType         nodeType = _nodeAttr.Node.GetNodeType();
            CustomDefineType type     = CustomDefine.GetTypeByNodeType(nodeType);

            _typeNameList = CustomDefine.GetCustomDefineListByType(type);
            for (int i = 0; i < _typeNameList.Count; i++)
            {
                GameObject    item = ResourceManager.GetInstance().GetPrefab("Prefabs/Views/EditViews", "SelectCustomizedTypeItem");
                RectTransform tf   = item.GetComponent <RectTransform>();
                tf.SetParent(_itemContainerTf, false);
                Text typeNameText = tf.Find("CustomizedTypeText").GetComponent <Text>();
                typeNameText.text = _typeNameList[i];
                item.GetComponent <Image>().color = UnSelectedColor;
                int itemIndex = i;
                UIEventListener.Get(item).AddClick(() => {
                    OnItemClickHandler(itemIndex, false);
                });
                _itemList.Add(item);
            }
            // 计算content面板的高度
            float preferredHeight = _typeNameList.Count * 30 + 5;

            _contentPreferredHeight    = preferredHeight < _contentDefaultSize.y ? _contentDefaultSize.y : preferredHeight;
            _itemContainerTf.sizeDelta = new Vector2(_contentDefaultSize.x, _contentPreferredHeight);
            _contentScrollRect.Rebuild(CanvasUpdate.PostLayout);
            _curSelectedItemIndex = -1;
            // 默认选中节点值的那个item,如果没有对应的,则不选中任何一个
            int index = _typeNameList.IndexOf(_nodeAttr.GetValueString());

            OnItemClickHandler(index, true);
        }
Ejemplo n.º 2
0
 public static void UnloadProject()
 {
     CustomDefine.Clear();
     if (RootNode != null)
     {
         RootNode.Destroy();
     }
     RootNode = null;
     SetProjectPath(null);
 }
Ejemplo n.º 3
0
        public override string ToLuaHead()
        {
            string           typeName = _attrs[0].GetValueString();
            CustomDefineData data     = CustomDefine.GetDataByTypeAndName(CustomDefineType.SimpleBullet, typeName);

            return(string.Format("last = CreateCustomizedBullet(\"{0}\",{1},{2}{3})\n",
                                 typeName,
                                 _attrs[1].GetValueString(),
                                 _attrs[2].GetValueString(),
                                 _attrs[3].GetValueString() == "" ? "" : "," + _attrs[3].GetValueString()));
        }
Ejemplo n.º 4
0
 public override void Destroy()
 {
     EventManager.GetInstance().Remove(EditorEvents.DefineNodeDestroy, this);
     if (_isWatchingData)
     {
         string typeName = GetAttrByIndex(0).GetValueString();
         CustomDefine.RemoveData(CustomDefineType.Enemy, typeName);
         EventManager.GetInstance().PostEvent(EditorEvents.DefineNodeDestroy, new List <object> {
             CustomDefineType.Enemy, typeName
         });
     }
     base.Destroy();
 }
Ejemplo n.º 5
0
 public override void OnAttributeValueChanged(BaseNodeAttr attr = null)
 {
     if (attr != null)
     {
         if (attr.GetPreValue() == null)
         {
             string newTypeName = attr.GetValueString();
             if (newTypeName != "")
             {
                 BaseNode onCreteNode = GetChildByType(NodeType.OnEnemyCreate);
                 _isWatchingData = CustomDefine.AddData(CustomDefineType.Enemy, newTypeName, onCreteNode.GetAttrByIndex(0).GetValueString());
             }
         }
         else
         {
             string fromName = attr.GetPreValue().ToString();
             if (fromName != "")
             {
                 if (_isWatchingData)
                 {
                     _isWatchingData = CustomDefine.ModifyDefineName(CustomDefineType.Enemy, fromName, attr.GetValueString());
                 }
                 else
                 {
                     BaseNode onCreteNode = GetChildByType(NodeType.OnEnemyCreate);
                     _isWatchingData = CustomDefine.AddData(CustomDefineType.Enemy, attr.GetValueString(), onCreteNode.GetAttrByIndex(0).GetValueString());
                 }
             }
             else
             {
                 string newTypeName = attr.GetValueString();
                 if (newTypeName != "")
                 {
                     BaseNode onCreteNode = GetChildByType(NodeType.OnEnemyCreate);
                     _isWatchingData = CustomDefine.AddData(CustomDefineType.Enemy, newTypeName, onCreteNode.GetAttrByIndex(0).GetValueString());
                 }
             }
         }
     }
     else // 载入节点数据or设置节点默认值时
     {
         string typeName = GetAttrByIndex(0).GetValueString();
         if (typeName != "")
         {
             BaseNode onCreteNode = GetChildByType(NodeType.OnEnemyCreate);
             string   paraList    = onCreteNode.GetAttrByIndex(0).GetValueString();
             _isWatchingData = CustomDefine.AddData(CustomDefineType.Enemy, typeName, paraList);
         }
     }
     base.OnAttributeValueChanged(attr);
 }
 public override void OnAttributeValueChanged(BaseNodeAttr attr = null)
 {
     // 手动修改引起的参数变更
     // 则更新DefineList
     if (attr != null && attr == GetAttrByIndex(ParamListAttrIndex))
     {
         if ((_parentNode as NodeDefineLinearLaser).IsWatchingData)
         {
             // 参数列表发生变化,修改缓存
             string name = _parentNode.GetAttrByIndex(ParamListAttrIndex).GetValueString();
             CustomDefine.ModifyDefineParaList(CustomDefineType.LinearLaser, name, attr.GetValueString());
         }
     }
     base.OnAttributeValueChanged(attr);
 }
Ejemplo n.º 7
0
 public void Execute(int eventId, object data)
 {
     if (eventId == EditorEvents.DefineNodeDestroy)
     {
         if (!_isWatchingData)
         {
             List <object> datas    = data as List <object>;
             string        typeName = GetAttrByIndex(0).GetValueString();
             if ((CustomDefineType)datas[0] == CustomDefineType.SpellCard && (string)datas[1] == typeName)
             {
                 _isWatchingData = CustomDefine.AddData(CustomDefineType.SpellCard, typeName, "");
             }
         }
     }
 }
        private void InitParas()
        {
            CustomDefineType type     = CustomDefine.GetTypeByNodeType(_nodeAttr.Node.GetNodeType());
            string           typeName = _nodeAttr.Node.GetAttrByIndex(0).GetValueString();
            CustomDefineData data     = CustomDefine.GetDataByTypeAndName(type, typeName);

            // 获取参数名称的列表
            if (data == null)
            {
                _paraNameList = new List <string>();
            }
            else
            {
                if (data.paraListStr == "")
                {
                    _paraNameList = new List <string>();
                }
                else
                {
                    _paraNameList = new List <string>(data.paraListStr.Split(','));
                }
            }
            // 获取参数值的列表
            List <string> paraValueList = GetParaValuesFromParaStr(_nodeAttr.GetValueString());

            for (int i = 0; i < _paraNameList.Count; i++)
            {
                GameObject    item = ResourceManager.GetInstance().GetPrefab("Prefabs/Views/EditViews", "EditParaItem");
                RectTransform tf   = item.GetComponent <RectTransform>();
                tf.SetParent(_itemContainerTf, false);
                EditParaItem itemSt = new EditParaItem
                {
                    go        = item,
                    valueText = tf.Find("ParaValueField").GetComponent <InputField>(),
                };
                Text paraNameText = tf.Find("ParaNameText").GetComponent <Text>();
                paraNameText.text = _paraNameList[i];
                if (i < paraValueList.Count)
                {
                    itemSt.valueText.text = paraValueList[i];
                }
                else
                {
                    itemSt.valueText.text = "";
                }
                _itemList.Add(itemSt);
            }
        }
Ejemplo n.º 9
0
        public override void BindItem(RectTransform parentTf)
        {
            base.BindItem(parentTf);
            List <Dropdown.OptionData> optionList = new List <Dropdown.OptionData>();
            CustomDefineType           type       = CustomDefine.GetTypeByNodeType(_node.GetNodeType());
            List <string> list = CustomDefine.GetCustomDefineListByType(type);

            for (int i = 0; i < list.Count; i++)
            {
                optionList.Add(new Dropdown.OptionData(list[i]));
            }
            _dropDown.options = optionList;
            _dropDown.onValueChanged.AddListener(OnDropdownValueChangedHandler);

            UIEventListener.Get(_editBtnGo).AddClick(OnEditBtnClickHandler);
        }
Ejemplo n.º 10
0
 public void Execute(int eventId, object data)
 {
     if (eventId == EditorEvents.DefineNodeDestroy)
     {
         if (!_isWatchingData)
         {
             List <object> datas    = data as List <object>;
             string        typeName = GetAttrByIndex(0).GetValueString();
             if ((CustomDefineType)datas[0] == CustomDefineType.Enemy && (string)datas[1] == typeName)
             {
                 BaseNode onCreteNode = GetChildByType(NodeType.OnEnemyCreate);
                 string   paraList    = onCreteNode.GetAttrByIndex(1).GetValueString();
                 _isWatchingData = CustomDefine.AddData(CustomDefineType.Enemy, typeName, paraList);
             }
         }
     }
 }
Ejemplo n.º 11
0
 public override void OnAttributeValueChanged(BaseNodeAttr attr = null)
 {
     if (attr != null)
     {
         if (attr.GetPreValue() == null)
         {
             string newTypeName = attr.GetValueString();
             if (newTypeName != "")
             {
                 _isWatchingData = CustomDefine.AddData(CustomDefineType.SpellCard, newTypeName, "");
             }
         }
         else
         {
             string fromName = attr.GetPreValue().ToString();
             if (fromName != "")
             {
                 if (_isWatchingData)
                 {
                     _isWatchingData = CustomDefine.ModifyDefineName(CustomDefineType.SpellCard, fromName, attr.GetValueString());
                 }
                 else
                 {
                     _isWatchingData = CustomDefine.AddData(CustomDefineType.SpellCard, attr.GetValueString(), "");
                 }
             }
             else
             {
                 string newTypeName = attr.GetValueString();
                 if (newTypeName != "")
                 {
                     _isWatchingData = CustomDefine.AddData(CustomDefineType.SpellCard, newTypeName, "");
                 }
             }
         }
     }
     else // 载入节点数据or设置节点默认值时
     {
         string typeName = GetAttrByIndex(0).GetValueString();
         if (typeName != "")
         {
             _isWatchingData = CustomDefine.AddData(CustomDefineType.SpellCard, typeName, "");
         }
     }
     base.OnAttributeValueChanged(attr);
 }
        public override string ToLuaHead()
        {
            string           typeName = _attrs[0].GetValueString();
            CustomDefineData data     = CustomDefine.GetDataByTypeAndName(CustomDefineType.Collider, typeName);
            int paraCount             = 0;

            if (data != null)
            {
                if (data.paraListStr.IndexOf(',') != -1)
                {
                    paraCount = data.paraListStr.Split(',').Length;
                }
            }
            return(string.Format("last = CreateCustomizedCollider(\"{0}\",{1}{2})\n",
                                 typeName,
                                 _attrs[1].GetValueString(),
                                 _attrs[2].GetValueString() == "" ? "" : _attrs[4].GetValueString() + ","));
        }