public void BlackBoardAddSameValMultipleTimesNoEx_Red()
        {
            var bb = new BlackBoard();

            bb.SetValue("pos", 5);
            Assert.That(() => bb.SetValue("pos", 20), Throws.Nothing);
            Assert.That(bb.ReadValue <int>("pos"), Is.Not.EqualTo(5));
        }
        public void BlackBoardReadTypeObjectNoEx()
        {
            var bb = new BlackBoard();

            bb.SetValue("foo", 10f);
            Assert.That(() => bb.ReadValue <object>("foo"), Throws.Nothing);
        }
        public void BlackBoardReadUnexistingKeyEx()
        {
            var bb = new BlackBoard();

            bb.SetValue("foo", 10f);
            Assert.That(() => bb.ReadValue <float>("bar"), Throws.Exception.TypeOf <KeyNotFoundException>());
        }
        public void BlackBoardReadFloatIntoIntEx()
        {
            var bb = new BlackBoard();

            bb.SetValue("foo", -50f);
            Assert.That(() => bb.ReadValue <int>("foo"), Throws.Exception.TypeOf <InvalidCastException>());
        }
        public void BlackBoardReadWrongTypeWithoutImplicitCastEx()
        {
            var bb = new BlackBoard();

            bb.SetValue("pos", true);
            Assert.That(() => bb.ReadValue <Node>("pos"), Throws.Exception);
        }
        public void BlackBoardReadTypeObject()
        {
            var bb = new BlackBoard();

            bb.SetValue("foo", 1);
            Assert.That(bb.ReadValue <object>("foo"), Is.EqualTo(1));    //not sure about this
        }
        public void BlackBoardReadFloat()
        {
            var bb = new BlackBoard();

            bb.SetValue("foo", 10f);
            Assert.That(() => bb.ReadValue <float>("foo"), Throws.Nothing);
            Assert.That(bb.ReadValue <float>("foo"), Is.EqualTo(10f).Within(float.Epsilon));
        }
Пример #8
0
 private void Damaged(Soldier shooter)
 {
     blackBoard.SetValue(shooterPosKey, shooter.transform.position);
     this.shooter  = shooter;
     rememberTimer = rememberTime;
     if (!npc.isHaveWeapon)
     {
         SetFallBackPos(shooter.transform.position);
     }
 }
Пример #9
0
    public void Tick(BlackBoard board, object target)
    {
        Tick tick = new Tick(this, board, target);

        _root.Execute(tick);
        List <Node> lastOpenNodes    = board.GetValue(MemoryKeys.OPEN_NODES.ToString(), _id) as List <Node>;
        List <Node> currentOpenNodes = new List <Node>(tick.OpenNodes);

        if (lastOpenNodes != null)
        {
            int activeNodesCount = GetOpenNodesCount(lastOpenNodes, currentOpenNodes);
            for (int i = lastOpenNodes.Count - 1; i >= activeNodesCount; i--)
            {
                lastOpenNodes[i].Close(tick);
            }
        }
        board.SetValue(MemoryKeys.OPEN_NODES.ToString(), _id, currentOpenNodes);
        board.SetValue(MemoryKeys.NODES_COUNT.ToString(), _id, tick.NodesCount);

        return;
    }
Пример #10
0
 public void DoUpdate(LFloat deltaTime)
 {
     //update working data
     BehaviorWorkingData.EntityAnimatorView.speed = (LFloat)1;
     BehaviorWorkingData.deltaTime = deltaTime;
     BehaviorWorkingData.ClearRunTimeInfo();
     _blackboard.SetValue(BBKEY_NEXTMOVINGPOSITION, GameManager.player.transform.pos);
     if (_behaviorTree.Evaluate(BehaviorWorkingData))
     {
         _behaviorTree.Update(BehaviorWorkingData);
     }
     else
     {
         _behaviorTree.Transition(BehaviorWorkingData);
     }
 }
Пример #11
0
        public int UpdateBehavior(float gameTime, float deltaTime)
        {
            if (_currentRequest == null)
            {
                return(0);
            }
            //update working data
            _behaviorWorkingData.entityAnimator.speed = GameTimer.instance.timeScale;
            _behaviorWorkingData.gameTime             = gameTime;
            _behaviorWorkingData.deltaTime            = deltaTime;

            //test bb usage
            _blackboard.SetValue(BBKEY_NEXTMOVINGPOSITION, _currentRequest.nextMovingTarget);

            if (_behaviorTree.Evaluate(_behaviorWorkingData))
            {
                _behaviorTree.Update(_behaviorWorkingData);
            }
            else
            {
                _behaviorTree.Transition(_behaviorWorkingData);
            }
            return(0);
        }
Пример #12
0
 // Set value
 static public bool SetValue <T>(string key, T val)
 {
     return(blackboard.SetValue <T>(key, val));
 }
        public void BlackBoardAddVal()
        {
            var bb = new BlackBoard();

            Assert.That(() => bb.SetValue("pos", 3f), Throws.Nothing);
        }
Пример #14
0
 public void SetValue(string key, object value)
 {
     m_BLackBoard.SetValue(key, value);
 }