public void TestNumberOfCamerasFromDAL() { GlobalInformation.ReadConfigFile(); var dal = new DataAccessLayer(); var expectedNumberOfCameras = 5; var cameras = dal.GetCameras(); Assert.AreEqual(expectedNumberOfCameras, cameras.ToList().Count); }
public void TestSetup(string picturePath) { Directory.CreateDirectory(picturePath); DBConnectionFactory.Mock = true; try { GlobalInformation gi = GlobalInformation.InitializeInstance(picturePath); } catch (Exception) { } }
public void TestGetSingleCameraWithWrongID() { GlobalInformation.ReadConfigFile(); var dal = new DataAccessLayer(); var expectedIDofCamera = 2; var camera = dal.GetCamera(1); Assert.AreNotEqual(expectedIDofCamera, camera.ID); }
public void TestNumberOfPicturesFromDAL() { GlobalInformation.ReadConfigFile(); var dal = new DataAccessLayer(); var expectedNumberOfPictures = 6; var picture = dal.GetPictures(null, null, null, null); Assert.AreEqual(expectedNumberOfPictures, picture.ToList().Count); }
public void TestExistCheckForPhotographerFromDAL() { GlobalInformation.ReadConfigFile(); var dal = new DataAccessLayer(); var photographer = dal.GetPhotographer(1); var exists = dal.Exists(photographer); Assert.IsTrue(exists); }
public void TestExistCheckForPicturesFromDAL() { GlobalInformation.ReadConfigFile(); var dal = new DataAccessLayer(); var picture = dal.GetPicture(2018); var exists = dal.Exists(picture); Assert.IsTrue(exists); }
public void TestGetSinglePhotographerWithWrongID() { GlobalInformation.ReadConfigFile(); var dal = new DataAccessLayer(); var expectedIdOfPhotographer = 2; var photographer = dal.GetPhotographer(1); Assert.AreNotEqual(expectedIdOfPhotographer, photographer.ID); }
public void TestNumberOfPhotographersFromDal() { GlobalInformation.ReadConfigFile(); var dal = new DataAccessLayer(); var expectedNumberOfPhotographers = 5; var photographer = dal.GetPhotographers(); Assert.AreEqual(expectedNumberOfPhotographers, photographer.ToList().Count); }
private void Awake() { if (!init) { init = this; } else { Destroy(gameObject); } }
void Awake() { //Takes in the GlobalInformation which is part of the game master. GM = (GlobalInformation)FindObjectOfType(typeof(GlobalInformation)); totalTime = totalTime + Time.time; timeDelay = Time.time + inBetweenTime; random = new System.Random(); //Starts the Chili Spawning sequence InvokeRepeating("SpawnChili", 0, inBetweenTime); text.text = ""; }
void Start() { //Keeps the original GameMaster if the next scene has a game master. GM = (GlobalInformation)FindObjectOfType(typeof(GlobalInformation)); if (GM.GMActive == true) { Destroy(this.gameObject); } GMActive = true; //Keeps the GameMaster throughout the game DontDestroyOnLoad(this); }
public void Initialise(BuildingGenerator bg) { gridGenerator = bg.gridGenerator; edgelength = gridGenerator.cellSize; generationAllowed = true; //Temporary cellCollider = gridGenerator.getCellCollider(); mainCam = Camera.main; camTransform = mainCam.gameObject.transform; groundCursor = GlobalInformation.groundCursor.transform; viewDistance = GlobalInformation.viewDistance; buildingGenerator = bg; localSeed = GlobalInformation.hash((int)transform.position.x ^ GlobalInformation.hash(GlobalInformation.worldSeed ^ (int)transform.position.z)); initialised = true; }
public NexusPoll(ILogger <NexusPoll> logger, AppSettings settings, SqlService service, GlobalInformation globalInformation, NexusKeyMaintainance keys) { _sql = service; _settings = settings; _globalInformation = globalInformation; _logger = logger; _keys = keys; }
void Awake() { speech.text = ""; StuffToSayThisFrame = ""; GM = (GlobalInformation)FindObjectOfType(typeof(GlobalInformation)); }
Node[,] generateStreetGrid(Transform parent) { //Lay out grid of nodes Node[,] grid = new Node[(int)areaLength / cellSize, (int)areaWidth / cellSize]; for (int i = 0; i < grid.GetLength(0); i++) { for (int j = 0; j < grid.GetLength(1); j++) { grid[i, j] = new Node(new Vector3( cellGrid[i, j].transform.position.x + cellSize / 2, 0, cellGrid[i, j].transform.position.z + cellSize / 2 )); } } //----------------------- Random.InitState(GlobalInformation.hash(GlobalInformation.worldSeed ^ gameObject.name.GetHashCode())); //Instantiate street Grid in random fashion--------- for (int i = 0; i < (int)areaLength / cellSize; i++) { for (int j = 0; j < (int)areaWidth / cellSize; j++) { //Instantiate street to the west if (Random.Range(0.0f, 1.0f) > streetDensity) { GameObject streetWest = Instantiate(street, new Vector3(grid[i, j].position.x, 0.1f, grid[i, j].position.z - cellSize / 2), street.transform.rotation); streetWest.AddComponent <Street>(); streetWest.name = "Street_x=" + grid[i, j].position.x + ", z=" + (grid[i, j].position.z - cellSize / 2); streetWest.transform.parent = parent; grid[i, j].roadEast = true; try { grid[i, j - 1].roadWest = true; } catch (Exception) { } } //Instantiate street to the south if (Random.Range(0.0f, 1.0f) > streetDensity) { GameObject streetSouth = Instantiate(street, new Vector3(grid[i, j].position.x - cellSize / 2, 0.1f, grid[i, j].position.z), street.transform.rotation); streetSouth.AddComponent <Street>(); streetSouth.name = "Street_x=" + (grid[i, j].position.x - cellSize / 2) + ", z=" + grid[i, j].position.z; streetSouth.transform.parent = parent; streetSouth.transform.Rotate(new Vector3(0, 90, 0)); grid[i, j].roadSouth = true; try { grid[i - 1, j].roadNorth = true; } catch (Exception) { } } } } //--------------------------------------------------- //Connect the streets-------------------------------- GameObject con = new GameObject(); foreach (Node n in grid) { if (n.roadNorth && n.roadSouth && n.roadEast && n.roadWest) //crossroad { con = crossRoad(n); } if (!n.roadNorth && n.roadSouth && n.roadEast && n.roadWest) //T-junction w/o North { con = tJunction(n); } if (n.roadNorth && n.roadSouth && !n.roadEast && n.roadWest) //T-junction w/o East { con = tJunction(n); } if (n.roadNorth && !n.roadSouth && n.roadEast && n.roadWest) //T-junction w/o South { con = tJunction(n); } if (n.roadNorth && n.roadSouth && n.roadEast && !n.roadWest) //T-junction w/o West { con = tJunction(n); } if (!n.roadNorth && !n.roadSouth && n.roadEast && n.roadWest) //Connect 2 horizontal streets { con = connectHorizontal(n); } if (n.roadNorth && n.roadSouth && !n.roadEast && !n.roadWest) //Connect 2 vertical streets { con = connectVertical(n); } if (n.roadNorth && !n.roadSouth && n.roadEast && !n.roadWest) //Corner N/E { con = corner(n); } if (!n.roadNorth && n.roadSouth && n.roadEast && !n.roadWest) //Corner E/S { con = corner(n); } if (!n.roadNorth && n.roadSouth && !n.roadEast && n.roadWest) //Corner S/W { con = corner(n); } if (n.roadNorth && !n.roadSouth && !n.roadEast && n.roadWest) //Corner W/N { con = corner(n); } if (n.roadNorth && !n.roadSouth && !n.roadEast && !n.roadWest) //end N { con = end(n); } if (!n.roadNorth && !n.roadSouth && n.roadEast && !n.roadWest) //end E { con = end(n); } if (!n.roadNorth && n.roadSouth && !n.roadEast && !n.roadWest) //end S { con = end(n); } if (!n.roadNorth && !n.roadSouth && !n.roadEast && n.roadWest) //end W { con = end(n); } //If node has got a gameobject try { con.GetComponent <Street>().setNode(n); n.inheritor = con; } catch (Exception) { } //add connection to street parent con.transform.parent = parent; } //--------------------------------------------------- //Set height of all streets------------------------------ float spawnHeight = 0; foreach (Node n in grid) { int i = 0; bool found = false; //Get height of terrain at every node while (!found) { RaycastHit hit; if (Physics.Raycast(new Vector3(n.position.x, i, n.position.z), transform.TransformDirection(-Vector3.up), out hit)) { if (hit.collider.gameObject == GlobalInformation.terrain) { if (hit.point.y > spawnHeight) { spawnHeight = hit.point.y + 0.1f; } found = true; } } i++; if (i > 100) { Debug.LogError("Something is wrong, is there terrain?"); found = true; } } } foreach (Transform child in parent.GetComponentsInChildren <Transform>()) { if (child.GetComponent <Street>()) { child.position = new Vector3(child.position.x, spawnHeight + 0.1f, child.position.z); } } //------------------------------------------------------ return(grid); }
public NexusPoll(ILogger <NexusPoll> logger, AppSettings settings, SqlService service, GlobalInformation globalInformation) { _sql = service; _settings = settings; _globalInformation = globalInformation; _logger = logger; }
void Start() { Random.InitState(GlobalInformation.hash(GlobalInformation.worldSeed ^ gameObject.name.GetHashCode())); PerlinOffset = Random.Range(0, 100); cubeRotation = transform.rotation; transform.rotation = Quaternion.identity; cellCollider = new GameObject(); generators = GetComponentsInChildren <BuildingGenerator>(); ArrayList obstacles = new ArrayList(); foreach (Collider col in FindObjectsOfType <Collider>()) { if (!col.CompareTag("ignore")) { Debug.Log(col.name + " is added to obstacles by " + name); obstacles.Add(col); } } Debug.Log(name); //compute cellSize by computing maximum building dimensions if (automaticCellsize) { float biggestSize = 0; foreach (BuildingGenerator generator in generators) { foreach (buildingStep step in generator.steps) { if (step.isPolygon) { if (biggestSize < step.maxRadius * 2) { Debug.Log("step.maxRadius * 2 = " + step.maxRadius * 2); biggestSize = step.maxRadius * 2; } } else { if (biggestSize < Mathf.Sqrt(step.maxWidth * step.maxWidth + step.maxLength * step.maxLength) * 2) { Debug.Log(String.Format("Mathf.Sqrt({0}*{0}+{1}*{1}) = {2})*2", step.maxWidth, step.maxLength, Mathf.Sqrt(step.maxWidth * step.maxWidth + step.maxLength * step.maxLength) * 2)); biggestSize = Mathf.Sqrt(step.maxWidth * step.maxWidth + step.maxLength * step.maxLength) * 2; } } } } cellSize = Mathf.CeilToInt(biggestSize) + roadWidth / 4; } //--------------------------------------------------------- areaLength = GlobalInformation.get2DBounds(gameObject).x; areaWidth = GlobalInformation.get2DBounds(gameObject).y; //Generate cellgrid GameObject cellGridParent = new GameObject(); cellGridParent.name = "CellGrid" + name; cellGridParent.transform.parent = transform; cellGrid = generateCellGrid(cellGridParent.transform); //Generate streetGrid GameObject streetGridParent = new GameObject(); streetGridParent.name = "StreetGrid" + name; streetGridParent.transform.parent = transform; streetGrid = generateStreetGrid(streetGridParent.transform); //Delete Grid where Obstacles are found foreach (Collider col in obstacles) { RaycastHit hit; Ray ray; foreach (Transform obj in streetGridParent.GetComponentsInChildren <Transform>()) { //Check if obj is within obstacle try{ Vector3 offset = col.bounds.center - obj.position; ray = new Ray(obj.position, offset.normalized); if (!col.Raycast(ray, out hit, offset.magnitude * 1.1f)) { Debug.Log(obj.name + "will be destroyed"); Destroy(obj.gameObject); } } catch (Exception e) { Debug.LogWarning(e); } } foreach (Transform obj in cellGridParent.GetComponentsInChildren <Transform>()) { //Check if obj is within obstacle try{ Vector3 offset = col.bounds.center - obj.position; ray = new Ray(obj.position, offset.normalized); if (!col.Raycast(ray, out hit, offset.magnitude * 1.1f)) { Debug.Log(obj.name + "will be destroyed"); Destroy(obj.gameObject); } } catch (Exception e) { Debug.LogWarning(e); } } } //-------------------------------- foreach (Collider col in GetComponentsInChildren <Collider>()) { col.gameObject.tag = "ignore"; } gameObject.GetComponent <MeshRenderer>().enabled = false; transform.rotation = cubeRotation; }
void Awake() { instance = this; }
public void Config_Sets_ReportPath() { GlobalInformation.ReadConfigFile(); Assert.IsNotNull(GlobalInformation.ReportPath); }
public void Config_Sets_ConnectiongString() { GlobalInformation.ReadConfigFile(); Assert.IsNotNull(GlobalInformation.ConnectionString); }
public Heartbeat(ILogger <Heartbeat> logger, SqlService sql, GlobalInformation globalInformation) { _globalInformation = globalInformation; _sql = sql; _logger = logger; }
static MyTestCases() { GlobalInformation.ReadConfigFile(); _dal = (DataAccessLayer)DataAccessLayerFactory.Instance.CreateDataAccessLayer(false); }