예제 #1
0
        public void TestDelayNode()
        {
            int n = 50;

            Frame[][] input = new Frame[n][];
            for (int i = 0; i < n; i++)
            {
                input[i]          = new Frame[1];
                input[i][0]       = new Frame(new Size(1, 1));
                input[i][0][0, 0] = new Rgb((byte)i, (byte)i, (byte)i);
            }
            for (int k = 0; k < 31; k++)
            {
                DelayNode node = new DelayNode();
                node.Delay = k;
                for (int i = 0; i < n; i++)
                {
                    Frame[] output = node.Process(input[i], 0);
                    if (i >= k)
                    {
                        Assert.Equal(input[i - k][0], output[0]);
                    }
                }
            }
        }
            /// <summary>
            /// overridden copy constructor
            /// </summary>
            /// <param name="node">node to copy</param>
            /// <param name="position">position to copy to</param>
            public override void Copy(BaseNode node, Vector2 position)
            {
                base.Copy(node, position);

                DelayNode delayNode = node as DelayNode;

                // copy delay time
                m_delayTime = delayNode.m_delayTime;
            }
예제 #3
0
		public void TestPEVM() {
			PropertyEditorViewModel pevm = new PropertyEditorViewModel();
			DelayNode node = new DelayNode { Delay = 0 };
			IoC.GetAllInstances = IoCLookAlike;
			pevm.Source = node;
			Assert.Equal(node, pevm.Source);
			Assert.Equal(true, pevm.Properties.Single() is IntPropertyViewModel);
			Assert.Equal(1, pevm.Properties.Count());
		}
예제 #4
0
        void Start()
        {
            this.Delay(1.0f, () =>
            {
                Log.I("延时 1s");
            });

            var delay2s = DelayNode.Allocate(2.0f, () => { Log.I("延时 2s"); });

            this.ExecuteNode(delay2s);
        }
