コード例 #1
0
        public void UpdateProjectiles_TouchBunkers()
        {
            //arrange
            int         bombSpeed    = 5;
            int         bombWidth    = 1;
            int         bombHeight   = 1;
            int         numBombSlots = 5;
            BombFactory bomb         = new BombFactory(bombSpeed, bombWidth, bombHeight, numBombSlots);

            int     numBunkers   = 1;
            int     screenWidth  = 100;
            int     screenHeight = 100;
            Bunkers bunkers      = new Bunkers(numBunkers, screenWidth, screenHeight, bunkerWidth, bunkerHeight, bunkerHealth, playerHeight, spaceBetweenBunkerAndPlayer);

            //act
            int xBomb = bomb.Bombs[0].BoundingBox.X;
            int yBomb = bomb.Bombs[0].BoundingBox.Y;

            bomb.UpdateProjectiles();

            int xBomb1 = bomb.Bombs[0].BoundingBox.X;
            int yBomb1 = bomb.Bombs[0].BoundingBox.Y;

            //assert

            Assert.AreEqual(0, xBomb); //expected, actual
            Assert.AreEqual(0, yBomb);

            Assert.AreEqual(0, xBomb1); //expected, actual
            Assert.AreEqual(0, yBomb1);
        }
コード例 #2
0
 // Use this for initialization
 public LevelManager(Vector3 spawnValues)
 {
     this.SpawnValues = spawnValues;
     Level            = new List <IList <Launchable> >();
     bombFactory      = new BombFactory();
     coinFactory      = new CoinFactory();
 }
コード例 #3
0
        public void Update()
        {
            LaserFactory laserFactory = new LaserFactory(laserSpeed, laserWidth, laserHeight, numRows * numColumns);
            BombFactory  bombFactory  = new BombFactory(bombSpeed, bombWidth, bombHeight, numBombSlots);

            ScoreAndLife scoreAndLife = new ScoreAndLife(lives, laserFactory, bombFactory);
            Player       player       = new Player(screenWidth, screenHeight, playerSpeed, playerWidth, playerHeight, laserFactory, bombFactory, scoreAndLife, timerIntervalPlayerRespawn);
            Bunkers      bunkers      = new Bunkers(numBunkers, screenWidth, screenHeight, bunkerWidth, bunkerHeight, bunkerHealth, playerHeight, spaceBetweenBunkerAndPlayer);
            Mothership   mothership   = new Mothership(screenWidth, mothershipWidth, mothershipHeight, mothershipSpeed, mothershipPoints, timerIntervalMothership, mothershipSpacerFromTop);
            //int screenWidth = 100;
            //int alienWidth = 1;
            //int alienHeight = 2;
            //int alienSpeed = 1;
            //int spacer = 1;
            //int numRows = 1;
            //int rowLength = 1;
            //int playerHeight = 0;
            //arrange
            //Bunkers bunkers = new Bunkers(numBunkers, screenWidth, screenHeight, bunkerWidth, bunkerHeight, bunkerHealth, playerHeight, spaceBetweenBunkerAndPlayer);
            BombFactory bf = new BombFactory(0, 0, 0, 0);

            AlienSquad alienS = new AlienSquad(bunkers, bombFactory, laserFactory, player, mothership, scoreAndLife, numRows, numColumns, screenWidth, player.BoundingBox.Height, alienWidth, alienHeight, alienSpeed, spacer, bombFrequency, alienPointStart, alienPointDecrement, alienSpacerFromTop, speedIncrease, bombFrequencyIncrement, bombFrequencyMin);

            //act
            alienS.Update();

            //assert
            //Assert.AreEqual(,); //expected, actual
        }
コード例 #4
0
        public void Update(GameTime gameTime)
        {
            StarFactory.Update(gameTime, _tunnel, Scene, _player);
            BombFactory.Update(gameTime, _tunnel, Scene, _player);

            ExplosionParticles.Update(gameTime);
            FireParticles.Update(gameTime);
            SmokeParticles.Update(gameTime);
            StarsParticles.Update(gameTime);
        }
コード例 #5
0
        public ScoreAndLife(int lives, LaserFactory laserFactory, BombFactory bombFactory)
        {
            this.bombFactory  = bombFactory;
            this.laserFactory = laserFactory;
            this.lives        = lives;

            laserFactory.alienDeath      += OnAlienDeath;
            laserFactory.mothershipDeath += OnAlienDeath;
            gameOver += laserFactory.EndGame;
        }
