亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? gameform.cs

?? Pocket 1945 is a classic shooter inspired by the classic 1942 game. The game is written in C# target
?? CS
字號:
using System;
using System.IO;
using System.Drawing;
using System.Threading;
using System.Collections;
using System.Windows.Forms;
using System.Reflection;

namespace Pocket1945
{
	/// <summary>
	/// This is the actuall gameform used to display the game to the user. 
	/// The class inherits the System.Windows.Forms.Form class.	
	/// </summary>
	public class GameForm : Form
	{		
		//Private game variables.
		private bool playing;		
		private Bitmap offScreenBitmap;
		private Graphics offScreenGraphics;
		private Graphics onScreenGraphics;		
		private LevelGui levelGui;
		private Input input;		
		private string[] levelFiles;
		private int menuTick;
		private int titleTick;
		private GameFont levelFont;
		private GameFont exitFont;

		/// <summary>
		/// Which level the player is on.
		/// </summary>
		public static int LevelCount;
		
		/// <summary>
		/// A public static instance of the player.
		/// </summary>
		public static Player Player;		

		/// <summary>
		/// A public static int counting the number of ticks used
		/// in the game.
		/// </summary>
		public static int TickCount;

		/// <summary>
		/// A public static rectangle determing the size of the 
		/// game area.
		/// </summary>
		public static Rectangle GameArea;

		/// <summary>
		/// A public static randomizer used by all game objects to
		/// generate random numbers.
		/// </summary>
		public static Random Randomizer;

		/// <summary>
		/// Field holding a public static reference to the current level. 
		/// Trough this field other game objects like bullets, players and enemies 
		/// gain access to the level properties.
		/// </summary>
		public static Level CurrentLevel;

		/// <summary>
		/// The framerate of the game. This const is used to determine speed
		/// for all game object. The speed of the game is mesured in pixel pr. second.
		/// So, if a enemy moves 30 pixel pr second the speed variable is PixelPerSecond / FramesPerSecond.
		/// 
		/// Variables like ReloadTime is messured in seconds, so the tick variable is Seconds * FramesPerSecond.
		/// </summary>
		internal const float FramesPerSecond = 30F;

		/// <summary>
		/// The lenght of one frame (1 second / FramesPerSecond).
		/// </summary>
		internal const float SecondsPerFrame = 1.0F / FramesPerSecond;
		
		/// <summary>
		/// Instanciates the main game form.
		/// </summary>
		public GameForm()
		{			
			TickCount = 0;			
			this.Visible = true;			
			this.WindowState = FormWindowState.Maximized;									
			offScreenBitmap = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);			
			offScreenGraphics = Graphics.FromImage(offScreenBitmap);
			offScreenGraphics.Clear(Color.Black);
			GameArea = this.ClientRectangle;			

			SpriteList.Instance.LoadSprites();
		
			Randomizer = new Random(DateTime.Now.Millisecond);						
			Player = new Player();
			input = new Input();			
			levelGui = new LevelGui();
			levelFiles = GetLevels();
			levelFont = new GameFont(Color.Yellow, string.Empty, new Font(FontFamily.GenericSansSerif, 24, FontStyle.Bold), 60, 130);			
			exitFont = new GameFont(Color.Red, string.Empty, new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold), 70, 160);
			
