Add() публичный статический Метод

public static Add ( AIBehaviour, n, AIBehaviour, list ) : AIBehaviour[],
n AIBehaviour,
list AIBehaviour,
Результат AIBehaviour[],
Пример #1
0
        public void DrawLanguages()
        {
            GUILayout.BeginVertical();

            GUILayout.Label("Languages:");

            for (int i = 0; i < languagesTemp.Length; i++)
            {
                GUILayout.BeginHorizontal();

                languagesTemp[i].name = EditorGUILayout.TextField(languagesTemp[i].name);

                // TODO: Implements dub and sub in the Options.
                // languagesTemp[i].subtitle = GUILayout.Toggle(languagesTemp[i].subtitle, "Sub");
                // languagesTemp[i].dubbing = GUILayout.Toggle(languagesTemp[i].dubbing, "Dub");

                if (GUILayout.Button("X", GUILayout.Width(20)))
                {
                    languagesTemp = ArrayHelper.Remove(languagesTemp, languagesTemp[i]);
                }

                GUILayout.EndHorizontal();
            }

            EditorGUILayout.Separator();

            if (GUILayout.Button("Add language"))
            {
                languagesTemp = ArrayHelper.Add(languagesTemp, new Language(""));
            }

            GUILayout.EndVertical();
        }
Пример #2
0
        public static Column[] RemoveEmptyColumns(Column[] columns)
        {
            var newArray = new Column[0];

            for (var i = 0; i < columns.Length; i++)
            {
                if (columns[i].messages.Length > 0)
                {
                    newArray = ArrayHelper.Add(newArray, columns[i]);
                }
            }

            for (var i = 0; i < newArray.Length; i++)
            {
                if (newArray[i].id == i + 1)
                {
                    newArray[i].id = i;

                    foreach (var msg in newArray[i].messages)
                    {
                        msg.columnId = i;
                    }
                }
            }

            return(newArray);
        }
Пример #3
0
 /// <summary>
 /// 조건 상수 추가.
 /// </summary>
 public void AddNumberVariableCondition()
 {
     this.numberVarKey     = ArrayHelper.Add("key", this.numberVarKey);
     this.numberVarValue   = ArrayHelper.Add(0, this.numberVarValue);
     this.numberCheckType  = ArrayHelper.Add(true, this.numberCheckType);
     this.numberValueCheck = ArrayHelper.Add(ValueCheck.EQUALS, this.numberValueCheck);
 }
Пример #4
0
        private static void CheckRepeatedInteractable(Interactable interactable, Options options, List <Interactable> interactables)
        {
            bool canAdd = true;

            foreach (string interactableName in options.interactableList)
            {
                if (interactableName == interactable.name)
                {
                    canAdd = false;
                    break;
                }
            }

            if (canAdd)
            {
                interactables.Add(interactable);

                options.interactableList = ArrayHelper.Add(options.interactableList, interactable.name);
                OptionsController.Save(options, options.jsonPrettyPrint);

                JSONHelper.Create(interactable, interactable.name, options.jsonPrettyPrint, "Diplomata/Interactables/");
            }

            else
            {
                Debug.LogError("This name already exists!");
            }
        }
Пример #5
0
 /// <summary>
 /// Add a state to the states list.
 /// </summary>
 /// <param name="questState">The state name.</param>
 public void AddState(string questState, string longDescription)
 {
     if (!finished)
     {
         questStates = ArrayHelper.Add(questStates, new QuestState());
     }
 }
Пример #6
0
        public void DrawAttributes()
        {
            GUILayout.BeginVertical(GUILayout.Width(position.width / 2));
            GUILayout.Label("Attributes:");

            for (int i = 0; i < attributesTemp.Length; i++)
            {
                GUILayout.BeginHorizontal();
                attributesTemp[i] = EditorGUILayout.TextField(attributesTemp[i]);

                if (GUILayout.Button("X", GUILayout.Width(20)))
                {
                    attributesTemp = ArrayHelper.Remove(attributesTemp, attributesTemp[i]);
                }

                GUILayout.EndHorizontal();
            }

            EditorGUILayout.Separator();

            if (GUILayout.Button("Add attribute"))
            {
                attributesTemp = ArrayHelper.Add(attributesTemp, "");
            }

            GUILayout.EndVertical();
        }
