Ejemplo n.º 1
0
 private void Start()
 {
     if (_vehicle != null)
     {
         _motor    = _vehicle.GetComponentInChildren <IMotor>();
         _steering = _vehicle.GetComponentInChildren <ISteering>();
     }
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
        public void Update(ISteering steering, float frametime)
        {
            Position += Velocity * frametime;

            Velocity += steering.GetLinearAcceleration() * frametime;

            if (Velocity.Length > MaxSpeed)
            {
                Velocity = Velocity.Normalized() * MaxSpeed;
            }
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
        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}");
            }
        }
Ejemplo n.º 7
0
    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;
    }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
    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());
    }
Ejemplo n.º 10
0
 public LeftRightInputManager(ISteering steering)
 {
     _steering = steering;
 }
Ejemplo n.º 11
0
 public Van(string brand, int numberOfSeats, int numberOfWheels, ColorType color, /*CarType type, */ ISteering steering)
     : base(brand, numberOfSeats, numberOfWheels, color, CarType.Van, steering)
 {
 }
Ejemplo n.º 12
0
 public SwipeInputManager(ISteering steering)
 {
     _steering = steering;
 }
Ejemplo n.º 13
0
 public void Init(SteeringManager steeringManager)
 {
     Self             = steeringManager.Self;
     _steeringManager = steeringManager;
     OnInit();
 }
Ejemplo n.º 14
0
 // Start is called before the first frame update
 void Start()
 {
     _sb = new Seek(player, transform, 3);
 }
Ejemplo n.º 15
0
 //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));
 }
Ejemplo n.º 16
0
 public FixedAgent(ISteering self)
 {
     _self = self;
 }
Ejemplo n.º 17
0
 public EditorInputManager(ISteering steering)
 {
     _steering = steering;
 }
Ejemplo n.º 18
0
 public SteeringManager(ISteering self)
 {
     Self            = self;
     _steeringResult = new SteeringResult();
 }