			titleTick = 120;
			DoGameLoop();
		}

		/// <summary>
		/// The game loop.
		/// </summary>
		private void DoGameLoop()
		{
			playing = true;
			onScreenGraphics = this.CreateGraphics();			
			input.RegisterAllHardwareKeys();
			
			while(playing)
			{
				DoLevel(levelFiles[LevelCount]);
			}
			
			input.UnregisterAllHardwareKeys();
			onScreenGraphics.Dispose();
			Application.DoEvents();
			Application.Exit();
		}

		/// <summary>
		/// The level loop.
		/// </summary>
		private void DoLevel(string filename)
		{	
			CurrentLevel = new Level(GetFullPath(filename));
			StopWatch sw = new StopWatch();
			bool levelCompleted = false;
			bool displayMenu = false;

			while((playing) && (!levelCompleted))
			{
				// Store the tick at which this frame started
				Int64 startTick = sw.CurrentTick();				
				input.Update();		
	
				//Update the rownumber.
				TickCount++;				
							
				//Draw the background map.					
				CurrentLevel.BackgroundMap.Draw(offScreenGraphics);				

				//Update bullets, enemies and bonuses.
				HandleBonuses();
				HandleBullets();				
				HandleEnemies();				

				//Update and draw the player.
				Player.Update(input);	
				Player.Draw(offScreenGraphics);
				playing = (Player.Status != PlayerStatus.Dead);

				//Draw in-game user interface
				levelGui.Draw(offScreenGraphics);

				//Draw level title.
				if(titleTick > 0)
				{
					titleTick--;
					levelFont.Text = CurrentLevel.Name;
					levelFont.Draw(offScreenGraphics);
				}

				//Display a simple menu.
				if (displayMenu)
				{
					menuTick--;
					if(menuTick == 0)
						displayMenu = false;

					if (input.KeyJustPressed(193))					
						playing = false;
					exitFont.Text = "Click again to Exit";
					exitFont.Draw(offScreenGraphics);
				}

				if (input.KeyJustPressed(193))
				{
					menuTick = 120;
					displayMenu = true;
				}

				//Check if the level is compleated.
				if(CurrentLevel.BackgroundMap.Y == 0)
				{
					LevelCount++;
					titleTick = 120;
					if(LevelCount == levelFiles.Length)
						LevelCount = 0;
					Player.Power = Player.ShieldThickness;
					Player.UpdateHealth();
					levelCompleted = true;
				}
							
				//Move the offScreenBitmap buffer to the screen.
				onScreenGraphics.DrawImage(offScreenBitmap, 0, 0, this.ClientRectangle, GraphicsUnit.Pixel);				
				
				//Process all events in the event que.
				Application.DoEvents();				
				
				// Lock the framerate...
				Int64 deltaMs = sw.DeltaTime_ms(sw.CurrentTick(), startTick);
				Int64 targetMs = (Int64)(1000.0F * SecondsPerFrame);

				// Check if the frame time was fast enough
				if (deltaMs <= targetMs)
				{
					// Loop until the frame time is met
					while (sw.DeltaTime_ms(sw.CurrentTick(), startTick) < targetMs)
					{
						Thread.Sleep(0);
						Application.DoEvents();
					}
				}
			}			
		}

		#region Method handeling bonus elements.
		/// <summary>
		/// Method handeling all the bonus elements in the game.
		/// </summary>
		private void HandleBonuses()
		{
			for(int i = 0; i < CurrentLevel.Bonuses.Length; ++i)
			{
				Bonus b = (Bonus)CurrentLevel.Bonuses[i];
				if(b.HasFocus())
				{
					b.Move();
					b.Draw(offScreenGraphics);

					//Check if the player have collected the bonus.
					if(b.GetCollitionRectangle().IntersectsWith(Player.GetCollitionRectangle()))
					{						
						Player.GetBonus(b);
						b.Collected = true;
					}
				}
			}
		}
		#endregion

		#region Method handeling bullets.
		/// <summary>
		/// Method handeling all the bullets in the game.
		/// </summary>
		private void HandleBullets()
		{
			//Loop trough all bullets in the game.
			for(int i = 0; i < CurrentLevel.Bullets.Count; ++i)
			{
				Bullet b = (Bullet)CurrentLevel.Bullets[i];

				//Check if the bullet has focus.
				if(b.HasFoucs())
				{
					b.Move();
					b.Draw(offScreenGraphics);

					//If the bullet is mowing upwards it's aimed at enemies.
					if(b.Direction == MoveDirection.Up)
					{
						//Loop trough the enemies and check for a hit.
						for(int j = 0; j < CurrentLevel.Enemies.Length; ++j)
						{
							Enemy e = (Enemy)CurrentLevel.Enemies[j];																
							//Check if we got a hit.
							if(e.HasFocus() && e.Status != EnemyStatus.Dying && b.GetCollitionRectangle().IntersectsWith(e.GetCollitionRectangle())) 
							{						
								//The bullet hit a enemey.
								e.Hit(b);

								//Remove the bullet from the game.
								CurrentLevel.Bullets.RemoveAt(i);

								//Collect score.
								if(e.Status == EnemyStatus.Dying)
									Player.Score += e.GiveScore();
								break;
							}
						}
					}
					//If the bullet is moving downwards it's aimed at the player.
					else
					{
						//Check if the enemey hits the player.
						if(b.GetCollitionRectangle().IntersectsWith(Player.GetCollitionRectangle()))
						{
							//Hit the player and remove the bullet.
							Player.Hit(b);
							CurrentLevel.Bullets.RemoveAt(i);								
						}
					}						
				}
				//The bullet is out of scope remove the bullet to free memory.
				else
					CurrentLevel.Bullets.RemoveAt(i);
			}
		}
		#endregion

		#region Method handeling enemies.
		/// <summary>
		/// Method handeling all the enemies of the game.
		/// </summary>
		public void HandleEnemies()
		{
			//Loop trough all enemies and move, draw and fire.
			for(int i = 0; i < CurrentLevel.Enemies.Length; ++i)
			{
				Enemy e = (Enemy)CurrentLevel.Enemies[i];					
				if(e.HasFocus())
				{		
					//Move the enemey.
					e.Move();

					//If the enemy can fire, add a new bullet to the game.
					if(e.CanFire())
						CurrentLevel.Bullets.Add(e.Fire());

					//Draw the enemey.
					e.Draw(offScreenGraphics);

					//Check if the player collides with a enemy plane.
					if(e.Status != EnemyStatus.Dying && e.GetCollitionRectangle().IntersectsWith(Player.GetCollitionRectangle()))
					{
						//The effect of a collition is the same as if they where hit by a bullet.
						Player.Hit(e.Fire());						
						e.Hit(Player.Fire());

						//Give score if the enemy is dying.
						if(e.Status == EnemyStatus.Dying)
							Player.Score += e.GiveScore();
					}
				}
			}
		}
		#endregion

		/// <summary>
		/// Method returning a string array with all level files in the game folder.
		/// </summary>
		/// <returns>All level files.</returns>
		public string[] GetLevels()
		{
			Assembly asm = Assembly.GetExecutingAssembly();
			DirectoryInfo dir = new DirectoryInfo(Path.GetDirectoryName(asm.GetName().CodeBase));
			FileInfo[] files = dir.GetFiles("*.xml");
			string[] fileNames = new string[files.Length];			
			for(int i = files.Length; i > 0; --i)						
				fileNames[i - 1] = files[files.Length - i].Name;
			return fileNames;
		}

		/// <summary>
		/// Method used to determine the full path of a file.
		/// </summary>
		/// <param name="fileName">The filename you want the full path for.</param>
		/// <returns>The full paht of the file.</returns>
		private string GetFullPath(string fileName)
		{
			Assembly asm = Assembly.GetExecutingAssembly();
			string fullName = Path.GetDirectoryName(asm.GetName().CodeBase);
			return Path.Combine(fullName, fileName);
		}
		
		/// <summary>
		/// Left empty, all drawing is done in the game loop.
		/// </summary>
		/// <param name="e">Event arguments.</param>
		protected override void OnPaint(PaintEventArgs e) {}

		/// <summary>
		/// Since all drawing is done in the gameloop the Form does not need 
		/// to draw a background for us. By leaving this method empty we 
		/// avoids undesirable flickering.
		/// </summary>
		/// <param name="e">Event arguments.</param>
		protected override void OnPaintBackground(PaintEventArgs e) {}
		
		/// <summary>
		/// Entrypoint of the application starting the game.
		/// </summary>
		public static void Main() 
		{
			Application.Run(new GameForm());
		}
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
538在线一区二区精品国产| 樱桃国产成人精品视频| 在线欧美日韩精品| 久久精品一区二区三区不卡牛牛| 99精品视频在线观看| 国产乱人伦偷精品视频不卡| 日韩电影在线一区二区三区| 亚洲h在线观看| 亚洲成人在线免费| 三级久久三级久久久| 视频一区二区三区入口| 亚洲成人免费电影| 日韩综合在线视频| 日本三级亚洲精品| 日本三级亚洲精品| 麻豆精品在线看| 国产在线一区二区| 国产成人超碰人人澡人人澡| 国产69精品久久99不卡| 成人免费视频一区| 91丨九色丨国产丨porny| 91色在线porny| 欧美吻胸吃奶大尺度电影 | 亚洲免费在线视频| 亚洲黄色尤物视频| 三级不卡在线观看| 久久99精品一区二区三区| 国产一区二区三区免费看| 成年人网站91| 欧洲精品中文字幕| 日韩欧美一区二区在线视频| 精品不卡在线视频| 日韩一区欧美一区| 视频一区二区不卡| 成人理论电影网| 欧美综合一区二区| 精品乱人伦小说| 国产精品拍天天在线| 亚洲丰满少妇videoshd| 捆绑变态av一区二区三区| 成人av在线网| 91精品国产福利| 国产精品视频第一区| 日韩高清在线一区| jlzzjlzz国产精品久久| 91精品视频网| 亚洲欧美在线观看| 国产精品国产馆在线真实露脸 | 欧美日韩免费视频| 久久久99精品久久| 午夜视频在线观看一区| 国产91富婆露脸刺激对白| 91国产成人在线| 久久精品一区四区| 日韩成人dvd| 在线亚洲高清视频| 国产精品全国免费观看高清| 日韩成人一区二区三区在线观看| 成人黄色小视频在线观看| 欧美日韩一本到| 国产精品视频观看| 国产精品一区免费视频| 在线电影国产精品| 亚洲制服丝袜一区| av不卡在线观看| 国产亚洲精久久久久久| 日本在线不卡视频| 欧美日韩国产小视频在线观看| 亚洲国产精品国自产拍av| 精品亚洲成a人| 51久久夜色精品国产麻豆| 一区二区三区四区五区视频在线观看 | 欧美日韩一区不卡| 亚洲乱码日产精品bd| 成人精品在线视频观看| 久久久久亚洲蜜桃| 麻豆成人av在线| 日韩你懂的在线播放| 日本亚洲视频在线| 欧美一区二区三区免费在线看| 亚洲影视资源网| 欧美在线啊v一区| 亚洲激情第一区| 91国偷自产一区二区使用方法| 亚洲人xxxx| 欧美无乱码久久久免费午夜一区| 一区二区三区av电影| 色婷婷综合久久久久中文| 日韩一区欧美一区| 在线免费不卡视频| 亚洲成人精品影院| 欧美一区二区成人6969| 毛片av一区二区| 久久精品欧美日韩| 成人午夜视频免费看| 国产精品私房写真福利视频| 99久久精品国产毛片| 亚洲美女精品一区| 欧美精品在线观看播放| 美日韩黄色大片| 国产欧美日韩精品一区| 成人av在线播放网站| 亚洲精品国产一区二区三区四区在线| 色综合久久综合网欧美综合网| 亚洲欧美另类在线| 欧美另类高清zo欧美| 九九精品一区二区| 自拍av一区二区三区| 精品日韩欧美一区二区| 亚洲欧美另类久久久精品2019| 欧美色视频一区| 精品一区在线看| 18成人在线视频| 欧美日韩精品免费观看视频| 玖玖九九国产精品| 亚洲天天做日日做天天谢日日欢| 欧美中文字幕久久| 黑人精品欧美一区二区蜜桃| 综合电影一区二区三区| 欧美一区二区三区视频| 成人激情视频网站| 日本欧美韩国一区三区| 国产精品成人一区二区三区夜夜夜| 在线欧美一区二区| 国产精品亚洲一区二区三区在线| 亚洲免费在线电影| 久久综合九色综合欧美就去吻| 99精品视频中文字幕| 精品制服美女丁香| 一区二区三区四区五区视频在线观看| 精品欧美黑人一区二区三区| 色综合久久天天| 国产在线播放一区| 日韩二区三区四区| 一区二区成人在线| 亚洲国产精品ⅴa在线观看| 欧美一区二区视频网站| 91麻豆精东视频| 高清日韩电视剧大全免费| 人禽交欧美网站| 亚洲高清免费在线| 亚洲裸体xxx| 精品国产欧美一区二区| 欧美日韩国产三级| 欧美在线|欧美| 一本大道av一区二区在线播放| 国产专区综合网| 另类小说综合欧美亚洲| 午夜电影网亚洲视频| 亚洲图片欧美综合| 一区二区欧美国产| 玉米视频成人免费看| 17c精品麻豆一区二区免费| 日本一区二区三区国色天香| www国产亚洲精品久久麻豆| 欧美一级夜夜爽| 91麻豆精品国产91久久久久| 精品视频在线视频| 欧美三片在线视频观看| 欧美性色黄大片手机版| 欧美亚洲日本国产| 在线观看视频一区二区欧美日韩| 91麻豆文化传媒在线观看| 91视频一区二区三区| 97精品国产露脸对白| 色综合久久综合网97色综合| 91浏览器在线视频| 欧美在线短视频| 欧美三级韩国三级日本三斤| 欧美日韩一区精品| 日韩午夜激情电影| 久久久亚洲午夜电影| 国产精品久久久久一区二区三区 | 久久久久久久久久美女| 国产欧美日韩在线看| 亚洲国产精品成人久久综合一区| 国产亚洲视频系列| 中文字幕亚洲不卡| 亚洲成av人片| 久久爱www久久做| 国产69精品久久99不卡| 色综合久久精品| 欧美人妇做爰xxxⅹ性高电影| 欧美疯狂性受xxxxx喷水图片| 日韩午夜在线影院| 国产精品日日摸夜夜摸av| 亚洲宅男天堂在线观看无病毒| 午夜精品久久久久久久久久久 | 91麻豆免费观看| 欧美色手机在线观看| 日韩欧美高清在线| 中文字幕免费不卡在线| 一区二区在线看| 国内外精品视频| 99天天综合性| 欧美刺激午夜性久久久久久久| 国产精品久久久久精k8| 美女网站在线免费欧美精品| 成人av一区二区三区| 欧美一区二区视频在线观看2020|