private void button2_Click(object sender, RoutedEventArgs e)
        {
            Label itemname = new Label();
            itemname.Width = wrapPanel1.Width*(0.2f);
            itemname.Content = "Item Name";
            TextBox itemval = new TextBox();
            itemval.Width = wrapPanel1.Width * (0.2f);

            Label itemnamet = new Label();
            itemnamet.Width = wrapPanel1.Width * (0.2f);
            itemnamet.Content = "Type";
            TextBox itemvalt = new TextBox();
            itemvalt.Width = wrapPanel1.Width * (0.2f);




            ComponentItem citem = new ComponentItem();
            citem.lb = itemname;
            citem.tb = itemval;

            citem.lbtype = itemnamet;
            citem.tbtype = itemvalt;

            items.Add(citem);

            wrapPanel1.Children.Add(itemname);
            wrapPanel1.Children.Add(itemval);
            wrapPanel1.Children.Add(itemnamet);
            wrapPanel1.Children.Add(itemvalt);

        }
Exemplo n.º 2
0
    public WeaponItem(Item baseItem, string componentKey1, string componentKey2, string componentKey3, int moveIn, int damageIn, int rangeIn, bool droppableIn)
    {
        ID           = baseItem.ID;
        Title        = baseItem.Title;
        Type         = baseItem.Type;
        Value        = baseItem.Value;
        Descritption = baseItem.Descritption;
        Rarity       = baseItem.Rarity;
        Stackable    = false;
        Slug         = baseItem.Slug;
        Sprite       = Resources.Load <Sprite>(Slug);

        ComponentItem[] defaultComponents = WeaponController.GetDefaultComponents(Slug);
        baseComponent      = defaultComponents[0];
        secondaryComponent = defaultComponents[1];
        tertiaryComponent  = defaultComponents[2];

        componentKey[0] = componentKey1;
        componentKey[1] = componentKey2;
        componentKey[2] = componentKey3;
        moveModifier    = moveIn;
        damage          = damageIn;
        maxRange        = rangeIn;
        droppable       = droppableIn;

        Craftable = true;
    }
Exemplo n.º 3
0
 void ConstructItemDatabase()
 {
     for (int i = 0; i < itemData.Count; i++)
     {
         dataBase.Add(new Item((int)itemData[i]["id"], itemData[i]["title"].ToString(), itemData[i]["type"].ToString(),
                               (int)itemData[i]["value"], itemData[i]["description"].ToString(), (int)itemData[i]["rarity"],
                               (bool)itemData[i]["stackable"], itemData[i]["slug"].ToString()));
         if (dataBase[i].Type == "Weapon")
         {
             WeaponItem newWeapon = new WeaponItem(dataBase[i], itemData[i]["components"]["1"].ToString(),
                                                   itemData[i]["components"]["2"].ToString(), itemData[i]["components"]["3"].ToString(),
                                                   (int)itemData[i]["stats"]["moveSpeed"], (int)itemData[i]["stats"]["damage"], (int)itemData[i]["stats"]["range"],
                                                   (bool)itemData[i]["droppable"]);
             dataBase[i] = newWeapon;
         }
         else if (dataBase[i].Type == "Component")
         {
             ComponentItem newComponent = new ComponentItem(dataBase[i]);
             for (int j = 0; j < itemData[i]["parts"].Count; j++)
             {
                 ComponentData newComponentData = new ComponentData(dataBase[i].Slug, itemData[i]["parts"][j].ToString());
                 newComponent.componentTypes.Add(newComponentData);
             }
             dataBase[i] = newComponent;
         }
     }
 }
        private void DrawTarget(Rect targetRect, ComponentItem item)
        {
            EditorGUI.BeginChangeCheck();
            var newTarget = EditorGUI.ObjectField(targetRect, item.target, item.componentType, true);

            if (newTarget != item.target)
            {
                var prefabTarget = PrefabUtility.GetPrefabParent(newTarget);
                if (prefabTarget != null)
                {
                    newTarget = prefabTarget;
                }
                item.target = newTarget.GetType().GetProperty("gameObject").GetValue(newTarget, null) as GameObject;
            }

            if (EditorGUI.EndChangeCheck() && item.target)
            {
                var parent = PrefabUtility.GetPrefabParent(item.target);
                if (parent)
                {
                    item.target = parent as GameObject;
                }
                if (string.IsNullOrEmpty(item.name))
                {
                    item.name = item.target.name;
                }
                item.components = GenCodeUtil.SortComponent(item.target as GameObject);
            }
        }
