示例#1
0
        public GameWorld(Form form)
        {
            mainWindow = form;
            MessageBox.Show("Hra bude spuštěna", "Zpráva hry");
            timer.Interval = 100;
            mainWindow.Paint += MainWindow_Paint;
            timer.Tick += UpdateGame;
            timer.Start();

            Player player = new Player(this);
            listOfGameObjects.Add(player);
            Enemy enemy = new Enemy(this, "Graphics\\Nepritel1.bmp");
            listOfGameObjects.Add(enemy);

            mainWindow.KeyDown += MainWindow_KeyDown;

            enemyGenerator.Interval = 2000;
            enemyGenerator.Tick += EnemyGenerator_Tick;
            enemyGenerator.Start();
        }
示例#2
0
 public void removeEnemy(Enemy e)
 {
     mEnemies.Remove(e);
     --mCount;
 }
示例#3
0
 public void addEnemy(Enemy e)
 {
     mEnemies.Add(e);
     ++mCount;
 }
示例#4
0
        private void EnemyGenerator_Tick(object sender, EventArgs e)
        {
            Random enemyTypeGenerator = new Random();
            Enemy enemy = null;

            if (enemyTypeGenerator.Next(0, 2) == 0) {
                enemy = new Enemy(this, "Graphics\\Nepritel1.bmp");
            }
            else {
                enemy = new Enemy(this, "Graphics\\Nepritel2.bmp");
            }

            enemy.X = enemyTypeGenerator.Next(GameObject.MAX_X - 100);

            for (int i = 0; i < this.listOfGameObjects.Count; i++) {
                if (ObjectsCollide(listOfGameObjects[i], enemy)) {
                    return;
                }
            }

            listOfGameObjects.Add(enemy);
        }