public Condition(ConditionFunction condition)
    {
        if (condition == null)
            throw new System.ArgumentNullException("condition", "ConditionFunction in Condition cannot be null");

        this.CachedFunc = condition;
    }
Ejemplo n.º 2
0
        public Loop(IEnumerable <Expression> initialValue, ConditionFunction condition, NewValueFunction body)
        {
            if (condition == null)
            {
                throw new ArgumentNullException(nameof(condition));
            }
            State     = initialValue.Select((v, i) => new State(i, 0, v)).ToList().AsReadOnly();
            Body      = new ReadOnlyCollection <Expression>(body(State).ToArray());
            Condition = condition(State);
            if (Body.Any(e => e == null))
            {
                throw new ArgumentException("An operand was null");
            }

            if (State.Count != Body.Count)
            {
                throw new ArgumentException("Collection counts were different");
            }

            // Increment the scope number if there's nested loops
            var scope = Body.SelectMany(n => n.AllDependent)
                        .Concat(Condition.AllDependent)
                        .OfType <State>()
                        .OrderBy(s => s.Scope)
                        .FirstOrDefault();

            if (scope != null)
            {
                State     = initialValue.Select((v, i) => new State(i, scope.Id + 1, v)).ToList().AsReadOnly();
                Body      = new ReadOnlyCollection <Expression>(body(State).ToArray());
                Condition = condition(State);
            }
        }
Ejemplo n.º 3
0
 internal void AddTransfer(State <T> targetState, ConditionFunction condition, TransferFunction transfer = null)
 {
     _routes.Add(new Route
     {
         nextState = targetState,
         condition = condition,
         transfer  = transfer
     });
 }
 /// <summary>
 /// 条件に一致する再生中のモーションを終了させる。
 /// </summary>
 /// <param name="condition">この関数がtrueを返すモーションを終了する</param>
 /// <param name="fade_out_seconds">フェードアウトする時間[秒]。0なら瞬時に終了する。</param>
 public void TerminateMotions(ConditionFunction condition, double fade_out_seconds = 0.0)
 {
     foreach (var queue_entry in MotionQueue)
     {
         if (queue_entry.Finished == true)
         {
             continue;
         }
         if ((queue_entry.Terminated == true) && ((queue_entry.TerminatingDuration - queue_entry.TerminatingElapsed) <= fade_out_seconds))
         {
             // このモーションはfade_out_secondsよりも早く終了するので条件式を評価しない
             continue;
         }
         if (condition(queue_entry) == true)
         {
             queue_entry.Terminate(fade_out_seconds);
         }
     }
 }
    public Task Initialize(ActionFunction action, ConditionFunction condition, float priority, string name, bool bLooping, int counter)
    {
        if (action == null)
            throw new System.ArgumentNullException("action", "ActionFunction supplied to Task cannot be null");
        if (condition == null)
            throw new System.ArgumentNullException("condition", "ConditionFunction supplied to Task cannot be null; use an overload without the Condition parameter");

        this.Action = new Action(action);
        this.Condition = new Condition(condition);
        this.Priority = priority;

        if (!string.IsNullOrEmpty(name))
            this.BTName = name;

        this.Looping = bLooping;
        this.Counter = counter;

        return this;
    }
Ejemplo n.º 6
0
        public string getPersonList()
        {
            string strSQL = "Select * from Person";

            //Get data from Database Layer
            DataTable person = connectDatabase.Excute(strSQL);

            //Use LINQ to Dataset
            var query = from item in person.AsEnumerable()
                        where ConditionFunction.filterCondition(item) == true
                        select new ModelPerson
            {
                firstName = item.Field <string>("FirstName"),
                lastName  = item.Field <string>("LastName"),
                age       = item.Field <int>("Age")
            };

            //Convert EnumberableRowCollection to List<ModelPerson>
            List <ModelPerson> personList = query.ToList();
            //Sort Array and parse to JSON
            var responseOfAjax = WriteJSon.writeFileJSON(personList);

            return(responseOfAjax);
        }
Ejemplo n.º 7
0
    public override void DrawNode()
    {
        GUILayout.BeginHorizontal();

        GUILayoutOption op = GUILayout.MinWidth(300);

        Condition = (AI_Conditions)EditorGUILayout.EnumPopup("Condition : ", Condition, op);

        // From Linker Node
        if (Event.current.type == EventType.Repaint)
        {
            if (Linkers[(int)Node.LinkType.From])
            {
                Linkers[(int)Node.LinkType.From].SetRect(new Rect(
                                                             rect.x + rect.width / 2,
                                                             rect.y - 16,
                                                             16, 16
                                                             ));
            }
        }

        // ToKO Linker Node

        if (Event.current.type == EventType.Repaint)
        {
            if (Linkers[(int)Node.LinkType.ToKO])
            {
                Linkers[(int)Node.LinkType.ToKO].SetRect(new Rect(
                                                             rect.x + rect.width / 4,
                                                             rect.y + rect.height,
                                                             16, 16
                                                             ));
            }
        }

        // ToOK Linker Node

        if (Event.current.type == EventType.Repaint)
        {
            if (Linkers[(int)Node.LinkType.ToOK])
            {
                Linkers[(int)Node.LinkType.ToOK].SetRect(new Rect(
                                                             rect.x + rect.width / 4 + rect.width / 2,
                                                             rect.y + rect.height,
                                                             16, 16
                                                             ));
            }
        }


        GUILayout.EndHorizontal();

        ConditionFunction.DrawGUI();

        if (GUI.changed)
        {
            Node_Editor.editor.RecalculateFrom(this);

            if (oldCondition != Condition)
            {
                var type = System.Type.GetType(AI_ConditionsDico[(int)Condition]);
                ConditionFunction = (ConditionNodeFunctions)System.Activator.CreateInstance(type);
                oldCondition      = Condition;
            }
        }
    }
 public Task Initialize(ActionFunction action, ConditionFunction condition)
 {
     return Initialize(action, condition, 0.5f);
 }
 public Task Initialize(ActionFunction action, ConditionFunction condition, float priority)
 {
     return Initialize(action, condition, priority, "");
 }
Ejemplo n.º 10
0
 public Task Initialize(ActionFunction action, ConditionFunction condition, float priority, string name)
 {
     return Initialize(action, condition, priority, name, false, 0);
 }