Exemplo n.º 1
0
        public async Task LoadGameAsync(String path)
        {
            Pair panelSize       = new Pair(0, 0);
            Pair motorDimension  = new Pair(0, 0);
            Pair petrolDimension = new Pair(0, 0);
            AccelerationGameModel model;

            if (m_dataAccess == null)
            {
                throw new InvalidOperationException("No data access is provided.");
            }

            model = await m_dataAccess.LoadAsync(path);

            m_panelSize  = model.m_panelSize;
            m_motorCycle = model.m_motorCycle;
            m_motorCycle.m_coordinates.m_x = model.m_motorCycle.m_coordinates.m_x;
            m_motorCycle.m_coordinates.m_y = model.m_motorCycle.m_coordinates.m_y;
            m_petrolsList = model.m_petrolsList;
            m_time        = model.m_time;
            m_speed       = model.m_speed;
            m_counter     = model.m_counter;
            On_RefreshTimeAndPetrol();
            On_RefreshMotorPosition();
        }
Exemplo n.º 2
0
        public void NewGame()
        {
            Pair coordinates = new Pair(m_panelSize.m_x - m_motorDimension.m_x, m_panelSize.m_y / 2 - m_motorDimension.m_y / 2);

            m_motorCycle = new MotorCycleObject(coordinates, m_motorDimension);
            if (this.RefreshMotorPosition != null)
            {
                this.RefreshMotorPosition(this, new AccelerationEventArgs(m_motorCycle.m_coordinates, m_motorCycle.m_dimensions));
            }

            m_motorCycle.m_petrolQuantity = 1000;
            m_motorCycle.m_consumption    = 1;
            m_speed   = 10;
            m_counter = 0;
            m_petrolsList.Clear();
            m_time = 0;
            if (m_ticker != null)
            {
                m_ticker.Stop();
            }

            if (m_timer != null)
            {
                m_timer.Stop();
            }

            if (m_timerOfMoving != null)
            {
                m_timerOfMoving.Stop();
            }

            if (m_accelerationTime != null)
            {
                m_accelerationTime.Stop();
            }
            m_ticker.Interval           = TimeSpan.FromSeconds(1);
            m_timer.Interval            = TimeSpan.FromSeconds(3);
            m_timerOfMoving.Interval    = TimeSpan.FromSeconds(1);
            m_accelerationTime.Interval = TimeSpan.FromMilliseconds(100);

            m_accelerationTime.Stop();
            m_accelerationTime.Start();

            m_ticker.Stop();
            m_ticker.Start();

            m_timerOfMoving.Stop();
            m_timerOfMoving.Start();

            m_timer.Stop();
            m_timer.Start();
            On_RefreshTimeAndPetrol();
        }
Exemplo n.º 3
0
        public void NewGame()
        {
            m_speed   = 10;
            m_counter = 0;
            Debug.WriteLine(m_speed);
            Debug.WriteLine(m_counter);
            m_petrolsList.Clear();
            Pair coordinates = new Pair(m_panelSize.m_x - m_motorDimension.m_x, m_panelSize.m_y / 2 - m_motorDimension.m_y / 2);

            m_motorCycle = new MotorCycleObject(coordinates, m_motorDimension);
            m_time       = 0;
            if (m_ticker != null)
            {
                m_ticker.Stop();
            }

            if (m_timer != null)
            {
                m_timer.Stop();
            }

            if (m_timerOfMoving != null)
            {
                m_timerOfMoving.Stop();
            }

            if (m_accelerationTime != null)
            {
                m_accelerationTime.Stop();
            }

            m_ticker.Interval           = 1000;
            m_timer.Interval            = 3000;
            m_timerOfMoving.Interval    = 1000;
            m_accelerationTime.Interval = 100;

            m_accelerationTime.Stop();
            m_accelerationTime.Start();

            m_ticker.Stop();
            m_ticker.Start();

            m_timerOfMoving.Stop();
            m_timerOfMoving.Start();

            m_timer.Stop();
            m_timer.Start();
            On_RefreshTimeAndPetrol();
        }
Exemplo n.º 4
0
        public AccelerationGameModel(IAccelerationDataAccess dataAccess, Pair panelSize, Pair motorDimension, Pair petrolDimension)
        {
            m_dataAccess                = dataAccess;
            m_panelSize                 = panelSize;
            m_motorDimension            = motorDimension;
            m_petrolDimension           = petrolDimension;
            m_timer                     = new DispatcherTimer();
            m_timerOfMoving             = new DispatcherTimer();
            m_ticker                    = new DispatcherTimer();
            m_accelerationTime          = new DispatcherTimer();
            m_ticker.Tick              += On_SecTicking;
            m_timer.Tick               += On_NewPetrol;
            m_accelerationTime.Tick    += On_PetrolMoving;
            m_ticker.Tick              += On_DecreaseFuel;
            m_ticker.Interval           = TimeSpan.FromSeconds(1);
            m_timer.Interval            = TimeSpan.FromSeconds(3);
            m_timerOfMoving.Interval    = TimeSpan.FromSeconds(1);
            m_accelerationTime.Interval = TimeSpan.FromMilliseconds(100);
            Pair coordinates = new Pair(m_panelSize.m_x - m_motorDimension.m_x, m_panelSize.m_y / 2 - m_motorDimension.m_y / 2);

            m_motorCycle = new MotorCycleObject(coordinates, m_motorDimension);
            stepQuantity = 10;
            m_loading    = false;
        }