예제 #1
0
 public Enemy(Coordinates coordinates, long spawnTime)
 {
     SpawnTime             = spawnTime;
     _myInitialCoordinates = coordinates;
     _coordinates          = coordinates;
     _oldCoordinates       = coordinates;
     _oldCoordinates.SetDisplacements(0, -1);
     _relativeBoundry = new Coordinates(Designs.GetEnemy().Length - 1, 0);
 }
        /// <summary>
        /// Creates an istance of an enemy line within the board and its appropriate stats.
        /// </summary>
        /// <param name="spawnTime"></param>
        public EnemyLine(long spawnTime)
        {
            SpawTime = spawnTime;

            for (int i = 0; i < DisplayParameters.NumberEnemiesLine; i++)
            {
                Coordinates coordinates = DisplayParameters.FirstEnemy;
                _enemies.Add(new Enemy(coordinates.SetDisplacements((Designs.GetEnemy().Length + 1) * i, 1), spawnTime));
            }
        }
예제 #3
0
 /// <summary>
 /// Calculates the positions for all static fileds on the console and all initial positions of the moveing ones.
 /// </summary>
 public static void Calculate()
 {
     Score               = new Coordinates(5, 3);
     Lives               = new Coordinates(ConsoleParameters.Width / 2 - 5, 3);
     Fps                 = new Coordinates(ConsoleParameters.Width - 16, 3);
     ScoreBoardLine      = new Coordinates(0, 5);
     HeroSpaceLine       = new Coordinates(0, ConsoleParameters.Height - 7);
     HeroInitial         = new Coordinates(ConsoleParameters.Width / 2 - 2, ConsoleParameters.Height - 5);
     FirstEnemy          = new Coordinates(5, 6);
     NumberEnemiesLine   = (int)((ConsoleParameters.Width - 10) / (Designs.GetEnemy().Length + 1));
     EnemyMovementsPermS = 0.0002;
 }
예제 #4
0
 public void ForceDisplay()
 {
     for (int i = 0; i <= _relativeBoundry.Y; i++)
     {
         if (Designs.GetEnemy().Length + _coordinates.X > ConsoleParameters.Width - 5)
         {
             throw new ArgumentOutOfRangeException($" {nameof(Enemy)} is placed too close to boudry.");
         }
         ;
         Console.SetCursorPosition(_coordinates.X, _coordinates.Y + i);
         Console.Write(Designs.GetEnemy());
     }
 }
예제 #5
0
 /// <summary>
 /// Displays the hero, if it has moved.
 /// </summary>
 public override void Display()
 {
     if (!_coordinates.Equals(_oldCoordinates))
     {
         for (int i = 0; i <= _relativeBoundry.Y; i++)
         {
             if (Designs.GetHero(Level, EngineLevel)[i].Length + _coordinates.X > ConsoleParameters.Width)
             {
                 throw new ArgumentOutOfRangeException($" {nameof(Hero)} is placed too close to boudry.");
             }
             ;
             Console.SetCursorPosition(_coordinates.X, _coordinates.Y + i);
             Console.Write(Designs.GetHero(Level, EngineLevel)[i]);
         }
     }
 }
예제 #6
0
        public MainWindow()
        {
            playerlife = 2;
            InitializeComponent();
            Globals.playerMissiles = new List <PlayerMissile>();
            PlayerShip statekgracza = PlayerShip.Instance();
            Designs    designs      = new Designs();

            highscores = new Dictionary <string, int>();


            #region Adding Textures
            Uri uri = new Uri(@"/Cruiser.PNG", UriKind.Relative);
            designs.addDesign("Cruiser", uri);
            uri = new Uri(@"/Destroyer.PNG", UriKind.Relative);
            designs.addDesign("Destroyer", uri);
            uri = new Uri(@"/PlayerShip.PNG", UriKind.Relative);
            designs.addDesign("PlayerShip", uri);
            uri = new Uri(@"/bullet.PNG", UriKind.Relative);
            designs.addDesign("Missile1", uri);
            uri = new Uri(@"/bullet.PNG", UriKind.Relative);
            designs.addDesign("Missile2", uri);
            uri = new Uri(@"/Booster.PNG", UriKind.Relative);
            designs.addDesign("Booster", uri);
            #endregion



            #region Adding Commands
            moveLeft  = new MoveLeft(statekgracza);
            moveRight = new MoveRight(statekgracza);
            shoot     = new Shoot(statekgracza);
            exit      = new Exit(this);
            commands  = new PlayerCommands();
            #endregion

            #region Adding Scores
            highscores.Add("Kamil", 20);
            highscores.Add("Piotr", 30);
            highscores.Add("Rafał", 40);
            #endregion


            #region Initialize Window
            main            = this;
            LifePoints      = "5";
            mapa            = new Canvas();
            lifecounter     = LifeCounter;
            pointscounter   = PointCounter;
            mapa.Width      = 800;
            mapa.Height     = 600;
            mapa.Background = new SolidColorBrush(Colors.White);
            mapa.Focusable  = true;
            Grid.SetRow(mapa, 0);
            Grid.SetRow(mapa, 0);
            Grid.SetColumnSpan(mapa, 6);
            Root.Children.Add(mapa);
            statekgracza.CreateShipDynamically(mapa);
            GameMaster gameMaster = new GameMaster(mapa, statekgracza);
            Thread     t          = new Thread(new ThreadStart(gameMaster.RunGame));
            t.Start();
            #endregion
        }