private void Start() { if (_vehicle != null) { _motor = _vehicle.GetComponentInChildren <IMotor>(); _steering = _vehicle.GetComponentInChildren <ISteering>(); } }
public Car(string brand, int numberOfSeats, int numberOfWheels, ColorType color, CarType type, ISteering steering) { Brand = brand; NumberOfSeats = numberOfSeats; NumberOfWheels = numberOfWheels; Color = color; Type = type; Steering = steering; }
public void Update(ISteering steering, float frametime) { Position += Velocity * frametime; Velocity += steering.GetLinearAcceleration() * frametime; if (Velocity.Length > MaxSpeed) { Velocity = Velocity.Normalized() * MaxSpeed; } }
public static Car CreateCar(CarType type, string brand, int numberOfSeats, int numberOfWheels, ColorType color, SteeringType steeringType) { Car carToReturn = null; ISteering steering = null; // Hvilken styring skal bruges switch (steeringType) { case SteeringType.SteeringWheel: steering = new SteeringWheel(); break; case SteeringType.Brain: steering = new Brain(); break; case SteeringType.Joystick: steering = new Joystick(); break; default: throw new Exception("SteeringType ikke valgt korrekt"); } // Hvilken biltype switch (type) { case CarType.Personal: carToReturn = new Personal(brand, numberOfSeats, numberOfWheels, color, steering); break; case CarType.SUV: carToReturn = new SUV(brand, numberOfSeats, numberOfWheels, color, steering); break; case CarType.Van: carToReturn = new Van(brand, numberOfSeats, numberOfWheels, color, steering); break; case CarType.Truck: carToReturn = new Truck(brand, numberOfSeats, numberOfWheels, color, steering); break; case CarType.Bus: carToReturn = new Bus(brand, numberOfSeats, numberOfWheels, color, steering); break; default: throw new Exception("CarType ikke valgt korrekt"); } return(carToReturn); }
public Car(IWheel frontLeft, IWheel frontRight, IWheel rearLeft, IWheel rearRight, ISteering steering, IDriving driving, IManufacturer manufacturer, string carName) { this.FrontLeft = frontLeft; this.FrontRight = frontRight; this.RearLeft = rearLeft; this.RearRight = rearRight; this.Steering = steering; this.Driving = driving; this.Manufacturer = manufacturer; this.Name = carName; }
private void Start() { _rigidbody = GetComponentInParent <Rigidbody>(); _steering = _rigidbody.transform.GetComponentInChildren <ISteering>(); _initialMinTurningRadius = _steering?.GetMinTurningRadius() ?? 0; if (_rigidbody == null) { Debug.LogWarning($"Missing {nameof(Rigidbody)} in parent of {transform.name}"); } if (_steering == null) { Debug.LogWarning($"Missing {nameof(ISteering)} in children of {transform.name}"); } }
public override void SetWayPoints(List <Node> newPoints, Vector3 finalPos) { if (newPoints.Count == 0) { return; } waypoints = newPoints; _finalPos = finalPos; _nextPoint = 0; var pos = waypoints[_nextPoint].transform.position; pos.y = transform.position.y; _sb = new ObstacleAvoidance(transform, waypoints[_nextPoint].transform, obstacleDistance, avoidWeight, _avoidLayer); _lastConnection = false; _readyToMove = true; }
public static void InitializeSteering() { face = new Face(0.1f, 2, 0.1f); arriveGraze = new Arrive(120, 100, 0.1f); arriveBush = new Arrive(50, 30, 2f); bushSeparation = new Separation(40); velocityMatch = new VelocityMatch(0.1f); separationFromDeer = new Separation(75); separationFromHunter = new Separation(300); separationFromLion = new Separation(300); lookWhereGoing = new LookWhereYourGoing(0.1f, 2, 0.1f); flee200 = new Flee(200, 10, 0.1f); cohesion = new Cohesion(50, 25, 50, 0.1f); cohesionGraze = new Cohesion(300, 100, 75, 0.1f); seek = new Seek(10, 50, 0.1f); seekPounce = new Seek(10, 20, 0.1f); wander = new Wander(50, 10, 0.1f, 0.1f, 1, 0.1f); eatWander = new Wander(50, 30, 0.1f, 1, 10, 0.01f); pursue = new Pursue(3, 4, 1, 0.1f); }
public override void Run() { var point = waypoints[_nextPoint]; var posPoint = point.transform.position; posPoint.y = transform.position.y; Vector3 dir; if (!_lastConnection) { dir = posPoint - transform.position; } else { dir = _finalPos - transform.position; } if (dir.magnitude < nextWaypointDistance) { if (!_lastConnection) { if (_nextPoint + 1 < waypoints.Count) { _nextPoint++; _sb = new ObstacleAvoidance(transform, waypoints[_nextPoint].transform, obstacleDistance, avoidWeight, _avoidLayer); } else if (_nextPoint + 1 >= waypoints.Count) { _lastConnection = true; _sb = new ObstacleAvoidance(transform, _finalPos, obstacleDistance, avoidWeight, _avoidLayer); } } } _model.Move(dir.normalized + _sb.GetDir()); }
public LeftRightInputManager(ISteering steering) { _steering = steering; }
public Van(string brand, int numberOfSeats, int numberOfWheels, ColorType color, /*CarType type, */ ISteering steering) : base(brand, numberOfSeats, numberOfWheels, color, CarType.Van, steering) { }
public SwipeInputManager(ISteering steering) { _steering = steering; }
public void Init(SteeringManager steeringManager) { Self = steeringManager.Self; _steeringManager = steeringManager; OnInit(); }
// Start is called before the first frame update void Start() { _sb = new Seek(player, transform, 3); }
//public Vector3d PredictFutureDesiredPosition(ISteering agent, long predictionTime) //{ // return agent.Position + (agent.Velocity * predictionTime); //} public Vector3 PredictFutureDesiredPosition(ISteering agent, float predictionTime) { return(agent.Position.ToVector3() + (agent.Velocity.ToVector3() * predictionTime)); }
public FixedAgent(ISteering self) { _self = self; }
public EditorInputManager(ISteering steering) { _steering = steering; }
public SteeringManager(ISteering self) { Self = self; _steeringResult = new SteeringResult(); }