Exemple #1
0
    private void SetupWalkingSequence(Script_Sequence p_walkingSequence)
    {
        Script_Action_SetFlag setFriendlies = new Script_Action_SetFlag(_behaviourTree, _manager.GetFriendlies(), _entityListFlag);
        Script_Condition_IsEntityTypeNearby isEntityTypeNearby = 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 moveToLocationNode = 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 setFriendliesLeaf             = new Script_LeafTask(_behaviourTree, setFriendlies);
        Script_LeafTask moveTowardsRandomLocationLeaf = new Script_LeafTask(_behaviourTree, moveToLocationNode);
        Script_LeafTask occupyLocationLeaf            = new Script_LeafTask(_behaviourTree, occupyLocation);

        Script_LeafTask areFriendliesNearby = new Script_LeafTask(_behaviourTree, isEntityTypeNearby);

        Script_Decorator_Inverter areFriendliesNotNearbyDecorator = new Script_Decorator_Inverter(_behaviourTree, areFriendliesNearby);

        p_walkingSequence.AddTask(setFriendliesLeaf);
        p_walkingSequence.AddTask(unoccupyTileLeaf);
        p_walkingSequence.AddTask(setRandomLocationAroundSelfLeaf);
        p_walkingSequence.AddTask(occupyLocationLeaf);
        p_walkingSequence.AddTask(areFriendliesNotNearbyDecorator);
        p_walkingSequence.AddTask(moveTowardsRandomLocationLeaf);
    }
Exemple #2
0
    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 isEnemyAtMyPosition   = 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 setLocationAroundSelf = 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 isEnemyAtMyPositionLeaf   = new Script_LeafTask(_behaviourTree, isEnemyAtMyPosition);
        Script_LeafTask setFlagToSelfLeaf         = new Script_LeafTask(_behaviourTree, setFlagToSelf);
        Script_LeafTask unoccupyTileLeaf          = new Script_LeafTask(_behaviourTree, unoccupyTile);
        Script_LeafTask setLocationAroundSelfLeaf = new Script_LeafTask(_behaviourTree, setLocationAroundSelf);
        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(isEnemyAtMyPositionLeaf);
        p_getFreeSpaceSequence.AddTask(setFlagToSelfLeaf);
        p_getFreeSpaceSequence.AddTask(unoccupyTileLeaf);
        p_getFreeSpaceSequence.AddTask(setLocationAroundSelfLeaf);
        p_getFreeSpaceSequence.AddTask(occupyTileLeaf);
        p_getFreeSpaceSequence.AddTask(moveToLocationAndNeverSucceedDecorator);
    }
