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>();
        }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
        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>();
 }
Esempio n. 7
0
 public Arrive(IMovingEntity movingEntity)
 {
     this.MovingEntity = movingEntity;
 }
Esempio n. 8
0
 public Cohesion(IMovingEntity movingEntity)
 {
     this.MovingEntity = movingEntity;
 }
Esempio n. 9
0
 public Alignment(IMovingEntity movingEntity)
 {
     this.MovingEntity = movingEntity;
 }
Esempio n. 10
0
 private void OnEnable()
 {
     movingEntity = GetComponent <IMovingEntity>();
 }
Esempio n. 11
0
 public Pursuit(IMovingEntity vehicle, IMovingEntity evader)
 {
     this.vehicle = vehicle;
     this.evader = evader;
 }
 public CurrentPosition(Graphics graphics, IMovingEntity movingEntity)
     : base(graphics, movingEntity)
 {
 }
Esempio n. 13
0
 public Separation(IMovingEntity movingEntity)
 {
     this.MovingEntity = movingEntity;
 }
 public DesiredVelocity(Graphics graphics, IMovingEntity movingEntity, Vector2D desired)
     : base(graphics, movingEntity)
 {
     this.desiredVector = desired;
 }
Esempio n. 15
0
 public Arrive(IMovingEntity movingEntity, Vector2D targetPosition)
 {
     this.MovingEntity = movingEntity;
     this.TargetPosition = targetPosition;
 }
Esempio n. 16
0
 public Seek(IMovingEntity entity, Vector2D targetPosition)
 {
     this.movingEntity = entity;
     this.TargetPosition = targetPosition;
 }
Esempio n. 17
0
 public PanicDistance(Graphics graphics, IMovingEntity movingEntity)
     : base(graphics, movingEntity)
 {
 }
Esempio n. 18
0
 public WallAvoidance(IMovingEntity vehicle, IList<IWallEntity> walls)
 {
     this.walls = walls;
     this.movingEntity = vehicle;
 }
Esempio n. 19
0
        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;
        }
Esempio n. 20
0
 public Flee(IMovingEntity entity, int multiplier = 1)
 {
     this.movingEntity = entity;
     this.PositionToFleeFrom = null;
     this.FleeingMultiplier = multiplier;
 }