private void SetupPursuitSequence(Script_Sequence p_pursuitSequence)
    {
        Script_Action_UnoccupyTile      unoccupyTile      = new Script_Action_UnoccupyTile(_behaviourTree, _grid, _locationFlag);
        Script_Action_MoveTowardsEntity moveTowardsTarget = new Script_Action_MoveTowardsEntity(_behaviourTree, _grid, _targetEntityFlag, this as Script_IEntity);
        Script_Action_SetNearestLocationSurroundingEntity setLocationAroundTarget = new Script_Action_SetNearestLocationSurroundingEntity(_behaviourTree, _grid, _targetEntityFlag, this as Script_IEntity, _locationFlag);
        Script_Action_MoveToLocation moveToLocation = new Script_Action_MoveToLocation(_behaviourTree, this as Script_IEntity, _locationFlag);
        Script_Action_OccupyTile     occupyTile     = new Script_Action_OccupyTile(_behaviourTree, _grid, _locationFlag);

        Script_Condition_IsEntityNull   isTargetNull     = new Script_Condition_IsEntityNull(_behaviourTree, _targetEntityFlag);
        Script_Condition_IsEntityNearby isTargetAdjacent = new Script_Condition_IsEntityNearby(_behaviourTree, _grid, _targetEntityFlag, this as Script_IEntity, _attackRange);

        Script_LeafTask isTargetNullLeaf            = new Script_LeafTask(_behaviourTree, isTargetNull);
        Script_LeafTask isTargetAdjacentLeaf        = new Script_LeafTask(_behaviourTree, isTargetAdjacent);
        Script_LeafTask occupyTileLeaf              = new Script_LeafTask(_behaviourTree, occupyTile);
        Script_LeafTask unoccupyTileLeaf            = new Script_LeafTask(_behaviourTree, unoccupyTile);
        Script_LeafTask moveTowardsTargetLeaf       = new Script_LeafTask(_behaviourTree, moveTowardsTarget);
        Script_LeafTask setLocationAroundTargetLeaf = new Script_LeafTask(_behaviourTree, setLocationAroundTarget);
        Script_LeafTask moveToLocationLeaf          = new Script_LeafTask(_behaviourTree, moveToLocation);

        Script_Decorator_Inverter isTargetNotAdjacentDecorator = new Script_Decorator_Inverter(_behaviourTree, isTargetAdjacentLeaf);
        Script_Decorator_Inverter isTargetNotNullDecorator     = new Script_Decorator_Inverter(_behaviourTree, isTargetNullLeaf);

        p_pursuitSequence.AddTask(isTargetNotNullDecorator);
        p_pursuitSequence.AddTask(isTargetNotAdjacentDecorator);
        p_pursuitSequence.AddTask(unoccupyTileLeaf);
        p_pursuitSequence.AddTask(moveTowardsTargetLeaf);
        p_pursuitSequence.AddTask(setLocationAroundTargetLeaf);
        p_pursuitSequence.AddTask(occupyTileLeaf);
        p_pursuitSequence.AddTask(moveToLocationLeaf);
    }
    private void SetupGetFreeSpaceSequence(Script_Sequence p_getFreeSpaceSequence)
    {
        int range = 1;
        Script_Action_SetFlag setEnemies = new Script_Action_SetFlag(_behaviourTree, _manager.GetEnemies(), _getSpaceEntityListFlag);
        Script_Action_SetEntitiesWithinRange            setEnemiesWithinRange = new Script_Action_SetEntitiesWithinRange(_behaviourTree, _grid, _getSpaceEntityListFlag, _getSpaceEntityListFlag, this as Script_IEntity, range);
        Script_Condition_AreAnyEntitiesAtEntityLocation isEnemyAtLocation     = new Script_Condition_AreAnyEntitiesAtEntityLocation(_behaviourTree, _getSpaceEntityListFlag, this as Script_IEntity);

        Script_Action_SetFlag setFlagToSelf = new Script_Action_SetFlag(_behaviourTree, this as Script_IEntity, _selfFlag);

        Script_Action_UnoccupyTile unoccupyTile = new Script_Action_UnoccupyTile(_behaviourTree, _grid, _locationFlag);
        Script_Action_SetNearestLocationSurroundingEntity getLocationAroundSelf = new Script_Action_SetNearestLocationSurroundingEntity(_behaviourTree, _grid, _selfFlag, this as Script_IEntity, _locationFlag);
        Script_Action_OccupyTile     occupyTile     = new Script_Action_OccupyTile(_behaviourTree, _grid, _locationFlag);
        Script_Action_MoveToLocation moveToLocation = new Script_Action_MoveToLocation(_behaviourTree, this as Script_IEntity, _locationFlag);


        Script_LeafTask setEnemiesLeaf            = new Script_LeafTask(_behaviourTree, setEnemies);
        Script_LeafTask setEnemiesWithinRangeLeaf = new Script_LeafTask(_behaviourTree, setEnemiesWithinRange);
        Script_LeafTask isEnemyAtLocationLeaf     = new Script_LeafTask(_behaviourTree, isEnemyAtLocation);
        Script_LeafTask setFlagToSelfLeaf         = new Script_LeafTask(_behaviourTree, setFlagToSelf);
        Script_LeafTask unoccupyTileLeaf          = new Script_LeafTask(_behaviourTree, unoccupyTile);
        Script_LeafTask getLocationAroundSelfLeaf = new Script_LeafTask(_behaviourTree, getLocationAroundSelf);
        Script_LeafTask occupyTileLeaf            = new Script_LeafTask(_behaviourTree, occupyTile);
        Script_LeafTask moveToLocationleaf        = new Script_LeafTask(_behaviourTree, moveToLocation);

        Script_Decorator_NeverSucceed moveToLocationAndNeverSucceedDecorator = new Script_Decorator_NeverSucceed(_behaviourTree, moveToLocationleaf);

        p_getFreeSpaceSequence.AddTask(setEnemiesLeaf);
        p_getFreeSpaceSequence.AddTask(setEnemiesWithinRangeLeaf);
        p_getFreeSpaceSequence.AddTask(isEnemyAtLocationLeaf);
        p_getFreeSpaceSequence.AddTask(setFlagToSelfLeaf);
        p_getFreeSpaceSequence.AddTask(unoccupyTileLeaf);
        p_getFreeSpaceSequence.AddTask(getLocationAroundSelfLeaf);
        p_getFreeSpaceSequence.AddTask(occupyTileLeaf);
        p_getFreeSpaceSequence.AddTask(moveToLocationAndNeverSucceedDecorator);
    }
