private void restart()
        {
            levelcounter.Text = Level.ToString();

            if (Level >= 1)
            {
                //this sets the ships at level 1 and above to be at their default positions
                enemyship1.Location   = new Point(21, 12);
                enemyship2.Location   = new Point(131, 12);
                enemyship3.Location   = new Point(257, 12);
                enemyship4.Location   = new Point(380, 12);
                enemyship1.Visible    = true;
                enemyship2.Visible    = true;
                enemyship3.Visible    = true;
                enemyship4.Visible    = true;
                enemybullet1.Visible  = true;
                enemybullet2.Visible  = true;
                enemybullet3.Visible  = true;
                enemybullet4.Visible  = true;
                enemybullet1.Location = enemyship1.Location;
                enemybullet2.Location = enemyship2.Location;
                enemybullet3.Location = enemyship3.Location;
                enemybullet4.Location = enemyship4.Location;
            }
            if (Level > 1)
            {
                // after level one, two more ships appear at their default positions
                enemyship5.Location   = new Point(459, 100);
                enemyship6.Location   = new Point(597, 100);
                enemybullet5.Location = enemyship5.Location;
                enemybullet6.Location = enemyship6.Location;

                enemyship5.Visible   = true;
                enemyship6.Visible   = true;
                enemybullet5.Visible = true;
                enemybullet6.Visible = true;
                // this background image for level 2 is set in this conditon
                if (Level == 2)
                {
                    Image myimage = new Bitmap(@"bg2.png");
                    this.BackgroundImage = myimage;
                }
                // this background image for level 3 is set in this conditon

                if (Level == 3)
                {
                    Image myimage = new Bitmap(@"bg3.png");
                    this.BackgroundImage = myimage;
                }
            }
            scorecounter.Visible  = false;
            scorelabel.Visible    = false;
            gameoverlabel.Visible = false;
            heroship1.Visible     = true;
            laser.Visible         = true;
            randint.Start();
            enemyshiptimer.Start();
            MainButton.Visible = false;
            PlayTimer.Start();
        }
Beispiel #2
0
 public TBoard()
 {
     InitializeComponent();
     MouseWheel    += MakeZoom;
     DoubleBuffered = true;
     PlayTimer.Start();
 }
Beispiel #3
0
        private void ScoreTimer_Tick(object sender, EventArgs e)
        {
            scoreLabel.Text      = myscore.ToString();
            TaikoCountLabel.Text = taikocount.ToString();

            if (taikocount == 100)
            {
                Taikotimer.Stop();
                HitSecondsTimer.Stop();
                ScoreTimer.Stop();

                /*System.Media.SoundPlayer player = new System.Media.SoundPlayer();
                 * //player.SoundLocation = @"C:\Users\acer\Desktop\Things\Music\wav\My Dearest.wav";
                 * player.Stop();
                 * player.Dispose();*/


                Taiko1.Visible   = false;
                Taiko2.Visible   = false;
                Taiko3.Visible   = false;
                Taiko4.Visible   = false;
                HitTaiko.Visible = false;
                owari.Visible    = true;
                endtime          = 0;
                PlayTimer.Stop();
            }
        }