コード例 #6
0
    public void CreatesLaunchableOfCorrectType()
    {
        var launchPoint = new Vector3(0, 0, 0);
        var coinFactory = new CoinFactory();
        var bombFactory = new BombFactory();
        var bomb        = bombFactory.CreateLaunchable(100, launchPoint);
        var coin        = coinFactory.CreateLaunchable(100, launchPoint);

        Assert.AreEqual(LaunchType.Bomb, bomb.LaunchType);
        Assert.AreEqual(LaunchType.Coin, coin.LaunchType);
        // Use the Assert class to test conditions.
    }
コード例 #7
0
        public void Update(GameTime gameTime)
        {
            StarFactory.Update(gameTime, _tunnel, Scene, _player);
            BombFactory.Update(gameTime, _tunnel, Scene, _player);
            // Log the position for the analysis
            LoopGame.Instance.GameObjects.TryUpdate("PlayerPosition", new Vector3(_player.Angle, Globals.Lives, Globals.TotalScore));

            ExplosionParticles.Update(gameTime);
            FireParticles.Update(gameTime);
            SmokeParticles.Update(gameTime);
            StarsParticles.Update(gameTime);
        }
コード例 #8
0
        public EnclosureFactoryUseCase(BombFactory bombFactory, HeartFactory heartFactory, BulletFactory bulletFactory,
                                       EncloseEffectFactory encloseEffectFactory)
        {
            _factories = new List <IEnclosureObjectFactory>
            {
                bombFactory,
                heartFactory,
                bulletFactory,
            };
            _encloseEffectFactory = encloseEffectFactory;

            Initialize();
        }
コード例 #9
0
    void Start()
    {
        mSystemManager      = GameObject.Find("SystemManager");
        mBombFactory        = mSystemManager.GetComponent <BombFactory>();
        mBombExplodeFactory = mSystemManager.GetComponent <BombExplodeFactory>();
        mCharacterManager   = mSystemManager.GetComponent <CharacterManager>();
        mItemFactory        = mSystemManager.GetComponent <ItemFactory>();

        mTileMap   = mSystemManager.GetComponent <TileMap>();
        mCharacter = this.GetComponent <Character>();

        mNearIndex     = new Dictionary <int, float>();
        mBestIndexList = new List <int>();
    }
コード例 #10
0
    void Start()
    {
        mSystemManager      = GameObject.Find("SystemManager");
        mBombFactory        = mSystemManager.GetComponent <BombFactory>();
        mBombExplodeFactory = mSystemManager.GetComponent <BombExplodeFactory>();
        mCharacterManager   = mSystemManager.GetComponent <CharacterManager>();
        mItemFactory        = mSystemManager.GetComponent <ItemFactory>();

        mTileMap   = mSystemManager.GetComponent <TileMap>();
        mCharacter = this.GetComponent <Character>();

        mCurIndex  = TileMap.PosToIndex(transform.position);
        mNextIndex = mCurIndex;

        CalcBehavior();
    }
コード例 #11
0
        public void MoveLeft_EnoughSpace()
        {
            int          playerW      = 10;
            int          screenW      = 20;
            int          speed        = 5; //should end up at 0
            LaserFactory laserFactory = new LaserFactory(laserSpeed, laserWidth, laserHeight, numRows * numColumns);
            BombFactory  bombFactory  = new BombFactory(bombSpeed, bombWidth, bombHeight, numBombSlots);

            // Create game objects
            ScoreAndLife scoreAndLife = new ScoreAndLife(lives, laserFactory, bombFactory);
            //arrange

            Player player = new Player(screenW, 100, speed, playerW, 2, laserFactory, bombFactory, scoreAndLife, timerIntervalPlayerRespawn);

            //act
            player.MoveLeft();
            int x = player.BoundingBox.X;


            //assert
            Assert.AreEqual(0, x); //expected, actual
        }
コード例 #12
0
        public void UpdateProjectiles_TouchPlayer()
        {
            int          bombSpeed    = 5;
            int          bombWidth    = 1;
            int          bombHeight   = 1;
            int          numBombSlots = 5;
            LaserFactory laserFactory = new LaserFactory(laserSpeed, laserWidth, laserHeight, numRows * numColumns);
            BombFactory  bombFactory  = new BombFactory(bombSpeed, bombWidth, bombHeight, numBombSlots);

            // Create game objects
            ScoreAndLife scoreAndLife = new ScoreAndLife(lives, laserFactory, bombFactory);
            Player       player       = new Player(screenWidth, screenHeight, playerSpeed, playerWidth, playerHeight, laserFactory, bombFactory, scoreAndLife, timerIntervalPlayerRespawn);
            //arrange
            BombFactory bomb = new BombFactory(bombSpeed, bombWidth, bombHeight, numBombSlots);

            //int playerW = 10;
            //int screenW = 20;
            //int speed = 5; //should end up at 0

            //act
            int xBomb = bomb.Bombs[0].BoundingBox.X;
            int yBomb = bomb.Bombs[0].BoundingBox.Y;

            bomb.UpdateProjectiles();

            int xBomb1 = bomb.Bombs[0].BoundingBox.X;
            int yBomb1 = bomb.Bombs[0].BoundingBox.Y;

            //assert

            Assert.AreEqual(0, xBomb); //expected, actual
            Assert.AreEqual(0, yBomb);

            Assert.AreEqual(0, xBomb1); //expected, actual
            Assert.AreEqual(0, yBomb1);
        }
