Exemplo n.º 1
0
 /// <summary>
 /// Method to create ennemies
 /// Add more if you dare
 /// </summary>
 private void CreateEnemies()
 {
     enemies = new EnemyBlock(new Vecteur2d(10, 10), gameSize.Width - 50, Side.Enemy);
     enemies.AddLine(6, 1, Properties.Resources.ship2);
     enemies.AddLine(6, 1, Properties.Resources.ship9);
     enemies.AddLine(6, 1, Properties.Resources.ship8);
     enemies.AddLine(3, 1, Properties.Resources.ship4);
     enemies.UpdateSize();
     AddNewGameObject(enemies);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initialiser les composants du jeu
        /// </summary>
        /// <param name="gameSize">La taille du jeu</param>
        public void InitGame(Size gameSize)
        {
            this.gameSize = gameSize;

            for (int i = 1; i <= 3; i++)
            {
                AddNewGameObject(new Bunker(i * 135, gameSize.Height - 130, Side.Neutral));
            }

            PlayerShip = new PlayerSpaceship(this.gameSize.Width / 2, this.gameSize.Height, 50, Side.Ally);
            this.AddNewGameObject(this.PlayerShip);

            this.enemies = new EnemyBlock(50, 50, 400, Side.Enemy);
            enemies.AddLine(6, 5, SpaceInvaders.Properties.Resources.ship7);
            enemies.AddLine(6, 10, SpaceInvaders.Properties.Resources.ship2);
            enemies.AddLine(6, 10, SpaceInvaders.Properties.Resources.ship5);
            this.AddNewGameObject(this.enemies);

            state = GameState.Play;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Supprimer tous les objets
 /// </summary>
 public void ClearGame()
 {
     gameObjects.Clear();
     pendingNewGameObjects.Clear();
     enemies = null;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Load enemy block from a txt file
        /// </summary>
        /// <param name="filename">File name</param>
        public EnemyBlock InitFromFile(string filename)
        {
            string[] lines = System.IO.File.ReadAllLines(@"Resources\" + filename);
            string[] rec   = lines[0].Split(' ');

            if (rec.Length == 2)
            {
                enemyBlock = new EnemyBlock(new Vecteur2D(Convert.ToDouble(rec[0]), Convert.ToDouble(rec[1])));
            }
            else
            {
                throw new Exception();
            }

            for (int i = 1; i < lines.Length; i++)
            {
                rec = lines[i].Split(' ');
                if (rec.Length == 4)
                {
                    switch (rec[3])
                    {
                    case "ship1":
                        enemyBlock.AddLine(Convert.ToInt32(rec[0]),
                                           Convert.ToInt32(rec[1]),
                                           Convert.ToInt32(rec[2]),
                                           space_invaders.Properties.Resources.ship1);
                        break;

                    case "ship2":
                        enemyBlock.AddLine(Convert.ToInt32(rec[0]),
                                           Convert.ToInt32(rec[1]),
                                           Convert.ToInt32(rec[2]),
                                           space_invaders.Properties.Resources.ship2);
                        break;

                    case "ship3":
                        enemyBlock.AddLine(Convert.ToInt32(rec[0]),
                                           Convert.ToInt32(rec[1]),
                                           Convert.ToInt32(rec[2]),
                                           space_invaders.Properties.Resources.ship3);
                        break;

                    case "ship4":
                        enemyBlock.AddLine(Convert.ToInt32(rec[0]),
                                           Convert.ToInt32(rec[1]),
                                           Convert.ToInt32(rec[2]),
                                           space_invaders.Properties.Resources.ship4);
                        break;

                    case "ship5":
                        enemyBlock.AddLine(Convert.ToInt32(rec[0]),
                                           Convert.ToInt32(rec[1]),
                                           Convert.ToInt32(rec[2]),
                                           space_invaders.Properties.Resources.ship5);
                        break;

                    case "ship6":
                        enemyBlock.AddLine(Convert.ToInt32(rec[0]),
                                           Convert.ToInt32(rec[1]),
                                           Convert.ToInt32(rec[2]),
                                           space_invaders.Properties.Resources.ship6);
                        break;

                    case "ship7":
                        enemyBlock.AddLine(Convert.ToInt32(rec[0]),
                                           Convert.ToInt32(rec[1]),
                                           Convert.ToInt32(rec[2]),
                                           space_invaders.Properties.Resources.ship7);
                        break;

                    case "ship8":
                        enemyBlock.AddLine(Convert.ToInt32(rec[0]),
                                           Convert.ToInt32(rec[1]),
                                           Convert.ToInt32(rec[2]),
                                           space_invaders.Properties.Resources.ship8);
                        break;

                    case "ship9":
                        enemyBlock.AddLine(Convert.ToInt32(rec[0]),
                                           Convert.ToInt32(rec[1]),
                                           Convert.ToInt32(rec[2]),
                                           space_invaders.Properties.Resources.ship9);
                        break;
                    }
                }
                else
                {
                    throw new Exception();
                }
            }

            return(enemyBlock);
        }