/// <summary> /// Checking if mouse is clicking within the valid game locations /// </summary> /// <param name="x">the x coordinate</param> /// <param name="y">the y coordinate</param> /// <returns>True if it is valid</returns> private Boolean isWithInBound(float x, float y) { return(x < testScenario.getGameWorld().map.width&& x >= 0 && y < testScenario.getGameWorld().map.height&& y >= 0); }
public void testAddNewBuilding() { initialize(); ZRTSModel.Entities.Building b = new ZRTSModel.Entities.Building(testScenario.getPlayer(), new ZRTSModel.Entities.BuildingStats()); ///Test building ontop of unit at location (17,17). Should fail, because there is a unit there ///Test building at location (8,8). Should fail because of impassible tile ///at (9,9). bool success = testGameController.makeUnitBuild(testScenario.getUnit(17, 17), b, testScenario.getGameWorld().map.getCell(17, 17)); Assert.False(success); ///Test building at location (8,8). Should fail because of impassible tile ///at (9,9). success = testGameController.makeUnitBuild(testScenario.getUnit(17, 17), b, testScenario.getGameWorld().map.getCell(8, 8)); Assert.False(success); ///Test building at location(0,0). Should succeed. success = testGameController.makeUnitBuild(testScenario.getUnit(17, 17), b, testScenario.getGameWorld().map.getCell(0, 0)); Assert.True(success); ///Test building at location (12,12). Should fail from lack of resources. success = testGameController.makeUnitBuild(testScenario.getUnit(17, 17), b, testScenario.getGameWorld().map.getCell(12, 12)); Assert.False(success); }