コード例 #1
0
        public bool ConnectBooleanOnTransition(string transitionName, string boolName, bool valueForTransit)
        {
            ActionTransition transition = null;

            if (transitions.TryGetValue(transitionName, out transition))
            {
                transition.AddBool(boolName, valueForTransit);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        public bool ConnectIntergerOnTransition(string transitionName, string integerName, int valueForTransit)
        {
            ActionTransition transition = null;

            if (transitions.TryGetValue(transitionName, out transition))
            {
                transition.AddInteger(integerName, valueForTransit);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        public bool ExecuteTransit()
        {
            ActionTransition noParameterTransition = null;

            foreach (var transitionKVP in transitions)
            {
                ActionTransition transition = transitionKVP.Value;
                int parameterCount          = 0;
                parameterCount += transition.BooleanParameters.Count;
                parameterCount += transition.IntegerParameters.Count;

                foreach (var booleanKVP in machine.BooleanParameters)
                {
                    if (transition.EqualsTransitTrigger_Boolean(booleanKVP.Key, booleanKVP.Value))
                    {
                        transition.ExecuteTransit();
                        return(true);
                    }
                }
                foreach (var integerKVP in machine.IntegerParameters)
                {
                    if (transition.EqualsTransitTrigger_Integer(integerKVP.Key, integerKVP.Value))
                    {
                        transition.ExecuteTransit();
                        return(true);
                    }
                }
                if (parameterCount == 0)
                {
                    noParameterTransition = transition;
                }
            }
            if (noParameterTransition != null)
            {
                noParameterTransition.ExecuteTransit();
                return(true);
            }
            return(false);
        }
コード例 #4
0
 // Transition Method
 public void AddTransition(string key, ActionTransition transition)
 {
     transitions.Add(key, transition);
 }