using System.Collections; using System.Collections.Generic; using UnityEngine; using SiegeSong; namespace SiegeSong { public class LoadingCellInstantiator : MonoBehaviour { public GameObject ParentTerrain; private float TerrainWidth = 1024.0f; private Color CellRenderColor = Color.blue; private float CellWidth = 32.0f; private float CellHeight = 1.0f; private int rotationX = 270; private int verticalOffset = 30; public void InstantiateCells() { ParentTerrain = gameObject; var cells = new List>(); var cellsObject = new GameObject("Loading Cells"); cellsObject.transform.parent = ParentTerrain.transform; var cellPerRowCount = (TerrainWidth / CellWidth); for (var y = 0; y < cellPerRowCount; y++) { var cellRow = new List(); cells.Add(cellRow); for (var x = 0; x < cellPerRowCount; x++) { var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.name = $"{ParentTerrain.name}_LoadingCell_{y}_{x}"; cube.transform.position = new Vector3(CellWidth * y, CellWidth * x, 0); cube.transform.localScale = new Vector3(CellWidth, CellWidth, CellHeight); cube.transform.parent = cellsObject.transform; cube.GetComponent().sharedMaterial.SetColor("_Color", CellRenderColor); cube.layer = 11; cube.GetComponent().enabled = false; cube.AddComponent(); var loadingCell = cube.AddComponent(); loadingCell.LocationName = $"Loading Cell {y} {x}"; loadingCell.Public = true; loadingCell.DangerLevel = DangerLevel.Calm; loadingCell.ColumnNumber = x; loadingCell.RowNumber = y; cellRow.Add(loadingCell); } } cellsObject.transform.eulerAngles = new Vector3(rotationX, 0, 0); cellsObject.transform.position = new Vector3((CellWidth / 2) + ParentTerrain.transform.position.x, verticalOffset, ParentTerrain.transform.position.z + TerrainWidth); } void Start() { } void Update() { } } }