Пример #7
0
        public Message(int id, string emitter, int columnId, string labelId, Options options)
        {
            conditions                = new Condition[0];
            content                   = new LanguageDictionary[0];
            attachedContent           = new AttachedContent[0];
            attributes                = new AttributeDictionary[0];
            screenplayNotes           = new LanguageDictionary[0];
            effects                   = new Effect[0];
            audioClipPath             = new LanguageDictionary[0];
            animatorAttributesSetters = new AnimatorAttributeSetter[0];
            this.labelId              = labelId;

            foreach (string str in options.attributes)
            {
                attributes = ArrayHelper.Add(attributes, new AttributeDictionary(str));
            }

            foreach (Language lang in options.languages)
            {
                content         = ArrayHelper.Add(content, new LanguageDictionary(lang.name, "[ Message content here ]"));
                screenplayNotes = ArrayHelper.Add(screenplayNotes, new LanguageDictionary(lang.name, ""));
                audioClipPath   = ArrayHelper.Add(audioClipPath, new LanguageDictionary(lang.name, string.Empty));
            }

            this.id       = id;
            this.columnId = columnId;

            uniqueId = SetUniqueId();
        }
Пример #8
0
        /// <summary>
        /// Update the characters and interactables lists from JSON's.
        /// </summary>
        public void UpdateList()
        {
            var charactersFiles    = Resources.LoadAll("Diplomata/Characters/");
            var interactablesFiles = Resources.LoadAll("Diplomata/Interactables/");

            characters    = new List <Character>();
            interactables = new List <Interactable>();

            options.characterList    = new string[0];
            options.interactableList = new string[0];

            foreach (UnityEngine.Object obj in charactersFiles)
            {
                var json      = (TextAsset)obj;
                var character = JsonUtility.FromJson <Character>(json.text);

                characters.Add(character);
                options.characterList = ArrayHelper.Add(options.characterList, obj.name);
            }

            foreach (UnityEngine.Object obj in interactablesFiles)
            {
                var json         = (TextAsset)obj;
                var interactable = JsonUtility.FromJson <Interactable>(json.text);

                interactables.Add(interactable);
                options.interactableList = ArrayHelper.Add(options.interactableList, obj.name);
            }
        }
Пример #9
0
        private static void CheckRepeatedCharacter(Character character, Options options, List <Character> characters)
        {
            bool canAdd = true;

            foreach (string characterName in options.characterList)
            {
                if (characterName == character.name)
                {
                    canAdd = false;
                    break;
                }
            }

            if (canAdd)
            {
                characters.Add(character);
                if (characters.Count == 1)
                {
                    options.playerCharacterName = character.name;
                }

                options.characterList = ArrayHelper.Add(options.characterList, character.name);
                OptionsController.Save(options, options.jsonPrettyPrint);

                JSONHelper.Create(character, character.name, options.jsonPrettyPrint, "Diplomata/Characters/");
            }

            else
            {
                Debug.LogError("This name already exists!");
            }
        }
Пример #10
0
 public void AddTest()
 {
     CollectionAssert.AreEqual(new int[6] {
         1, 2, 3, 4, 5, 6
     }, ArrayHelper.Add(new int[5] {
         1, 2, 3, 4, 5
     }, 6));
 }
Пример #11
0
        /// <summary>
        /// Set the global attributes to the character local attributes.
        /// </summary>
        public void SetAttributes(Options options)
        {
            attributes = new AttributeDictionary[0];

            foreach (var attrName in options.attributes)
            {
                attributes = ArrayHelper.Add(attributes, new AttributeDictionary(attrName));
            }
        }
Пример #12
0
        /// <summary>
        /// Return a array of persistent objects from a data object.
        /// </summary>
        /// <param name="array">The array of data objects.</param>
        /// <returns>A array of persistent objects.</returns>
        public static T[] GetArrayData <T>(Data[] array)
        {
            var persistent = new T[0];

            foreach (var item in array)
            {
                persistent = ArrayHelper.Add(persistent, (T)Convert.ChangeType(item.GetData(), typeof(T)));
            }
            return(persistent);
        }
Пример #13
0
        /// <summary>
        /// Get the names of the languages from a array of languages.
        /// </summary>
        /// <param name="languages">A array of languages.</param>
        /// <returns>A array of strings with the languages names.</returns>
        public static string[] GetNames(Language[] languages)
        {
            var names = new string[0];

            foreach (var language in languages)
            {
                names = ArrayHelper.Add(names, language.name);
            }
            return(names);
        }
Пример #14
0
        /// <summary>
        /// Get only the names of all local variables.
        /// </summary>
        /// <returns>A array of strings with all the names.</returns>
        public string[] GetLocalVariablesNames()
        {
            var names = new string[0];

            foreach (var localVariable in LocalVariables)
            {
                names = ArrayHelper.Add(names, localVariable.Name);
            }
            return(names);
        }
