Exemplo n.º 1
0
    private void SetupWalkingSequence(Script_Sequence p_walkingSequence)
    {
        Script_Action_SetFlag setEnemies = new Script_Action_SetFlag(_behaviourTree, _manager.GetEnemies(), _entityListFlag);
        Script_Condition_IsEntityTypeNearby areEnemiesNearby = new Script_Condition_IsEntityTypeNearby(_behaviourTree, _grid, _entityListFlag, this as Script_IEntity, _engageTargetRange);


        int walkRange = 1;

        Script_Action_UnoccupyTile unoccupyTile = new Script_Action_UnoccupyTile(_behaviourTree, _grid, _locationFlag);
        Script_Action_SetRandomLocationWithinRange setRandomLocationAroundSelf = new Script_Action_SetRandomLocationWithinRange(_behaviourTree, _locationFlag, this as Script_IEntity, _grid, walkRange);
        Script_Action_MoveToLocation moveToLocation = new Script_Action_MoveToLocation(_behaviourTree, this as Script_IEntity, _locationFlag);
        Script_Action_OccupyTile     occupyLocation = new Script_Action_OccupyTile(_behaviourTree, _grid, _locationFlag);


        Script_LeafTask unoccupyTileLeaf = new Script_LeafTask(_behaviourTree, unoccupyTile);
        Script_LeafTask setRandomLocationAroundSelfLeaf = new Script_LeafTask(_behaviourTree, setRandomLocationAroundSelf);
        Script_LeafTask setEnemiesLeaf     = new Script_LeafTask(_behaviourTree, setEnemies);
        Script_LeafTask moveToLocationLeaf = new Script_LeafTask(_behaviourTree, moveToLocation);
        Script_LeafTask occupyLocationLeaf = new Script_LeafTask(_behaviourTree, occupyLocation);

        Script_LeafTask areEnemiesNearbyLeaf = new Script_LeafTask(_behaviourTree, areEnemiesNearby);

        Script_Decorator_Inverter areEnemiesNotNearbyDecorator = new Script_Decorator_Inverter(_behaviourTree, areEnemiesNearbyLeaf);

        p_walkingSequence.AddTask(setEnemiesLeaf);
        p_walkingSequence.AddTask(unoccupyTileLeaf);
        p_walkingSequence.AddTask(setRandomLocationAroundSelfLeaf);
        p_walkingSequence.AddTask(occupyLocationLeaf);
        p_walkingSequence.AddTask(areEnemiesNotNearbyDecorator);
        p_walkingSequence.AddTask(moveToLocationLeaf);
    }
 public void CreateEnemy(Vector3Int p_location)
 {
     if (_manager.GetEnemies().Count < _maxEnemyAmount)
     {
         Script_Enemy enemy = new Script_Enemy(_manager, _grid, p_location);
         _manager.AddEnemy(enemy);
     }
 }