Beispiel #4
0
 public Form1()
 {
     InitializeComponent();
     tBoard1.Game.Timer = PlayTimer;
     tBoard1.Scroll    += TBoard1_Scroll;
     PlayTimer.Start();
 }
        private void GameOver()
        {
            this.ActiveControl    = null;
            heroship1.Visible     = false;
            laser.Visible         = false;
            scorelabel.Visible    = true;
            scorecounter.Visible  = true;
            gameoverlabel.Visible = true;
            enemybullet1.Visible  = false;
            enemybullet2.Visible  = false;
            enemybullet3.Visible  = false;
            enemybullet4.Visible  = false;
            enemybullet5.Visible  = false;
            enemybullet6.Visible  = false;



            calcscore();
            aggregatescore   += levelscore;
            scorecounter.Text = aggregatescore.ToString();


            PlayTimer.Stop();
            bosstimer.Stop();

            enemyshiptimer.Stop();

            if (herohealth > 0 && Level == 3)
            {
                gameoverlabel.Text = "Congrats! Welcome Back to Earth!";
                MainButton.Text    = "Back To Menu";
                MainButton.Visible = true;
            }
            else if (herohealth == 0)
            {
                gameoverlabel.Text = "Game Over";
                MainButton.Text    = "Back to Menu";
                enemyship1.Visible = false;
                enemyship2.Visible = false;
                enemyship3.Visible = false;
                enemyship4.Visible = false;
                enemyship5.Visible = false;
                enemyship6.Visible = false;
            }
            else if (herohealth > 0)
            {
                gameoverlabel.Text = "Good Job!";
                Level++;
                MainButton.Text   = "Next Level";
                levelcounter.Text = Level.ToString();
            }
            PlayTimer.Stop();
            randint.Stop();


            MainButton.Visible = true;
        }
        private void GameOver()
        {
            // this takes the activecontrol away from the hero ship
            this.ActiveControl = null;
            heroship1.Visible  = false;
            laser.Visible      = false;
            // allows the score and scorecounter as wel as the game over label to be displayed
            scorelabel.Visible    = true;
            scorecounter.Visible  = true;
            gameoverlabel.Visible = true;
            enemybullet1.Visible  = false;
            enemybullet2.Visible  = false;
            enemybullet3.Visible  = false;
            enemybullet4.Visible  = false;
            enemybullet5.Visible  = false;
            enemybullet6.Visible  = false;

            calcscore();
            A_Journey_Home.Variables.aggregatescore += levelscore;
            scorecounter.Text = A_Journey_Home.Variables.aggregatescore.ToString();
            // stops all the timers in the game
            PlayTimer.Stop();
            bosstimer.Stop();
            enemyshiptimer.Stop();

            // puts the game over label for the final level completion
            if (A_Journey_Home.Variables.herohealth > 0 && Level == 3)
            {
                gameoverlabel.Text = "Congratulations!\n Welcome Back to Earth!";
                button1.Visible    = true;
            }
            // if the hero dies then this is displayed
            else if (A_Journey_Home.Variables.herohealth == 0)
            {
                gameoverlabel.Text = "Game Over";

                enemyship1.Visible = false;
                enemyship2.Visible = false;
                enemyship3.Visible = false;
                enemyship4.Visible = false;
                enemyship5.Visible = false;
                enemyship6.Visible = false;
                button1.Visible    = true;
            }
            // if the hero completes a level and the level is not theh final one, it will display this
            else if (A_Journey_Home.Variables.herohealth > 0)
            {
                gameoverlabel.Text = "Good Job!";
                Level++;
                MainButton.Text    = "Next Level";
                levelcounter.Text  = Level.ToString();
                MainButton.Visible = true;
            }
            // the play timer and the random int timer are stopped for memory saving
            PlayTimer.Stop();
            randint.Stop();
        }
 public void Play()
 {
     if (seqLoaded)
     {
         mPlaying = true;
         watch.Start();
         PlayTimer.Start();
     }
 }
Beispiel #8
0
 protected override void OnBattleUnLoad()
 {
     base.OnBattleUnLoad();
     PlayTimer.Pause();
     foreach (var item in BaseGlobal.ClearWhenUnload)
     {
         item.Clear();
     }
 }
Beispiel #9
0
 /// <summary>
 /// För att starta spelet
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnStart_Click(object sender, EventArgs e)
 {
     //Run randomiser if not using loaded
     SaveGame("DefaultGameName");
     savegame         = true;
     btnPause.Enabled = true;
     btnStart.Enabled = false;
     PlayTimer.Start();
 }
        public Form2()
        {
            InitializeComponent();


            PlayTimer.Start();
            healthcounter.Text = herohealth.ToString();
            this.ActiveControl = heroship1;
            bool shoot = false;
        }
    DateTime playTime;     // NOTE: By default 1 realtime second == 1 ingame minute

    void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
        }
        else
        {
            Instance = this;
        }
    }
