Beispiel #1
0
    void Update()
    {
        if (!Input.GetMouseButton(0))
        {
            _motorBike.Neutral();
            return;
        }

        if (Input.mousePosition.x > Screen.width / 2)
        {
            _motorBike.Accelerate();
        }
        else
        {
            _motorBike.Break();
        }
    }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("car: c");
            Car c = new Car();

            Console.WriteLine(c.IsOn);
            c.Start();
            c.SteerLeft();
            c.SteerRight();
            c.Reverse();
            c.Break();
            c.Stop();
            Console.WriteLine(c.IsOn);

            Console.WriteLine("motorbike: m");
            MotorBike m = new MotorBike();

            Console.WriteLine(m.IsOn);
            m.Start();
            m.SteerLeft();
            m.SteerRight();
            m.Break();
            m.Stop();
            Console.WriteLine(m.IsOn);

            Console.WriteLine("boat: b");
            Boat b = new Boat();

            Console.WriteLine(b.IsOn);
            b.Start();
            b.SteerLeft();
            b.SteerRight();
            b.Reverse();
            b.Stop();
            Console.WriteLine(b.IsOn);
        }
        static void Main(string[] args)
        {
            // NO NO can't have instances of an abstract class or interface
            //AutoMobile auto = new AutoMobile();

            Console.WriteLine("car");
            Car car = new Car(true);

            car.Start();
            car.SteerLeft();
            car.SteerRight();
            car.Steer(false);
            car.Steer(true);
            car.Reverse();
            car.Break();
            car.Stop();

            Console.WriteLine("moto");

            MotorBike moto = new MotorBike(true);

            moto.Start();
            moto.SteerLeft();
            moto.SteerRight();
            moto.Steer(false);
            moto.Steer(true);
            moto.Break();
            moto.Stop();

            Console.WriteLine("boat");

            Boat boat = new Boat(true);

            boat.Start();
            boat.SteerLeft();
            boat.SteerRight();
            boat.Steer(false);
            boat.Steer(true);
            boat.Reverse();
            boat.Stop();


            //Console.WriteLine("car car");
            //Car car = new Car();
            //Console.WriteLine(car.IsOn);
            //car.Start();
            //car.SteerLeft();
            //Console.WriteLine(car.IsOn);

            //// with private set doesn't work
            ////car.IsOn = false;

            //car.Stop();
            //Console.WriteLine(car.IsOn);

            //Console.WriteLine("motorbike moto");
            //MotorBike moto = new MotorBike();
            //moto.Start();
            //moto.SteerLeft();
            //Console.WriteLine(moto.IsOn);

            //Console.WriteLine("motorbike moto2");
            //MotorBike moto2 = new MotorBike(true);
            //Console.WriteLine(moto2.IsOn);
            //moto2.SteerLeft();
            //moto2.Stop();
            //Console.WriteLine(moto2.IsOn);
            //car.Steer(true);
            //moto.Steer(false);



            Console.ReadLine();
        }