Example #1
0
        public void NullFieldIsIgnored()
        {
            var condition = new NotCondition(new TestCondition("TEST"));

            Assert.That(condition.Field, Is.Null);
            Assert.That(!condition.Options.Any());
        }
        ICondition ExtractCondition(ref CssToken token)
        {
            var condition = default(ICondition);

            if (token.Type == CssTokenType.RoundBracketOpen)
            {
                token = _tokenizer.Get();
                condition = CreateCondition(ref token);

                if (condition != null)
                    condition = new GroupCondition(condition);
                else if (token.Type == CssTokenType.Ident)
                    condition = DeclarationCondition(ref token);

                if (token.Type == CssTokenType.RoundBracketClose)
                    token = _tokenizer.Get();
            }
            else if (token.Data.Equals(Keywords.Not, StringComparison.OrdinalIgnoreCase))
            {
                token = _tokenizer.Get();
                condition = ExtractCondition(ref token);

                if (condition != null)
                    condition = new NotCondition(condition);
            }

            return condition;
        }
Example #3
0
        public void TermIsWrapped()
        {
            var condition = new NotCondition(new TestCondition("TEST"));
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("(not TEST)"));
        }
Example #4
0
        private System.Windows.Automation.Condition BuildNotCondition(XmlNode xnNotCondition)
        {
            NotCondition condition       = null;
            XmlNode      xnPropCondition = xnNotCondition.SelectSingleNode("PropertyCondition");
            XmlNode      node2           = xnNotCondition.SelectSingleNode("AndCondition");
            XmlNode      node3           = xnNotCondition.SelectSingleNode("OrCondition");

            if (xnPropCondition != null)
            {
                System.Windows.Automation.Condition condition2 = this.BuildPropertyCondition(xnPropCondition);
                if (condition2 != null)
                {
                    condition = new NotCondition(condition2);
                }
                return(condition);
            }
            if (node2 != null)
            {
                System.Windows.Automation.Condition condition3 = this.BuildAndCondition(xnPropCondition);
                if (condition3 != null)
                {
                    condition = new NotCondition(condition3);
                }
                return(condition);
            }
            if (node3 != null)
            {
                System.Windows.Automation.Condition condition4 = this.BuildOrCondition(xnPropCondition);
                if (condition4 != null)
                {
                    condition = new NotCondition(condition4);
                }
            }
            return(condition);
        }
Example #5
0
        public static string GenerateSqlFor(NotCondition condition)
        {
            var innerExpression  = ConditionSqlGenerator.GenerateSqlFor(condition.ConditionToNegate);
            var filterExpression = $"NOT ({innerExpression})";

            return(filterExpression);
        }
Example #6
0
        public void ConstructorTest()
        {
            NotCondition target = new NotCondition();

            // TODO: Implement code to verify target
            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Example #7
0
        public void BoostIsAddedToDefinition()
        {
            var condition = new NotCondition(new TestCondition("TEST"), 3);
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("(not boost=3 TEST)"));
        }
Example #8
0
        public void TestNotEvaluatorReturnsNullWhenConditionIsNull()
        {
            var notCondition = new NotCondition {
                Condition = null
            };

            Assert.That(notCondition.Evaluate(null, null, Logger), Is.Null);
        }
Example #9
0
        public void TestNotEvaluatorReturnsNullWhenOperandEvaluateToNull()
        {
            var notCondition = new NotCondition {
                Condition = NullCondition
            };

            Assert.That(notCondition.Evaluate(null, null, Logger), Is.Null);
        }
Example #10
0
        public void TestNotEvaluatorReturnsFalseWhenOperandEvaluateToTrue()
        {
            var notCondition = new NotCondition {
                Condition = TrueCondition
            };

            Assert.That(notCondition.Evaluate(null, null, Logger), Is.False);
        }
Example #11
0
    public void ToStringTest()
    {
        var condition = new FakeToStringCondition("Condição");

        var sut    = new NotCondition(condition);
        var actual = sut.ToString();

        actual.Should().Be("Not (Condição)");
    }
