Example #1
0
        public string AddBehaviourMode(string _key)
        {
            _key = GetFixedBehaviourModeKey(_key);

            if (SystemTools.IsValid(_key) && !BehaviourModeExists(_key))
            {
                m_BehaviourModes.Add(new BehaviourModeObject(_key));
            }

            return(_key);
        }
        /// <summary>
        /// Handles the behaviour settings.
        /// </summary>
        public static void Print(ICECreatureControl _control)
        {
            if (!_control.Display.ShowBehaviour)
            {
                return;
            }

            ICEEditorStyle.SplitterByIndent(0);

            ICEEditorLayout.BeginHorizontal();
            _control.Display.FoldoutBehaviours = ICEEditorLayout.Foldout(_control.Display.FoldoutBehaviours, "Behaviours");
            if (ICEEditorLayout.SaveButton("Saves behaviours to file"))
            {
                CreatureEditorIO.SaveBehaviourToFile(_control.Creature.Behaviour, _control.gameObject.name);
            }
            if (ICEEditorLayout.LoadButton("Loads behavious form file"))
            {
                _control.Creature.Behaviour = CreatureEditorIO.LoadBehaviourFromFile(_control.Creature.Behaviour);
            }
            if (ICEEditorLayout.ResetButton("Removes all behaviours"))
            {
                _control.Creature.Behaviour.Reset();
            }
            ICEEditorLayout.ListFoldoutButtons(_control.Creature.Behaviour.BehaviourModes);
            ICEEditorLayout.EndHorizontal(Info.BEHAVIOUR);

            if (_control.Display.FoldoutBehaviours == false)
            {
                return;
            }

            EditorGUI.indentLevel++;
            for (int i = 0; i < _control.Creature.Behaviour.BehaviourModes.Count; i++)
            {
                if (DrawBehaviourMode(_control, _control.Creature.Behaviour.BehaviourModes[i]))
                {
                    return;
                }
            }
            EditorGUI.indentLevel--;

            m_BehaviourKey = (!SystemTools.IsValid(m_BehaviourKey) ? "NEW" : m_BehaviourKey);
            if (ICEEditorLayout.DrawListAddLine("Add behaviour mode by key", ref m_BehaviourKey))
            {
                _control.Creature.Behaviour.AddBehaviourModeNumbered(m_BehaviourKey);
                m_BehaviourKey = "";
            }
        }
Example #3
0
        public string AddBehaviourModeNumbered(string _key)
        {
            _key = GetFixedBehaviourModeKey(_key);

            string _index_key = _key;
            int    _index     = 0;

            while (BehaviourModeExists(_index_key))
            {
                _index++;

                _index_key = _key + "_" + _index;
            }

            _key = _index_key;

            if (SystemTools.IsValid(_key) && !BehaviourModeExists(_key))
            {
                m_BehaviourModes.Add(new BehaviourModeObject(_key));
            }

            return(_key);
        }