void Awake() { if (leftLegOrigins.Count != rightLegOrigins.Count) { Debug.LogError("need same number of legs each side!"); GameObject.Destroy(this); return; } Vector3 leftOffset = transform.TransformPoint(Vector3.left * legOffset); leftFeet = new List <Foot>(leftLegOrigins.Count); foreach (var position in leftLegOrigins) { var foot = GameObject.Instantiate(footPrefab, position + leftOffset, transform.rotation); leftFeet.Add(foot.GetComponent <Foot>()); } Vector3 rightOffset = transform.TransformPoint(Vector3.right * legOffset); rightFeet = new List <Foot>(rightLegOrigins.Count); foreach (var position in rightLegOrigins) { var foot = GameObject.Instantiate(footPrefab, position + rightOffset, transform.rotation); rightFeet.Add(foot.GetComponent <Foot>()); } footIndexer = new FootIndexer(leftFeet.Count); leftOffset = Vector3.left * legOffset; rightOffset = Vector3.right * legOffset; entityReference = gameObject.GetComponent <IMovingEntity>(); }
public Wander(IMovingEntity entity, float circleRadius = 3f, float circleDistance = 300f, float circleAngleChange = 10f, float displacementAngle = 0f) { this.movingEntity = entity; this.circleRadius = circleRadius; this.circleDistance = circleDistance; this.circleAngleChange = circleAngleChange; this.displacementAngle = displacementAngle; }
public Flocking(IMovingEntity movingEntity) { this.MovingEntity = movingEntity; this.seperation = new Separation(movingEntity); this.cohesion = new Cohesion(movingEntity); this.alignment = new Alignment(movingEntity); }
public CurrentVelocity(Graphics graphics, IMovingEntity movingEntity) : base(graphics, movingEntity) { }
public WallAvoidanceFeelers(Graphics graphics, IMovingEntity movingEntity) : base(graphics, movingEntity) { }
public SteeringBehaviours(IMovingEntity entity) { this._entity = entity; this.Behaviours = new List<ISteeringBehaviour>(); }
public Arrive(IMovingEntity movingEntity) { this.MovingEntity = movingEntity; }
public Cohesion(IMovingEntity movingEntity) { this.MovingEntity = movingEntity; }
public Alignment(IMovingEntity movingEntity) { this.MovingEntity = movingEntity; }
private void OnEnable() { movingEntity = GetComponent <IMovingEntity>(); }
public Pursuit(IMovingEntity vehicle, IMovingEntity evader) { this.vehicle = vehicle; this.evader = evader; }
public CurrentPosition(Graphics graphics, IMovingEntity movingEntity) : base(graphics, movingEntity) { }
public Separation(IMovingEntity movingEntity) { this.MovingEntity = movingEntity; }
public DesiredVelocity(Graphics graphics, IMovingEntity movingEntity, Vector2D desired) : base(graphics, movingEntity) { this.desiredVector = desired; }
public Arrive(IMovingEntity movingEntity, Vector2D targetPosition) { this.MovingEntity = movingEntity; this.TargetPosition = targetPosition; }
public Seek(IMovingEntity entity, Vector2D targetPosition) { this.movingEntity = entity; this.TargetPosition = targetPosition; }
public PanicDistance(Graphics graphics, IMovingEntity movingEntity) : base(graphics, movingEntity) { }
public WallAvoidance(IMovingEntity vehicle, IList<IWallEntity> walls) { this.walls = walls; this.movingEntity = vehicle; }
private List<Vector2D> CreateFeelers(IMovingEntity vehicle) { List<Vector2D> feelers = new List<Vector2D>(); var feelerLength = (vehicle.GetVelocity() * wallDetectionFeelerLengthMultiplier).GetLength(); //Feeler pointing straight in front feelers.Add(vehicle.GetPosition() + vehicle.GetHeading() * feelerLength); //Feeler to left Vector2D angle = movingEntity.GetHeading().Rotate((float)(Math.PI / 2) * WallAvoidance.WallDetectionFeelerAngle); feelers.Add(vehicle.GetPosition() + angle * (feelerLength) / 1.5f); //Feel to right angle = movingEntity.GetHeading().Rotate(-(float)(Math.PI / 2) * WallAvoidance.WallDetectionFeelerAngle); feelers.Add(vehicle.GetPosition() + angle * (feelerLength) / 1.5f); return feelers; }
public Flee(IMovingEntity entity, int multiplier = 1) { this.movingEntity = entity; this.PositionToFleeFrom = null; this.FleeingMultiplier = multiplier; }