Example #12
0
        public void Test___Method_Check()
        {
            var testee = new NotCondition()
            {
                Condition = new TrueCondition()
            };

            Assert.IsFalse(testee.Check());
        }
Example #13
0
        public void NotConditionTest()// throws SIMPLTranslationException
        {
            String       xml = "<not><and><or><and /><or /></or><not_null /></and></not>";
            NotCondition not = (NotCondition)MetaMetadataTranslationScope.Get().Deserialize(xml, StringFormat.Xml);

            Console.WriteLine(not);
            Console.WriteLine(not.Check);
            Console.WriteLine(SimplTypesScope.Serialize(not, StringFormat.Xml));
        }
Example #14
0
        public void BoostIsAddedToOptions()
        {
            var condition = new NotCondition(new TestCondition("TEST"), 456);
            var option    = condition.Options.Single();

            Assert.That(option, Is.Not.Null);
            Assert.That(option.Name, Is.EqualTo("boost"));
            Assert.That(option.Value, Is.EqualTo("456"));
        }
Example #15
0
        public void BoostIsAddedToOptions()
        {
            var condition = new NotCondition(new TestCondition("TEST"), 456);
            var option = condition.Options.Single();

            Assert.That(option, Is.Not.Null);
            Assert.That(option.Name, Is.EqualTo("boost"));
            Assert.That(option.Value, Is.EqualTo("456"));
        }
Example #16
0
        public void NotConditionTest()
        {
            Condition    condition = Condition.TrueCondition;
            NotCondition target    = new NotCondition(condition);

            Assert.IsNotNull(target);
            Condition child = target.Condition;

            Assert.IsNotNull(child);
        }