Beispiel #12
0
 // Reseter programmet som det var ved opstart
 private void ResetButton_Click(object sender, EventArgs e)
 {
     Runners.Clear();
     player.Second = 0;
     PlayTimer.Stop();
     Map1.Refresh();
     ResetButton.Hide();
     LoadButton.Show();
     player.ShutDown();
     RunnersCheckBox.Items.Clear();
 }
        private void restart()
        {
            levelcounter.Text = Level.ToString();

            if (Level >= 1)
            {
                enemyship1.Location   = new Point(21, 12);
                enemyship2.Location   = new Point(131, 12);
                enemyship3.Location   = new Point(257, 12);
                enemyship4.Location   = new Point(380, 12);
                enemyship1.Visible    = true;
                enemyship2.Visible    = true;
                enemyship3.Visible    = true;
                enemyship4.Visible    = true;
                enemybullet1.Visible  = true;
                enemybullet2.Visible  = true;
                enemybullet3.Visible  = true;
                enemybullet4.Visible  = true;
                enemybullet1.Location = enemyship1.Location;
                enemybullet2.Location = enemyship2.Location;
                enemybullet3.Location = enemyship3.Location;
                enemybullet4.Location = enemyship4.Location;


                herohealth = 3;
            }
            if (Level > 1)
            {
                enemyship5.Location   = new Point(459, 100);
                enemyship6.Location   = new Point(597, 100);
                enemybullet5.Location = enemyship5.Location;
                enemybullet6.Location = enemyship6.Location;

                enemyship5.Visible   = true;
                enemyship6.Visible   = true;
                enemybullet5.Visible = true;
                enemybullet6.Visible = true;
                BackgroundImage      = Properties.Resources.bg2;
            }



            scorecounter.Visible  = false;
            scorelabel.Visible    = false;
            gameoverlabel.Visible = false;
            heroship1.Visible     = true;
            laser.Visible         = true;
            randint.Start();
            enemyshiptimer.Start();
            MainButton.Visible = false;
            PlayTimer.Start();
        }
Beispiel #14
0
 private void PlayTimer_Tick(object sender, EventArgs e)
 {
     if (savegame)
     {
         SaveRound();
     }
     if (s.PastGameTurnArray == s.NewGameTurnArray) // If the cells doesnt change anymore
     {
         PlayTimer.Stop();
         btnPause.Enabled = false;
     }
     PlayRound();
 }
Beispiel #15
0
 /// <summary>
 /// Knapp för att pausa spelet.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnPause_Click(object sender, EventArgs e)
 {
     if (btnPause.Text == "Pause")
     {
         PlayTimer.Stop();
         btnPause.Text = "Continue";
     }
     else
     {
         btnPause.Text = "Pause";
         PlayTimer.Start();
     }
 }
 public Form2()
 {
     InitializeComponent();
     // these are global variables
     A_Journey_Home.Variables.aggregatescore = 0;
     A_Journey_Home.Variables.herohealth     = 3;
     // this is the main timer for all of the bullets
     PlayTimer.Start();
     // gives the level counter the value of the health variables
     healthcounter.Text = A_Journey_Home.Variables.herohealth.ToString();
     // this gives the user activecontrol to the heroship
     this.ActiveControl = heroship1;
     bool shoot = false;
 }