Exemplo n.º 5
0
 public static dynamic GetTSObject(ComponentItem dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
 public void DrawItemOnRect(Rect rect, int index, ComponentItem item, bool bindingAble)
 {
     rect.height = GetItemHeight(item, bindingAble);
     DrawInfoHead(rect, item);
     DrawIndex(rect, index);
     if (item.open && !item.isScriptComponent)
     {
         DrawLists(rect, item, bindingAble);
     }
 }
Exemplo n.º 7
0
        public void DrawBackground(Rect rect, bool active, ComponentItem item, bool bindingAble)
        {
            item.open   = active;
            rect.height = GetItemHeight(item, bindingAble);
            var innerRect1 = new Rect(rect.x + padding, rect.y + padding, rect.width - 2 * padding, rect.height - 2 * padding);

            GUI.color = active ? activeColor : fieldColor;
            GUI.Box(innerRect1, "");
            GUI.color = Color.white;
        }
Exemplo n.º 8
0
 public void Clear()
 {
     if (ComponentItem == null)
     {
         ComponentItem = new List <GlobalItem>();
     }
     ComponentItem.Clear();
     SidesItem.Clear();
     PathName = "";
 }
Exemplo n.º 9
0
    void Update()
    {
        if (Time.time > 1 && debug == 0)
        {
            addItem(3);
            debug++;
        }
        else if (Time.time > 4 && debug == 1)
        {
            addItem(3, 50);
            addItem(4, 3);
            debug++;
        }
        else if (Time.time > 7 && debug == 2)
        {
            addItem(3, 500);
            addItem(5, 3);
            debug++;
        }
        else if (Time.time > 10 && debug == 3)
        {
            addItem(3, 2000);
            addItem(6, 3);

            Item specialEdition = new ComponentItem(database.FetchItemWithID(5));
            addItem(specialEdition);
            specialEdition.Value = 10;
            addItem(specialEdition);

            debug++;
        }
        else if (Time.time > 13 && debug == 4)
        {
            addItem(3, 5000);
            addItem(5);
            addItem(6);
            addItem(4);
            debug++;
        }
        else if (Time.time > 16 && debug == 5)
        {
            addItem(3, 10000);
            addItem(1);
            addItem(3);
            addItem(0);
            debug++;
        }

        if (dumbHack && Time.time > 1)
        {
            GameObject test = GameObject.FindGameObjectWithTag("InventoryPanel").transform.GetChild(0).gameObject;
            Destroy(test.GetComponent <GridLayoutGroup>());
            dumbHack = false;
        }
    }
Exemplo n.º 10
0
        private static bool TryAddComponentToParentComponentByName(List <ComponentItem> components, string key,
                                                                   ComponentItem component)
        {
            if (!key.Contains("/"))
            {
                var parent = components.FirstOrDefault(c => c.Placeholders?.ContainsKey(key) ?? false);
                parent?.Placeholders[key].Add(component);
                return(true);
            }

            return(false);
        }
        private void removeItem(ComponentItem it)
        {


            wrapPanel1.Children.Remove(it.lb);
            wrapPanel1.Children.Remove(it.tb);
            wrapPanel1.Children.Remove(it.lbtype);
            wrapPanel1.Children.Remove(it.tbtype);
            items.Remove(it); 
        
        
        }
Exemplo n.º 12
0
    string addComponentData(ComponentItem item)
    {
        string newString = "<color=#ff0066>";

        for (int i = 0; i < item.componentTypes.Count; i++)
        {
            newString += item.componentTypes[i].slug + "\n";
        }

        newString += "</color>\n";
        return(newString);
    }
Exemplo n.º 13
0
 private void UpdateHeights(ComponentItem item, bool bindingAble)
 {
     if (bindingAble)
     {
         viewHeight = EditorGUIUtility.singleLineHeight * (item.viewItems.Count >= 1 ? item.viewItems.Count + 3 : 4);
     }
     else
     {
         viewHeight = 0;
     }
     eventHeight = EditorGUIUtility.singleLineHeight * (item.eventItems.Count >= 1 ? item.eventItems.Count + 3 : 4);
 }
 public float GetItemHeight(ComponentItem item, bool bindingAble)
 {
     if (item.isScriptComponent)
     {
         return(singleLineHeight);
     }
     else
     {
         UpdateHeights(item, bindingAble);
         var height = singleLineHeight + (item.open ? ((bindingAble ? viewHeight : 0) + eventHeight) : 0f);
         return(height);
     }
 }
Exemplo n.º 15
0
        private void DrawLists(Rect rect, ComponentItem item)
        {
            UpdateHeights(item, bindingAble);
            var innerRect1 = new Rect(rect.x + padding, rect.y, rect.width - 30, rect.height - 2 * padding);

            viewList = GetViewList(item);
            var viewRect = new Rect(innerRect1.x, innerRect1.y + singleLineHeight, innerRect1.width, viewHeight);

            viewList.DoList(viewRect);

            eventList = GetEventList(item);
            var eventRect = new Rect(innerRect1.x, innerRect1.y + viewHeight + singleLineHeight, innerRect1.width, eventHeight);

            eventList.DoList(eventRect);
        }
Exemplo n.º 16
0
 private void ListAllCustomComponents()
 {
     Tekla.Structures.Catalogs.CatalogHandler          catHandler = new Tekla.Structures.Catalogs.CatalogHandler();
     Tekla.Structures.Catalogs.ComponentItemEnumerator cEnum      = catHandler.GetComponentItems();
     if (!catHandler.GetConnectionStatus())
     {
         SetInfoText("Ei yhteyttä CatalogHandler:in kanssa!");
         return;
     }
     while (cEnum.MoveNext())
     {
         ComponentItem componentItem = cEnum.Current as ComponentItem;
         if (componentItem.Name == "" || componentItem.Number > 0)
         {
             continue;
         }
         allComponents.Add(componentItem);
     }
 }
Exemplo n.º 17
0
        /// <summary>
        /// Binds the block type repeater.
        /// </summary>
        private void BindBlockTypeRepeater()
        {
            var items = new List <ComponentItem>();

            //
            // Find all mobile block types and build the component repeater.
            //
            var blockTypes = BlockTypeCache.All()
                             .Where(t => t.Category == ddlBlockTypeCategory.SelectedValue)
                             .OrderBy(t => t.Name);

            foreach (var blockType in blockTypes)
            {
                try
                {
                    var blockCompiledType = blockType.GetCompiledType();

                    if (!typeof(Rock.Blocks.IRockMobileBlockType).IsAssignableFrom(blockCompiledType))
                    {
                        continue;
                    }

                    var iconCssClassAttribute = ( IconCssClassAttribute )blockCompiledType.GetCustomAttribute(typeof(IconCssClassAttribute));

                    var item = new ComponentItem
                    {
                        IconCssClass = iconCssClassAttribute != null ? iconCssClassAttribute.IconCssClass : "fa fa-question",
                        Name         = blockType.Name,
                        Id           = blockType.Id
                    };

                    items.Add(item);
                }
                catch
                {
                    /* Intentionally ignored. */
                }
            }

            ComponentItemState        = items;
            rptrBlockTypes.DataSource = ComponentItemState;
            rptrBlockTypes.DataBind();
        }
        private ReorderableList GetViewList(ComponentItem item)
        {
            if (!viewDic.ContainsKey(item) || viewDic[item] == null)
            {
                var list = viewDic[item] = new ReorderableList(item.viewItems, typeof(BindingShow));
                list.drawHeaderCallback = (rect) =>
                {
                    EditorGUI.LabelField(rect, "Members");
                };
                list.drawElementCallback = (rect, index, a, f) =>
                {
                    var viewItem = item.viewItems[index];
                    rect = new Rect(rect.x, rect.y + 2, rect.width, rect.height - 4);
                    var targetRect = new Rect(rect.x + rect.width * 0.1f, rect.y, rect.width * 0.5f, rect.height);
                    var sourceRect = new Rect(rect.x + rect.width * 0.65f, rect.y, rect.width * 0.25f, EditorGUIUtility.singleLineHeight);
                    var enableRect = new Rect(rect.x + rect.width * 0.92f, rect.y, rect.width * 0.1f, rect.height);

                    EditorGUI.LabelField(new Rect(rect.x, rect.y, rect.width * 0.1f, rect.height), new GUIContent("[t]", "Target"));
                    if (string.IsNullOrEmpty(viewItem.bindingSource))
                    {
                        EditorGUI.LabelField(sourceRect, "Source");
                    }
                    UpdateMemberByType(item.componentType);
                    EditorGUI.BeginChangeCheck();
                    var viewNameIndex = Array.IndexOf(viewMemberViewer.currentNames, viewItem.bindingTarget);
                    viewNameIndex          = EditorGUI.Popup(targetRect, viewNameIndex, viewMemberViewer.currentViewNames);
                    viewItem.bindingSource = EditorGUI.TextArea(sourceRect, viewItem.bindingSource);
                    if (EditorGUI.EndChangeCheck())
                    {
                        viewItem.bindingTargetType = new BridgeUI.TypeInfo(viewMemberViewer.currentTypes[viewNameIndex]);
                        viewItem.bindingTarget     = viewMemberViewer.currentNames[viewNameIndex];
                        viewItem.isMethod          = viewMemberViewer.currentMethods.Contains(viewItem.bindingTarget);
                        Debug.Log(viewItem.bindingTarget + ":" + viewItem.isMethod);
                    }
                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUI.Toggle(enableRect, true);
                    EditorGUI.EndDisabledGroup();
                };
            }
            return(viewDic[item]);
        }
Exemplo n.º 19
0
        private ReorderableList GetEventList(ComponentItem item)
        {
            if (!eventDic.ContainsKey(item) || eventDic[item] == null)
            {
                var list = eventDic[item] = new ReorderableList(item.eventItems, typeof(BindingEvent));
                list.drawHeaderCallback = (rect) =>
                {
                    EditorGUI.LabelField(rect, "Events");
                };

                list.drawElementCallback = (rect, index, a, f) =>
                {
                    var eventItem = item.eventItems[index];
                    UpdateEventByType(item.componentType);
                    var targetRect = new Rect(rect.x + rect.width * 0.1f, rect.y, rect.width * 0.35f, rect.height);
                    var sourceRect = new Rect(rect.x + rect.width * 0.475f, rect.y, rect.width * 0.3f, EditorGUIUtility.singleLineHeight);
                    var enableRect = new Rect(rect.x + rect.width * 0.8f, rect.y, rect.width * 0.2f, rect.height);
                    EditorGUI.LabelField(new Rect(rect.x, rect.y, rect.width * 0.1f, rect.height), new GUIContent("[t]", "Target"));

                    if (string.IsNullOrEmpty(eventItem.bindingSource))
                    {
                        EditorGUI.LabelField(sourceRect, "Source");
                    }

                    EditorGUI.BeginChangeCheck();
                    var viewNameIndex = Array.IndexOf(eventMemberViewer.currentNames, eventItem.bindingTarget);
                    viewNameIndex           = EditorGUI.Popup(targetRect, viewNameIndex, eventMemberViewer.currentViewNames);
                    eventItem.bindingSource = EditorGUI.TextArea(sourceRect, eventItem.bindingSource);
                    if (EditorGUI.EndChangeCheck())
                    {
                        eventItem.bindingTargetType = new BridgeUI.TypeInfo(eventMemberViewer.currentTypes[viewNameIndex]);
                        eventItem.bindingTarget     = eventMemberViewer.currentNames[viewNameIndex];
                    }
                    EditorGUI.BeginDisabledGroup(!bindingAble);
                    eventItem.type = (BindingType)EditorGUI.EnumPopup(enableRect, eventItem.type);
                    EditorGUI.EndDisabledGroup();
                };
            }
            return(eventDic[item]);
        }
        private void DrawInfoHead(Rect rect, ComponentItem item)
        {
            var innerRect = new Rect(rect.x + padding + 20, rect.y + padding, rect.width - 2 * padding - 20, EditorGUIUtility.singleLineHeight);

            var nameRect   = new Rect(innerRect.x, innerRect.y, innerRect.width * 0.2f, innerRect.height);
            var targetRect = new Rect(innerRect.x + innerRect.width * 0.2f, innerRect.y, innerRect.width * 0.25f, innerRect.height);
            var typeRect   = new Rect(innerRect.x + innerRect.width * 0.5f, innerRect.y, innerRect.width * 0.5f, innerRect.height);
            var iconRect   = new Rect(innerRect.x + innerRect.width * 0.2f + 2.5f, innerRect.y + 2.5f, 12, 12);

            item.name = EditorGUI.TextField(nameRect, item.name);

            if (!item.isScriptComponent)
            {
                DrawTarget(targetRect, item);

                if (item.components != null)
                {
                    item.componentID = EditorGUI.Popup(typeRect, item.componentID, item.componentStrs);
                }

                if (previewIcons.ContainsKey(item.componentType))
                {
                    var icon = previewIcons[item.componentType];
                    EditorGUI.DrawTextureTransparent(iconRect, icon, ScaleMode.ScaleAndCrop);
                }
            }
            else
            {
                DrawScriptTarget(targetRect, item);

                EditorGUI.LabelField(typeRect, item.componentType.FullName);

                var icon = previewIcons[typeof(ScriptableObject)];
                EditorGUI.DrawTextureTransparent(iconRect, icon, ScaleMode.ScaleAndCrop);
            }
        }
        private void DrawScriptTarget(Rect targetRect, ComponentItem item)
        {
            EditorGUI.BeginChangeCheck();
            var newTarget = EditorGUI.ObjectField(targetRect, item.scriptTarget, item.componentType, true);

            if (newTarget != item.scriptTarget)
            {
                var prefabTarget = PrefabUtility.GetPrefabParent(newTarget);
                Debug.Log(prefabTarget);
                if (prefabTarget != null)
                {
                    newTarget = prefabTarget;
                }
                item.scriptTarget = newTarget as ScriptableObject;
            }

            if (EditorGUI.EndChangeCheck() && item.scriptTarget)
            {
                if (string.IsNullOrEmpty(item.name))
                {
                    item.name = item.scriptTarget.name;
                }
            }
        }
        private void DrawPreComponents()
        {
            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(new GUIContent("←", "快速解析"), EditorStyles.toolbarButton, GUILayout.Width(20)))
                {
                    var component = prefab.GetComponent <MonoBehaviour>();
                    if (component == null)
                    {
                        EditorApplication.Beep();
                    }
                    else
                    {
                        //从旧的脚本解析出
                        GenCodeUtil.AnalysisComponent(component, components);
                    }
                }
            }

            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("BaseType:", GUILayout.Width(lableWidth));
                rule.baseTypeIndex = EditorGUILayout.Popup(rule.baseTypeIndex, GenCodeUtil.supportBaseTypes);
                if (GUILayout.Button(new GUIContent("update", "更新脚本控件信息"), EditorStyles.miniButton, GUILayout.Width(60)))
                {
                    var go = prefab;
                    rule.bindingAble = BindingAble;
                    GenCodeUtil.UpdateScripts(go, components, rule);
                }
            }


            preComponentList.DoLayoutList();

            var addRect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, EditorGUIUtility.singleLineHeight);

            if (addRect.Contains(Event.current.mousePosition))
            {
                if (Event.current.type == EventType.DragUpdated)
                {
                    if (DragAndDrop.objectReferences.Length > 0)
                    {
                        foreach (var item in DragAndDrop.objectReferences)
                        {
                            if (item is GameObject || item is ScriptableObject)
                            {
                                DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                            }
                        }
                    }
                }
                else if (Event.current.type == EventType.DragPerform)
                {
                    if (DragAndDrop.objectReferences.Length > 0)
                    {
                        foreach (var item in DragAndDrop.objectReferences)
                        {
                            if (item is GameObject)
                            {
                                var obj    = item as GameObject;
                                var parent = PrefabUtility.GetPrefabParent(obj);
                                if (parent)
                                {
                                    obj = parent as GameObject;
                                }
                                var c_item = new ComponentItem(obj);
                                c_item.components = GenCodeUtil.SortComponent(obj);
                                components.Add(c_item);
                            }

                            else if (item is ScriptableObject)
                            {
                                var c_item = new ComponentItem(item as ScriptableObject);
                                components.Add(c_item);
                            }
                        }
                        DragAndDrop.AcceptDrag();
                    }
                }
            }
        }
