private void AddObject() { for (int nbEntity = 0; nbEntity < maxEntity; nbEntity++) { MazeEntity targetTransformInstance = Instantiate(entityPrefab[Random.Range(0, entityPrefab.Length)]) as MazeEntity; IntVector2 cellCoordinate; do { cellCoordinate = RandomCoordinates; } while (entityMap[cellCoordinate.x, cellCoordinate.z] != 0); targetTransformInstance.Initialize(cells[cellCoordinate.x, cellCoordinate.z], (MazeDirection)Random.Range(0, 3)); entityMap[cellCoordinate.x, cellCoordinate.z] = 2; } }
private void PlaceLight() { int offsetH = (int)Mathf.Floor((float)(size.x / (size.x / lightOffset + 1)) / 2f); int offsetV = (int)Mathf.Floor((float)(size.z / (size.z / lightOffset + 1)) / 2f); for (int i = offsetH; i < size.x; i += lightOffset) { for (int j = offsetV; j < size.z; j += lightOffset) { MazeEntity lightInstance = Instantiate(lightPrefab) as MazeEntity; lightInstance.Initialize(cells[i, j]); entityMap[i, j] = 3; entityOnMap++; } } }
private void CreateTarget() { if (targetTransform != null) { MazeEntity targetTransformInstance = Instantiate(targetTransform) as MazeEntity; IntVector2 cellCoordinate; do { cellCoordinate = RandomCoordinates; } while (cellCoordinate.dist(new IntVector2(size.x / 2, size.z / 2)) <= 5 || entityMap[cellCoordinate.x, cellCoordinate.z] != 0); targetTransformInstance.Initialize(cells[cellCoordinate.x, cellCoordinate.z]); entityMap[cellCoordinate.x, cellCoordinate.z] = 2; entityOnMap++; if (targetPrefab != null) { MazeTarget targetInstance = Instantiate(targetPrefab) as MazeTarget; targetInstance.transform.parent = targetTransformInstance.transform; targetInstance.transform.localPosition = new Vector3(); } } }