protected override Activity CreateActivityInternal(IActivityCreationContext context, StimulusContext stimulusContext, GameEntity entity) { GameEntity enemyNearby = context.EntityDetector.DetectEntities(entity.position.Position, entity.vision.VisionRange) .FirstOrDefault(e => !context.FriendshipResolver.AreFriends(entity, e)); return(new AttackActivity(context.ActionFactory, context.Navigator, GiveUpDistance, enemyNearby, "Attack", context.Rng, context.GameConfig, context.EntityDetector)); }
protected override Activity CreateActivityInternal(IActivityCreationContext context, StimulusContext stimulusContext, GameEntity entity) { GameEntity enemyNearby = context.EntityDetector.DetectEntities(entity.position.Position, entity.vision.VisionRange) .FirstOrDefault(e => !context.FriendshipResolver.AreFriends(entity, e)); Func <Position> targetPositionGetter = () => enemyNearby.position.Position; return(new ApproachActivity(context.ActionFactory, context.Navigator, targetPositionGetter, 10, "Approach")); }
protected override Activity CreateActivityInternal(IActivityCreationContext context, StimulusContext stimulusContext, GameEntity entity) { if (entity.hasView && entity.view.Controller is EntityViewBehaviour) { var evb = (EntityViewBehaviour)entity.view.Controller; evb.SortingOrder = 0; } return(new WaitActivity(context.ActionFactory, 1, "Pass")); }
protected override Activity CreateActivityInternal(IActivityCreationContext context, StimulusContext stimulusContext, GameEntity entity) { Position herdCenter = GetHerdCenterOf(context.EntityDetector, entity, context.FriendshipResolver); var betweenMeAndHerdCenter = new Position((herdCenter.x + entity.position.Position.x) / 2, (herdCenter.y + entity.position.Position.y) / 2); NavigationData navigationData = GetReachableNavigationDataForHerdWander(context, entity, betweenMeAndHerdCenter, MaxWalkawayRangeFromHerdCenter); return(new SequenceActivity(new List <IActivity> { new GoToActivity(context.ActionFactory, navigationData, context.Navigator, "Roam"), new WaitActivity(context.ActionFactory, context.Rng.Next(15), "Wait") }.GetEnumerator(), "Herd roam")); }
protected override Activity CreateActivityInternal(IActivityCreationContext context, StimulusContext stimulusContext, GameEntity entity) { IEnumerable <GameEntity> entitiesSeen = entity.vision.EntitiesRecentlySeen; GameEntity enemyNearby = entitiesSeen.FirstOrDefault(e => !context.FriendshipResolver.AreFriends(entity, e)); if (enemyNearby == null) { throw new InvalidOperationException("Running away, but from whom?"); } return(new RunAwayActivity(context.ActionFactory, context.CalculatedAreaAccessor, enemyNearby.position.Position, "Run away")); }
protected override Activity CreateActivityInternal(IActivityCreationContext context, StimulusContext stimulusContext, GameEntity entity) { GameEntity enemyNearby = context.EntityDetector.DetectEntities(entity.position.Position, entity.vision.VisionRange) .FirstOrDefault(e => !context.FriendshipResolver.AreFriends(entity, e)); return(new KeepDistanceActivity(context.ActionFactory, PreferredDistance, context.Navigator, enemyNearby, context.CalculatedAreaAccessor, context.Rng, "Keep distance", context.ContextManager)); }
protected override Activity CreateActivityInternal(IActivityCreationContext context, StimulusContext stimulusContext, GameEntity entity) { entity.ReplaceSleeping(30); var sleepActivity = new WaitActivity(context.ActionFactory, 30, "Sleep", entityArg => entity.hasSleeping); return(sleepActivity); }
public Activity CreateActivity(IActivityCreationContext context, float chosenSkillScore, StimulusContext stimulusContext, GameEntity entity) { Activity activity = CreateActivityInternal(context, stimulusContext, entity); activity.Score = chosenSkillScore; return(activity); }
protected abstract Activity CreateActivityInternal(IActivityCreationContext context, StimulusContext stimulusContext, GameEntity entity);
protected override Activity CreateActivityInternal(IActivityCreationContext context, StimulusContext stimulusContext, GameEntity entity) { NavigationData navigationData1 = GetReachableNavigationDataForWander(context, entity.position.Position, entity.position.Position, RoamRange, entity); NavigationData navigationData2 = GetReachableNavigationDataForWander(context, navigationData1.Destination, entity.position.Position, RoamRange, entity); return(new SequenceActivity(new List <IActivity> { new WaitActivity(context.ActionFactory, context.Rng.Next(MaxWaitTime) + 1, "Wait 1/2"), new GoToActivity(context.ActionFactory, navigationData1, context.Navigator, "GoTo 1/2"), new WaitActivity(context.ActionFactory, context.Rng.Next(MaxWaitTime) + 1, "Wait 1/2"), new GoToActivity(context.ActionFactory, navigationData2, context.Navigator, "GoTo 2/2"), new WaitActivity(context.ActionFactory, context.Rng.Next(MaxWaitTime) + 1, "Wait 2/2"), }.GetEnumerator(), "Roam")); }