public Decomposer(SteeringPipeline pipeline, NavMeshPathGraph navMesh, DynamicCharacter character) { Character = character; Pipeline = pipeline; aStarPathFinding = new NodeArrayAStarPathFinding(navMesh, new EuclideanDistanceHeuristic()); aStarPathFinding.NodesPerSearch = 150; }
public StandStillActuator(SteeringPipeline pipeline) : base(pipeline) { this.StopMovement = new DynamicStop(this.Pipeline.Character) { MaxAcceleration = 40.0f, TimeToStop = 2.0f }; }
public FollowPathActuator(SteeringPipeline pipeline) : base(pipeline) { this.FollowPathMovement = new DynamicFollowPath(this.Pipeline.Character, null) { MaxAcceleration = 40.0f, MaxSpeed = 40.0f }; }
public FollowPathActuator(SteeringPipeline pipeline) : base(pipeline) { this.FollowPathMovement = new DynamicFollowPath(this.Pipeline.Character,null) { MaxAcceleration = 40.0f, //MaxSpeed = 20.0f }; }
public ConstraitColisionWithWalls(SteeringPipeline steeringPipeline, GameObject[] obstacles) : base(steeringPipeline) { this.obstacle = obstacles; this.MinimumDistance = 500.0f; aMaxYOffset = 1f; AvoidMargin = 4f; MaxLookAhead = 10f; MaxWhiskersLookAhead = 10f; WhiskersAngle = MathConstants.MATH_PI_4; //innit the colliders this.collider = new Collider[obstacle.Length]; for (int i = 0; i < obstacle.Length; i++) { collider[i] = obstacles[i].GetComponent<Collider>(); } }
public SteeringPipelineComponent(SteeringPipeline pipeline) { this.Pipeline = pipeline; }
public FixedTargeter(SteeringPipeline pipeline) : base(pipeline) { this.Target = new SteeringGoal(); }
public Targeter(SteeringPipeline pipeline) { Pipeline = pipeline; }
public DecomposerComponent(SteeringPipeline pipeline) : base(pipeline) { }
public PedestrianAvoidanceConstraint(SteeringPipeline pipeline, DynamicCharacter character, List <Pedestrian> pedestrians) { this.Pedestrians = pedestrians; this.Character = character; }
public ActuatorSwitch(SteeringPipeline pipeline) : base(pipeline) { this.ActiveActuator = this.Name; this.Actuators = new Dictionary <string, ActuatorComponent>(); }
public MouseClickTargeter(SteeringPipeline pipeline, Camera camera) : base(pipeline) { this.Camera = camera; this.Goal = new SteeringGoal(); }
public SteeringPipeline InitializeSteeringPipeline(DynamicCharacter orig, KinematicData dest) { //Pipeline SteeringPipeline pipe = new SteeringPipeline(orig.KinematicData) { MaxAcceleration = 15.0f }; //Targeter Targeter MouseClickTargeter = new Targeter() { Target = dest }; pipe.Targeters.Add(MouseClickTargeter); //Decomposer pathfindingDecomposer = new PathfindingDecomposer() { Graph = this.navMesh, Heuristic = new EuclideanDistanceHeuristic() }; pipe.Decomposers.Add(pathfindingDecomposer); //Actuator - Default: Car behaviour Actuator actuator = new CarActuator() { MaxAcceleration = 15.0f, Character = orig.KinematicData }; if (orig.GameObject.tag.Equals("Enemies")) { actuator = new TrollActuator() { MaxAcceleration = 10.0f, Character = orig.KinematicData }; } pipe.Actuator = actuator; //Constraints foreach (DynamicCharacter troll in enemies) { TrollConstraint trollConstraint = new TrollConstraint() { Troll = troll, margin = 1.0f }; pipe.Constraints.Add(trollConstraint); } MapConstraint mapConstraint = new MapConstraint() { chars = character, navMeshP = navMesh, margin = 1.0f }; pipe.Constraints.Add(mapConstraint); return pipe; }
public TargeterComponent(SteeringPipeline pipeline) : base(pipeline) { }
public PathFindingDecomposer(SteeringPipeline pipeline, AStarPathfinding pathfindingAlgorithm) : base(pipeline) { this.PathfindingAlgorithm = pathfindingAlgorithm; }
protected ActuatorComponent(SteeringPipeline pipeline) : base(pipeline) { }
public SteeringPipeline InitializeSteeringPipeline(DynamicCharacter orig, KinematicData dest) { //Pipeline SteeringPipeline pipe = new SteeringPipeline(orig.KinematicData) { MaxAcceleration = 15.0f }; //Targeter Targeter MouseClickTargeter = new Targeter() { Target = dest }; pipe.Targeters.Add(MouseClickTargeter); //Decomposer pathfindingDecomposer = new PathfindingDecomposer() { Graph = this.navMesh, Heuristic = new EuclideanDistanceHeuristic() }; pipe.Decomposers.Add(pathfindingDecomposer); //Actuator - Default: Car behaviour Actuator actuator = new CarActuator() { MaxAcceleration = 15.0f, Character = orig.KinematicData }; if (orig.GameObject.tag.Equals("Enemies")) { actuator = new TrollActuator() { MaxAcceleration = 10.0f, Character = orig.KinematicData }; } pipe.Actuator = actuator; //Constraints foreach (DynamicCharacter troll in enemies) { TrollConstraint trollConstraint = new TrollConstraint() { Troll = troll, margin = 1.0f }; pipe.Constraints.Add(trollConstraint); } MapConstraint mapConstraint = new MapConstraint() { chars = character, navMeshP = navMesh, margin = 1.0f }; pipe.Constraints.Add(mapConstraint); return(pipe); }
public BasicActuator(SteeringPipeline pipeline) : base(pipeline) { }
// Use this for initialization void Awake() { this.draw = false; this.character = new DynamicCharacter(this.characterAvatar); this.character.Drag = 0.3f; this.people = new DynamicCharacter[this.peopleAvatar.Length]; for(int i = 0; i < this.peopleAvatar.Length;i++) { this.people[i] = new DynamicCharacter(this.peopleAvatar[i]); } var obstacles = GameObject.FindGameObjectsWithTag("Obstacle"); SteeringPipeline steeringPipeline = new SteeringPipeline(); steeringPipeline.Character = character.KinematicData; steeringPipeline.Targeters.Add(targeter = new TargetPosition()); steeringPipeline.Decomposers.Add(decomposerAStar = new NodeAStarDecomposer()); steeringPipeline.Constraints.Add( constraint = new ConstraitColisionWithWalls(obstacles, 500.0f) { AvoidMargin = 7f, MaxLookAhead = 7f, MaxWhiskersLookAhead = 5f }); steeringPipeline.Constraints.Add( constraint2 = new ConstraitColisionWithPeople(peopleAvatar, 15f) { }); steeringPipeline.Actuator = actuator = new PathFollowingActuator() { movement = new DynamicFollowPath() { MaxAcceleration = 40.0f, PathOffset = 0.05f, Movement = new DynamicCarSeek() { MaxSpeed = character.MaxSpeed, MinSpeed = 4f } }, SecondsToSmooth = 2f }; character.Movement = steeringPipeline; for (int i = 0; i < this.people.Length; i++) { SteeringPipeline personSteeringPipeline = new SteeringPipeline(); TargetPersonPosition personTargeter = new TargetPersonPosition(10.0f); personSteeringPipeline.Targeters.Add(personTargeter); DecomposerPersonPathCreation personDecomposer = new DecomposerPersonPathCreation(); personSteeringPipeline.Decomposers.Add(personDecomposer); personSteeringPipeline.Constraints.Add( constraint = new ConstraitColisionWithWalls(obstacles, 500.0f) { AvoidMargin = 7f, MaxLookAhead = 15f, MaxWhiskersLookAhead = 10f }); personSteeringPipeline.Actuator = personActuator = new PersonActuator() { movement = new DynamicFollowPath() { MaxAcceleration = 20.0f, PathOffset = 0.05f, Movement = new DynamicPedestrianSeek() }, }; personSteeringPipeline.Character = this.people[i].KinematicData; people[i].Movement = personSteeringPipeline; } StringPullingPathSmoothing.MinWidth = 10f; StringPullingPathSmoothing.MinDistanceToCharacter = 10f; }
public PedestrianAvoidanceConstraint(SteeringPipeline pipeline, DynamicCharacter character, List<Pedestrian> pedestrians) { this.Pedestrians = pedestrians; this.Character = character; }
public void Start() { this.draw = true; this.influenceMapDebugMode = 0; this.navMesh = NavigationManager.Instance.NavMeshGraphs[0]; this.Character = new DynamicCharacter(this.gameObject); //initialization of the movement algorithms this.aStarPathFinding = new NodeArrayAStarPathFinding(this.navMesh, new EuclideanDistanceHeuristic()); this.aStarPathFinding.NodesPerSearch = 100; var steeringPipeline = new SteeringPipeline { MaxAcceleration = 40.0f, MaxConstraintSteps = 2, Character = this.Character.KinematicData, }; this.decomposer = new PathFindingDecomposer(steeringPipeline, this.aStarPathFinding); this.Targeter = new FixedTargeter(steeringPipeline); steeringPipeline.Targeters.Add(this.Targeter); steeringPipeline.Decomposers.Add(this.decomposer); steeringPipeline.Actuator = new FollowPathActuator(steeringPipeline); this.Character.Movement = steeringPipeline; //initialization of the Influence Maps this.RedInfluenceMap = new InfluenceMap(this.navMesh, new SimpleUnorderedList(), new ClosedLocationRecordDictionary(), new LinearInfluenceFunction(), 0.1f); this.GreenInfluenceMap = new InfluenceMap(this.navMesh, new SimpleUnorderedList(), new ClosedLocationRecordDictionary(), new LinearInfluenceFunction(), 0.1f); //initialization of the GOB decision making //let's start by creating 4 main goals //the eatgoal is the only goal that increases at a fixed rate per second, it increases at a rate of 0.1 per second this.SurviveGoal = new Goal(SURVIVE_GOAL, 2.0f); this.EatGoal = new Goal(EAT_GOAL, 1.0f) { ChangeRate = 0.1f }; this.GetRichGoal = new Goal(GET_RICH_GOAL, 1.0f) { InsistenceValue = 5.0f, ChangeRate = 0.2f }; this.RestGoal = new Goal(REST_GOAL, 1.0f); this.ConquerGoal = new Goal(CONQUER_GOAL, 1.5f) { InsistenceValue = 5.0f }; this.Goals = new List <Goal>(); this.Goals.Add(this.SurviveGoal); this.Goals.Add(this.EatGoal); this.Goals.Add(this.GetRichGoal); this.Goals.Add(this.RestGoal); this.Goals.Add(this.ConquerGoal); //initialize the available actions var restAction = new Rest(this); this.Actions = new List <Action>(); this.Actions.Add(restAction); foreach (var chest in GameObject.FindGameObjectsWithTag("Chest")) { this.Actions.Add(new PickUpChest(this, chest)); } foreach (var tree in GameObject.FindGameObjectsWithTag("Tree")) { this.Actions.Add(new GetArrows(this, tree)); } foreach (var bed in GameObject.FindGameObjectsWithTag("Bed")) { this.Actions.Add(new Sleep(this, bed)); } foreach (var boar in GameObject.FindGameObjectsWithTag("Boar")) { this.Actions.Add(new MeleeAttack(this, boar)); this.Actions.Add(new Shoot(this, boar)); } //flags used for the influence map this.RedFlags = new List <IInfluenceUnit>(); foreach (var redFlag in GameObject.FindGameObjectsWithTag("RedFlag")) { this.RedFlags.Add(new Flag(this.navMesh.QuantizeToNode(redFlag.transform.position, 1.0f), FlagColor.Red)); } this.GreenFlags = new List <IInfluenceUnit>(); foreach (var greenFlag in GameObject.FindGameObjectsWithTag("GreenFlag")) { this.GreenFlags.Add(new Flag(this.navMesh.QuantizeToNode(greenFlag.transform.position, 1.0f), FlagColor.Green)); } this.RedInfluenceMap.Initialize(this.RedFlags); this.GreenInfluenceMap.Initialize(this.GreenFlags); var worldModel = new CurrentStateWorldModel(this.GameManager, this.Actions, this.Goals); this.GOAPDecisionMaking = new DepthLimitedGOAPDecisionMaking(worldModel, this.Actions, this.Goals); }
protected ConstraintComponent(SteeringPipeline pipeline) : base(pipeline) { this.SuggestionUsed = false; }
public ActuatorSwitch(SteeringPipeline pipeline) : base(pipeline) { this.ActiveActuator = this.Name; this.Actuators = new Dictionary<string, ActuatorComponent>(); }