Exemplo n.º 23
0
 private void UpdateHeights(ComponentItem item, bool bindingAble)
 {
     viewHeight  = (EditorGUIUtility.singleLineHeight + padding) * (item.viewItems.Count >= 1 ? item.viewItems.Count + 2 : 3);
     eventHeight = (EditorGUIUtility.singleLineHeight + padding) * (item.eventItems.Count >= 1 ? item.eventItems.Count + 2 : 3);
 }
Exemplo n.º 24
0
    public static ComponentItem[] GetDefaultComponents(string weaponSlug)
    {
        ComponentItem[] components = new ComponentItem[3];

        return(components);
    }
Exemplo n.º 25
0
        private static bool TryAddComponentToLayoutPlaceholder(ItemModel model, string key, ComponentItem component)
        {
            if (model.Placeholders.ContainsKey(key))
            {
                model.Placeholders[key].Add(component);
                return(true);
            }

            return(false);
        }
Exemplo n.º 26
0
        private static bool TryAddComponentToParentComponentByPath(ItemModel model, string key, ComponentItem component)
        {
            var keys = key.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            var currentPlaceholder =
                model.Placeholders.ContainsKey(keys[0])
                    ? model.Placeholders[keys[0]]
                    : null;

            var i = 1;

            while (currentPlaceholder != null && i < keys.Length)
            {
                currentPlaceholder =
                    currentPlaceholder.FirstOrDefault(c => c.Placeholders?.ContainsKey(keys[i]) ?? false)
                    ?.Placeholders[keys[i]];
                i++;
            }

            currentPlaceholder?.Add(component);
            return(currentPlaceholder != null);
        }
