Beispiel #1
0
        public void TickSelectorParentSequenceChildrenSelectorSucceedes()
        {
            Selector     selector  = new Selector();
            MockSequence sequence1 = new MockSequence(2);
            MockSequence sequence2 = new MockSequence(2);

            selector.Add(sequence1);
            selector.Add(sequence2);

            selector.Tick();
            Assert.AreEqual(Status.BhRunning, selector.Status);
            Assert.AreEqual(0, sequence1[0].TerminateCalled);
            Assert.AreEqual(1, sequence1[0].InitializeCalled);

            sequence1[0].ReturnStatus = Status.BhSuccess;
            selector.Tick();
            Assert.AreEqual(Status.BhRunning, selector.Status);
            Assert.AreEqual(1, sequence1[0].TerminateCalled);
            Assert.AreEqual(1, sequence1[0].InitializeCalled);

            sequence1[1].ReturnStatus = Status.BhSuccess;
            selector.Tick();
            Assert.AreEqual(Status.BhSuccess, selector.Status);
            Assert.AreEqual(1, sequence1[1].TerminateCalled);
        }
        public RunStatusCollectionViewModel([Inject] DataStorage dataStore, [Inject] IEventAggregator Event)
        {
            for (int i = 0; i < 12; i++)
            {
                _items.Add(new StatusViewModel(dataStore, i + 1, Event)
                {
                    Parent = this.Parent
                });
            }

            _radioCnt = _items.Count / _unit + (_items.Count % _unit > 0 ? 1 : 0);
            for (int i = 0; i < _radioCnt; i++)
            {
                Selector.Add(new OeeCollectionViewModel.Ts());
            }
            _index = 0;
            var l = _items.Take(_unit);

            Items.AddRange(l);

            Task.Run(() =>
            {
                while (true)
                {
                    lock (this)
                    {
                        SaveRunStatus();
                        Thread.Sleep(1000);
                    }
                }
            });
        }
    public ToKillPlayer(TreeBase _treeBase)
    {
        treeBase = _treeBase;

        Add <Behavior>().Update = IsFindPlayer;

        Selector makeStrategy = Add <Selector>();
        {
            PrioritySequence fight = makeStrategy.Add <PrioritySequence>();
            {
                fight.Add <Condition>().CanPass = IsHealthLow;
                fight.Add <Behavior>().Update   = KillingPlayer;
            }

            makeStrategy.Add <Behavior>().Update = Hide;
        }
    }
Beispiel #4
0
        public void Is_Executed_From_Selector()
        {
            FakeLeaf cud      = new FakeLeaf(NodeStatus.Success);
            Selector selector = new Selector();

            selector.Add(cud);

            TestHelper.AssertResult(selector, NodeStatus.Success);
        }
Beispiel #5
0
 private void SetSelected(Selector <VertexData> selector, List <VertexData[]> polys)
 {
     selector.Clear();
     foreach (var poly in polys)
     {
         foreach (var v in poly)
         {
             selector.Add(v);
         }
     }
 }
Beispiel #6
0
        public void TickOnSecondTickSelectorStartsWhereItLeftOff()
        {
            Selector     selector  = new Selector();
            MockBehavior behavior  = selector.Add <MockBehavior>();
            MockBehavior behavior1 = selector.Add <MockBehavior>();
            MockBehavior behavior2 = selector.Add <MockBehavior>();

            behavior.ReturnStatus  = Status.BhFailure;
            behavior1.ReturnStatus = Status.BhRunning;
            behavior2.ReturnStatus = Status.BhRunning;

            selector.Tick();
            Assert.AreEqual(Status.BhRunning, selector.Status);

            behavior.ReturnStatus  = Status.BhRunning;
            behavior1.ReturnStatus = Status.BhFailure;
            behavior2.ReturnStatus = Status.BhFailure;

            selector.Tick();
            Assert.AreEqual(Status.BhFailure, selector.Status);
        }