Beispiel #3
0
    private void SetupMoveToTankSequence(Script_Sequence p_moveNearTankSequence)
    {
        Script_Action_SetFlag      setTankFlag  = new Script_Action_SetFlag(_behaviourTree, _manager.GetTank() as Script_IEntity, _entityToFollowFlag);
        Script_Action_UnoccupyTile unoccupyTile = new Script_Action_UnoccupyTile(_behaviourTree, _grid, _locationFlag);
        Script_Action_SetNearestLocationSurroundingEntity setLocationNearTank = new Script_Action_SetNearestLocationSurroundingEntity(_behaviourTree, _grid, _entityToFollowFlag, this as Script_IEntity, _locationFlag);
        Script_Action_OccupyTile     occupyTile     = new Script_Action_OccupyTile(_behaviourTree, _grid, _locationFlag);
        Script_Action_MoveToLocation moveToLocation = new Script_Action_MoveToLocation(_behaviourTree, this as Script_IEntity, _locationFlag);

        Script_Condition_IsEntityNull isTankNull = new Script_Condition_IsEntityNull(_behaviourTree, _entityToFollowFlag);

        Script_LeafTask setTankFlagLeaf         = new Script_LeafTask(_behaviourTree, setTankFlag);
        Script_LeafTask isTankNullLeaf          = new Script_LeafTask(_behaviourTree, isTankNull);
        Script_LeafTask unoccupyTileLeaf        = new Script_LeafTask(_behaviourTree, unoccupyTile);
        Script_LeafTask setLocationNearTankLeaf = new Script_LeafTask(_behaviourTree, setLocationNearTank);
        Script_LeafTask occupyTileLeaf          = new Script_LeafTask(_behaviourTree, occupyTile);
        Script_LeafTask moveToLocationLeaf      = new Script_LeafTask(_behaviourTree, moveToLocation);

        Script_Decorator_Inverter isTankNotNullDecorator = new Script_Decorator_Inverter(_behaviourTree, isTankNullLeaf);

        p_moveNearTankSequence.AddTask(setTankFlagLeaf);
        p_moveNearTankSequence.AddTask(isTankNotNullDecorator);
        p_moveNearTankSequence.AddTask(unoccupyTileLeaf);
        p_moveNearTankSequence.AddTask(setLocationNearTankLeaf);
        p_moveNearTankSequence.AddTask(occupyTileLeaf);
        p_moveNearTankSequence.AddTask(moveToLocationLeaf);
    }