Пример #15
0
        /// <summary>
        /// A talkable base constructor with name.
        /// </summary>
        /// <param name="name">The talkable name.</param>
        /// <param name="languages">All languages to set.</param>
        public Talkable(string name, Options options)
        {
            uniqueId    = Guid.NewGuid().ToString();
            this.name   = name;
            contexts    = new Context[0];
            description = new LanguageDictionary[0];

            foreach (var lang in options.languages)
            {
                description = ArrayHelper.Add(description, new LanguageDictionary(lang.name, ""));
            }
        }
Пример #16
0
        /// <summary>
        /// Instantiate a item with a id.
        /// </summary>
        /// <param name="id">The item id.</param>
        public Item(int id, Options options)
        {
            SetId();
//      uniqueId = Guid.NewGuid().ToString();
            this.id = id;

            foreach (Language language in options.languages)
            {
                name        = ArrayHelper.Add(name, new LanguageDictionary(language.name, "[ Edit to change this name ]"));
                description = ArrayHelper.Add(description, new LanguageDictionary(language.name, ""));
            }
        }
Пример #17
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 public void AddEffect(string name)
 {
     if (this.names == null)
     {
         this.names       = new string[] { name };
         this.effectClips = new EffectClip[] { new EffectClip() };
     }
     else
     {
         this.names       = ArrayHelper.Add(name, this.names);
         this.effectClips = ArrayHelper.Add(new EffectClip(), this.effectClips);
     }
 }
Пример #18
0
 public void AddSound(string _name, string _clipPath = "", string _clipName = "")
 {
     if (names == null)
     {
         names      = new string[] { _name };
         soundClips = new SoundClip[] { new SoundClip(_clipPath, _clipName) };
     }
     else
     {
         names      = ArrayHelper.Add(_name, names);
         soundClips = ArrayHelper.Add <SoundClip>(new SoundClip(), soundClips);
     }
 }
Пример #19
0
        /// <summary>
        /// Get all complete quests.
        /// </summary>
        /// <returns>A array of complete quests.</returns>
        public static Quest[] GetCompleteQuests()
        {
            var activeQuests = new Quest[0];

            foreach (var quest in Data.quests)
            {
                if (quest.IsComplete())
                {
                    activeQuests = ArrayHelper.Add(activeQuests, quest);
                }
            }
            return(activeQuests);
        }
Пример #20
0
 /// <summary>
 ///
 /// </summary>
 public void AddSound(string name, string clipPath, string clipName)
 {
     if (this.names == null)
     {
         this.names      = new string[] { name };
         this.soundClips = new SoundClip[] { new SoundClip(clipPath, clipName) };
     }
     else
     {
         this.names      = ArrayHelper.Add(name, this.names);
         this.soundClips = ArrayHelper.Add(new SoundClip(clipPath, clipName), this.soundClips);
     }
 }
Пример #21
0
 public override int AddData(string newName)
 {
     if (this.names == null)
     {
         this.names      = new string[] { newName };
         this.soundClips = new SoundClip[] { new SoundClip() };
     }
     else
     {
         this.names      = ArrayHelper.Add(newName, names);
         this.soundClips = ArrayHelper.Add(new SoundClip(), soundClips);
     }
     return(GetDataCount());
 }
Пример #22
0
        /// <summary>
        /// Update the list of talkables in the DiplomataManager.Data.
        /// </summary>
        public static void UpdateList <TModel, TMono>(string path, ref List <TModel> talkables, ref Options options) where TModel : Talkable where TMono : DiplomataTalkable
        {
            var files = Resources.LoadAll(path);

            talkables = new List <TModel>();

            if (typeof(TModel) == typeof(Character))
            {
                options.characterList = new string[0];
            }
            if (typeof(TModel) == typeof(Interactable))
            {
                options.interactableList = new string[0];
            }

            foreach (var file in files)
            {
                var json     = (TextAsset)file;
                var talkable = JsonUtility.FromJson <TModel>(json.text);

                talkables.Add(talkable);

                if (typeof(TModel) == typeof(Character))
                {
                    options.characterList = ArrayHelper.Add(options.characterList, file.name);
                }

                if (typeof(TModel) == typeof(Interactable))
                {
                    options.interactableList = ArrayHelper.Add(options.interactableList, file.name);
                }
            }

            var charactersOnScene = UnityEngine.Object.FindObjectsOfType <TMono>();

            foreach (var talkable in talkables)
            {
                foreach (var mono in charactersOnScene)
                {
                    if (mono.talkable != null)
                    {
                        if (talkable.name == mono.talkable.name)
                        {
                            talkable.onScene = true;
                        }
                    }
                }
            }
        }
