Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        bb = new BlackBoard();

        bb.Set <int>("testInt", 123);
        bb.Set <Vector2>("TestVector2", new Vector2());

        print(bb.Get <int>("testInt"));
        print(bb.Get <Vector2>("TestVector2"));
    }
Exemplo n.º 2
0
	// Use this for initialization
	void Start () {
        bb = new BlackBoard();

        bb.Set<int>("testInt", 123);
        bb.Set<Vector2>("TestVector2", new Vector2());

        print(bb.Get<int>("testInt"));
        print(bb.Get<Vector2>("TestVector2"));

    }
    BehaviorReturnCode wanderAroundPlayer()
    {
        Vector2 targetPos;
        Vector3 playerPos = Memory.Get <GameObject>("Player").transform.position;

        if (Memory.Contains("targetPos"))
        {
            targetPos = Memory.Get <Vector2>("targetPos");
        }
        else
        {
            targetPos = Random.insideUnitSphere;

            Memory.Set <Vector2>("targetPos", targetPos);
        }


        if (!isAtTargetPos())
        {
            gameObject.transform.position = Vector3.Lerp(gameObject.transform.position, targetPos + new Vector2(playerPos.x, playerPos.y), speed * Time.deltaTime);
            return(BehaviorReturnCode.Running);
        }
        else
        {
            Memory.Remove("targetPos");
            return(BehaviorReturnCode.Success);
        }
    }
	// Use this for initialization
	void Start () {
        Memory = new BlackBoard();

        Memory.Set<GameObject>("Player", GameObject.FindGameObjectWithTag("Player"));

        Conditional playerClose = new Conditional(isCloseToPlayer);
        Conditional playerMoving = new Conditional(isPlayerMoving);

        BehaviorAction MoveToPlayer = new BehaviorAction(moveToPlayer);
        BehaviorAction WanderAroundPlayer = new BehaviorAction(wanderAroundPlayer);

        Selector stayCloseToPlayer = new Selector(

            new Sequence(
                new Inverter(playerClose),
                playerMoving,
                MoveToPlayer                
                ),
            WanderAroundPlayer
            );

        behaviour = new BehaviorLibrary.Behavior(stayCloseToPlayer);
	
	}
    // Use this for initialization
    void Start()
    {
        Memory = new BlackBoard();

        Memory.Set <GameObject>("Player", GameObject.FindGameObjectWithTag("Player"));

        Conditional playerClose  = new Conditional(isCloseToPlayer);
        Conditional playerMoving = new Conditional(isPlayerMoving);

        BehaviorAction MoveToPlayer       = new BehaviorAction(moveToPlayer);
        BehaviorAction WanderAroundPlayer = new BehaviorAction(wanderAroundPlayer);

        Selector stayCloseToPlayer = new Selector(

            new Sequence(
                new Inverter(playerClose),
                playerMoving,
                MoveToPlayer
                ),
            WanderAroundPlayer
            );

        behaviour = new BehaviorLibrary.Behavior(stayCloseToPlayer);
    }