Exemple #1
0
        public Enemy(FourFrameSprite sprite, Vector2 position, int currentFrame)
        {
            _sprite = sprite;
            _position = position;
            _prevPosition = position;
            _currentFrame = currentFrame;
            _health = 100;

            playerMoveSpeed = 3.0f;
            _control = new EnemyControl(_position, Width, Height, _directions[currentFrame]);
        }
Exemple #2
0
        public Player_2(FourFrameSprite sprite, Vector2 position, int currentFrame)
        {
            _sprite = sprite;
            _position = position;
            _prevPosition = position;
            _currentFrame = currentFrame;
            _health = 100;

            playerMoveSpeed = 4.0f;
            _control = new Control_2(_position, Width, Height);
        }
Exemple #3
0
        //private void LoadLevel() //for random level generation
        //{
        //    Random random = new Random();
        //    for (int row = 0; row < _levelMask.GetLength(0); row++)
        //    {
        //    }
        //}
        private void GenerateEnemy()
        {
            if(_currentLevel==1)
            {
                Random randomSP = new Random(); // Random SpawnPoint
                Random randomTT = new Random(); // random TankTextures
                Random randomDir = new Random();

                FourFrameSprite tempSprite = null;

                int tmpRandom = randomSP.Next(0, _spawnPoints.Length);
                int tmpTexture = randomTT.Next(0, _enemyTexture.Length);
                int tmpDirection = randomDir.Next(0, 4);
                int enemyIdCount = 2001;

                if (_enemyCount <= _maxEnemy && !_enemyTrackingList.Contains(tmpRandom) && _enemiesKilled <= _maxEnemiesKilled)
                {
                    _enemyTrackingList.Add(tmpRandom);
                    tempSprite = new FourFrameSprite(_enemyTexture[tmpTexture], 40, 40, Color.White);
                    Vector2 tempVector = new Vector2((int)_spawnPoints[tmpRandom].X, (int)_spawnPoints[tmpRandom].Y);

                    _gameObjects.Add(new Enemy(tempSprite, tempVector, tmpDirection) { Id = enemyIdCount++ });
                    _enemyCount++;
            }

            }
        }
Exemple #4
0
        public void LoadContent()
        {
            if (_currentLevel == 0) // menu
            {
                buttonsTextures[0] = _content.Load<Texture2D>("textures/Buttons/start");
                buttonsTextures[1] = _content.Load<Texture2D>("textures/Buttons/exit");
                buttonsTextures[2] = _content.Load<Texture2D>("textures/Buttons/pause");
                buttonsTextures[3] = _content.Load<Texture2D>("textures/Buttons/resume");
                buttonsTextures[4] = _content.Load<Texture2D>("textures/Buttons/Menu");
                buttonsTextures[5] = _content.Load<Texture2D>("textures/Buttons/multiplayerButton");

                menu = new Menu(buttonsTextures, 1280, 720);
            }
            else if (_currentLevel == 1)  //level 1
            {

                //background
                Sprite levelBackground = new Sprite(_backgroundTexture, new Rectangle(0, 0, _backgroundTexture.Width, _backgroundTexture.Height)) {Id = 8000 , IsActive = true}; // this way it collides but loads the bg
                _gameObjects.Add(levelBackground);

                //player tank
                Texture2D tank = _content.Load<Texture2D>("sprites/BlueTank/BlueTank");
                FourFrameSprite playerSprite = new FourFrameSprite(tank, 40, 40, Color.White);
                _gameObjects.Add(new Player(playerSprite, new Vector2(620,700 ), 3) { Id = 1 });

                //level (will extract in a method or class)
                //Texture2D tuhla_v2 = _content.Load<Texture2D>("textures/Bricks/480px-Brick_Block_-_New_Super_Mario_Bros");
                _level1 = new Level_1();
                GenerateLevel(_level1.GetLevel());

                //Load Bullets
                LoadBullets();

            }
            else if (_currentLevel == 2) // Player vs Player (local)
            {
                //background
                Sprite levelBackground = new Sprite(_backgroundTexture, new Rectangle(0, 0, _backgroundTexture.Width, _backgroundTexture.Height)) { Id = 8000, IsActive = true }; // this way it collides but loads the bg
                _gameObjects.Add(levelBackground);

                //player tank
                Texture2D tank = _content.Load<Texture2D>("sprites/BlueTank/BlueTank");
                FourFrameSprite playerSprite = new FourFrameSprite(tank, 40, 40, Color.White);
                _gameObjects.Add(new Player(playerSprite, new Vector2(620, 700), 2) { Id = 1 });

                //player2 tank
                Texture2D tank2 = _content.Load<Texture2D>("sprites/GreenTank/GreenTank");
                FourFrameSprite player2Sprite = new FourFrameSprite(tank2, 40, 40, Color.White);
                _gameObjects.Add(new Player_2(player2Sprite, new Vector2(620, 0), 3) { Id = 2 });
                //level (will extract in a method or class)
                //Texture2D tuhla_v2 = _content.Load<Texture2D>("textures/Bricks/480px-Brick_Block_-_New_Super_Mario_Bros");
                _level1 = new Level_1();
                GenerateLevel(_level1.GetLevel());

                //Load Bullets
                LoadBullets();
            }
        }