public bool addTransition(Transition trans) { // search for transition foreach (Transition t in m_transitions) { if (t == trans) return false; } m_transitions.Add(trans); return true; }
public void removeTransition(Transition trans) { int index = m_states.IndexOf(trans.From); if (index >= 0) { m_states[index].removeTransition(trans); m_transitions.Remove(trans); // remove from gameobject foreach (Parameter p in m_transitionsParameter.Params) { if (p.Name == TransitionId) { bool del1 = false; bool del2 = false; foreach (Parameter sub in p.Params) { del1 |= sub.Name == FromId && sub.Values == trans.From.Name; del2 |= sub.Name == ToId && sub.Values == trans.To.Name; } if (del1 && del2) { p.Remove(); } } } } }
public void removeTransition(Transition trans) { m_transitions.Remove(trans); }
public void addTransition(Transition trans) { int index = m_states.IndexOf(trans.From); if (index >= 0) { if (m_states[index].addTransition(trans)) m_transitions.Add(trans); } // add the transition to the gameobject Parameter transition = new Parameter(TransitionId, ParameterType.COMPOUNDPARAMETER, "", 1); transition.Params.Add(new Parameter(MsgId, ParameterType.ID, "", 1)); transition.Params.Add(new Parameter(FromId, ParameterType.ID, trans.From.Name, 1)); transition.Params.Add(new Parameter(ToId, ParameterType.ID, trans.To.Name, 1)); m_transitionsParameter.Params.Add(transition); }
private void StateMouseUp(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Released) { if (sender is Rectangle) { State s = (sender as Rectangle).DataContext as State; StateMachine sm = DataContext as StateMachine; if (sm == null) return; if (sm.SelectedState != null) { // create new Transition Transition trans = new Transition(sm.SelectedState, s); sm.addTransition(trans); selectState(sm, null); ShowLine = false; } e.Handled = true; } } }