Пример #23
0
        /// <summary>
        /// Context constructor with id and the talkable name.
        /// </summary>
        /// <param name="id">A int id.</param>
        /// <param name="talkableName">The talkable parent name.</param>
        public Context(int id, string talkableName, Language[] languages)
        {
            uniqueId          = Guid.NewGuid().ToString();
            this.id           = id;
            this.talkableName = talkableName;
            name           = new LanguageDictionary[0];
            columns        = new Column[0];
            labels         = new Label[] { new Label() };
            LocalVariables = new LocalVariable[0];

            foreach (Language lang in languages)
            {
                name = ArrayHelper.Add(name, new LanguageDictionary(lang.name, "Name [Change clicking on Edit]"));
            }
        }
Пример #24
0
    /// <summary>
    /// newName 이름의 새로운 데이터를 추가하는 메소드
    /// names는 배열이기 때문에 현재 add될 데이터가 들어갈 끝 인덱스 찾기가 어렵다.
    /// 그렇기 때문에 ArrayHelper의 add를 통해 names를 foreach로 순회하고
    /// list tmp로 받아서 각각 추가한뒤, 가장 마지막에 새로 추가될 데이터를 추가하고 array로 바꿔서 반화
    /// </summary>
    /// <returns>데이터가 새로 추가된 뒤의 데이터 개수를 반환</returns>
    public override int AddData(string newName)
    {
        if (this.names == null)
        {
            this.names       = new string[] { name }; //아무 이름
            this.effectClips = new EffectClip[] { new EffectClip() };
        }
        else
        {
            this.names       = ArrayHelper.Add(newName, this.names);
            this.effectClips = ArrayHelper.Add(new EffectClip(), this.effectClips);
        }

        return(GetDataCount());
    }
Пример #25
0
    public override int AddData(string newName)
    {
        if (names == null)
        {
            names       = new string[] { newName };
            effectClips = new EffectClip[] { new EffectClip() };
        }
        else
        {
            names       = ArrayHelper.Add(newName, names);
            effectClips = ArrayHelper.Add(new EffectClip(), effectClips);
        }

        return(GetDataCount());
    }
Пример #26
0
 /// <summary>
 /// Add a category to the categories array.
 /// </summary>
 /// <param name="category">The category to add.</param>
 public void AddCategory(string category)
 {
     if (category != "" && category != null)
     {
         if (categories == null)
         {
             categories = new string[0];
         }
         if (!ArrayHelper.Contains(categories, category))
         {
             categories = ArrayHelper.Add(categories, category);
         }
         RemoveNotUsedCategory();
     }
 }
Пример #27
0
        /// <summary>
        /// Get all context names of the array.
        /// </summary>
        /// <param name="contexts">A array of contexts.</param>
        /// <param name="language">The language of the names.</param>
        /// <returns>Return a string array with all names.</returns>
        public static string[] GetNames(Context[] contexts, string language)
        {
            var names = new string[0];

            foreach (var context in contexts)
            {
                foreach (var name in context.name)
                {
                    if (name.key == language)
                    {
                        names = ArrayHelper.Add(names, name.value);
                    }
                }
            }

            return(names);
        }
Пример #28
0
        public static List <Interactable> UpdateList(Options options)
        {
            var interactablesFiles = Resources.LoadAll("Diplomata/Interactables/");
            var interactables      = new List <Interactable>();

            options.interactableList = new string[0];

            foreach (Object obj in interactablesFiles)
            {
                var json         = (TextAsset)obj;
                var interactable = JsonUtility.FromJson <Interactable>(json.text);

                interactables.Add(interactable);
                options.interactableList = ArrayHelper.Add(options.interactableList, obj.name);
            }

            return(interactables);
        }
Пример #29
0
        /// <summary>
        /// Generate a id for a new item without repeat the used ids.
        /// </summary>
        /// <returns>the new int id.</returns>
        public int GenerateId()
        {
            var usedIds = new int[0];

            foreach (var item in items)
            {
                usedIds = ArrayHelper.Add(usedIds, item.id);
            }

            var id = items.Length;

            while (ArrayHelper.Contains(usedIds, id))
            {
                id++;
            }

            return(id);
        }
Пример #30
0
        public static List <Character> UpdateList(Options options)
        {
            var charactersFiles = Resources.LoadAll("Diplomata/Characters/");
            var characters      = new List <Character>();

            options.characterList = new string[0];

            foreach (Object obj in charactersFiles)
            {
                var json      = (TextAsset)obj;
                var character = JsonUtility.FromJson <Character>(json.text);

                characters.Add(character);
                options.characterList = ArrayHelper.Add(options.characterList, obj.name);
            }

            return(characters);
        }