예제 #1
0
    // Logic memasukan resource gerakan kedalam pool, terutama bagian looping
    public void SetToPool(ActionResources moves)
    {
        int _loopCount = 0;

        // maksimal yg dapat ditampung pool 7+1 (8 object)
        if (_count < 7)
        {
            _count++;
            if (moves.type != "loop")
            {
                allActionMoves.Add(moves);
            }
            else
            {
                allActionMoves.Add(moves);
                if (allActionMoves.Count > 0)
                {
                    _loopCount     = int.Parse(moves.action);
                    tmpActionMoves = new List <ActionResources>(allActionMoves);
                    // tmpActionMoves = allActionMoves;
                    for (int i = 1; i < _loopCount; i++)
                    {
                        // allActionMoves = allActionMoves.Concat(tmpActionMoves).ToList();
                        allActionMoves.AddRange(tmpActionMoves);
                        // Debug.Log(allActionMoves.Count + "-" + tmpActionMoves.Count);
                        _loopIndex += tmpActionMoves.Count;
                    }

                    tmpActionMoves = null;
                }
            }
            // Debug.Log("loop: "+ _loopIndex);

            // Buat object di dalam pool sesuai dengan resource aksi yang dipanggil
            _moves = Instantiate(allActionMoves[_count + _loopIndex].actionObject, transform.position, Quaternion.identity);
            _moves.transform.SetParent(GameObject.FindGameObjectWithTag("Pool").transform, false);
            _moves.transform.position = gameObject.transform.GetChild(_count).transform.position;
        }
    }
