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

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

            spaceship.MoveRight();

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

            spaceship.MoveLeft();

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

            spaceship.MoveDown();

            Assert.AreEqual(0 + spaceship.Speed, spaceship.Y);
        }
Ejemplo 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);
        }
Ejemplo 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;
 }
Ejemplo 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();
 }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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;
        }
Ejemplo n.º 12
0
 public SpaceshipController(Spaceship spaceship, InputManager input)
 {
     this.spaceship = spaceship;
     this.input = input;
 }
Ejemplo 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);
        }
Ejemplo n.º 14
0
        public void MoveUpTest()
        {
            Spaceship spaceship = new Spaceship();
            spaceship.Y = 300;

            spaceship.MoveUp();

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

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

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