Ejemplo n.º 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();
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 3
0
        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;
                }
            }
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 5
0
        // ------------нажат "СТОП"----------------
        private void stop_Click(object sender, EventArgs e)
        {
            // то же что при пуске, но наоборот
            UnlockInterface();
            AnimationTimer.Stop();
            TimerLabel.Text = "0,00 с";

            scene.dH = 0.0f;
            ticks    = 1;
            scene.render();
        }
Ejemplo n.º 6
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++;
            }
        }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
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);
     }
 }
Ejemplo n.º 9
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);
            }
        }
Ejemplo n.º 10
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();
                }
            }
        }