Beispiel #17
0
 public void Save(Version fv, WsgFileStream fs)
 {
     try
     {
         if (BeforeSaveEvent != null)
         {
             BeforeSaveEvent();
         }
         if (fv.Major > 0)
         {
             while (PlayTimer.Enabled)
             {
                 PlayTimer.Stop();
             }
             fs.Seek(0, System.IO.SeekOrigin.Begin);
             FileVersion.Save(fv, fs);
             StockIndexes.Save(fv, fs);
             Stocks.Save(fv, fs);
             Players.Save(fv, fs);
             MarketState.Save(fv, fs);
             fs.Flush();
             FileName = fs.Name;
             while (!PlayTimer.Enabled)
             {
                 PlayTimer.Start();
             }
         }
         if (AfterSaveEvent != null)
         {
             AfterSaveEvent();
         }
         if (UpdateStockInformationsEvent != null)
         {
             UpdateStockInformationsEvent();
         }
         if (UpdatePlayerInformationsEvent != null)
         {
             UpdatePlayerInformationsEvent();
         }
     }
     catch (System.Exception ex)
     {
         while (!PlayTimer.Enabled)
         {
             PlayTimer.Start();
         }
         throw ex;
     }
 }
Beispiel #18
0
        private void PlayBtn_Click(object sender, EventArgs e)
        {
            System.Media.SoundPlayer player = new System.Media.SoundPlayer();
            player.Stream = Properties.Resources.Believer3;
            //player.SoundLocation = @"C:\Users\acer\Desktop\Things\Music\wav\My Dearest.wav";

            player.Play();
            Taiko1.Visible = true;
            Taikotimer.Start();
            ScoreTimer.Start();
            PlayTimer.Start();
            taikocount    = 0;
            myscore       = 0;
            owari.Visible = false;
        }
Beispiel #19
0
        /// <summary>
        /// Knapp för att stoppa/spara spelet.
        /// Om man inte skrivit in namn så får den namnet DefaultGameName.
        /// Annars tas den bort.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStopSave_Click(object sender, EventArgs e)
        {
            PlayTimer.Stop();

            if (txbNameOfTheGame.Text == "")
            {
                DeleteGame("DefaultGameName");
            }
            else
            {
                manageDB.RenameGame("DefaultGameName", txbNameOfTheGame.Text);
                txbNameOfTheGame.Text = "";
            }
            btnPause.Enabled = false;
            ResetGame();
        }