예제 #2
0
    public void OnGUI()
    {
        GUILayout.BeginHorizontal("Toolbar", new GUILayoutOption[0]);
        {
            if (GUILayout.Button("Add", EditorStyles.toolbarButton, new GUILayoutOption[0]))
            {
                if (ActionEditor.instance != null)
                {
                    ActionNetworkCreation.GetWindow(typeof(ActionNetworkCreation), true);
                }
            }

            if (GUILayout.Button("Duplicate", EditorStyles.toolbarButton, new GUILayoutOption[0]))
            {
                if (ActionEditor.instance != null && ActionEditor.instance.currentLibraryNetwork != null)
                {
                    if (highlightedItemType == ItemType.ActionNetwork)
                    {
                        int ind = 1;

                        string copy = ActionEditor.instance.currentLibraryNetwork.name.Clone().ToString();

                        while (ActionEditor.instance.currentAssetLibrary.Get(copy + ind) != null)
                        {
                            ++ind;
                        }

                        copy += ind;

                        ActionEditor.instance.currentLibraryNetwork = ActionEditor.instance.currentAssetLibrary.Add(new ActionNetwork(copy, ActionEditor.instance.currentLibraryNetwork));

                        ActionEditor.instance.SaveLibrary();
                    }
                    else if (highlightedItemType == ItemType.ActionSkill)
                    {
                        int ind = 1;

                        string copy = highlightedSkill.Name.Clone().ToString();

                        while (ActionEditor.instance.currentLibraryNetwork.Get(copy + ind) != null)
                        {
                            ++ind;
                        }

                        ActionSkill oldSkill = ActionEditor.instance.currentLibraryNetwork.Get(highlightedSkill.Name);

                        copy += ind;

                        highlightedSkill = ActionEditor.instance.currentLibraryNetwork.AddSkill(copy, highlightedSkill.Q, highlightedSkill.B, highlightedSkill.v, new EditorTwoVector(highlightedSkill.drawPos.TopLeft().x
                                                                                                                                                                                      + 10f - ActionNetworkEditor.instance.offset.X, highlightedSkill.drawPos.TopLeft().y + 10f - ActionNetworkEditor.instance.offset.Y));

                        List <ActionConnection> newConnections = new List <ActionConnection>();

                        foreach (ActionConnection actC in ActionEditor.instance.currentLibraryNetwork.connections)
                        {
                            if (actC.Contains(oldSkill))
                            {
                                if (actC.isTo(oldSkill))
                                {
                                    newConnections.Add(new ActionConnection(highlightedSkill, actC.From, actC.toValue, actC.fromValue, ActionEditor.instance.currentLibraryNetwork));
                                }
                                else
                                {
                                    newConnections.Add(new ActionConnection(actC.To, highlightedSkill, actC.toValue, actC.fromValue, ActionEditor.instance.currentLibraryNetwork));
                                }
                            }
                        }

                        foreach (ActionConnection actC in newConnections)
                        {
                            ActionEditor.instance.currentLibraryNetwork.connections.Add(actC);
                        }

                        ActionNetworkEditor.instance.selectedSkills.Clear();

                        ActionNetworkEditor.instance.selectedSkills.Add(ActionEditor.instance.currentLibraryNetwork.skills.IndexOf(highlightedSkill));

                        ActionEditor.instance.SaveLibrary();

                        ActionNetworkEditor.instance.Repaint();
                    }
                }
            }

            if (ActionEditor.instance != null && ActionEditor.instance.currentLibraryNetwork != null)
            {
                if (GUILayout.Button("Rename", EditorStyles.toolbarButton, new GUILayoutOption[0]))
                {
                    editingNames = !editingNames;
                }
            }
            else
            {
                if (GUILayout.Button("Rename", EditorStyles.toolbarButton, new GUILayoutOption[0]))
                {
                }
            }

            if (GUILayout.Button("Delete", EditorStyles.toolbarButton, new GUILayoutOption[0]))
            {
                DeleteItems();
            }

            GUILayout.FlexibleSpace();
        }
        GUILayout.EndHorizontal();

        if (ActionEditor.instance == null || ActionEditor.instance.currentAssetLibrary == null)
        {
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(10f);
            GUILayout.Label("No library loaded.\n\nTo load an Action Library, select a library in the project folder then press edit in the Inspector panel", new GUILayoutOption[0]);
            GUILayout.Space(10f);
            GUILayout.EndHorizontal();
        }
        else
        {
            this.explorerScroll = GUILayout.BeginScrollView(this.explorerScroll, new GUILayoutOption[0]);

            GUILayout.Label(new GUIContent(ActionEditor.instance.currentAsset.name), new GUILayoutOption[0]);

            ActionEditor.instance.currentLibraryNetwork = (ActionNetwork)ActionResources.SelectList(ActionEditor.instance.currentAssetLibrary.networks, ActionEditor.instance.currentLibraryNetwork, new ActionResources.OnListItemGUI(OnNetworkListItemGUI));

            GUILayout.EndScrollView();

            if (highlightedItemType == ItemType.ActionSkill)
            {
                ActionEditor.instance.currentLibraryNetwork = highlightedSkill.owner;
            }
        }

        HandleShortcutEvents();
    }
