private void SetupChooseTargetSequence(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, _engageTargetRange); Script_Action_SetNearestEntityFromEntityWithinRange setNearestEnemy = new Script_Action_SetNearestEntityFromEntityWithinRange(_behaviourTree, _grid, _entityListFlag, _engageTargetRange, this as Script_IEntity, _targetEntityFlag); Script_Action_SetEnemyAttackingTarget setEnemyAttackingDps = new Script_Action_SetEnemyAttackingTarget(_behaviourTree, _entityListFlag, _manager.GetDps() as Script_IEntity, _targetEntityFlag); Script_Action_SetEnemyAttackingTarget setEnemyAttackingHealer = new Script_Action_SetEnemyAttackingTarget(_behaviourTree, _entityListFlag, _manager.GetHealer() as Script_IEntity, _targetEntityFlag); Script_Selector chooseTargetToAidSelector = new Script_Selector(_behaviourTree); Script_LeafTask setEnemiesLeaf = new Script_LeafTask(_behaviourTree, setEnemies); Script_LeafTask setEnemiesWithinRangeLeaf = new Script_LeafTask(_behaviourTree, setEnemiesWithinRange); Script_LeafTask setNearestEnemyLeaf = new Script_LeafTask(_behaviourTree, setNearestEnemy); Script_LeafTask setEnemyAttackingHealerLeaf = new Script_LeafTask(_behaviourTree, setEnemyAttackingHealer); Script_LeafTask setEnemyAttackingDpsLeaf = new Script_LeafTask(_behaviourTree, setEnemyAttackingDps); chooseTargetToAidSelector.AddTask(setEnemyAttackingHealerLeaf); chooseTargetToAidSelector.AddTask(setEnemyAttackingDpsLeaf); p_chooseTargetSequence.AddTask(setEnemiesLeaf); p_chooseTargetSequence.AddTask(setEnemiesWithinRangeLeaf); p_chooseTargetSequence.AddTask(setNearestEnemyLeaf); p_chooseTargetSequence.AddTask(chooseTargetToAidSelector); }
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); }
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); }
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 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); }
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); }
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); }
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); }
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); }