示例#1
0
                void _MnuBreak_Click(object sender, System.EventArgs e)
                {
                    AudioConnection       connection = (AudioConnection)Owner;
                    AudioStateGraphEditor editor     = Owner.FindInParents <AudioStateGraphEditor>();

                    editor.Break(connection);
                }
示例#2
0
        public void RemoveNode(AudioStateNode node)
        {
            _Panel.Controls.Remove(node);
            List <AudioConnection> connectionList = new List <AudioConnection>();

            foreach (var c in _ConnectionHost.Controls)
            {
                if (c is AudioConnection)
                {
                    AudioConnection ac = (AudioConnection)c;
                    if (ac.Start == node || ac.End == node)
                    {
                        connectionList.Add(ac);
                    }
                }
            }

            foreach (var item in connectionList)
            {
                _ConnectionHost.Controls.Remove(item);
            }
            connectionList.Clear();

            node.NextState = null;
            foreach (var c in _Panel.Controls)
            {
                if (c is AudioStateNode)
                {
                    AudioStateNode asn = (AudioStateNode)c;
                    if (asn.NextState == node)
                    {
                        asn.NextState = null;
                    }
                }
            }
        }
示例#3
0
 public AudioConnectionProperties(AudioConnection connection)
     : base(connection)
 {
 }
示例#4
0
        public void Save()
        {
            AudioStateNode        defaultState = null;
            List <AudioStateNode> stateList    = new List <AudioStateNode>();

            foreach (var item in this._Panel.Controls)
            {
                if (item is AudioStateNode)
                {
                    ((AudioStateNode)item).Transitions.Clear();
                    stateList.Add((AudioStateNode)item);

                    if (defaultState == null)
                    {
                        if (((AudioStateNode)item).IsDefault)
                        {
                            defaultState = (AudioStateNode)item;
                        }
                    }
                    else
                    {
                        ((AudioStateNode)item).IsDefault = false;
                    }
                }
            }

            if (defaultState == null && stateList.Count > 0)
            {
                defaultState = stateList[0];
            }

            foreach (var state in stateList)
            {
                state.StateName = GetUniqueStateName(state.StateName, stateList);
            }

            foreach (var item in this._ConnectionHost.Controls)
            {
                if (item is AudioConnection)
                {
                    AudioConnection ac = (AudioConnection)item;
                    if (ac.Start != null && ac.End != null)
                    {
                        ac.Transition.Destination = ((AudioStateNode)ac.End).State.Name;
                        ((AudioStateNode)ac.Start).Transitions.Add(ac.Transition);
                    }
                }
            }

            foreach (var state in stateList)
            {
                state.Save();
            }

            _Editor.Controller.States = new AudioState[stateList.Count];
            for (int i = 0; i < _Editor.Controller.States.Length; i++)
            {
                _Editor.Controller.States[i] = stateList[i].State;
            }

            if (defaultState != null)
            {
                _Editor.Controller.DefaultState = (defaultState != null) ? defaultState.StateName : string.Empty;
            }

            _Editor.Controller.Zoom = this._Panel.ZoomFactor;
            _Editor.Controller.PanX = this._Panel.PanPosition.x;
            _Editor.Controller.PanY = this._Panel.PanPosition.y;
        }
示例#5
0
 private void Break(AudioConnection connection)
 {
     _ConnectionHost.Controls.Remove(connection);
 }
示例#6
0
        public void Rebuild()
        {
            Clear();
            if (_Editor.Controller != null)
            {
                List <AudioStateNode> stateList = new List <AudioStateNode>();
                if (_Editor.Controller.States != null)
                {
                    foreach (var state in _Editor.Controller.States)
                    {
                        stateList.Add(CreateNode(state));
                    }

                    foreach (var s in _Editor.Controller.States)
                    {
                        AudioStateNode start = FindState(s.Name);
                        if (start != null && s.Transitions != null)
                        {
                            start.Transitions.Clear();
                            foreach (var t in s.Transitions)
                            {
                                AudioStateNode end = FindState(t.Destination);
                                if (end != null)
                                {
                                    start.Transitions.Add(t);
                                    AudioConnection ac = new AudioConnection(start, end, t);
                                    _ConnectionHost.Controls.Add(ac);
                                }
                            }
                        }
                    }

                    foreach (var state in stateList)
                    {
                        state.NextState = FindState(state.State.NextState);
                    }

                    if (_Editor.Controller.DefaultState != null)
                    {
                        AudioStateNode defaultState = FindState(_Editor.Controller.DefaultState);
                        if (defaultState != null)
                        {
                            defaultState.IsDefault = true;
                        }
                        else
                        {
                            if (_Panel.Controls.Count > 0)
                            {
                                ((AudioStateNode)_Panel.Controls[0]).IsDefault = true;
                                _Editor.Controller.DefaultState = ((AudioStateNode)_Panel.Controls[0]).StateName;
                            }
                            else
                            {
                                _Editor.Controller.DefaultState = string.Empty;
                            }
                        }
                    }
                }

                _Panel.ZoomFactor  = _Editor.Controller.Zoom;
                _Panel.PanPosition = new Vector2(_Editor.Controller.PanX, _Editor.Controller.PanY);
            }
        }