コード例 #1
0
            private static void CalculateRectAfterMove(PlayerPlane entity)
            {
                var pointAfterVerticalMovement = new Vector2D(entity.Get <Rectangle>().TopLeft.X,
                                                              entity.Get <Rectangle>().TopLeft.Y + entity.Get <Velocity2D>().velocity.Y *Time.Delta);

                entity.Set(new Rectangle(pointAfterVerticalMovement, entity.Get <Rectangle>().Size));
            }
コード例 #2
0
 private static void CHeckIfHittingABorder(PlayerPlane entity)
 {
     if (entity.defeated)
     {
         return;
     }
     isHittingABorder = false;
     drawArea         = entity.Get <Rectangle>();
     movementSpeed    = entity.Get <Velocity2D>();
     CheckStopTopBorder(ScreenSpace.Current.Viewport);
     CheckStopBottomBorder(ScreenSpace.Current.Viewport);
     entity.Set(drawArea);
     entity.Set(movementSpeed);
 }
コード例 #3
0
ファイル: Game.cs プロジェクト: whztt07/DeltaEngine
		public void StartGame()
		{
			IsActive = true;
			mainMenu.Hide();
			if (backToMenuCommand != null && backToMenuCommand.IsActive)
				backToMenuCommand.Dispose(); //ncrunch: no coverage
			if (gameOverMessage != null)
				gameOverMessage.Dispose(); //ncrunch: no coverage
			interact = new InteractionLogics();
			enemyTexture = new Material(ShaderFlags.Position2DColoredTextured, "EnemyPlane");
			player = new PlayerPlane(new Vector2D(ScreenSpace.Current.Viewport.Left + 0.08f, 0.5f));
			controls = new PlayerControls(player);
			background = new ParallaxBackground(4, layerImageNames, layerScrollFactors);
			background.BaseSpeed = 0.2f;
			player.Destroyed += DisplayGameOverMessage;
			Start<EnemySpawner>();
		}
コード例 #4
0
 public void StartGame()
 {
     IsActive = true;
     mainMenu.Hide();
     if (backToMenuCommand != null && backToMenuCommand.IsActive)
     {
         backToMenuCommand.Dispose();                 //ncrunch: no coverage
     }
     if (gameOverMessage != null)
     {
         gameOverMessage.Dispose();                 //ncrunch: no coverage
     }
     interact             = new InteractionLogics();
     enemyTexture         = new Material(ShaderFlags.Position2DColoredTextured, "EnemyPlane");
     player               = new PlayerPlane(new Vector2D(ScreenSpace.Current.Viewport.Left + 0.08f, 0.5f));
     controls             = new PlayerControls(player);
     background           = new ParallaxBackground(4, layerImageNames, layerScrollFactors);
     background.BaseSpeed = 0.2f;
     player.Destroyed    += DisplayGameOverMessage;
     Start <EnemySpawner>();
 }
コード例 #5
0
            private static void HitTestToEnemyPlanes(PlayerPlane playerPlane)
            {
                var enemies = EntitiesRunner.Current.GetEntitiesOfType <EnemyPlane>();

                if (enemies == null)
                {
                    return;
                }
                foreach (var enemy in enemies)
                {
                    if (playerPlane.DrawArea.IsColliding(playerPlane.Rotation, enemy.DrawArea, enemy.Rotation))
                    {
                        playerPlane.ReceiveAttack(5);
                        enemy.ReceiveAttack(5);
                    }
                }

                var bullets = playerPlane.machineGunAndLauncher.AttachedEmitters[0].particles;

                if (bullets != null)
                {
                    for (int i = 0; i < bullets.Length; i++)
                    {
                        if (!bullets[i].IsActive)
                        {
                            continue;
                        }
                        if (bullets[i].Position.X > ScreenSpace.Current.Viewport.Right)
                        {
                            bullets[i].IsActive = false;
                        }
                        foreach (var enemy in enemies)
                        {
                            if (enemy.DrawArea.Contains(bullets[i].Position.GetVector2D()))
                            {
                                enemy.ReceiveAttack();
                                bullets[i].IsActive = false;
                            }
                        }
                    }
                }

                var rockets = playerPlane.machineGunAndLauncher.AttachedEmitters[1].particles;

                if (rockets != null)
                {
                    for (int i = 0; i < rockets.Length; i++)
                    {
                        if (!rockets[i].IsActive)
                        {
                            continue;
                        }
                        if (rockets[i].Position.X > ScreenSpace.Current.Viewport.Right)
                        {
                            rockets[i].IsActive = false;
                        }
                        foreach (var enemy in enemies)
                        {
                            if (enemy.DrawArea.Contains(rockets[i].Position.GetVector2D()))
                            {
                                enemy.ReceiveAttack(5, true);
                                rockets[i].IsActive = false;
                            }
                        }
                    }
                }
            }
