Exemplo n.º 1
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();
        EntityType type = EntityType.Enemy | EntityType.GuardEnemy;

        AddType(type);

        speed = 2.0f;

        enemyNearby   = false;
        gunController = GetComponent <GunController>();

        blackboard.treeData.Add("eyes", eyes);
        blackboard.treeData.Add("gunController", gunController);

        NodeSequencer root = new NodeSequencer(new BTNode[]
        {
            new NodeSelector(new BTNode[]
            {
                new ActionCheckForEnemiesInSight(),
                new NodeAlwaysFail(
                    new ActionLookForEnemy()
                    )
            }),
            new ActionUseWeapon()
        });


        brain = new AIBrain(root, blackboard);

        brain.Start();
    }
Exemplo n.º 2
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();

        EntityType type = EntityType.Enemy | EntityType.PatrolEnemy;

        AddType(type);

        enemyNearby   = false;
        blackboard    = new Blackboard();
        gunController = GetComponent <GunController>();

        blackboard.treeData.Add("patrolRoute", patrolRoute);
        blackboard.treeData.Add("entity", this);
        blackboard.treeData.Add("eyes", eyes);
        blackboard.treeData.Add("gunController", gunController);

        NodeSequencer root = new NodeSequencer(new BTNode[]
        {
            new NodeSelector(new BTNode[]
            {
                new NodeSelector(new BTNode[]
                {
                    new ActionCheckForEnemiesInSight(),
                    new NodeAlwaysFail(
                        new NodeSequencer(new BTNode[]
                    {
                        new ActionCheckHitLocation(),
                        new ActionRequestPathToTarget()
                    })
                        ),
                    new NodeSequencer(new BTNode[]
                    {
                        new ActionGetLastSightedSearchPosition(),
                        new ActionRequestPathToTarget()
                    }),
                    new NodeSequencer(new BTNode[]
                    {
                        new ActionSearchingForEnemyBool(),
                        new NodeSelector(new BTNode[]
                        {
                            new NodeInverter(
                                new ActionReachedTarget()
                                ),
                            new NodeAlwaysFail(
                                new NodeSequencer(new BTNode[]
                            {
                                new ActionFindNearestWaypoint(),
                                new ActionRequestPathToTarget()
                            })
                                )
                        })
                    }),
                    new NodeSequencer(new BTNode[]
                    {
                        new ActionCheckForEnemiesNearby(),
                        new ActionStopMovement()
                    })
                }),
                new NodeSequencer(new BTNode[]
                {
                    new ActionReachedTarget(),
                    new ActionGetNextWaypoint(),
                    new NodeAlwaysFail(
                        new ActionRequestPathToTarget()
                        )
                })
            }),
            new NodeSelector(new BTNode[]
            {
                new ActionCheckForEnemiesInSight(),
                new NodeAlwaysFail(
                    new ActionLookForEnemy()
                    )
            }),
            new NodeSelector(new BTNode[]
            {
                new NodeSequencer(new BTNode[]
                {
                    new NodeSequencer(new BTNode[]
                    {
                        new NodeAlwaysSuccess(
                            new NodeCounter(
                                new ActionGetAttackPosition(), 5)
                            ),
                        new ActionUseWeapon(),
                        new ActionReachedTarget()
                    }),
                    new NodeAlwaysSuccess(
                        new NodeSequencer(new BTNode[]
                    {
                        new NodeInverter(
                            new ActionCheckAttackPosition()
                            ),
                        new ActionGetAttackPosition(),
                        new ActionRequestPathToTarget()
                    })),
                }),
                new ActionRequestPathToTarget()
            })
        });

        brain = new AIBrain(root, blackboard);
        brain.Start();
    }
