Exemple #1
0
        // таймер анимации
        private void AnimationTimer_Tick(object sender, EventArgs e)
        {
            float time = ExpTimer.ElapsedMilliseconds / (1000.0f * TimeFactor);

            TimerLabel.Text = time.ToString("F2") + " с";

            Experiment.T.Add(time);
            Experiment.Vt.Add(Experiment.V(time));

            scene.dH = Experiment.H(time);

            if (scene.H0 - scene.dH <= 5.25f && !Experiment.FirstRingPassed)
            {
                Experiment.FirstRingPassed = true;
                Experiment.FirstRingTime   = time;
            }

            if (scene.H0 - scene.dH <= 1.25f && !Experiment.SecondRingPassed)
            {
                Experiment.SecondRingPassed = true;
                Experiment.SecondRingTime   = time;
            }

            if (scene.H0 - 0.1f <= scene.dH + R)
            {
                AnimationTimer.Stop();
                ExpTimer.Stop();
                ExpTimer.Reset();
                scene.dH = scene.H0 - 0.1f - R * 10;

                UnlockInterface();
                Graph.Enabled = true;
            }
            scene.render();
        }
Exemple #2
0
 private void GameForm_Paint(object sender, PaintEventArgs e)
 {
     if (gameStart)
     {
         text.Draw(e.Graphics, "Press space to start and pause" + "\n" + "Use the arrow keys to move around" + "\n" + "Mines reduce the amount of balls collected" + "\n" + "Collect 20 balls to level up", DisplayRectangle.Width / 3, DisplayRectangle.Height / 3);
     }
     text.Draw(e.Graphics, string.Format("Level: {0}", level), DisplayRectangle.Width - 200, 20);
     UpdateBallsCollected(e.Graphics);
     hippo.Draw(e.Graphics);
     foreach (Ball ball in balls)
     {
         ball.Draw(e.Graphics);
     }
     foreach (Mine mine in mines)
     {
         mine.Draw(e.Graphics);
     }
     if (paused)
     {
         text.Draw(e.Graphics, "PAUSED", DisplayRectangle.Width / 2, DisplayRectangle.Height / 2);
     }
     if (ballsCollected >= 20)//balls needed to level up
     {
         level++;
         ballsCollected = 0;
         maxMines      += 2;
         AnimationTimer.Stop();
         BallTimer.Stop();
         text.Draw(e.Graphics, "Level Up. Press Space For The Next level", DisplayRectangle.Width / 3, DisplayRectangle.Height / 2);
     }
 }
        private void OnTimerTick(object sender, EventArgs e)
        {
            const double fadePerTick = 0.075;

            if (Opacity < 1.0 && (_animationState == AnimationState.Opening || _animationState == AnimationState.Maximizing))
            {
                Opacity += fadePerTick;
            }
            else if (Opacity > 0.0 && (_animationState == AnimationState.Closing || _animationState == AnimationState.Minimizing))
            {
                Opacity -= fadePerTick;
            }
            else
            {
                AnimationTimer.Stop();
                switch (_animationState)
                {
                case AnimationState.Closing:
                    Dispose(true);
                    break;

                case AnimationState.Minimizing:
                    FormsContainer.MainForm.WindowState = FormWindowState.Minimized;
                    break;
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Releases all resources used by the <see cref="MapViewManager"/> object.</summary>
        /// <remarks><para>
        /// <b>Dispose</b> disposes of all <see cref="MapView"/> objects contained in the <see
        /// cref="MapViews"/> collection, stops the <see cref="AnimationTimer"/> if it is running,
        /// and finally calls <see cref="CatalogManager.Dispose"/> to dispose of the bitmap catalog
        /// and to set the <see cref="CatalogManager.IsDisposed"/> flag.
        /// </para><para>
        /// <b>Dispose</b> also resets the <see cref="Instance"/> property to a null reference,
        /// allowing the creation of another instance of the <see cref="MapViewManager"/> class.
        /// </para></remarks>

        public override void Dispose()
        {
            try {
                // guaranteed by CreateInstance
                Debug.Assert(Instance == this);

                // clear singleton reference
                Instance = null;

                // stop animation timer if running
                if (AnimationTimer != null)
                {
                    AnimationTimer.Stop();
                    AnimationTimer = null;
                }

                // close all active map views
                for (int i = 0; i < MapViews.Count; i++)
                {
                    MapView mapView = MapViews[i];
                    if (!mapView.IsDisposed)
                    {
                        mapView.Dispose();
                    }
                }

                this._mapViews.Clear();
            }
            finally {
                // complete disposal
                base.Dispose();
            }
        }
Exemple #5
0
        public float GetValue(float time, IAnimationTimer animationTimer, InterpolatorDelegate interpolator)
        {
            if (!this.keyframes.Any())
            {
                return(0);
            }

            KeyValuePair <float, float> minTime = this.keyframes.First();
            KeyValuePair <float, float> maxTime = this.keyframes.Last();

            float startTime = StartingTime;

            time = startTime + AnimationTimer.Value(time, FinishingTime - startTime);

            if (time <= minTime.Key)
            {
                return(minTime.Value);
            }

            if (time >= maxTime.Key)
            {
                return(maxTime.Value);
            }

            KeyValuePair <float, float> prevTime = this.keyframes.First(kf => kf.Key >= time);
            KeyValuePair <float, float> succTime = this.keyframes.First(kf => kf.Key > prevTime.Value);

            float dt = succTime.Key - prevTime.Key;
            float t  = (time - prevTime.Key) / dt;

            return(interpolator.Invoke(t, prevTime.Value, succTime.Value));
        }
        // ------------нажат "ПУСК"----------------
        private void start_Click_1(object sender, EventArgs e)
        {
            // отключаем интерфейс
            LockInterface();
            // запускаем таймер по которому будем перерисовывать сцену

            AnimationTimer.Start();
            Experiment = new Experiment(R, BallDensity, LiquidDensity, Viscosity);
        }
 private void OnResized(object sender, EventArgs e)
 {
     if (FormsContainer.MainForm.WindowState == FormWindowState.Normal &&
         _animationState == AnimationState.Minimizing)
     {
         FormsContainer.MainForm.WindowState = FormWindowState.Normal;
         _animationState = AnimationState.Maximizing;
         AnimationTimer.Start();
     }
 }
Exemple #8
0
 private void MSRTimerEventProcessor(Object myObject, EventArgs myEventArgs)
 {
     MSRTimer.Stop();
     //MessageBox.Show("Timer done");
     if (ProductCode == conf.Wash1Code || ProductCode == conf.Wash2Code)
     {
         AnimationPhase = 2;
         AnimationTimer.Start();
         WashPlayer.PlayLooping();
         (MainPage.Document.GetElementById("Plate")).InnerHtml = "Welcome " + dd.plate;
     }
     else if (true)//CheckAuth(cardtoauth, ActiveNozz, ref limit, ref type, ref plate, ref reason))
     {
         ps = PumpStatus.InUse;
         pup.ResetVol(conf.PumpAuthDelay);
         pup.SetStatus(ps, dd.limit, dd.type, dd.plate, conf.flowrate, -1);
         //AddToLogList(MsgLogType.Authorized, reason, 0, plate, limit, dd.cardnum);
         (MainPage.Document.GetElementById("Plate")).InnerHtml = "Welcome " + dd.plate;
         if (dd.type == "Money")
         {
             (MainPage.Document.GetElementById("Limit")).InnerHtml = dd.limit.ToString("0") + " " + conf.LimitPerMoneyText;
         }
         else
         {
             (MainPage.Document.GetElementById("Limit")).InnerHtml = dd.limit.ToString("0") + " " + conf.LimitPerVolText;
         }
     }
     else if (reason == "CPass required")
     {
         AddToLogList(MsgLogType.CheckCPass, reason, 0, plate, limit, cardtoauth);
         MSRTimer.Start();  //recheck in as few seconds
     }
     else if (reason == "CPass wait")
     {
         //AddToLogList(MsgLogType.CheckCPass, reason, 0, plate, limit, cardtoauth); //no second message
         if (CPassTry == conf.CPassRetry)
         {
             reason = "No mobile confirmation";
             if (statustouse != 0x30)
             {
                 AddToLogList(MsgLogType.CannotAuth, reason, 0, plate, limit, gotmsg.carddata);
             }
             return;
         }
         CPassTry++;
         MSRTimer.Start();  //recheck in as few seconds
     }
     else
     {
         if (statustouse != 0x30)
         {
             AddToLogList(MsgLogType.CannotAuth, reason, 0, plate, limit, gotmsg.carddata);
         }
     }
 }
        // ------------нажат "СТОП"----------------
        private void stop_Click(object sender, EventArgs e)
        {
            // то же что при пуске, но наоборот
            UnlockInterface();
            AnimationTimer.Stop();
            TimerLabel.Text = "0,00 с";

            scene.dH = 0.0f;
            ticks    = 1;
            scene.render();
        }
Exemple #10
0
        /// <summary>
        /// The logic implement movement of destroing asteroids and calculating using a timer
        /// This method chek if lives == 0 -> Game Over
        /// </summary>
        private void AnimationTimer_Tick(object sender, EventArgs e)
        {
            if (destroyedImageCounter > 1 && destroyed)
            {
                ExplodingAsteroid.Hide();
                destroyed             = false;
                destroyedImageCounter = 0;
            }
            else if (destroyed)
            {
                destroyedImageCounter++;
            }

            if (nukeCity && !destroyed)
            {
                if (nukeCloudCounter == 0)
                {
                    MissCounter();

                    if (missCount == 0)
                    {
                        AsteroidPositionTimer.Stop();
                        StartGame.IsStarted = false;

                        BombPB.Hide();
                        RedGift.Hide();
                        NukeCloud.Hide();
                        ExplodingAsteroid.Hide();
                        RocketPB.Hide();
                        RocketGift.Hide();
                        Lives.Hide();

                        GameOver.Show();
                    }

                    nukeCity           = true;
                    NukeCloud.Location = new Point(Bomb.X, Bomb.Y);
                    NukeCloud.Show();
                    PlaySound.PlayExplodeSound();

                    Bomb.Life = BombLife;
                    SpawnNewBomb();
                }
                else if (nukeCloudCounter > 10)
                {
                    NukeCloud.Hide();
                    AnimationTimer.Stop();
                    nukeCity = false;
                }

                nukeCloudCounter++;
            }
        }
Exemple #11
0
        // Инициализация
        private void Form1_Load(object sender, EventArgs e)
        {
            OpenGlInit();
            DevIlInit();
            AnimationTimer.Start();

            logger           = new StreamWriter("logger.txt", true);
            listener         = new MyListener();
            listener.output += (string s) => { logger.WriteLine(s); };

            controller = new Controller();
            controller.AddListener(listener);
        }
Exemple #12
0
        public override void OnActivate()
        {
            Debug.WriteLine($"{nameof(SplashScreenPageHandler)} OnActivate");

            _currentDisplayImageIndex = 0;

            _currentFadeStep = FadeStep.FadeIn;
            _fadeTimer       = CreateFadeTimer(_currentFadeStep);

            for (int i = 0; i < _splashScreenContents.Length; i++)
            {
                _splashScreenContents[i].Opacity = 0;
            }
            _loadingText.Text = null;
        }
 public void AddChar(string s)
 {
     if (Animation != null)
     {
         Animation.Stop();
     }
     if (AnimationTimer != null)
     {
         AnimationTimer.Stop();
     }
     Current.Children.Add(new TextBlock()
     {
         FontSize = 30, TextAlignment = TextAlignment.Center, Text = s, Width = 40
     });
     Animations.ShowWordAnimation(Current);
 }
Exemple #14
0
        private readonly string situation; /* Derecha o izquierda. */

        /* Función constructora de un flipper. */
        public Flipper(string situation, Vector position, double angle, FlipperData data)
        {
            /* Guardo algunas variables. */
            this.length = data.length;
            this.height = data.height;

            this.situation = String.Copy(situation);
            this.position  = position.Copy();
            this.angle     = angle;

            /* Inicializo los timers. */
            riseTimer = new AnimationTimer(25, "easeout");
            fallTimer = new AnimationTimer(175, "easein");

            /* Establezco ángulos mínimo y máximo. */
            this.minAngle = -Math.PI / 5;
            this.maxAngle = Math.PI / 5;

            /* Creo los vértices distinguiendo derecha e izquierda. */
            List <Vector> vertices  = new List <Vector>();
            Vector        direction = new Vector(Math.Cos(this.angle), Math.Sin(this.angle));

            direction.SetLength(this.length);
            Vector perp;

            if (this.situation == "left")
            {
                perp = direction.NewPositiveRotation(Math.PI / 2);
                perp.SetLength(this.height);
                Vector begin = Vector.Subtract(this.position, perp.NewWithLength(this.height / 2));
                vertices.Add(begin);
                vertices.Add(Vector.Sum(vertices[0], perp));
                vertices.Add(Vector.Sum(vertices[1], direction));
                vertices.Add(Vector.Subtract(vertices[2], perp));
            }
            else
            {
                perp = direction.NewNegativeRotation(Math.PI / 2);
                perp.SetLength(this.height);
                Vector begin = Vector.Sum(this.position, perp.NewWithLength(this.height / 2));
                vertices.Add(begin);
                vertices.Add(Vector.Subtract(vertices[0], perp));
                vertices.Add(Vector.Sum(vertices[1], direction));
                vertices.Add(Vector.Sum(vertices[2], perp));
            }
            this.polygon = new Polygon(vertices);
        }
Exemple #15
0
        public override void Update()
        {
            if (IsAnimationFinished)
            {
                return;
            }

            if (_currentDisplayImageIndex < _splashScreenContents.Length)
            {
                float dt = (float)Game.UpdateTime.Elapsed.TotalSeconds;
                _fadeTimer.Update(dt);
                var opacity = _currentFadeStep switch
                {
                    FadeStep.FadeIn => _fadeTimer.CompletionValueInDecimal * _fadeTimer.CompletionValueInDecimal,
                    FadeStep.Hold => 1,
                    FadeStep.FadeOut => (1 - _fadeTimer.CompletionValueInDecimal),
                    _ => 0,
                };
                _splashScreenContents[_currentDisplayImageIndex].Opacity = opacity;
                if (_fadeTimer.IsComplete)
                {
                    if (_currentFadeStep < FadeStep.Finished)
                    {
                        _currentFadeStep++;
                        if (_currentFadeStep == FadeStep.Finished)
                        {
                            _currentDisplayImageIndex++;
                            if (_currentDisplayImageIndex >= _splashScreenContents.Length)
                            {
                                _loadingText.Text = "Loading...";
                            }
                            else
                            {
                                _currentFadeStep = FadeStep.FadeIn;
                                _fadeTimer       = CreateFadeTimer(_currentFadeStep);
                            }
                        }
                        else
                        {
                            _fadeTimer = CreateFadeTimer(_currentFadeStep);
                        }
                    }
                }
            }
        }
Exemple #16
0
        public Form1()
        {
            InitializeComponent();

            this.StartPosition = FormStartPosition.CenterScreen;

            // Use DoubleBuffered to stop flickering at Refresh method
            this.DoubleBuffered = true;

            // Declare new game, setting game boundaries
            game = new Game(this.DisplayRectangle);

            // Start the animation timer straight away - animate stars and sets refreshing interval
            bitmap   = new Bitmap(this.Width, this.Height);
            graphics = Graphics.FromImage(bitmap);
            AnimationTimer.Interval = Parameters.animationTimerInterval;
            AnimationTimer.Start();
        }
Exemple #17
0
 /// <summary>
 /// Starts and Stops all of the game-play timers.
 /// </summary>
 /// <returns></returns>
 public bool StartPause()
 {
     if (!running)
     {
         AnimationTimer.Start();
         AsteroidTimer.Start();
         HealthTimer.Start();
         return(true);
     }
     else
     {
         AnimationTimer.Stop();
         AsteroidTimer.Stop();
         HealthTimer.Stop();
         Invalidate();
         return(false);
     }
 }
Exemple #18
0
        /// <summary>
        /// Logic implement Destroying a Bomb
        /// Hide unnecessary pictures
        /// Show destroing animation, reset the constants and spawn new bomb.
        /// </summary>
        private void DestroyBomb()
        {
            PlaySound.PlayExplodeSound();
            BombPB.Hide();
            RocketPB.Hide();
            LaserPB.Hide();

            ExplodingAsteroid.Left = BombPB.Left - 10;
            ExplodingAsteroid.Top  = BombPB.Top - 20;
            ExplodingAsteroid.Show();

            destroyed        = true;
            nukeCity         = false;
            Bomb.IsExploding = false;
            Rocket.IsFired   = false;
            Bomb.Life        = 3;

            SpawnNewBomb();
            ScoreCounter();
            AnimationTimer.Start();
        }
Exemple #19
0
        /// <summary>
        /// StartRestoreViewTo is a helper method that is called by ZoomExtentsWithGesture to
        /// return the viewport back to it's "home" view.
        /// </summary>
        private void StartRestoreViewTo(Rhino.DocObjects.ViewportInfo targetPosition)
        {
            if (Camera == null)
            {
                return;
            }

            IsInAnimatedRestoreView = true;

            View.UserInteractionEnabled = false;
            RestoreViewStartTime        = DateTime.Now;
            RestoreViewTotalTime        = new TimeSpan(0, 0, 0, 0, 500);

            RestoreViewStartViewport  = new ViewportInfo(Camera);            // start from current position
            RestoreViewFinishViewport = new ViewportInfo(targetPosition);    // end on the target position

            // fix frustum aspect to match current screen aspect
            RestoreViewFinishViewport.FrustumAspect = Camera.FrustumAspect;

            AnimationTimer = NSTimer.CreateScheduledTimer(0.0, this, new Selector("AnimateRestoreView"), null, true);
            AnimationTimer.Fire();
        }
Exemple #20
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (player.isTurd)
            {
                player.updateStatus(TURD_SCALAR);
            }
            else
            {
                player.updateStatus();
                if (player.getEnergy() >= -JOB_ENERGY_COST)
                {
                    ml_ene.Visible = true;
                }
                else
                {
                    ml_ene.Visible = false;
                }
            }
            if (player.getHunger() + player.getHygine() < 125)
            {
                ml_heart.Visible = true;
                Message.Visible  = true;
            }
            else
            {
                ml_heart.Visible = false;
                Message.Visible  = false;
            }
            if (player.getWallet() >= EAT_DOLLAR_COST)
            {
                ml_hung.Visible = true;
            }
            else
            {
                ml_hung.Visible = false;
            }

            if (player.getWallet() >= TEETH_BRUSH_DOLLAR_COST)
            {
                ml_hyg.Visible = true;
            }
            else
            {
                ml_hyg.Visible = false;
            }


            if (player.isDead)
            {
                player.death();
                AnimationTimer.Stop();
                StatusCheckTimer.Stop();
                Cat.Image     = Catagatchi.Properties.Resources.Tombstone;
                lblDeath.Text = "Your Wildcat lived for " + player.getAge().ToString() + " seconds";
            }
            if (finalStageStopWactch.ElapsedMilliseconds > STAGE_THREE_LENGTH && mode == 2)
            {
                AnimationTimer.Stop();
                StatusCheckTimer.Stop();
                winGame(player);
            }
            checkErrorMessages();
            if (mode == 1)
            {
                updateFields(stage2Watch);
            }
            else if (mode == 2)
            {
                updateFields(finalStageStopWactch);
            }
        }
Exemple #21
0
        /// <summary>
        /// Listens for keys pressed
        /// </summary>
        /// <param name="sender">key pressed object</param>
        /// <param name="e">Key event arguments</param>
        private void GameForm_KeyDown(object sender, KeyEventArgs e)
        {
            if (AnimationTimer.Enabled)
            {
                switch (e.KeyData)
                {
                case Keys.Left:
                {
                    if (!KeyList.Contains(Keys.Left))
                    {
                        KeyList.Add(Keys.Left);
                    }
                    break;
                }

                case Keys.Right:
                {
                    if (!KeyList.Contains(Keys.Right))
                    {
                        KeyList.Add(Keys.Right);
                    }
                    break;
                }

                case Keys.Up:
                {
                    if (!KeyList.Contains(Keys.Up))
                    {
                        KeyList.Add(Keys.Up);
                    }
                    break;
                }

                case Keys.Down:
                {
                    if (!KeyList.Contains(Keys.Down))
                    {
                        KeyList.Add(Keys.Down);
                    }
                    break;
                }
                }
            }

            if (e.KeyData == Keys.Space)
            {
                if (gameStart)
                {
                    gameStart = false;
                }

                if (AnimationTimer.Enabled)
                {
                    paused = true;
                    AnimationTimer.Stop();
                    BallTimer.Stop();
                    Invalidate();
                }
                else
                {
                    paused = false;

                    AnimationTimer.Start();
                    BallTimer.Start();
                }
            }
        }
Exemple #22
0
        private void AnimateRestoreView()
        {
            FastDrawing = true;
            var restoreViewCurrentTime = DateTime.Now;

            var    currentTime              = restoreViewCurrentTime;
            var    startTime                = RestoreViewStartTime;
            var    timeElapsed              = currentTime.Subtract(startTime);
            var    timeElapsedInMs          = timeElapsed.TotalMilliseconds;
            var    totalTimeOfAnimationInMs = RestoreViewTotalTime.TotalMilliseconds;
            double percentCompleted         = timeElapsedInMs / totalTimeOfAnimationInMs;

            if (percentCompleted > 1)
            {
                // Animation is completed. Perform one last draw.
                percentCompleted            = 1;
                IsInAnimatedRestoreView     = false;
                View.UserInteractionEnabled = true;
                CameraIsAtInitialPosition   = !ShouldStartRestoreToInitialPosition;
                AnimationTimer.Invalidate();
            }

            // Get some data from the starting view
            Rhino.Geometry.Point3d sourceTarget = RestoreViewStartViewport.TargetPoint;
            Rhino.Geometry.Point3d sourceCamera = RestoreViewStartViewport.CameraLocation;
            double sourceDistance = sourceCamera.DistanceTo(sourceTarget);

            Rhino.Geometry.Vector3d sourceUp = RestoreViewStartViewport.CameraUp;
            sourceUp.Unitize();

            // Get some data from the ending view
            Rhino.Geometry.Point3d targetTarget = RestoreViewFinishViewport.TargetPoint;
            Rhino.Geometry.Point3d targetCamera = RestoreViewFinishViewport.CameraLocation;
            double targetDistance = targetCamera.DistanceTo(targetTarget);

            Rhino.Geometry.Vector3d targetCameraDir = targetCamera - targetTarget;
            Rhino.Geometry.Vector3d targetUp        = RestoreViewFinishViewport.CameraUp;
            targetUp.Unitize();

            // Adjust the target camera location so that the starting camera to target distance
            // and the ending camera to target distance are the same.  Doing this will calculate
            // a constant rotational angular momentum when tweening the camera location.
            // Further down we independently tween the camera to target distance.
            targetCameraDir.Unitize();
            targetCameraDir *= sourceDistance;
            targetCamera     = targetCameraDir + targetTarget;

            // calculate interim viewport values
            double frameDistance = ViewportInfoExtensions.CosInterp(sourceDistance, targetDistance, percentCompleted);

            Rhino.Geometry.Point3d frameTarget = new Rhino.Geometry.Point3d();

            frameTarget.X = ViewportInfoExtensions.CosInterp(sourceTarget.X, targetTarget.X, percentCompleted);
            frameTarget.Y = ViewportInfoExtensions.CosInterp(sourceTarget.Y, targetTarget.Y, percentCompleted);
            frameTarget.Z = ViewportInfoExtensions.CosInterp(sourceTarget.Z, targetTarget.Z, percentCompleted);

            var origin = Rhino.Geometry.Point3d.Origin;

            Rhino.Geometry.Point3d  frameCamera    = origin + (ViewportInfoExtensions.Slerp((sourceCamera - origin), (targetCamera - origin), percentCompleted));
            Rhino.Geometry.Vector3d frameCameraDir = frameCamera - frameTarget;

            // adjust the camera location along the camera direction vector to preserve the target location and the camera distance
            frameCameraDir.Unitize();
            frameCameraDir *= frameDistance;
            frameCamera     = frameCameraDir + frameTarget;

            Rhino.Geometry.Vector3d frameUp = new Rhino.Geometry.Vector3d(ViewportInfoExtensions.Slerp(sourceUp, targetUp, percentCompleted));

            if (percentCompleted >= 1)
            {
                // put the last redraw at the exact end point to eliminate any rounding errors
                Camera.SetTarget(RestoreViewFinishViewport.TargetPoint, RestoreViewFinishViewport.CameraLocation, RestoreViewFinishViewport.CameraUp);
            }
            else
            {
                Camera.SetTarget(frameTarget, frameCamera, frameUp);
            }

            SetFrustum(Camera, App.Manager.CurrentModel.BBox);

            View.SetNeedsDisplay();

            if (!IsInAnimatedRestoreView)
            {
                // FastDrawing is still enabled and we just scheduled a draw of the model at the final location.
                // This entirely completes the animation. Now schedule one more redraw of the model with FastDrawing disabled
                // and this redraw will be done at exactly the same postion.  This prevents the final animation frame
                // from jumping to the final location because the final draw will take longer with FastDrawing disabled.
                PerformSelector(new Selector("RedrawDetailed"), null, 0.05);
            }
        }
Exemple #23
0
        /// <summary>
        /// The logic implement movement of gifts and asteroids and calculating using a timer
        /// </summary>
        private void AsteroidPositionTimer_Tick(object sender, EventArgs e)
        {
            /// <summary>
            /// Stop timer, when the game is not start with start buton
            /// </summary>
            if (!StartGame.GameIsStarted())
            {
                AsteroidPositionTimer.Stop();
            }

            /// <summary>
            /// If an asteroid and a gift appear at the same place, new coordinates are calculated
            /// </summary>
            if (Gift.ContentShowTyme > 0)
            {
                Gift.ContentShowTyme--;

                if (Gift.ContentShowTyme == 0)
                {
                    RocketGift.Hide();
                    DashboardGiftLabel.Hide();
                }
            }

            /// <summary>
            /// Look Rocket.cs class
            /// </summary>
            if (Rocket.IsFired)
            {
                Rocket.Move(RocketPB);
            }

            /// <summary>
            /// Chek count laser hits on asteroid and when asteroid is dead, hide Laser from the screen.
            /// </summary>
            if (Laser.TimeCounter > 0)
            {
                Laser.TimeCounter--;
            }
            else
            {
                LaserPB.Hide();
            }

            /// <summary>
            /// If asteroid is hiting by laser or rocket, we destroying him.
            /// </summary>
            if (Bomb.IsExploding)
            {
                DestroyBomb();
            }

            /// <summary>
            /// Set new coordinates on asteroid and show bomb.
            /// </summary>
            Bomb.Y         += 7;
            BombPB.Location = new Point(Bomb.X, Bomb.Y);
            BombPB.Show();

            /// <summary>
            /// Chek coordinates and explode asteroid random on screen.
            /// </summary>
            if (Bomb.Y >= rnd.Next(380, 470) && !Bomb.IsExploding)
            {
                nukeCity         = true;
                nukeCloudCounter = 0;
                AnimationTimer.Start();
            }

            /// <summary>
            /// If gift is hiting by laser or rocket, we destroying him.
            /// </summary>
            if (Gift.IsExploding)
            {
                DestroyGift();
            }

            /// <summary>
            /// Logic encompasses the movement and the disappearance of the gift when it's not hiting.
            /// </summary>
            if (isGiftVisible)
            {
                if (Gift.Y >= 700)
                {
                    isGiftVisible = false;
                    RedGift.Hide();
                }
                else
                {
                    Gift.Y          += 5;
                    RedGift.Location = new Point(Gift.X, Gift.Y);
                }
            }
            else
            {
                isGiftVisible = rnd.Next(0, 50) == 1;

                if (isGiftVisible)
                {
                    SpawnGift();
                }
            }
        }
Exemple #24
0
        private void ShowMSRProgress(MSRStatusData msg)
        {
            Thread.BeginCriticalRegion();

            try
            {
                if (msg.status == -1)
                {
                    AddToLogList(MsgLogType.MSRCommError, "", 0, "", 0, msg.carddata);
                    return;
                }


                if ((ProductCode == conf.Wash1Code || ProductCode == conf.Wash2Code) && msg.msg == MsgLogType.MSRWrongProduct) //we are in wash?
                {
                    if (ProductCode == conf.Wash1Code)
                    {
                        Wash1Clicked(); //simulate relese
                    }
                    else
                    {
                        Wash2Clicked();
                    }
                }

                if (msg.msg != MsgLogType.MSRAuth) //just update the status
                {
                    AddToLogList(msg.msg, msg.ErrorDesc, 1, msg.DriverName, msg.Limit, msg.carddata);
                    msgSaved = null;
                    return;
                }

                if (ProductCode == conf.Wash1Code || ProductCode == conf.Wash2Code) //we are in wash?
                {
                    AnimationPhase = 2;
                    WashInProgress = true;
                    AnimationTimer.Start();
                    WashPlayer.PlayLooping();
                    (MainPage.Document.GetElementById("Plate")).InnerHtml = "Welcome " + msg.DriverName;
                    lastamount = 490;  //wash price
                    lastvol    = 0;
                    bool          found     = false;
                    MyProductItem itemfound = null;
                    foreach (MyProductItem item in msg.ProductsList)
                    {
                        if (item.Code == ProductCode)
                        {
                            found     = true;
                            itemfound = item;
                            break;
                        }
                    }
                    if (found)
                    {
                        //check discount
                        if (itemfound.DiscountType == "%")
                        {
                            lastamount = lastamount * (1 - itemfound.Discount / 100);
                            (MainPage.Document.GetElementById("Discount")).InnerHtml = "Discount " + itemfound.Discount.ToString("00") + "%";
                        }
                        else
                        {
                            lastamount = lastamount - itemfound.Discount;
                            (MainPage.Document.GetElementById("Discount")).InnerHtml = "Discount " + itemfound.Discount.ToString("00") + "c";
                        }
                    }
                    return;
                }

                //we got authorization check if pump is ready

                switch (ps)
                {
                case PumpStatus.Idle:
                    AddToLogList(msg.msg, msg.ErrorDesc, 1, msg.DriverName, msg.Limit, msg.carddata);
                    AddToLogList(MsgLogType.MSRSSelectProduct, "", 0, "", 0, "");
                    //save auth data
                    msgSaved = msg;

                    break;

                case PumpStatus.Call:
                    AddToLogList(msg.msg, msg.ErrorDesc, 1, msg.DriverName, msg.Limit, msg.carddata);
                    if (msg.msg == MsgLogType.MSRAuth)
                    {
                        dd         = new DeviceData();
                        dd.bCPass  = false;
                        dd.cardnum = msg.carddata;
                        dd.limit   = msg.Limit;
                        dd.plate   = msg.DriverName;
                        dd.type    = msg.LimitType;
                        dd.bCPass  = msg.CPassRequired;
                        MobileRes  = "None";
                        CPassTry   = 0;
                        MsgID++;
                        //find the product discount
                        bool          found     = false;
                        MyProductItem itemfound = null;
                        foreach (MyProductItem item in msg.ProductsList)
                        {
                            if (item.Code == ProductCode)
                            {
                                found     = true;
                                itemfound = item;
                                break;
                            }
                        }
                        if (found)
                        {
                            //check limit type
                            if (itemfound.DiscountType == "%")
                            {
                                UpdatePPVPrecent(itemfound.Discount);
                                (MainPage.Document.GetElementById("Discount")).InnerHtml = "Discount " + itemfound.Discount.ToString("00") + "%";
                            }
                            else
                            {
                                UpdatePPVAbs(itemfound.Discount);
                                (MainPage.Document.GetElementById("Discount")).InnerHtml = "Discount " + itemfound.Discount.ToString("00") + "c";
                            }
                        }

                        MSRTimer.Start();
                    }

                    break;
                }
            }
            catch (Exception ex)
            {
                //  MessageBox.Show(ex.Message);
            }
            finally
            {
                Thread.EndCriticalRegion();
            }
        }
 private void OnMinimizeButtonClicked(object sender, EventArgs e)
 {
     _animationState = AnimationState.Minimizing;
     AnimationTimer.Start();
 }
Exemple #26
0
        void createCanvas
            (List <ExtendedBitmap> movie, Point point, out Canvas canvas, out World world)
        {
            if (this.прозрачностьToolStripMenuItem.Checked || this.прозрачностьТеньToolStripMenuItem.Checked)
            {
                movie = movie.ConvertAll <ExtendedBitmap>(
                    delegate(ExtendedBitmap exBm)
                {
                    exBm      = exBm.Clone();
                    Bitmap bm = exBm.Bm;
                    ColorPalette tempPalette = bm.Palette;
                    if (tempPalette.Entries.Length >= 255)
                    {
                        if (this.прозрачностьToolStripMenuItem.Checked)
                        {
                            tempPalette.Entries[0] = Color.Transparent;
                        }
                        if (this.прозрачностьТеньToolStripMenuItem.Checked)
                        {
                            tempPalette.Entries[254] = Color.Transparent;
                        }
                        bm.Palette = tempPalette;
                    }
                    return(exBm);
                });
            }

            List <ExtendedBitmap> tileMovie = new List <ExtendedBitmap>();

            //foreach (ExtendedBitmap exBm in movie)
            if (this.отрисовыватьТайлToolStripMenuItem.Checked)
            {
                tileMovie.Add(new ExtendedBitmap(dotNetStiEditor.Properties.Resources.Tile, 0, 0));
            }
            else
            {
                tileMovie.Add(new ExtendedBitmap(new Bitmap(1, 1), 0, 0));
            }
            canvas        = new Canvas(movie);
            TileCanvas    = new Canvas(tileMovie);
            world         = new World();
            this.graphics = this.pictureBox1.CreateGraphics();
            world.CreateViewport(pictureBox1, this.graphics, point,
                                 new Rectangle(point, new Size((pictureBox1.Width - 30) / 2, pictureBox1.Height)),
                                 pictureBox1.Image, this.прозрачностьToolStripMenuItem.Checked);

            world.AddSprite(TileCanvas, new Point(), 0, 15, false, false);
            world.AddSprite(canvas, point, 0, 15, false, true);
            Sprite         sprite       = world.Library.Item(1);
            ExtendedBitmap firstExBm    = canvas.PictureFile[0];
            Point          tilePosition = sprite.TilePosition;

            if (firstExBm.ApplicationData != null)
            {
                tilePosition.Offset(-20, -10);
            }

            world.Library.Item(0).oPosition = tilePosition;

            this.FPSScroll.Value = 15;
            textBox2.Text        = "15";

            FPStimer.Start();
            timer.Start();
            AnimationTimer.Start();
            world.RequestRendering(0);
            world.RequestRendering(1);
        }
 private void PlayCloseAnimation()
 {
     _animationState = AnimationState.Closing;
     AnimationTimer.Start();
 }
 private void PlayOpenAnimation()
 {
     Opacity         = 0.0;
     _animationState = AnimationState.Opening;
     AnimationTimer.Start();
 }
Exemple #29
0
 private void InitialiseTimer()
 {
     m_Timer = new AnimationTimer();
 }