Exemplo n.º 1
0
 /// <summary>  //this probably isn't in the right place, it is used in control
 /// returns 0-3 if the mouse is on one of the buttons
 /// -1 if not
 /// </summary>
 /// <param name="x">mouse x pos</param>
 /// <param name="y">mouse y pos</param>
 /// <returns></returns>
 public int onButton(int x, int y)
 {
     if (scenario.getPlayer().SelectedEntities.Count != 0)  //change this if there are different menus for different entity types
     {
         if (y < iconLocation.Y || y > iconLocation.Y + buttonHeight)
         {
             return(-1);
         }
         if (x > iconLocation.X && x < iconLocation.X + buttonWidth)
         {
             return(0);
         }
         if (x > iconLocation.X + buttonWidth && x < iconLocation.X + 2 * buttonWidth)
         {
             return(1);
         }
         if (x > iconLocation.X + 2 * buttonWidth && x < iconLocation.X + 3 * buttonWidth)
         {
             return(2);
         }
         if (x > iconLocation.X + 3 * buttonWidth && x < iconLocation.X + 4 * buttonWidth)
         {
             return(3);
         }
     }
     return(-1);
 }
        public void testAddNewBuilding()
        {
            initialize();
            ZRTSModel.Entities.Building b = new ZRTSModel.Entities.Building(testScenario.getPlayer(), new ZRTSModel.Entities.BuildingStats());

            ///Test building at location (8,8). Should fail because of impassible tile
            ///at (9,9).
            bool success = testGameController.addEntity(b, 8, 8);

            Assert.False(success);
            ///Test building ontop of unit at location (17,17). Should fail, because there is a unit there
            success = testGameController.addEntity(b, 17, 17);
            Assert.False(success);
            ///Test building at location(0,0). Should succeed.
            success = testGameController.addEntity(b, 0, 0);
            Assert.True(success);
            ///Test building at location (12,12). Should fail from lack of resources.
            success = testGameController.addEntity(b, 12, 12);
            Assert.False(success);
        }