예제 #3
0
    public bool OnNetworkListItemGUI(object item, bool selected, ICollection list)
    {
        ActionNetwork myItem = (ActionNetwork)item;

        GUIStyle style  = (!selected || highlightedItemType != ItemType.ActionNetwork) ? ActionResources.listItem : ((!this.HasFocus) ? ActionResources.unfocusedSelectedListItem : ActionResources.selectedListItem);
        GUIStyle style2 = (!selected || highlightedItemType != ItemType.ActionNetwork) ? ActionResources.list : ((!this.HasFocus) ? ActionResources.unfocusedSelectedList : ActionResources.selectedList);

        GUILayout.BeginHorizontal(style, new GUILayoutOption[0]);

        GUILayout.Space(20f);

        if (GUILayout.Button((myItem.explorerExpanded)?ActionResources.expanded:ActionResources.collapsed, style2, new GUILayoutOption[]
        {
            GUILayout.Width(14f),
            GUILayout.Height(14f)
        }))
        {
            myItem.explorerExpanded = !myItem.explorerExpanded;
        }

        if (editingNames && _highlightedItemType == ItemType.ActionNetwork && selected)
        {
            editingString = GUILayout.TextField(editingString, EditorStyles.textField, new GUILayoutOption[]
            {
                GUILayout.Height(14f)
            });
        }
        else if (GUILayout.Button(myItem.name, style2, new GUILayoutOption[]
        {
            GUILayout.Height(14f)
        }))
        {
            editingNames = false;

            if (highlightedItemType == ItemType.ActionNetwork)
            {
                ActionEditor.instance.currentLibraryNetwork.name = ActionEditor.instance.currentLibraryNetwork.name.Replace(" ", string.Empty);
            }
            else
            {
                highlightedSkill.Name = highlightedSkill.Name.Replace(" ", string.Empty);
            }

            selected = true;
            this.highlightedItemType = ItemType.ActionNetwork;

            ActionNetworkEditor.instance.selectedSkills.Clear();

            //ActionNetworkEditor.instance.CentreNetwork(ActionEditor.instance.currentLibraryNetwork);
        }
        GUILayout.EndHorizontal();

        if (myItem.explorerExpanded)
        {
            if (myItem.skills.Count > 0)
            {
                ActionSkill[] temp  = myItem.skills.ToArray();
                List <object> list2 = new List <object>(temp);
                list2.Sort((x, y) => string.Compare(x.ToString(), y.ToString()));

                highlightedSkill = (ActionSkill)ActionResources.SelectList(list2, highlightedSkill, new ActionResources.OnListItemGUI(OnSubCollectionListItemGUI));
            }
            else
            {
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(40f);
                    GUILayout.Label(new GUIContent("Empty Network"), new GUILayoutOption[0]);
                } GUILayout.EndHorizontal();
            }
        }

        return(selected);
    }
    public override void OnInspectorGUI()
    {
        if (ActionEditor.instance == null || ActionEditor.instance.currentAssetLibrary == null || ActionEditor.instance.currentLibraryNetwork == null)
        {
            GUILayout.Label("No Action Network currently loaded, please selected an Action Library from the project view" +
                            " and press 'Edit Library' in the inspector.", ActionResources.inspectorLabel, new GUILayoutOption[0]);
            return;
        }
        else
        {
            GUILayout.Space(15f);

            GUILayout.BeginHorizontal("toolbar", new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true)
            });
            {
                GUILayout.Label("Action Skill Editor", ActionResources.boldLabel, new GUILayoutOption[0]);
            } GUILayout.EndHorizontal();

            GUILayout.BeginVertical();
            {
                if (ActionNetworkEditor.instance.selectedConnection.HasValue)
                {
                    ActionConnection actC = ActionEditor.instance.currentLibraryNetwork.connections[ActionNetworkEditor.instance.selectedConnection.Value];

                    GUILayout.Space(2.5f);
                    GUILayout.Label(actC.From.Name + "-" + actC.To.Name + " Connection", ActionResources.boldLabel, new GUILayoutOption[0]);
                    GUILayout.Space(2.5f);

                    GUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.LabelField(actC.From.Name + " to " + actC.To.Name + ":");

                        double.TryParse(EditorGUILayout.TextField(actC.fromValue.ToString()), out actC.fromValue);

//						if(actC.fromValue == 0 && actC.toValue == 0)
//						{
//							ActionConnection connectionToDelete = ActionEditor.instance.currentLibraryNetwork.connections
//								[ActionNetworkEditor.instance.selectedConnection.Value];
//
//							ActionNetworkEditor.instance.selectedConnection = null;
//
//							ActionEditor.instance.currentLibraryNetwork.connections.Remove(connectionToDelete);
//
//							ActionEditor.instance.SaveLibrary();
//						}
                    } GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.LabelField(actC.To.Name + " to " + actC.From.Name + ":");

                        double.TryParse(EditorGUILayout.TextField(actC.toValue.ToString()), out actC.toValue);

//						if(actC.fromValue == 0 && actC.toValue == 0)
//						{
//							ActionConnection connectionToDelete = ActionEditor.instance.currentLibraryNetwork.connections
//								[ActionNetworkEditor.instance.selectedConnection.Value];
//
//							ActionNetworkEditor.instance.selectedConnection = null;
//
//							ActionEditor.instance.currentLibraryNetwork.connections.Remove(connectionToDelete);
//
//							ActionEditor.instance.SaveLibrary();
//						}
                    } GUILayout.EndHorizontal();

                    GUILayout.Space(2.5f);

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();

                        if (GUILayout.Button("Delete Connection"))
                        {
                            ActionConnection connectionToDelete = ActionEditor.instance.currentLibraryNetwork.connections
                                                                  [ActionNetworkEditor.instance.selectedConnection.Value];

                            ActionNetworkEditor.instance.selectedConnection = null;

                            ActionEditor.instance.currentLibraryNetwork.connections.Remove(connectionToDelete);

                            ActionEditor.instance.SaveLibrary();
                        }

                        GUILayout.Space(10f);
                    } GUILayout.EndHorizontal();

                    ActionResources.ActionSeparator();
                }

                foreach (int i in ActionNetworkEditor.instance.selectedSkills)
                {
                    ActionSkill actS = ActionEditor.instance.currentLibraryNetwork.skills[i];

                    GUILayout.Space(2.5f);
                    GUILayout.Label(actS.Name, ActionResources.boldLabel, new GUILayoutOption[0]);
                    GUILayout.Space(2.5f);

                    GUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.PrefixLabel("Name: ");
                        actS.Name = EditorGUILayout.TextField(actS.Name).Replace(" ", string.Empty);
                    } GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.PrefixLabel("Q: ");

                        double.TryParse(EditorGUILayout.TextField(actS.Q.ToString()), out actS.Q);
                    } GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.PrefixLabel("B: ");

                        double.TryParse(EditorGUILayout.TextField(actS.B.ToString()), out actS.B);
                    } GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.PrefixLabel("v: ");

                        double.TryParse(EditorGUILayout.TextField(actS.v.ToString()), out actS.v);
                    } GUILayout.EndHorizontal();

                    GUILayout.Space(2.5f);
                    GUILayout.Label("Connections", ActionResources.boldLabel, new GUILayoutOption[0]);
                    GUILayout.Space(2.5f);

                    foreach (ActionConnection actC in ActionEditor.instance.currentLibraryNetwork.connections)
                    {
                        if (actC.Contains(actS))
                        {
                            ActionSkill otherEnd = actC.OtherEnd(actS);

                            bool isToEnd = actC.isTo(actS);

                            GUILayout.BeginHorizontal();
                            {
                                EditorGUILayout.LabelField(actS.Name + " to " + otherEnd.Name + ":");

                                if (isToEnd)
                                {
                                    double.TryParse(EditorGUILayout.TextField(actC.toValue.ToString()), out actC.toValue);
                                }
                                else
                                {
                                    double.TryParse(EditorGUILayout.TextField(actC.fromValue.ToString()), out actC.fromValue);
                                }
                            } GUILayout.EndHorizontal();

                            GUILayout.BeginHorizontal();
                            {
                                EditorGUILayout.LabelField(otherEnd.Name + " to " + actS.Name + ":");

                                if (isToEnd)
                                {
                                    double.TryParse(EditorGUILayout.TextField(actC.fromValue.ToString()), out actC.fromValue);
                                }
                                else
                                {
                                    double.TryParse(EditorGUILayout.TextField(actC.toValue.ToString()), out actC.toValue);
                                }
                            } GUILayout.EndHorizontal();

                            GUILayout.Space(2.5f);
                        }
                    }

                    GUILayout.Space(2.5f);

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();

                        if (GUILayout.Button("Preview skill", new GUILayoutOption[]
                        {
                            GUILayout.Width(125f)
                        }))
                        {
                            ActionMenu.ShowSkillPreview(actS);
                        }

                        GUILayout.Space(10f);
                    } GUILayout.EndHorizontal();

                    ActionResources.ActionSeparator();
                }
            } GUILayout.EndVertical();
        }

        HandleEvents();
    }