Beispiel #20
0
 public System.Object ClientCommunication(Version serverversion, ICommunicateable communicator, bool full, System.Object obj)
 {
     try
     {
         if (serverversion.Major > 0)
         {
             lock (SynchronizeRoot)
             {
                 if (full)
                 {
                     // Send information about the client.
                     communicator.SendString(CurrentPlayer.Company);
                     communicator.SendString(CurrentPlayer.Name);
                     // Clear and reset game informations.
                     while (PlayTimer.Enabled)
                     {
                         PlayTimer.Stop();
                     }
                     while (StockIndexes.Count > 0)
                     {
                         StockIndexes.Clear();
                     }
                     while (Stocks.Count > 0)
                     {
                         Stocks.Clear();
                     }
                     while (Players.Count > 0)
                     {
                         Players.Clear();
                     }
                     MarketState.Reset(Random);
                     CurrentPlayer = null;
                 }
                 // Receive new game informations.
                 StockIndexes.ClientCommunication(serverversion, communicator, full, null);
                 Stocks.ClientCommunication(serverversion, communicator, full, StockIndexes);
                 CurrentPlayer = (Player)Players.ClientCommunication(serverversion, communicator, full, Stocks);
                 MarketState.ClientCommunication(serverversion, communicator, full, null);
             }
         }
         return(this);
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Beispiel #21
0
 /// <summary>
 /// För att ladda ett redan sparat spel och spela upp det.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnLoad_Click(object sender, EventArgs e)
 {
     if (lstBxSavedGames.SelectedItem != null)
     {
         string gameName        = lstBxSavedGames.SelectedItem.ToString();
         string loadedGameRound = manageDB.GetPlayingfield(gameName);
         if (loadedGameRound != "")
         {
             s.GridSize = manageDB.GetSavedGridSize();
             MakeLoadedRoundToAnArray(loadedGameRound);
             UpdateGrid();
             btnStart.Enabled = false;
             savegame         = false;
             PlayTimer.Start();
         }
     }
 }
        public void Flush()
        {
            PlayTimer.Stop();
            ImageHolder.BackgroundImage = null;

            if (mSequence != null)
            {
                foreach (Image CurImage in mSequence)
                {
                    CurImage.Dispose();
                }

                mSequence.Clear();
                mSequence = null;
                seqLoaded = false;
            }
        }
Beispiel #23
0
 public void Reset(System.Random random, bool startingserver)
 {
     try
     {
         bool b = true;
         if (BeforeResetEvent != null && !startingserver)
         {
             b = BeforeResetEvent();
         }
         if (b)
         {
             while (PlayTimer.Enabled)
             {
                 PlayTimer.Stop();
             }
             FileName = null;
             Stocks.Reset(random);
             Players.Reset(random);
             MarketState.Reset(random);
             while (!PlayTimer.Enabled)
             {
                 PlayTimer.Start();
             }
             if (AfterResetEvent != null && !startingserver)
             {
                 AfterResetEvent();
             }
             if (UpdateStockInformationsEvent != null)
             {
                 UpdateStockInformationsEvent();
             }
             if (UpdatePlayerInformationsEvent != null)
             {
                 UpdatePlayerInformationsEvent();
             }
         }
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Beispiel #24
0
 public void Continue()
 {
     try
     {
         if (IsPaused)
         {
             while (!PlayTimer.Enabled)
             {
                 PlayTimer.Start();
             }
             if (OnContinueEvent != null)
             {
                 OnContinueEvent();
             }
         }
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Beispiel #25
0
 public void Pause()
 {
     try
     {
         if (!IsPaused)
         {
             while (PlayTimer.Enabled)
             {
                 PlayTimer.Stop();
             }
             if (OnPauseEvent != null)
             {
                 OnPauseEvent();
             }
         }
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Beispiel #26
0
        public static void OnPickedInstrument(Mobile from, BaseInstrument instrument)
        {
            PlayerMobile pm = (PlayerMobile)from;

            if (!instrument.IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                 //This must be in your backpack
            }
            else if (instrument is Drums || instrument is Tambourine || instrument is TambourineTassel)
            {
                from.SendMessage("You cannot play a tune on that instrument.");
                BaseInstrument.SetInstrument(from, null);
            }
            else if (!pm.Playing)             // If this is a new tune, create a new timer and start it.
            {
                from.Emote("*plays a tune*"); // Player emotes to indicate they are playing
                pm.Playing = true;
                PlayTimer pt = new PlayTimer(pm);
                pt.Start();
            }
        }
Beispiel #27
0
 protected virtual void OnLoadBattleEnd()
 {
     //开始计时
     PlayTimer.Restart();
 }
Beispiel #28
0
 public System.Object Load(Version fv, WsgFileStream fs, System.Object obj)
 {
     try
     {
         if (BeforeLoadEvent != null)
         {
             BeforeLoadEvent();
         }
         if (fv.Major > 0)
         {
             while (PlayTimer.Enabled)
             {
                 PlayTimer.Stop();
             }
             fs.Seek(0, System.IO.SeekOrigin.Begin);
             Version loadedfv = (Version)FileVersion.Load(fv, fs, null);
             while (StockIndexes.Count > 0)
             {
                 StockIndexes.Clear();
             }
             while (Stocks.Count > 0)
             {
                 Stocks.Clear();
             }
             while (Players.Count > 0)
             {
                 Players.Clear();
             }
             MarketState.Reset(Random);
             CurrentPlayer = null;
             StockIndexes.Load(loadedfv, fs, null);
             Stocks.Load(loadedfv, fs, StockIndexes);
             CurrentPlayer = (Player)Players.Load(loadedfv, fs, Stocks);
             MarketState.Load(loadedfv, fs, null);
             FileName = fs.Name;
             while (!PlayTimer.Enabled)
             {
                 PlayTimer.Start();
             }
         }
         if (AfterLoadEvent != null)
         {
             AfterLoadEvent();
         }
         if (UpdateStockInformationsEvent != null)
         {
             UpdateStockInformationsEvent();
         }
         if (UpdatePlayerInformationsEvent != null)
         {
             UpdatePlayerInformationsEvent();
         }
         return(this);
     }
     catch (VersionNotSupportedException ex)
     {
         while (!PlayTimer.Enabled)
         {
             PlayTimer.Start();
         }
         throw ex;
     }
     catch (System.Exception ex)
     {
         while (!PlayTimer.Enabled)
         {
             PlayTimer.Start();
         }
         throw ex;
     }
 }
Beispiel #29
0
 public void Dispose(bool disposing)
 {
     try
     {
         if (!Disposed)
         {
             if (PlayTimer != null)
             {
                 while (PlayTimer.Enabled)
                 {
                     PlayTimer.Stop();
                 }
             }
             if (disposing)
             {
                 if (Random != null)
                 {
                     Random = null;
                 }
                 if (StockIndexes != null)
                 {
                     while (StockIndexes.Count > 0)
                     {
                         StockIndexes.Clear();
                     }
                     StockIndexes = null;
                 }
                 if (Stocks != null)
                 {
                     while (Stocks.Count > 0)
                     {
                         Stocks.Clear();
                     }
                     Stocks = null;
                 }
                 if (Players != null)
                 {
                     while (Players.Count > 0)
                     {
                         Players.Clear();
                     }
                     Players = null;
                 }
                 if (MarketState != null)
                 {
                     MarketState = null;
                 }
                 if (CurrentPlayer != null)
                 {
                     CurrentPlayer = null;
                 }
                 if (SynchronizeRoot != null)
                 {
                     SynchronizeRoot = null;
                 }
                 if (PlayTimer != null)
                 {
                     PlayTimer.Dispose();
                 }
                 if (BeforeResetEvent != null)
                 {
                     BeforeResetEvent = null;
                 }
                 if (AfterResetEvent != null)
                 {
                     AfterResetEvent = null;
                 }
                 if (BeforeLoadEvent != null)
                 {
                     BeforeLoadEvent = null;
                 }
                 if (AfterLoadEvent != null)
                 {
                     AfterLoadEvent = null;
                 }
                 if (BeforeSaveEvent != null)
                 {
                     BeforeSaveEvent = null;
                 }
                 if (AfterSaveEvent != null)
                 {
                     AfterSaveEvent = null;
                 }
                 if (UpdateStockInformationsEvent != null)
                 {
                     UpdateStockInformationsEvent = null;
                 }
                 if (UpdatePlayerInformationsEvent != null)
                 {
                     UpdatePlayerInformationsEvent = null;
                 }
             }
             Disposed = true;
         }
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Beispiel #30
0
 protected virtual void OnBattleOver()
 {
     PlayTimer.Stop();
 }
Beispiel #31
0
		public static void OnPickedInstrument(Mobile from, BaseInstrument instrument)
		{
			PlayerMobile pm = (PlayerMobile)from;

			if (!instrument.IsChildOf(from.Backpack))
			{
				from.SendLocalizedMessage(1042001); //This must be in your backpack
			}
			else if (instrument is Drums || instrument is Tambourine || instrument is TambourineTassel)
			{
				from.SendMessage("You cannot play a tune on that instrument.");
				BaseInstrument.SetInstrument(from, null);
			}
			else if (!pm.Playing) // If this is a new tune, create a new timer and start it.
			{
				from.Emote("*plays a tune*"); // Player emotes to indicate they are playing
				pm.Playing = true;
				PlayTimer pt = new PlayTimer(pm);
				pt.Start();
			}
		}