You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.4 KiB
C#
62 lines
2.4 KiB
C#
|
3 years ago
|
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<List<LoadingCell>>();
|
||
|
|
|
||
|
|
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<LoadingCell>();
|
||
|
|
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<Renderer>().sharedMaterial.SetColor("_Color", CellRenderColor);
|
||
|
|
cube.layer = 11;
|
||
|
|
cube.GetComponent<MeshRenderer>().enabled = false;
|
||
|
|
cube.AddComponent<BoxCollider>();
|
||
|
|
var loadingCell = cube.AddComponent<LoadingCell>();
|
||
|
|
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() { }
|
||
|
|
}
|
||
|
|
}
|