Example #17
0
        public void AcceptTest()
        {
            NotCondition target = new NotCondition();

            IVisitor visitor = null; // TODO: Initialize to an appropriate value

            target.Accept(visitor);

            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
        public void Multiple_conditions_can_be_added()
        {
            var conditionOne = new EnabledCondition();
            var conditionTwo = new NotCondition();

            _collection.Add(conditionOne);
            _collection.Add(conditionTwo);

            _collection.All.ShouldBe(new Condition[] { conditionOne, conditionTwo });
        }
Example #19
0
    public void Evaluate(bool value)
    {
        var variables = A.Dummy <IVariableDictionary>();

        var condition = A.Fake <ICondition>(i => i.Strict());

        A.CallTo(() => condition.Evaluate(variables)).Returns(value);

        var sut    = new NotCondition(condition);
        var actual = sut.Evaluate(variables);

        actual.Should().Be(!value);
    }
Example #20
0
        public void OperandTest()
        {
            NotCondition target = new NotCondition();

            ConditionExpression val = null; // TODO: Assign to an appropriate value for the property

            target.Operand = val;


            Assert.AreEqual(val, target.Operand, "Composestar.StarLight.Entities.WeaveSpec.ConditionExpressions.Not.Operand was not" +
                            " set correctly.");
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Example #21
0
 public void NoConditionSetForNot_IsNotValid()
 {
     Assert.Throws <ValidationException>(() =>
                                         StateMachineBuilder.StateMachine()
                                         .StartAt("Initial")
                                         .State("Initial", StateMachineBuilder.ChoiceState()
                                                .Choice(StateMachineBuilder.Choice()
                                                        .Condition(NotCondition.GetBuilder())
                                                        .Transition(StateMachineBuilder.Next("Terminal")))
                                                .DefaultStateName("Terminal"))
                                         .State("Terminal", StateMachineBuilder.SucceedState())
                                         .Build());
 }
    void SetupStateMachine()
    {
        // conditions.
        BoolCondition IsGamePausedCond    = new BoolCondition(IsGamePaused);
        NotCondition  IsGameNotPausedCond = new NotCondition(IsGamePausedCond);

        // transisiton.
        Transition PauseGame  = new Transition("Pause Game", IsGamePausedCond, PauseGameFunc);
        Transition ResumeGame = new Transition("Resume Game", IsGameNotPausedCond, UnPauseGameFunc);

        // states.
        State UnPaused = new State("UnPaused",
                                   new List <Transition>()
        {
            PauseGame
        },
                                   new List <Action>()
        {
        },
                                   new List <Action>()
        {
            PausedUpdate
        },
                                   new List <Action>()
        {
        });

        State Paused = new State("Paused",
                                 new List <Transition>()
        {
            ResumeGame
        },
                                 new List <Action>()
        {
        },
                                 new List <Action>()
        {
            PausedUpdate
        },
                                 new List <Action>()
        {
        });

        // set target states.
        PauseGame.SetTargetState(Paused);
        ResumeGame.SetTargetState(UnPaused);

        // setup machine.
        PausedMachine = new StateMachine(null, UnPaused, Paused);
        PausedMachine.InitMachine();
    }
        internal static TransportRulePredicate CreateFromInternalCondition(Condition condition)
        {
            bool flag = false;

            if (condition.ConditionType == ConditionType.Not)
            {
                condition = ((NotCondition)condition).SubCondition;
                flag      = true;
            }
            if (condition.ConditionType != ConditionType.And)
            {
                return(null);
            }
            AndCondition andCondition = (AndCondition)condition;

            if (andCondition.SubConditions.Count != 2 || andCondition.SubConditions[0].ConditionType != ConditionType.Not || andCondition.SubConditions[1].ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            NotCondition notCondition = (NotCondition)andCondition.SubConditions[0];

            if (notCondition.SubCondition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition  = (PredicateCondition)notCondition.SubCondition;
            PredicateCondition predicateCondition2 = (PredicateCondition)andCondition.SubConditions[1];

            if (!predicateCondition.Name.Equals("is") || !predicateCondition.Property.Name.Equals("Message.Auth") || predicateCondition.Value.RawValues.Count != 1 || !predicateCondition.Value.RawValues[0].Equals("<>"))
            {
                return(null);
            }
            if (!predicateCondition2.Name.Equals("isInternal") || !predicateCondition2.Property.Name.Equals("Message.From") || predicateCondition2.Value.RawValues.Count != 0)
            {
                return(null);
            }
            FromScopePredicate fromScopePredicate = new FromScopePredicate();

            if (flag)
            {
                fromScopePredicate.Scope = FromUserScope.NotInOrganization;
            }
            else
            {
                fromScopePredicate.Scope = FromUserScope.InOrganization;
            }
            return(fromScopePredicate);
        }
Example #24
0
        void ConditionGroup(SingleNodeTree parent)
        {
            ConditionGroup group = new ConditionGroup(); parent.SetChild(group); ExpressionTreeBase addTo = group; SingleNodeTree condition = null; ConditionalExpression lastOperation = null;

            Expect(6);
            while (StartOf(2))
            {
                lastOperation = lastOperation ?? new AndCondition();
                MultiAdd(addTo, lastOperation);
                addTo = lastOperation;

                if (la.kind == 5)
                {
                    Get();
                    NotCondition not = new NotCondition(); lastOperation.SetChild(not); lastOperation = not;
                }
                if (StartOf(3))
                {
                    Condition(lastOperation);
                }
                else if (la.kind == 6)
                {
                    ConditionGroup(lastOperation);
                }
                else
                {
                    SynErr(47);
                }
                if (la.kind == 9 || la.kind == 10)
                {
                    Operation(out lastOperation);
                }
                else
                {
                    lastOperation = null;
                }
            }
            if (lastOperation != null && lastOperation.Child == null)
            {
                SemErr("Invalid Condition");
            }
            Expect(7);
        }
Example #25
0
        public void PreDefinedConditionsTest()
        {
            Condition rawView = Automation.RawViewCondition;

            Assert.IsNotNull(rawView);

            Condition controlView = Automation.ControlViewCondition;

            Assert.IsInstanceOfType(controlView, typeof(NotCondition));
            NotCondition notCond = (NotCondition)controlView;

            Assert.IsInstanceOfType(notCond.Condition, typeof(PropertyCondition));

            Condition contentView = Automation.ContentViewCondition;

            Assert.IsInstanceOfType(contentView, typeof(NotCondition));
            NotCondition notCond2 = (NotCondition)contentView;

            Assert.IsInstanceOfType(notCond2.Condition, typeof(OrCondition));
        }
Example #26
0
        public void CurrentTest()
        {
            // We expect the Current one at this point to be the Default one
            CacheRequest actual;

            actual = CacheRequest.Current;
            Assert.IsNotNull(actual);
            Assert.AreEqual(actual.AutomationElementMode, AutomationElementMode.Full);
            Assert.AreEqual(actual.TreeScope, TreeScope.Element);
            Assert.IsNotNull(actual.TreeFilter);

            Assert.IsTrue(actual.TreeFilter is NotCondition);
            NotCondition notCond = (NotCondition)actual.TreeFilter;

            Assert.IsTrue(notCond.Condition is PropertyCondition);
            PropertyCondition propCond = (PropertyCondition)notCond.Condition;

            Assert.AreEqual(propCond.Property, AutomationElement.IsControlElementProperty);
            Assert.AreEqual(propCond.Value, false);
        }
Example #27
0
        CssCondition ExtractCondition(ref CssToken token)
        {
            var condition = default(CssCondition);

            CreateNewNode();

            if (token.Type == CssTokenType.RoundBracketOpen)
            {
                token = NextToken();
                CollectTrivia(ref token);
                condition = AggregateCondition(ref token);

                if (condition != null)
                {
                    condition = new GroupCondition(condition);
                }
                else if (token.Type == CssTokenType.Ident)
                {
                    condition = DeclarationCondition(ref token);
                }

                if (token.Type == CssTokenType.RoundBracketClose)
                {
                    token = NextToken();
                    CollectTrivia(ref token);
                }
            }
            else if (token.Data.Isi(Keywords.Not))
            {
                token = NextToken();
                CollectTrivia(ref token);
                condition = ExtractCondition(ref token);

                if (condition != null)
                {
                    condition = new NotCondition(condition);
                }
            }

            return(CloseNode(condition));
        }
Example #28
0
        void ComplexCondition(SingleNodeTree parent, SelectorExpression selector)
        {
            ConditionGroup group = new ConditionGroup(); parent.SetChild(group); ExpressionTreeBase addTo = group; SingleNodeTree condition = null; ConditionalExpression lastOperation = null;

            Expect(6);
            while (StartOf(2))
            {
                lastOperation = lastOperation ?? new AndCondition();
                MultiAdd(addTo, lastOperation);
                addTo    = lastOperation;
                selector = new SelectorExpression(selector.Field, ModifierTypes.Equals, selector.Path);

                if (la.kind == 5)
                {
                    Get();
                    NotCondition not = new NotCondition(); lastOperation.SetChild(not); lastOperation = not;
                }
                if (la.kind == 6)
                {
                    ComplexCondition(lastOperation, selector);
                }
                else if (StartOf(3))
                {
                    SelectorExpression nestedSelector = new SelectorExpression(selector.Field, ModifierTypes.Equals, selector.Path); MultiAdd(lastOperation, nestedSelector);
                    Literal(nestedSelector);
                }
                else
                {
                    SynErr(49);
                }
                if (la.kind == 9 || la.kind == 10)
                {
                    Operation(out lastOperation);
                }
                else
                {
                    lastOperation = null;
                }
            }
            Expect(7);
        }
        internal override Condition ToInternalCondition()
        {
            ShortList <string> valueEntries = new ShortList <string>
            {
                "<>"
            };
            PredicateCondition subCondition = TransportRuleParser.Instance.CreatePredicate("is", TransportRuleParser.Instance.CreateProperty("Message.Auth"), valueEntries);

            valueEntries = new ShortList <string>();
            NotCondition       item         = new NotCondition(subCondition);
            PredicateCondition item2        = TransportRuleParser.Instance.CreatePredicate("isInternal", TransportRuleParser.Instance.CreateProperty("Message.From"), valueEntries);
            AndCondition       andCondition = new AndCondition();

            andCondition.SubConditions.Add(item);
            andCondition.SubConditions.Add(item2);
            if (this.Scope == FromUserScope.NotInOrganization)
            {
                return(new NotCondition(andCondition));
            }
            return(andCondition);
        }
Example #30
0
        public void TrueConditionTest()
        {
            Condition trueCond = Condition.TrueCondition;

            Assert.IsNotNull(trueCond, "TrueCondition");

            PropertyCondition truePropCond = trueCond as PropertyCondition;

            Assert.IsNull(truePropCond, "TrueCondition is not a PropertyCondition");

            AndCondition trueAndCond = trueCond as AndCondition;

            Assert.IsNull(trueAndCond, "TrueCondition is not a AndCondition");

            OrCondition trueOrCond = trueCond as OrCondition;

            Assert.IsNull(trueOrCond, "TrueCondition is not a OrCondition");

            NotCondition trueNotCond = trueCond as NotCondition;

            Assert.IsNull(trueNotCond, "TrueCondition is not a NotCondition");
        }
Example #31
0
        public void FalseConditionTest()
        {
            Condition falseCond = Condition.FalseCondition;

            Assert.IsNotNull(falseCond, "FalseCondition");

            PropertyCondition falsePropCond = falseCond as PropertyCondition;

            Assert.IsNull(falsePropCond, "FalseCondition is not a PropertyCondition");

            AndCondition falseAndCond = falseCond as AndCondition;

            Assert.IsNull(falseAndCond, "FalseCondition is not a AndCondition");

            OrCondition falseOrCond = falseCond as OrCondition;

            Assert.IsNull(falseOrCond, "FalseCondition is not a OrCondition");

            NotCondition falseNotCond = falseCond as NotCondition;

            Assert.IsNull(falseNotCond, "FalseCondition is not a NotCondition");
        }
Example #32
0
        // </Snippet175>

        // <Snippet177> 
        /// <summary>
        /// Uses NotCondition to retrieve elements that do not match specified conditions.
        /// </summary>
        /// <param name="elementMainWindow">An application window element.</param>
        public void NotConditionExample(AutomationElement elementMainWindow)
        {
            if (elementMainWindow == null)
            {
                throw new ArgumentException();
            }

            // Set up a condition that finds all buttons and radio buttons.
            OrCondition conditionButtons = new OrCondition(
                new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button),
                new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.RadioButton));

            // Use NotCondition to retrieve elements that are not buttons or radio buttons.
            Condition conditionNotButtons = new NotCondition(conditionButtons);
            AutomationElementCollection elementCollectionNotButtons = elementMainWindow.FindAll(
                TreeScope.Subtree, conditionNotButtons);
            Console.WriteLine("Elements other than buttons:");
            foreach (AutomationElement autoElement in elementCollectionNotButtons)
            {
                Console.WriteLine(autoElement.Current.Name);
            }
        }
Example #33
0
        IConditionFunction ExtractCondition(ref CssToken token)
        {
            if (token.Type == CssTokenType.RoundBracketOpen)
            {
                token = NextToken();
                CollectTrivia(ref token);
                var condition = AggregateCondition(ref token);

                if (condition != null)
                {
                    var group = new GroupCondition();
                    group.Content = condition;
                    condition     = group;
                }
                else if (token.Type == CssTokenType.Ident)
                {
                    condition = DeclarationCondition(ref token);
                }

                if (token.Type == CssTokenType.RoundBracketClose)
                {
                    token = NextToken();
                    CollectTrivia(ref token);
                }

                return(condition);
            }
            else if (token.Data.Isi(Keywords.Not))
            {
                var condition = new NotCondition();
                token = NextToken();
                CollectTrivia(ref token);
                condition.Content = ExtractCondition(ref token);
                return(condition);
            }

            return(null);
        }
Example #34
0
        ICondition ExtractCondition(ref CssToken token)
        {
            var condition = default(ICondition);

            if (token.Type == CssTokenType.RoundBracketOpen)
            {
                token     = _tokenizer.Get();
                condition = CreateCondition(ref token);

                if (condition != null)
                {
                    condition = new GroupCondition(condition);
                }
                else if (token.Type == CssTokenType.Ident)
                {
                    condition = DeclarationCondition(ref token);
                }

                if (token.Type == CssTokenType.RoundBracketClose)
                {
                    token = _tokenizer.Get();
                }
            }
            else if (token.Data.Equals(Keywords.Not, StringComparison.OrdinalIgnoreCase))
            {
                token     = _tokenizer.Get();
                condition = ExtractCondition(ref token);

                if (condition != null)
                {
                    condition = new NotCondition(condition);
                }
            }

            return(condition);
        }
Example #35
0
    public float radiusRun   = 15f; //radio para huir

    void Start()
    {
        //INICIALIZAMOS LA DATA DEL EXTERIOR
        kinGlameow      = glameow.kineticsAgent;
        steeringGlameow = glameow.steeringAgent;
        kineticsTarget  = target.kineticsAgent;
        kineticsTrainer = trainer.kineticsAgent;
        kineticsRival   = rival.kineticsAgent;

        Vector3 center = (kinGlameow.transform.position + kineticsTarget.transform.position) / 2;


        //COMENZAMOS A CONSTRUIR LA MAQUINA DE ESTADOS

        //1. ACCIONES:

        //este es seek pero en verdad como meowth le hace seek tambien pareciera que huye
        FollowTarget seekTarget = new FollowTarget(steeringGlameow, kinGlameow, kineticsTarget, maxSeekAccel);
        //el target es null porque todavia no sabemos cual trainer se  acercara
        ArriveToTarget arriveTrainer = new ArriveToTarget(steeringGlameow, kinGlameow, null, MaxAccelerationArrive, glameow.maxspeed, targetRadiusArrive, slowRadiusArrive);

        Kinetics[] targets = new Kinetics[2];
        targets[0] = kineticsTrainer;
        targets[1] = kineticsRival;

        SetArriveTarget setTrainer = new SetArriveTarget(targets, arriveTrainer);
        //seek closes
        StopMoving  stop               = new StopMoving(kinGlameow, steeringGlameow);
        ShowIcon    showHeart          = new ShowIcon(this.gameObject, "Heart");
        DisableIcon disableHeart       = new DisableIcon(this.gameObject, "Heart");
        ShowIcon    showSweat          = new ShowIcon(this.gameObject, "Sweat");
        DisableIcon disableSweat       = new DisableIcon(this.gameObject, "Sweat");
        ShowIcon    showExclamation    = new ShowIcon(this.gameObject, "Exclamation");
        DisableIcon disableExclamation = new DisableIcon(this.gameObject, "Exclamation");


        //2. ESTADOS:

        List <Action> entryActions; //aqui iremos guardanndo todas las acciondes de entrada
        List <Action> exitActions;  //aqui iremos guardanndo todas las acciones de salida
        List <Action> actions;      //aqui guardaremos todas las acciones intermedias

        //2.a estado para huir de anamorado (meowth)

        entryActions = new List <Action>()
        {
            showSweat
        };                                            //al entrar al estado ponemos un corazon
        actions = new List <Action>()
        {
            seekTarget
        };                                       //durante el estado perseguimos al enamorado
        exitActions = new List <Action>()
        {
            disableSweat
        };                                             //al salir quitamos el corazon

        State stalked = new State(actions, entryActions, exitActions);


        //2.b estado para alertarse de entrenador cercano

        entryActions = new List <Action>()
        {
            showExclamation, stop
        };                                                       //al entrar al estado debemos mostrar un signo de exclamacion
        actions     = new List <Action>();
        exitActions = new List <Action>()
        {
            disableExclamation
        };                                                  //al salir quitamos el signo


        State alert = new State(actions, entryActions, exitActions);


        //2.c estado para perseguir enamorado al entrenador

        entryActions = new List <Action> {
            setTrainer, showHeart
        };
        actions = new List <Action>()
        {
            arriveTrainer
        };
        exitActions = new List <Action> {
            disableHeart
        };


        State stalkTrainer = new State(actions, entryActions, exitActions);



        //3. CONDICIONES:

        TooCloseToPoint closeCenterTrainer = new TooCloseToPoint(center, kineticsTrainer, radiusAlert);
        TooClose        closeTrainer       = new TooClose(kinGlameow, kineticsTrainer, radiusAlert);
        TooClose        veryCloseTrainer   = new TooClose(kinGlameow, kineticsTrainer, radiusRun);
        TooCloseToPoint closeCenterRival   = new TooCloseToPoint(center, kineticsRival, radiusAlert);
        TooClose        closeRival         = new TooClose(kinGlameow, kineticsRival, radiusAlert);
        TooClose        veryCloseRival     = new TooClose(kinGlameow, kineticsRival, radiusRun);


        //Estas son las que de verdad necesitamos
        OrCondition  anyTargetCloseCenter = new OrCondition(closeCenterRival, closeCenterTrainer);
        OrCondition  anyTargetClose       = new OrCondition(closeTrainer, closeRival);
        OrCondition  anyTargetVeryClose   = new OrCondition(veryCloseRival, veryCloseTrainer);
        NotCondition noOneClose           = new NotCondition(anyTargetClose);


        List <Action> noActions = new List <Action>();
        //4. TRANSICIONES:
        Transition anyHumanClose     = new Transition(anyTargetCloseCenter, noActions, alert);
        Transition noHumanClose      = new Transition(noOneClose, noActions, stalkTrainer);
        Transition anyHumanVeryClose = new Transition(anyTargetVeryClose, noActions, stalkTrainer);



        //4.1 AGREGAMOS TRANSICIONES A ESTADOS
        List <Transition> transitions = new List <Transition>()
        {
            anyHumanClose
        };

        stalked.transitions = transitions;

        transitions = new List <Transition>()
        {
            noHumanClose, anyHumanVeryClose
        };
        alert.transitions = transitions;

        transitions = new List <Transition>();
        stalkTrainer.transitions = transitions;

        //5 MAQUINA DE ESTADOS
        State[] states = new State[] { stalked, alert, stalkTrainer };
        glameowMachine = new StateMachine(states, stalked);
    }
Example #36
0
	void ConditionGroup(SingleNodeTree parent) {
		ConditionGroup group = new ConditionGroup(); parent.SetChild(group); ExpressionTreeBase addTo = group; SingleNodeTree condition = null; ConditionalExpression lastOperation = null; 
		Expect(6);
		while (StartOf(2)) {
			lastOperation = lastOperation ?? new AndCondition();
			MultiAdd(addTo, lastOperation);
			addTo = lastOperation;
			
			if (la.kind == 5) {
				Get();
				NotCondition not = new NotCondition(); lastOperation.SetChild(not); lastOperation = not; 
			}
			if (StartOf(3)) {
				Condition(lastOperation);
			} else if (la.kind == 6) {
				ConditionGroup(lastOperation);
			} else SynErr(47);
			if (la.kind == 9 || la.kind == 10) {
				Operation(out lastOperation);
			}
			else { lastOperation = null; } 
		}
		if (lastOperation != null && lastOperation.Child == null) SemErr("Invalid Condition"); 
		Expect(7);
	}
Example #37
0
	void ComplexCondition(SingleNodeTree parent, SelectorExpression selector) {
		ConditionGroup group = new ConditionGroup(); parent.SetChild(group); ExpressionTreeBase addTo = group; SingleNodeTree condition = null; ConditionalExpression lastOperation = null; 
		Expect(6);
		while (StartOf(2)) {
			lastOperation = lastOperation ?? new AndCondition();
			MultiAdd(addTo, lastOperation);
			addTo = lastOperation;
			selector = new SelectorExpression(selector.Field, ModifierTypes.Equals, selector.Path);
			
			if (la.kind == 5) {
				Get();
				NotCondition not = new NotCondition(); lastOperation.SetChild(not); lastOperation = not; 
			}
			if (la.kind == 6) {
				ComplexCondition(lastOperation, selector);
			} else if (StartOf(3)) {
				SelectorExpression nestedSelector = new SelectorExpression(selector.Field, ModifierTypes.Equals, selector.Path); MultiAdd(lastOperation, nestedSelector); 
				Literal(nestedSelector);
			} else SynErr(49);
			if (la.kind == 9 || la.kind == 10) {
				Operation(out lastOperation);
			}
			else { lastOperation = null; } 
		}
		Expect(7);
	}
Example #38
0
 private bool Equals(NotCondition other)
 {
     return Equals(other.condition, condition);
 }