コード例 #6
0
 public PlayerControls(PlayerPlane planeToControl)
 {
     commands            = new Command[9];
     this.planeToControl = planeToControl;
     SetUpCommands();
 }
コード例 #7
0
ファイル: PlayerPlane.cs プロジェクト: whztt07/DeltaEngine
			private static void CHeckIfHittingABorder(PlayerPlane entity)
			{
				if (entity.defeated)
					return;
				isHittingABorder = false;
				drawArea = entity.Get<Rectangle>();
				movementSpeed = entity.Get<Velocity2D>();
				CheckStopTopBorder(ScreenSpace.Current.Viewport);
				CheckStopBottomBorder(ScreenSpace.Current.Viewport);
				entity.Set(drawArea);
				entity.Set(movementSpeed);
			}
コード例 #8
0
ファイル: PlayerPlane.cs プロジェクト: whztt07/DeltaEngine
			private static void CalculateRectAfterMove(PlayerPlane entity)
			{
				var pointAfterVerticalMovement = new Vector2D(entity.Get<Rectangle>().TopLeft.X,
					entity.Get<Rectangle>().TopLeft.Y + entity.Get<Velocity2D>().velocity.Y * Time.Delta);
				entity.Set(new Rectangle(pointAfterVerticalMovement, entity.Get<Rectangle>().Size));
			}
コード例 #9
0
ファイル: PlayerPlane.cs プロジェクト: whztt07/DeltaEngine
			private static void HitTestToEnemyPlanes(PlayerPlane playerPlane)
			{
				var enemies = EntitiesRunner.Current.GetEntitiesOfType<EnemyPlane>();

				if (enemies == null)
					return;
				foreach (var enemy in enemies)
					if (playerPlane.DrawArea.IsColliding(playerPlane.Rotation, enemy.DrawArea, enemy.Rotation))
					{
						playerPlane.ReceiveAttack(5);
						enemy.ReceiveAttack(5);
					}

				var bullets = playerPlane.machineGunAndLauncher.AttachedEmitters[0].particles;
				if (bullets != null)
					for (int i = 0; i < bullets.Length; i++)
					{
						if (!bullets[i].IsActive)
							continue;
						if (bullets[i].Position.X > ScreenSpace.Current.Viewport.Right)
							bullets[i].IsActive = false;
						foreach (var enemy in enemies)
							if (enemy.DrawArea.Contains(bullets[i].Position.GetVector2D()))
							{
								enemy.ReceiveAttack();
								bullets[i].IsActive = false;
							}
					}

				var rockets = playerPlane.machineGunAndLauncher.AttachedEmitters[1].particles;
				if (rockets != null)
					for (int i = 0; i < rockets.Length; i++)
					{
						if (!rockets[i].IsActive)
							continue;
						if (rockets[i].Position.X > ScreenSpace.Current.Viewport.Right)
							rockets[i].IsActive = false;
						foreach (var enemy in enemies)
							if (enemy.DrawArea.Contains(rockets[i].Position.GetVector2D()))
							{
								enemy.ReceiveAttack(5, true);
								rockets[i].IsActive = false;
							}
					}
			}
コード例 #10
0
ファイル: PlayerControls.cs プロジェクト: whztt07/DeltaEngine
		public PlayerControls(PlayerPlane planeToControl)
		{
			commands = new Command[9];
			this.planeToControl = planeToControl;
			SetUpCommands();
		}