Exemplo n.º 1
0
        public void LeftBoundaryTest()
        {
            Spaceship spaceship = new Spaceship();
            spaceship.LeftBoundary = 0;
            spaceship.MoveLeft();

            Assert.AreEqual(-spaceship.Speed, spaceship.X);
        }
Exemplo n.º 2
0
        public void MoveRightTest()
        {
            Spaceship spaceship = new Spaceship();
            spaceship.X = 0;

            spaceship.MoveRight();

            Assert.AreEqual(0 + spaceship.Speed, spaceship.X);
        }
Exemplo n.º 3
0
        public void MoveLeftTest()
        {
            Spaceship spaceship = new Spaceship();
            spaceship.X = 300;

            spaceship.MoveLeft();

            Assert.AreEqual(300 - spaceship.Speed, spaceship.X);
        }
Exemplo n.º 4
0
        public void MoveDownTest()
        {
            Spaceship spaceship = new Spaceship();
            spaceship.Y = 0;

            spaceship.MoveDown();

            Assert.AreEqual(0 + spaceship.Speed, spaceship.Y);
        }
Exemplo n.º 5
0
        public void BottomBoundaryTest()
        {
            Spaceship spaceship = new Spaceship();
            spaceship.Y = 300 - spaceship.Height;
            spaceship.BottomBoundary = 300;
            spaceship.MoveDown();

            Assert.AreEqual(300 - spaceship.Height, spaceship.Y);
        }
Exemplo n.º 6
0
 public GameObjectsManager(Spaceship spaceship, Random random)
 {
     liftObjects = new List<LiftObject>();
     projectiles = new List<Projectile>();
     explosions = new List<Explosion>();
     objectsToRemove = new List<GameObject>();
     objectsToAdd = new List<GameObject>();
     explodeDelay = 0;
     this.random = random;
     Spaceship = spaceship;
 }
Exemplo n.º 7
0
 public GameScreen()
 {
     background = new Background();
     Spaceship spaceship = new Spaceship();
     input = new InputManager();
     controller = new SpaceshipController(spaceship, input);
     random = new Random();
     gameObjectsManager = new GameObjectsManager(spaceship, random);
     hud = new GameInfo();
     gameObjectsManager.AddStartingCows();
 }
Exemplo n.º 8
0
        public void ProcessSpaceInputTest()
        {
            Spaceship spaceship = new Spaceship();
            InputManager input = new InputManager();
            PrivateObject privateInput = new PrivateObject(input);
            privateInput.SetField("currentState", new KeyboardState(Keys.Space));

            SpaceshipController controller = new SpaceshipController(spaceship, input);

            controller.ProcessInput();
            Assert.IsTrue(spaceship.BeamOn);
        }
Exemplo n.º 9
0
        public void UpInputTest()
        {
            Spaceship spaceship = new Spaceship();
            InputManager input = new InputManager();
            PrivateObject privateInput = new PrivateObject(input);
            privateInput.SetField("currentState", new KeyboardState(Keys.W));

            SpaceshipController controller = new SpaceshipController(spaceship, input);

            spaceship.Y = 300;
            controller.ProcessInput();
            Assert.AreEqual(300 - spaceship.Speed, spaceship.Y);
        }
Exemplo n.º 10
0
        public void LiftObjectsTest()
        {
            Spaceship spaceship = new Spaceship();
            spaceship.X = 49;
            spaceship.Width = 200;
            GameObjectsManager manager = new GameObjectsManager(new Spaceship(), new Random());
            manager.AddRandomObject();
            manager.LiftObjects(spaceship);
            manager.Update(new GameTime());

            PrivateObject privateManager = new PrivateObject(manager);
            List<LiftObject> liftObjects = (List<LiftObject>)privateManager.GetField("liftObjects");

            Assert.IsTrue(liftObjects[0].Position.Y < 500);
        }
Exemplo n.º 11
0
        // Returns the captured object
        public LiftObject LiftObjects(Spaceship spaceship)
        {
            Vector2 spaceshipCenter = new Vector2(spaceship.X + spaceship.Width / 2, spaceship.Y + spaceship.Height / 2);

            // Currently using spaceships width for beam width
            foreach (LiftObject liftObject in liftObjects)
            {
                liftObject.Lift(spaceshipCenter, spaceship.CurrentBeam.Force, spaceship.CurrentBeam.Position, spaceship.Width);
                if (liftObject.Captured)
                {
                    RemoveObject(liftObject);
                    return liftObject;
                }
            }

            return null;
        }
Exemplo n.º 12
0
 public SpaceshipController(Spaceship spaceship, InputManager input)
 {
     this.spaceship = spaceship;
     this.input = input;
 }
Exemplo n.º 13
0
        public void RightBoundaryTest()
        {
            Spaceship spaceship = new Spaceship();
            spaceship.X = 300 - spaceship.Width;
            spaceship.RightBoundary = 300;
            spaceship.MoveRight();

            Assert.AreEqual(300 - spaceship.Width, spaceship.X);
        }
Exemplo n.º 14
0
        public void MoveUpTest()
        {
            Spaceship spaceship = new Spaceship();
            spaceship.Y = 300;

            spaceship.MoveUp();

            Assert.AreEqual(300 - spaceship.Speed, spaceship.Y);
        }
Exemplo n.º 15
0
        public void GetBeamNameTest()
        {
            Spaceship spaceship = new Spaceship();

            Assert.AreEqual("Tractor Beam", spaceship.CurrentBeam.Name);
        }
Exemplo n.º 16
0
        public void TopBoundaryTest()
        {
            Spaceship spaceship = new Spaceship();
            spaceship.Y = 0;
            spaceship.TopBoundary = 0;
            spaceship.MoveUp();

            Assert.AreEqual(0, spaceship.Y);
        }