Exemplo n.º 27
0
        private void DrawPreComponents()
        {
            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                GUILayout.Label("命名空间", GUILayout.Width(60));
                rule.nameSpace = GUILayout.TextField(rule.nameSpace);
                if (GUILayout.Button(new GUIContent("←", "快速解析"), EditorStyles.toolbarButton, GUILayout.Width(20)))
                {
                    GenCodeUtil.ChoiseAnReferenceMonobehiver(prefab, component =>
                    {
                        if (component == null)
                        {
                            EditorApplication.Beep();
                        }
                        else
                        {
                            //从旧的脚本解析出
                            GenCodeUtil.AnalysisComponent(component, components, rule);
                        }
                    });
                }
            }

            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("BaseType:", GUILayout.Width(lableWidth));
                EditorGUI.BeginChangeCheck();
                rule.baseTypeIndex = EditorGUILayout.Popup(rule.baseTypeIndex, GenCodeUtil.supportBaseTypes);
                if (EditorGUI.EndChangeCheck())
                {
                    UpdateBindingAble();
                }
                if (GUILayout.Button("update", EditorStyles.miniButton, GUILayout.Width(60)))
                {
                    var go = prefab;
                    rule.bindingAble = bindingAble;
                    GenCodeUtil.UpdateBindingScripts(go, components, rule);
                }
            }


            preComponentList.DoLayoutList();

            var addRect = GUILayoutUtility.GetRect(BridgeUI.Drawer.BridgeEditorUtility.currentViewWidth, EditorGUIUtility.singleLineHeight);

            if (addRect.Contains(Event.current.mousePosition))
            {
                if (Event.current.type == EventType.DragUpdated)
                {
                    if (DragAndDrop.objectReferences.Length > 0)
                    {
                        foreach (var item in DragAndDrop.objectReferences)
                        {
                            if (item is GameObject || item is ScriptableObject)
                            {
                                DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                            }
                        }
                    }
                }
                else if (Event.current.type == EventType.DragPerform)
                {
                    if (DragAndDrop.objectReferences.Length > 0)
                    {
                        foreach (var item in DragAndDrop.objectReferences)
                        {
                            if (item is GameObject)
                            {
                                var obj    = item as GameObject;
                                var parent = PrefabUtility.GetCorrespondingObjectFromSource(obj);
                                if (parent)
                                {
                                    obj = parent as GameObject;
                                }
                                var c_item = new ComponentItem(obj);
                                c_item.components = GenCodeUtil.SortComponent(obj);
                                components.Add(c_item);
                            }

                            else if (item is ScriptableObject)
                            {
                                var c_item = new ComponentItem(item as ScriptableObject);
                                components.Add(c_item);
                            }
                        }
                        DragAndDrop.AcceptDrag();
                    }
                }
            }
        }