コード例 #13
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Create textures
            Texture2D textureAlien      = this.Content.Load <Texture2D>(@"assets/bug");
            Texture2D textureBomb       = this.Content.Load <Texture2D>(@"assets/bomb");
            Texture2D textureBunker     = this.Content.Load <Texture2D>(@"assets/bunker");
            Texture2D textureLaser      = this.Content.Load <Texture2D>(@"assets/laser");
            Texture2D textureMothership = this.Content.Load <Texture2D>(@"assets/mothership");
            Texture2D texturePlayer     = this.Content.Load <Texture2D>(@"assets/player");

            // Initialize variables
            alienHeight      = textureAlien.Height;
            alienWidth       = textureAlien.Width;
            bombHeight       = textureBomb.Height;
            bombWidth        = textureBomb.Width;
            bunkerHeight     = textureBunker.Height;
            bunkerWidth      = textureBunker.Width;
            laserHeight      = textureLaser.Height;
            laserWidth       = textureLaser.Width;
            mothershipHeight = textureMothership.Height;
            mothershipWidth  = textureMothership.Width;
            playerHeight     = texturePlayer.Height;
            playerWidth      = texturePlayer.Width;

            // Create factories
            laserFactory = new LaserFactory(laserSpeed, laserWidth, laserHeight, numRows * numColumns);
            bombFactory  = new BombFactory(bombSpeed, bombWidth, bombHeight, numBombSlots);

            // Create game objects
            scoreAndLife = new ScoreAndLife(lives, laserFactory, bombFactory);
            player       = new Player(screenWidth, screenHeight, playerSpeed, playerWidth, playerHeight, laserFactory, bombFactory, scoreAndLife, timerIntervalPlayerRespawn);
            bunkers      = new Bunkers(numBunkers, screenWidth, screenHeight, bunkerWidth, bunkerHeight, bunkerHealth, playerHeight, spaceBetweenBunkerAndPlayer);
            mothership   = new Mothership(screenWidth, mothershipWidth, mothershipHeight, mothershipSpeed, mothershipPoints, timerIntervalMothership, mothershipSpacerFromTop);
            alienSquad   = new AlienSquad(bunkers, bombFactory, laserFactory, player, mothership, scoreAndLife, numRows, numColumns, screenWidth, player.BoundingBox.Height, alienWidth, alienHeight, alienSpeed, spacer, bombFrequency, alienPointStart, alienPointsPerRow, alienSpacerFromTop, speedIncrease, bombFrequencyIncrement, bombFrequencyMin);

            // Create sprite objects
            laserSprite      = new LaserSprite(this, laserFactory.Laser, textureLaser);
            mothershipSprite = new MothershipSprite(this, mothership, player, textureMothership);
            playerSprite     = new PlayerSprite(this, player, texturePlayer);
            scoreSprite      = new ScoreSprite(this, scoreAndLife);

            for (var x = 0; x < alienSquad.Length; x++)
            {
                Components.Add(new AlienSprite(this, (Alien)alienSquad[x], textureAlien));
            }
            foreach (Bunker bunker in bunkers)
            {
                Components.Add(new BunkerSprite(this, bunker, textureBunker));
            }
            foreach (Projectile bomb in bombFactory.Bombs)
            {
                Components.Add(new BombSprite(this, bomb, textureBomb));
            }

            // Add components
            Components.Add(mothershipSprite);
            Components.Add(playerSprite);
            Components.Add(scoreSprite);
            Components.Add(laserSprite);

            // Register objects
            laserFactory.RegisterAlienSquad(alienSquad);
            laserFactory.RegisterBunkers(bunkers);
            laserFactory.RegisterMothership(mothership);
            bombFactory.RegisterBunkers(bunkers);
            bombFactory.RegisterPlayer(player);

            base.Initialize();
        }
コード例 #14
0
 public void DestroyAllObjects()
 {
     StarFactory.DestroyAll(Scene);
     BombFactory.DestroyAll(Scene);
 }
コード例 #15
0
 public BombManager()
 {
     bombs       = new List <Bomb>();
     bombFactory = FactoryContainer.Instance.Resolve <BombFactory>();
 }
コード例 #16
0
 public Player(BombFactory bombFactory)
 {
     _bombFactory     = bombFactory;
     BomCreationState = new SimpleBombCreationState();
 }