void LevelDataRequestHandler(NetworkConnection jug, LevelDataRequest request) { Debug.Log("level data being requested"); StartCoroutine(GameUtils.EsperarTrueLuegoHacerCallback( () => rondaIniciada, () => { Debug.Log("level data ready, sending"); var agrupados = levelGenerator.generadorLayouts.generados.GroupBy(cuarto => cuarto.categoria); var grandes = agrupados.FirstOrDefault(grupo => grupo.Key == LayoutCuarto.Categoria.Grande); var peques = agrupados.FirstOrDefault(grupo => grupo.Key == LayoutCuarto.Categoria.Peque); var data = new LevelGeneratorData() { gridPos = gridPos, gridSizeX = gridSizeX, gridSizeY = gridSizeY, posGrandes = grandes.Select(cada => (Vector2)cada.BoxCol.transform.TransformPoint(cada.BoxCol.offset)).ToArray(), tamGrandes = grandes.Select(cada => (Vector2)cada.BoxCol.transform.TransformVector(cada.BoxCol.size)).ToArray(), posPeques = peques.Select(cada => (Vector2)cada.BoxCol.transform.TransformPoint(cada.BoxCol.offset)).ToArray(), tamPeques = peques.Select(cada => (Vector2)cada.BoxCol.transform.TransformVector(cada.BoxCol.size)).ToArray(), puertas = levelGenerator.generadorMapaArbol.vinculos.SelectMany(vinc => vinc.puertas).ToArray() }; jug.Send(data); })); }
private void Initializers(PlayerData playerData, PoolContext poolContext, LevelGeneratorData levelGeneratorData) { new PlayerInitializeController(playerData, poolContext.PlayerStartPosition, poolContext); new LevelGeneratorInitializeController(poolContext, levelGeneratorData); new CameraInitializeController(poolContext); new WheelieDetectorInitializeController(poolContext); new PlayerDistanceViewInitializeContoller(poolContext); new PlayerWheelieViewInitializeController(poolContext); }
IEnumerator PrepararRondaRutina() { yield return(levelGenerator.GenerarLayout()); levelGenerator.RenderNivel(true); // levelGenerator.ActualizarColliderYNavSurface(); var agrupados = levelGenerator.generadorLayouts.generados.GroupBy(cuarto => cuarto.categoria); var grandes = agrupados.FirstOrDefault(grupo => grupo.Key == LayoutCuarto.Categoria.Grande); var peques = agrupados.FirstOrDefault(grupo => grupo.Key == LayoutCuarto.Categoria.Peque); var data = new LevelGeneratorData() { posGrandes = grandes.Select(cada => (Vector2)cada.BoxCol.transform.TransformPoint(cada.BoxCol.offset)).ToArray(), tamGrandes = grandes.Select(cada => (Vector2)cada.BoxCol.transform.TransformVector(cada.BoxCol.size)).ToArray(), posPeques = peques.Select(cada => (Vector2)cada.BoxCol.transform.TransformPoint(cada.BoxCol.offset)).ToArray(), tamPeques = peques.Select(cada => (Vector2)cada.BoxCol.transform.TransformVector(cada.BoxCol.size)).ToArray(), puertas = levelGenerator.generadorMapaArbol.vinculos.SelectMany(vinc => vinc.puertas).ToArray() }; levelGenerator.generadorColliderGlobal.GenerarAMano( data.posGrandes, data.tamGrandes, data.posPeques, data.tamPeques, data.puertas ); levelGenerator.ActualizarColliderYNavSurface(); gridPos = levelGenerator.Bounds.min; var tam = levelGenerator.Bounds.size; // (gridSize.x, gridSize.y) = (Mathf.CeilToInt(tam.x / gridStepSize), Mathf.CeilToInt(tam.z / gridStepSize)); gridSizeX = (uint)Mathf.CeilToInt(tam.x / gridStepSize); gridSizeY = (uint)Mathf.CeilToInt(tam.z / gridStepSize); posList = new Vector3[gridSizeX * gridSizeY]; for (int i = 0; i < posList.Length; i++) { var x = i % gridSizeX; var y = i / gridSizeX; posList[i] = gridPos + new Vector3(gridStepSize * x, 0f, gridStepSize * y); } Debug.Log($"estimated bits needed - {Mathf.Ceil(Mathf.Log(gridSizeX * gridSizeY, 2))}"); GenerarJugadoresIniciales(); GenerarPatrullas(); rondaIniciada = true; StartCoroutine(GeneradorDeJugadores()); }
void LevelDataProcessor(LevelGeneratorData data) { gridPos = data.gridPos; gridSizeX = data.gridSizeX; gridSizeY = data.gridSizeY; Debug.Log("received data from level"); levelGenerator.generadorColliderGlobal.GenerarAMano( data.posGrandes, data.tamGrandes, data.posPeques, data.tamPeques, data.puertas ); Debug.Log($"{gridSizeX}-{gridSizeY}"); posList = new Vector3[gridSizeX * gridSizeY]; for (int i = 0; i < posList.Length; i++) { var x = i % gridSizeX; var y = i / gridSizeX; posList[i] = gridPos + new Vector3(gridStepSize * x, 0f, gridStepSize * y); } //no es necesario crear los colliders en el cliente // levelGenerator.ActualizarColliderYNavSurface(); }
public AllControllersInitialozator(PlayerData playerData, PoolContext poolContext, MainControllers updateController, LevelGeneratorData levelGeneratorData) { Initializers(playerData, poolContext, levelGeneratorData); Controllers(poolContext, updateController); }