Exemplo n.º 28
0
        public TrackNode explore(MSTSItems aeItems, List <TrackSegment> listConnector, int entryNode, StationItem parent)
        {
#if false
            Stopwatch stopWatch = new Stopwatch();
            TimeSpan  ts;
            string    elapsedTime;
#endif
            TrackNode currentNode = traveller.GetCurrentNode();
            if ((currentNode.TrJunctionNode == null) && !currentNode.TrEndNode)
            {
                do
                {
                    int          sectionIdx = traveller.TrackVectorSectionIndex;
                    TrackSegment item       = (TrackSegment)aeItems.GetTrackSegment(currentNode, sectionIdx);
                    foreach (TrackSegment conSeg in listConnector)
                    {
                        if (conSeg.associateNodeIdx == entryNode)
                        {
                            continue;
                        }
                        //  Il faut tester que l'on change bien d'index de node pour quitter  mais pas pour le premier et aussi l'idx de la section
                        if (currentNode.Index == conSeg.associateNodeIdx && sectionIdx == conSeg.associateSectionIdx)
                        {
                            setComplete(conSeg);
                            break;
                        }
                    }

                    item.inStationArea = true;
                    ComponentItem.Add(item);
                    ((TrackSegment)item).InStation(parent);

                    foreach (var trItem in item.sidings)
                    {
                        SidesItem.Add(trItem);
                        if (trItem.typeSiding == (int)TypeSiding.SIDING_START)
                        {
                            PathName = trItem.Name;
                            NbrSiding++;
                            if (trItem.sizeSiding > Siding)
                            {
                                Siding = trItem.sizeSiding;
                            }
                        }
                        else if (trItem.typeSiding == (int)TypeSiding.PLATFORM_START)
                        {
                            PathName = trItem.Name;
                            NbrPlatform++;
                            if (trItem.sizeSiding > Platform)
                            {
                                Platform = trItem.sizeSiding;
                            }
                        }
                    }
                    //yard += sideItem.lengthSegment;
#if false
                    ts = stopWatch.Elapsed;

                    // Format and display the TimeSpan value.
                    elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                ts.Hours, ts.Minutes, ts.Seconds,
                                                ts.Milliseconds / 10);
                    elapse.Add(elapsedTime);
#endif
                } while (traveller.NextVectorSection() && !complete);
                if (currentNode.Index != entryNode && !complete && traveller.TrackNodeLength > PassingYard)
                {
                    PassingYard = traveller.TrackNodeLength;
                }
                traveller.NextTrackNode();
            }
            else
            {
                GlobalItem item = aeItems.GetTrackSegment(currentNode, -1);
                item.inStationArea = true;
                ComponentItem.Add(item);
            }
            if (currentNode.TrEndNode)
            {
                complete = true;
            }
            return(currentNode);
        }