Beispiel #7
0
        public void SelectorAddSelectorItem()
        {
            tlog.Debug(tag, $"SelectorAddSelectorItem START");

            Selector <Color> colors = new Selector <Color>();

            SelectorItem <Color> item = new SelectorItem <Color>();

            item.Value = Color.White;
            item.State = ControlState.All;

            colors.Add(item);
            // if item be added, remove if first
            colors.Add(item);

            colors.GetValue(ControlState.All, out Color color);
            tlog.Debug(tag, "color : " + color);

            tlog.Debug(tag, "Count :" + colors.Count);
            tlog.Debug(tag, "IsReadOnly :" + colors.IsReadOnly);

            var result = colors.Contains(item);

            Assert.AreEqual(true, result, "Should be equal!");

            try
            {
                colors.GetEnumerator();
            }
            catch (Exception e)
            {
                tlog.Debug(tag, e.Message.ToString());
                Assert.Fail("Caught Exception : Failed!");
            }

            result = colors.Remove(item);
            Assert.AreEqual(true, result, "Should be equal!");

            tlog.Debug(tag, $"SelectorAddSelectorItem END (OK)");
        }
Beispiel #8
0
    public override void Start()
    {
        base.Start();

        behaviorFunc[(int)BossBehaviorKind.Run]         = Run;
        behaviorFunc[(int)BossBehaviorKind.MeleeAttack] = MeleeAttack;
        behaviorFunc[(int)BossBehaviorKind.Laser]       = ShootLaser;
        behaviorFunc[(int)BossBehaviorKind.Ball]        = FireBalls;
        behaviorFunc[(int)BossBehaviorKind.Spawn]       = SpawnMobs;
        behaviorFunc[(int)BossBehaviorKind.Curse]       = CursePlayer;

        sqrAttRad = attRad * attRad;

        wand = GetComponentInChildren <MeleeWeapon>();
        wand.SetDamage(damage);
        trail = GetComponentInChildren <WeaponTrail>();
        trail.SetColor(Color.blue);

        colliderRad = GetComponent <CapsuleCollider>().radius;

        mobSpawnPts = FindObjectsOfType <MobSpawnPt>();
        movePts     = FindObjectsOfType <BossMovePt>();

        selector = new Selector();
        selector.Add(BossBehaviorKind.Run, 9);
        selector.Add(BossBehaviorKind.MeleeAttack, 10);
        selector.Add(BossBehaviorKind.Laser, 5);
        selector.Add(BossBehaviorKind.Ball, 9);
        selector.Add(BossBehaviorKind.Spawn, 4);
        selector.Add(BossBehaviorKind.Curse, 6);

        InitPostProcessing();

        rIndicator.Init(laserLength, Color.blue, 15);
    }
    private void FighterAi()
    {
        /* fly out, fly on circled path around mothership
         * if target exists, fly to it
         * if in front of target, shoot
         *
         * */
        Selector root = MkInstance <Selector>();
        Sequence attackTargetBehaviour = MkInstance <Sequence>();

        attackTargetBehaviour.Add(MkInstance <MoveToEnemy>());
        attackTargetBehaviour.Add(MkInstance <InTargetRange>());
        attackTargetBehaviour.Add(MkInstance <SimpleFiring>());

        Sequence followMothershipBehaviour             = MkInstance <Sequence>();
        SpawnerTargetCircleMotion pathAroundMothership = MkInstance <SpawnerTargetCircleMotion>();

        followMothershipBehaviour.Add(pathAroundMothership);

        root.Add(attackTargetBehaviour);
        root.Add(followMothershipBehaviour);
        root.name = "FighterMod";
    }