Exemple #3
0
    private void SetupFollowingSequence(Script_Sequence p_followingSequence, Script_IEntity p_entityToFollow)
    {
        Script_Action_SetFlag      setTargetToFollowFlag = new Script_Action_SetFlag(_behaviourTree, p_entityToFollow as Script_IEntity, _targetToFollowFlag);
        Script_Action_UnoccupyTile unoccupyTile          = new Script_Action_UnoccupyTile(_behaviourTree, _grid, _locationFlag);
        Script_Action_SetNearestLocationSurroundingEntity setLocationNearTarget = new Script_Action_SetNearestLocationSurroundingEntity(_behaviourTree, _grid, _targetToFollowFlag, 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 isTargetNull = new Script_Condition_IsEntityNull(_behaviourTree, _targetToFollowFlag);

        Script_LeafTask setTargetToFollowFlagLeaf = new Script_LeafTask(_behaviourTree, setTargetToFollowFlag);
        Script_LeafTask isTargetNullLeaf          = new Script_LeafTask(_behaviourTree, isTargetNull);
        Script_LeafTask unoccupyTileLeaf          = new Script_LeafTask(_behaviourTree, unoccupyTile);
        Script_LeafTask setLocationNearTargetLeaf = new Script_LeafTask(_behaviourTree, setLocationNearTarget);
        Script_LeafTask occupyTileLeaf            = new Script_LeafTask(_behaviourTree, occupyTile);
        Script_LeafTask moveToLocationLeaf        = new Script_LeafTask(_behaviourTree, moveToLocation);

        Script_Decorator_Inverter isTargetNotNullDecorator = new Script_Decorator_Inverter(_behaviourTree, isTargetNullLeaf);

        p_followingSequence.AddTask(setTargetToFollowFlagLeaf);
        p_followingSequence.AddTask(isTargetNotNullDecorator);
        p_followingSequence.AddTask(unoccupyTileLeaf);
        p_followingSequence.AddTask(setLocationNearTargetLeaf);
        p_followingSequence.AddTask(occupyTileLeaf);
        p_followingSequence.AddTask(moveToLocationLeaf);
    }
Exemple #4
0
    private void SetupChooseTargetToAttackSequence(Script_Sequence p_chooseTargetSequence)
    {
        Script_Action_SetFlag setEnemies = new Script_Action_SetFlag(_behaviourTree, _manager.GetEnemies(), _entityListFlag);
        Script_Action_SetEntitiesWithinRange    setEnemiesWithinRange    = new Script_Action_SetEntitiesWithinRange(_behaviourTree, _grid, _entityListFlag, _entityListFlag, this as Script_IEntity, _attackRange);
        Script_Action_SetEntityWithLowestHealth setEnemyWithLowestHealth = new Script_Action_SetEntityWithLowestHealth(_behaviourTree, _entityListFlag, _targetEntityFlag);

        Script_LeafTask setEnemiesLeaf               = new Script_LeafTask(_behaviourTree, setEnemies);
        Script_LeafTask setEnemiesWithinRangeLeaf    = new Script_LeafTask(_behaviourTree, setEnemiesWithinRange);
        Script_LeafTask setEnemyWithLowestHealthLeaf = new Script_LeafTask(_behaviourTree, setEnemyWithLowestHealth);

        Script_Decorator_AlwaysFail setEnemyWithLowestHealthAndFailDecorator = new Script_Decorator_AlwaysFail(_behaviourTree, setEnemyWithLowestHealthLeaf);

        p_chooseTargetSequence.AddTask(setEnemiesLeaf);
        p_chooseTargetSequence.AddTask(setEnemiesWithinRangeLeaf);
        p_chooseTargetSequence.AddTask(setEnemyWithLowestHealthAndFailDecorator);
    }
Exemple #5
0
    private void SetupAttackSequence(Script_Sequence p_attackSequence)
    {
        Script_Condition_IsEntityNearby isTargetNearby      = new Script_Condition_IsEntityNearby(_behaviourTree, _grid, _targetToAttackFlag, this as Script_IEntity, _attackRange);
        Script_Action_SetFlag           setForwardSwingFlag = new Script_Action_SetFlag(_behaviourTree, false, _isForwardSwingingFlag);
        Script_Action_RangedAttack      attackTarget        = new Script_Action_RangedAttack(_behaviourTree, _manager, _targetToAttackFlag, _locationFlag, this as Script_IEntity, _isForwardSwingingFlag, Color.green);
        Script_Condition_IsEntityNull   isTargetNull        = new Script_Condition_IsEntityNull(_behaviourTree, _targetToAttackFlag);

        Script_LeafTask           isTargetNullLeaf         = new Script_LeafTask(_behaviourTree, isTargetNull);
        Script_Decorator_Inverter isTargetNotNullDecorator = new Script_Decorator_Inverter(_behaviourTree, isTargetNullLeaf);
        Script_LeafTask           isTargetNearbyLeaf       = new Script_LeafTask(_behaviourTree, isTargetNearby);
        Script_LeafTask           setForwardSwingFlagLeaf  = new Script_LeafTask(_behaviourTree, setForwardSwingFlag);
        Script_LeafTask           attackTargetLeaf         = new Script_LeafTask(_behaviourTree, attackTarget);

        p_attackSequence.AddTask(isTargetNotNullDecorator);
        p_attackSequence.AddTask(isTargetNearbyLeaf);
        p_attackSequence.AddTask(setForwardSwingFlagLeaf);
        p_attackSequence.AddTask(attackTargetLeaf);
    }
Exemple #6
0
    private void SetupGetHighestThreatOrNearestFriendlySequence(Script_Sequence p_getHighestThreatOrNearestSequence)
    {
        int threatThreshold = 0;
        Script_Action_SetFlag setFriendlies = new Script_Action_SetFlag(_behaviourTree, _manager.GetFriendlies(), _entityListFlag);
        Script_Action_SetNearestEntityFromEntityWithinRange setNearestFriendly          = new Script_Action_SetNearestEntityFromEntityWithinRange(_behaviourTree, _grid, _entityListFlag, _engageTargetRange, this as Script_IEntity, _targetEntityFlag);
        Script_Condition_IsThreatOverThreshold       isThreatOfAnyFriendlyOverThreshold = new Script_Condition_IsThreatOverThreshold(_behaviourTree, _entityListFlag, this as Script_IEnemy, threatThreshold);
        Script_Action_SetHighestThreatTargetFromList setHighestThreatTarget             = new Script_Action_SetHighestThreatTargetFromList(_behaviourTree, _entityListFlag, this as Script_IEnemy, _targetEntityFlag);
        Script_Action_SetTargetToAttack setFriendlyToAttack = new Script_Action_SetTargetToAttack(_behaviourTree, _targetEntityFlag, this as Script_IEntity);

        Script_LeafTask setFriendliesLeaf      = new Script_LeafTask(_behaviourTree, setFriendlies);
        Script_LeafTask setNearestFriendlyLeaf = new Script_LeafTask(_behaviourTree, setNearestFriendly);
        Script_LeafTask setHighestThreatTargetIfOverThreshold = new Script_LeafTask(_behaviourTree, setHighestThreatTarget, isThreatOfAnyFriendlyOverThreshold);
        Script_LeafTask setFriendlyToAttackLeaf = new Script_LeafTask(_behaviourTree, setFriendlyToAttack);

        Script_Decorator_AlwaysFail setTargetToAttackAndFailDecorator = new Script_Decorator_AlwaysFail(_behaviourTree, setFriendlyToAttackLeaf);

        p_getHighestThreatOrNearestSequence.AddTask(setFriendliesLeaf);
        p_getHighestThreatOrNearestSequence.AddTask(setNearestFriendlyLeaf);
        p_getHighestThreatOrNearestSequence.AddTask(setFriendlyToAttackLeaf);
        p_getHighestThreatOrNearestSequence.AddTask(setHighestThreatTargetIfOverThreshold);
        p_getHighestThreatOrNearestSequence.AddTask(setTargetToAttackAndFailDecorator);
    }
Exemple #7
0
    private void SetupHealSequence(Script_Sequence p_healSequence)
    {
        int healThreshold = 80;

        Script_Condition_IsEntityHealthUnderThreshold isTargetUnderHealthValue = new Script_Condition_IsEntityHealthUnderThreshold(_behaviourTree, _targetToHealFlag, healThreshold);
        Script_Condition_IsEntityNearby isTargetToHealNearby = new Script_Condition_IsEntityNearby(_behaviourTree, _grid, _targetToHealFlag, this as Script_IEntity, _attackRange);
        Script_Action_SetFlag           forwardSwingFlag     = new Script_Action_SetFlag(_behaviourTree, false, _isForwardSwingingFlag);
        Script_Action_Heal            healTarget             = new Script_Action_Heal(_behaviourTree, _manager, _targetToHealFlag, _locationFlag, this as Script_IEntity, _isForwardSwingingFlag);
        Script_Condition_IsEntityNull isTargetNull           = new Script_Condition_IsEntityNull(_behaviourTree, _targetToHealFlag);

        Script_LeafTask           isTargetNullLeaf             = new Script_LeafTask(_behaviourTree, isTargetNull);
        Script_Decorator_Inverter isTargetNotNullDecorator     = new Script_Decorator_Inverter(_behaviourTree, isTargetNullLeaf);
        Script_LeafTask           IsTargetUnderHealthValueLeaf = new Script_LeafTask(_behaviourTree, isTargetUnderHealthValue);
        Script_LeafTask           isTargetToHealNearbyLeaf     = new Script_LeafTask(_behaviourTree, isTargetToHealNearby);
        Script_LeafTask           SetForwardSwingFlagLeaf      = new Script_LeafTask(_behaviourTree, forwardSwingFlag);
        Script_LeafTask           healTargetLeaf = new Script_LeafTask(_behaviourTree, healTarget);

        p_healSequence.AddTask(isTargetNotNullDecorator);
        p_healSequence.AddTask(IsTargetUnderHealthValueLeaf);
        p_healSequence.AddTask(isTargetToHealNearbyLeaf);
        p_healSequence.AddTask(SetForwardSwingFlagLeaf);
        p_healSequence.AddTask(healTargetLeaf);
    }