Пример #1
0
        private void RemoveSelectedParameter()
        {
            if (_ParameterList.SelectedItem != null)
            {
                AnimationTreeParameter   data          = ((ParameterItem)_ParameterList.SelectedItem).Data;
                AnimationTreeParameter[] preParameters = _Editor.Tree.Parameters;
                AnimationTreeParameter[] newParameters = new AnimationTreeParameter[preParameters.Length - 1];

                int preIndex = 0;
                int newIndex = 0;
                while (newIndex < newParameters.Length && preIndex < preParameters.Length)
                {
                    if (preParameters[preIndex] == data)
                    {
                        preIndex++;
                        continue;
                    }
                    newParameters[newIndex] = preParameters[preIndex];
                    newIndex++;
                    preIndex++;
                }
                _Editor.Tree.Parameters = newParameters;
                _ParameterList.Items.Remove(_ParameterList.SelectedItem);
                _ParameterList.SelectedIndex = 0;
                SetButtonsEnable();
            }
            else
            {
                Debug.LogError("there is no selected Parameter to remove");
            }
        }
Пример #2
0
 public ParameterItem(ParameterEditor editor, AnimationTreeParameter data)
 {
     this._Editor = editor;
     this.Data    = data;
     this.Text    = data.Name;
     //if (data.Type == AnimationTreeParameterType.Float)
     //    this.Content.image = Skill.Editor.Resources.UITextures.Matinee.Float;
     //else
     //    this.Content.image = Skill.Editor.Resources.UITextures.Matinee.Integer;
 }
Пример #3
0
 private bool IsParameterExists(AnimationTreeParameter data)
 {
     foreach (ParameterItem item in _ParameterList.Items)
     {
         if (item.Data == data)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #4
0
        private void AddNewParameter(AnimationTreeParameterType type)
        {
            AnimationTreeParameter Parameter = new AnimationTreeParameter()
            {
                Type = type
            };

            Parameter.Name = GetUniqueParameterName(string.Format("new{0}", type));
            AnimationTreeParameter[] preParameters = _Editor.Tree.Parameters;
            AnimationTreeParameter[] newParameters = new AnimationTreeParameter[preParameters.Length + 1];
            preParameters.CopyTo(newParameters, 0);
            newParameters[newParameters.Length - 1] = Parameter;
            _Editor.Tree.Parameters = newParameters;
            Add(Parameter);
            SetButtonsEnable();
        }
Пример #5
0
        private void Add(AnimationTreeParameter data)
        {
            ParameterItem item = new ParameterItem(this, data);

            _ParameterList.Items.Add(item);
        }
Пример #6
0
        public void Load(XmlElement e)
        {
            this.Name = e.GetAttributeValueAsString("Name", "");
            this.Zoom = e.GetAttributeValueAsFloat("Zoom", Zoom);
            this.PanX = e.GetAttributeValueAsFloat("PanX", PanX);
            this.PanY = e.GetAttributeValueAsFloat("PanY", PanY);

            XmlElement parametersElement = e["Parameters"];

            if (parametersElement != null)
            {
                int stateCount = parametersElement.GetAttributeValueAsInt("Count", 0);
                this.Parameters = new AnimationTreeParameter[stateCount];
                int i = 0;
                foreach (var element in parametersElement)
                {
                    if (element.Name == "Parameter")
                    {
                        AnimationTreeParameter s = new AnimationTreeParameter();
                        s.Load(element);
                        this.Parameters[i++] = s;
                    }
                }
            }


            XmlElement profilesElement = e["Profiles"];

            if (profilesElement != null)
            {
                int profileCount = profilesElement.GetAttributeValueAsInt("Count", 0);
                this.Profiles = new AnimationTreeProfileData[profileCount];
                int i = 0;
                foreach (var element in profilesElement)
                {
                    if (element.Name == "Profile")
                    {
                        AnimationTreeProfileData p = new AnimationTreeProfileData();
                        p.Load(element);
                        this.Profiles[i++] = p;
                    }
                }
            }

            XmlElement nodes = e["Nodes"];

            //int count = nodes.GetAttributeValueAsInt("Count", 0);
            Clear();
            if (nodes != null)
            {
                foreach (var item in nodes)
                {
                    AnimNodeData node = CreateNode(item);
                    if (node != null)
                    {
                        node.Load(item);
                        this.Add(node);
                    }
                }
            }
            AddRoot();

            // create connections
            XmlElement            connections          = e["Connections"];
            List <ConnectionData> animationConnections = new List <ConnectionData>();

            if (connections != null)
            {
                foreach (var element in connections)
                {
                    ConnectionData connection = new ConnectionData(this);
                    connection.Load(element);
                    animationConnections.Add(connection);
                }
            }
            this.Connections = animationConnections.ToArray();
        }