Beispiel #10
0
        public void TickSelectorParentSequenceChildrenSelectorFailsOnSecondSequence()
        {
            Selector     selector  = new Selector();
            MockSequence sequence1 = new MockSequence(2);
            MockSequence sequence2 = new MockSequence(2);

            selector.Add(sequence1);
            selector.Add(sequence2);

            selector.Tick();
            Assert.AreEqual(Status.BhRunning, selector.Status);
            Assert.AreEqual(0, sequence1[0].TerminateCalled);
            Assert.AreEqual(1, sequence1[0].InitializeCalled);

            sequence1[0].ReturnStatus = Status.BhFailure; // child 1 of seq 1 fails
            selector.Tick();
            Assert.AreEqual(Status.BhRunning, selector.Status);
            Assert.AreEqual(1, sequence1[0].TerminateCalled);
            Assert.AreEqual(0, sequence1[1].InitializeCalled); // second child of seq 1 is not called

            // selector fails in sequence 1, should proceed to sequence 2
            Assert.AreEqual(1, sequence2[0].InitializeCalled);

            // set the first child of sequence2 as success
            sequence2[0].ReturnStatus = Status.BhSuccess;
            selector.Tick();
            Assert.AreEqual(Status.BhRunning, selector.Status);
            Assert.AreEqual(1, sequence2[0].TerminateCalled);
            Assert.AreEqual(1, sequence2[1].InitializeCalled);

            // set our second child of sequence 2 to to fail
            sequence2[1].ReturnStatus = Status.BhFailure;
            selector.Tick();
            Assert.AreEqual(Status.BhFailure, selector.Status);
            Assert.AreEqual(1, sequence2[1].TerminateCalled);
        }
Beispiel #11
0
        public void SelectorAddNullSelectorItem()
        {
            tlog.Debug(tag, $"SelectorAddNullSelectorItem START");

            Selector <Color> colors = new Selector <Color>();

            SelectorItem <Color> item = null;

            try
            {
                colors.Add(item);
            }
            catch (ArgumentNullException)
            {
                tlog.Debug(tag, $"SelectorAddNullSelectorItem END (OK)");
                Assert.Pass("Caught ArgumentNullException :  Passed!");
            }
        }
Beispiel #12
0
        public void SelectorGetHashCode()
        {
            tlog.Debug(tag, $"SelectorGetHashCode START");

            Selector <Color> colors = new Selector <Color>();

            SelectorItem <Color> item = new SelectorItem <Color>();

            item.Value = Color.White;
            item.State = ControlState.All;

            colors.Add(item);
            var result = colors.GetHashCode();

            tlog.Debug(tag, "HashCode : " + result);

            tlog.Debug(tag, $"SelectorGetHashCode END (OK)");
        }
Beispiel #13
0
        public void PaginationLastIndicatorImageUrl()
        {
            tlog.Debug(tag, $"PaginationLastIndicatorImageUrl START");

            PaginationStyle style = new PaginationStyle()
            {
                Size = new Size(80, 20),
            };

            var testingTarget = new Pagination(style);

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <Pagination>(testingTarget, "Should return Pagination instance.");

            Selector <String> url = new Selector <string>();

            url.Add(ControlState.All, image_path);

            testingTarget.LastIndicatorImageUrl = url;
            tlog.Debug(tag, "LastIndicatorImageUrl : " + testingTarget.LastIndicatorImageUrl);

            testingTarget.Dispose();
            tlog.Debug(tag, $"PaginationLastIndicatorImageUrl END (OK)");
        }
Beispiel #14
0
        public void SelectorEquals()
        {
            tlog.Debug(tag, $"SelectorEquals START");

            Selector <Color> colors = new Selector <Color>();

            SelectorItem <Color> item = new SelectorItem <Color>();

            item.Value = Color.White;
            item.State = ControlState.All;

            colors.Add(item);
            Selector <Color>  dummy1 = new Selector <Color>(Color.Cyan);
            Selector <string> dummy2 = new Selector <string>("mytest");

            var result = colors.Equals(dummy1);

            tlog.Debug(tag, "Equals : " + result);

            result = colors.Equals(dummy2);
            tlog.Debug(tag, "Equals : " + result);

            tlog.Debug(tag, $"SelectorEquals END (OK)");
        }
Beispiel #15
0
 //or just 'Concat' ?
 public SelectorNode <T, TOut> AddToConcatRest <TNextOut>(Expression <Func <TOut, TNextOut> > selector)
 {
     return(Selector.Add(this, selector, node => this));
 }
Beispiel #16
0
 public void addSelector(string selectorVal)
 {
     Selector.Add(selectorVal);
 }
Beispiel #17
0
 public SelectorNode <TOut, TNextOut> AddToAddToItsInner <TNextOut>(Expression <Func <TOut, TNextOut> > selector)
 {
     return(Selector.Add(this, selector, node => node));
 }