예제 #5
0
        public void GlobalTest10()
        {
            MainViewModel     mvm = MainViewModelTest.GetInstance();
            PipelineViewModel pvm = mvm.PipelineViewModel;

            // Step 1: The user clicks "New" to create a new pipeline
            mvm.Clear();
            Assert.Empty(mvm.Model.Graph.Nodes);
            var mock = new Mock <IDragEventInfo>();

            // Step 2: Create each type of node once by drag-and-drop
            VideoInputNode    vin = (VideoInputNode)AddNode <VideoInputNode>(pvm, mock, new Point(10, 30));
            AdditiveMergeNode amn = (AdditiveMergeNode)AddNode <AdditiveMergeNode>(pvm, mock, new Point(30, 30));
            BlurNode          bn  = (BlurNode)AddNode <BlurNode>(pvm, mock, new Point(50, 30));
            BrightnessContrastSaturationNode bcsn =
                (BrightnessContrastSaturationNode)AddNode <BrightnessContrastSaturationNode>(pvm, mock, new Point(70, 30));
            ColorInputNode            cin   = (ColorInputNode)AddNode <ColorInputNode>(pvm, mock, new Point(10, 50));
            DelayNode                 dln   = (DelayNode)AddNode <DelayNode>(pvm, mock, new Point(90, 30));
            DiagramNode               dgn   = (DiagramNode)AddNode <DiagramNode>(pvm, mock, new Point(110, 30));
            DifferenceNode            dfn   = (DifferenceNode)AddNode <DifferenceNode>(pvm, mock, new Point(30, 50));
            HistogramNode             hn    = (HistogramNode)AddNode <HistogramNode>(pvm, mock, new Point(50, 50));
            ImageInputNode            imin  = (ImageInputNode)AddNode <ImageInputNode>(pvm, mock, new Point(70, 50));
            InverterNode              invn  = (InverterNode)AddNode <InverterNode>(pvm, mock, new Point(90, 50));
            NoiseInputNode            nin   = (NoiseInputNode)AddNode <NoiseInputNode>(pvm, mock, new Point(110, 50));
            OverlayNode               on    = (OverlayNode)AddNode <OverlayNode>(pvm, mock, new Point(10, 70));
            RgbSplitNode              rgbsn = (RgbSplitNode)AddNode <RgbSplitNode>(pvm, mock, new Point(30, 70));
            WeightedAveragedMergeNode wamn  =
                (WeightedAveragedMergeNode)AddNode <WeightedAveragedMergeNode>(pvm, mock, new Point(50, 70));

            // Step 3: Create the edges
            mvm.Model.Graph.AddEdge(vin.Outputs[0], bn.Inputs[0]);
            Assert.Equal(vin.Outputs[0], bn.Inputs[0].Source);
            amn.Inputs.Add(new Node.Input());
            mvm.Model.Graph.AddEdge(vin.Outputs[0], amn.Inputs[0]);
            Assert.Equal(vin.Outputs[0], amn.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(bn.Outputs[0], dln.Inputs[0]);
            Assert.Equal(bn.Outputs[0], dln.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(dln.Outputs[0], dfn.Inputs[0]);
            Assert.Equal(dln.Outputs[0], dfn.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(imin.Outputs[0], dfn.Inputs[1]);
            Assert.Equal(imin.Outputs[0], dfn.Inputs[1].Source);
            mvm.Model.Graph.AddEdge(dfn.Outputs[0], invn.Inputs[0]);
            Assert.Equal(dfn.Outputs[0], invn.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(invn.Outputs[0], on.Inputs[0]);
            Assert.Equal(invn.Outputs[0], on.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(vin.Outputs[0], on.Inputs[1]);
            Assert.Equal(vin.Outputs[0], on.Inputs[1].Source);
            mvm.Model.Graph.AddEdge(vin.Outputs[0], rgbsn.Inputs[0]);
            Assert.Equal(vin.Outputs[0], rgbsn.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(rgbsn.Outputs[2], hn.Inputs[0]);
            Assert.Equal(rgbsn.Outputs[2], hn.Inputs[0].Source);
        }
예제 #6
0
        public void GeneralPropertyViewModelTest()
        {
            PropertyViewModel pvm  = new IntPropertyViewModel();
            DelayNode         node = new DelayNode();

            node.Delay = 3;
            PropertyDescriptor pd = TypeDescriptor.GetProperties(node).Find("Delay", true);

            pvm.Initialize(node, pd);
            Assert.Equal("Delay", pvm.DisplayName);
            pvm.Value = 1;
            Assert.Equal(1, pvm.Value);
        }
예제 #7
0
        public void TestPEVM()
        {
            PropertyEditorViewModel pevm = new PropertyEditorViewModel();
            DelayNode node = new DelayNode {
                Delay = 0
            };

            IoC.GetAllInstances = IoCLookAlike;
            pevm.Source         = node;
            Assert.Equal(node, pevm.Source);
            Assert.Equal(true, pevm.Properties.Single() is IntPropertyViewModel);
            Assert.Equal(1, pevm.Properties.Count());
        }
예제 #8
0
		public void GeneralPropertyViewModelTest()
		{
			PropertyViewModel pvm = new IntPropertyViewModel();
			DelayNode node = new DelayNode();
			node.Delay = 3;
			PropertyDescriptor pd = TypeDescriptor.GetProperties(node).Find("Delay", true);
			pvm.Initialize(node, pd);
			Assert.Equal("Delay", pvm.DisplayName);
			pvm.Value = 1;
			Assert.Equal(1, pvm.Value);
		}
예제 #9
0
        protected override SelectorNode CreateBehaviour()
        {
            //create the dig nodes
            CanDigNode               canDigNode         = new CanDigNode(this);
            HealthLessThanNode       healthCheckNode    = new HealthLessThanNode(this, 0.6f);
            AnimatorNode             digAnimationNode   = new AnimatorNode(this, m_AnimatorRef, "IsDigging", ref m_DigAnimationLink);
            ToggleParticleSystemNode toggleParticleNode = new ToggleParticleSystemNode(this, DigParticleSystem);

            DelegateNode.Delegate toggleTriggerFunc = SetColliderTrigger;
            DelegateNode          toggleTriggerNode = new DelegateNode(this, toggleTriggerFunc, true);

            DelegateNode.Delegate toggleColliderFunc = ToggleCollider;
            DelegateNode          toggleColliderNode = new DelegateNode(this, toggleColliderFunc);

            ToggleNavMeshAgentNode toggleAgentNode = new ToggleNavMeshAgentNode(this);
            DelayNode delayNode = new DelayNode(this, 2.0f);
            //TODO: COMMENT THIS SECTION AND ADD STRING
            PlaySoundNode digSFX       = new PlaySoundNode(this, "NergDig");
            LerpNode      lerpDownNode = new LerpNode(this, Vector3.down, 1.0f, 2.0f, 10.0f);

            DelegateNode.Delegate rotateFunc = RotateVertical;
            DelegateNode          rotateNode = new DelegateNode(this, rotateFunc);

            TeleportToTargetOffsetNode teleportNode     = new TeleportToTargetOffsetNode(this, new Vector3(0.0f, -5.0f, 0.0f));
            LerpToTargetNode           lerpToTargetNode = new LerpToTargetNode(this, 0.5f, 1.0f, 10.0f);
            AnimatorNode        biteAnimationNode       = new AnimatorNode(this, m_AnimatorRef, "IsBiting", ref m_BiteAnimationLink);
            RunUntillTargetNull targetNullNode          = new RunUntillTargetNull(this);

            //create the dig sequence
            SequenceNode digSequence = new SequenceNode(this, "DigSequence",
                                                        healthCheckNode,
                                                        canDigNode,
                                                        toggleParticleNode,
                                                        toggleTriggerNode,
                                                        toggleColliderNode,
                                                        toggleAgentNode,
                                                        delayNode,
                                                        digSFX,
                                                        lerpDownNode,
                                                        toggleParticleNode,
                                                        rotateNode,
                                                        teleportNode,
                                                        toggleColliderNode,
                                                        toggleParticleNode,
                                                        lerpToTargetNode,
                                                        digSFX,
                                                        delayNode,
                                                        toggleParticleNode,
                                                        targetNullNode
                                                        );

            //create the targeting nodes
            TargetingSightNode     sightNode  = new TargetingSightNode(this, 1);
            TargetingLowHealthNode lowHealth  = new TargetingLowHealthNode(this, 3);
            CalculateTargetNode    calcTarget = new CalculateTargetNode(this);

            //assign the targeting sequence
            SequenceNode targetingSequ = new SequenceNode(this, "TargetingSequence", sightNode, lowHealth, calcTarget);

            //create the spit nodes
            CooldownNode spitCooldownNode = new CooldownNode(this, 1.0f);
            //AnimatorNode spitAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsSpitting", ref m_SpitAnimationLink);
            ShootProjectileNode projectileNode = new ShootProjectileNode(this, 1, ProjectilePrefab, ProjectileSpawnLoc, "MasterNergProjectile", 10);
            //SFX for the sound of the nerg spitting
            PlaySoundNode spitSound = new PlaySoundNode(this, "NergSpit");


            //create the movement nodes
            CooldownNode movementCooldownNode = new CooldownNode(this, 3.0f);
            //BackAwayNode backAwayNode = new BackAwayNode(this, false, 1.0f);
            SideStepNode             sideStepNode        = new SideStepNode(this, false, 2.0f);
            PredictiveAvoidanceNode  predictMovementNode = new PredictiveAvoidanceNode(this, false, true, 2.0f, 5.0f);
            MovementOptionRandomNode movementNodes       = new MovementOptionRandomNode(this, sideStepNode, predictMovementNode);

            //SFX for the sound of the nerg moving backward
            //TODO: COMMENT THIS SECTION AND ADD STRING
            //PlaySoundNode crawlingSFX = new PlaySoundNode(this,);

            //create the spit sequence
            SequenceNode spitSequence = new SequenceNode(this, "SpitSequence", spitCooldownNode, projectileNode, spitSound, movementCooldownNode, movementNodes /*, crawlingSFX*/);

            //assign the attack selector
            SelectorNode attackSelector = new SelectorNode(this, "AttackSelector", digSequence, spitSequence);

            //create the attack sequence
            SequenceNode attackSequence = new SequenceNode(this, "AttackTargetSequence", targetingSequ, attackSelector);

            //create utility selector
            SelectorNode utilitySelector = new SelectorNode(this, "UtilitySelector", attackSequence);

            return(utilitySelector);
        }