Exemplo n.º 3
0
    public override void Start()
    {
        base.Start();
        EntityType type = EntityType.Companion;

        AddType(type);

        safeLocations = new List <Vector3>();
        InvokeRepeating("MarkLocation", 1, 5);

        gunController = GetComponent <GunController>();

        blackboard.treeData.Add("companion", this);
        blackboard.treeData.Add("eyes", eyes);
        blackboard.treeData.Add("gunController", gunController);

        NodeSequencer root = new NodeSequencer(new BTNode[]
        {
            new NodeSelector(new BTNode[]
            {
                new NodeAlwaysFail(
                    new ActionCheckHitLocation()
                    ),
                new NodeSequencer(new BTNode[]
                {
                    new ActionReachedTarget(),
                    new NodeInverter(
                        new ActionCheckHideTimer()
                        ),
                    new ActionGetHidePosition(),
                    new ActionRequestPathToTarget()
                }),
                new NodeSequencer(new BTNode[]
                {
                    new ActionCheckOverwatch(),
                    new ActionReachedTarget(),
                    new ActionLookForEnemy(),
                    new NodeCounter(
                        new NodeSequencer(new BTNode[]
                    {
                        new ActionGetOverwatchPosition(),
                        new ActionRequestPathToTarget()
                    }), 4
                        )
                }),
                new NodeSequencer(new BTNode[]
                {
                    new ActionCheckForEnemiesInSight(),
                    new NodeSelector(new BTNode[]
                    {
                        new ActionCheckAggressiveStance(),
                        new ActionCheckDefensiveStance(),

                        new NodeCounter(
                            new NodeSequencer(new BTNode[]
                        {
                            new ActionReachedTarget(),
                            new ActionGetHidePosition(),
                            new ActionRequestPathToTarget()
                        }), 1
                            )
                    })
                }),
                new ActionToggleFlank(),
                new NodeInverter(
                    new NodeSelector(new BTNode[]
                {
                    new NodeInverter(
                        new ActionCheckScavangeAction()
                        ),
                    new NodeInverter(
                        new NodeSelector(new BTNode[]
                    {
                        new NodeCounter(
                            new ActionCheckScavangeStatus(), 10
                            ),
                        new NodeCounter(
                            new NodeSequencer(new BTNode[]
                        {
                            new ActionReachedTarget(),
                            new ActionGetScavangeLocation(),
                            new ActionRequestPathToTarget()
                        }), 5
                            )
                    })
                        ),
                    new NodeSequencer(new BTNode[]
                    {
                        new ActionStopMovement(),
                        new ActionGiveMedKitToPlayer(),
                        new ActionRequestPathToTarget()
                    })
                })
                    ),
                new NodeSequencer(new BTNode[]
                {
                    new NodeCounter(
                        new NodeInverter(
                            new ActionCheckFollowPosition()
                            ), 0.5f
                        ),
                    new NodeSequencer(new BTNode[]
                    {
                        new ActionReachedTarget(),
                        new ActionGetFollowPosition(),
                        new ActionRequestPathToTarget()
                    })
                })
            }),
            new NodeSelector(new BTNode[]
            {
                new NodeSequencer(new BTNode[]
                {
                    new NodeCounter(
                        new NodeInverter(
                            new ActionCheckFollowPosition()
                            ), 2
                        ),
                    new ActionGetFollowPosition(),
                    new ActionRequestPathToTarget()
                }),
                new NodeSelector(new BTNode[]
                {
                    new NodeSequencer(new BTNode[]
                    {
                        new NodeInverter(
                            new ActionCheckDefensiveStance()
                            ),
                        new ActionCheckForEnemiesInSight(),
                        new NodeAlwaysFail(
                            new ActionUseWeapon()
                            )
                    }),
                    new NodeSequencer(new BTNode[]
                    {
                        new ActionCheckPlayerTarget(),
                        new ActionUseWeapon()
                    })
                }),
                new NodeSelector(new BTNode[]
                {
                    new NodeSequencer(new BTNode[]
                    {
                        new ActionCheckFlankAction(),
                        new NodeSequencer(new BTNode[]
                        {
                            new ActionGetAttackPosition(),
                            new ActionRequestPathToTarget()
                        })
                    }),
                    new NodeSequencer(new BTNode[]
                    {
                        new NodeInverter(
                            new ActionCheckFlankAction()
                            ),
                        new ActionReachedTarget(),
                        new ActionToggleFlank()
                    })
                })
            })
        });

        brain = new AIBrain(root, blackboard);
        brain.Start();
    }