private static void GenerateChunks() { GameObject chunkObject; chunks = new ChunkData[Metrics.chunkCountX * Metrics.chunkCountZ]; int i = 0; for (int z = 0; z < Metrics.chunkCountZ; z++) { for (int x = 0; x < Metrics.chunkCountX; x++) { chunkObject = new GameObject("Chunk (" + x.ToString() + ", " + z.ToString() + ")"); chunkObject.transform.SetParent(Metrics.gridObject.transform); chunks[i] = new ChunkData( new MeshGenerator("Grass", chunkObject.transform, x, z, false, true, false), new MeshGenerator("Fog", chunkObject.transform, x, z, true, true, false), new MeshGenerator("Liquid", chunkObject.transform, x, z, true, true, false), new MeshGenerator("Foundation", chunkObject.transform, x, z, true, true, true), new MeshGenerator("Structure", chunkObject.transform, x, z, true, true, true), new MeshGenerator("Ceiling", chunkObject.transform, x, z, true, true, true), new MeshGenerator("CeilingMask", chunkObject.transform, x, z, true, true, false) ); i++; } } StatsForNerds.UpdateChunkCount(chunks.Length); }
private static void GenerateCells() { cells = new CellData[width * length]; int chunkCoordinateX, chunkCoordinateZ; int cellCoordinateX, cellCoordinateZ; int i = 0; for (int z = 0; z < length; z++) { for (int x = 0; x < width; x++) { chunkCoordinateX = x / Metrics.chunkWidth; chunkCoordinateZ = z / Metrics.chunkLength; cellCoordinateX = x - chunkCoordinateX * Metrics.chunkWidth; cellCoordinateZ = z - chunkCoordinateZ * Metrics.chunkLength; ChunkData chunk = chunks[chunkCoordinateX + chunkCoordinateZ * Metrics.chunkCountX]; Coordinates coordinates = new Coordinates(x, z); CellData cell = new CellData(chunk, coordinates); chunk.AddCell(cellCoordinateX + cellCoordinateZ * Metrics.chunkWidth, cell); cells[i] = cell; if (x > 0) { cell.SetNeighbor(Direction.W, cells[i - 1]); } if (z > 0) { cell.SetNeighbor(Direction.S, cells[i - width]); } if (x > 0 && z > 0) { cell.SetNeighbor(Direction.SW, cells[i - width - 1]); } if (x < width && z > 0) { cell.SetNeighbor(Direction.SE, cells[i - width + 1]); } InstantiateFoundation(GetFoundationPrototype(PStrings.ground), cell); cell.foundation.materialIndex = (int)MatI.Boards; cell.foundation.colorIndex = (int)ColI.Brown; i++; } } StatsForNerds.UpdateCellCount(cells.Length); }
public static void EntityDestroyed(EntityData instance) { entities.Remove(instance.uniqueID); StatsForNerds.UpdateEntityCount(entities.Count); }
public static void EntityInstanciated(EntityData instance) { entities.Add(instance.uniqueID, instance); StatsForNerds.UpdateEntityCount(entities.Count); }
public static void ItemDestroyed(ItemData instance) { items.Remove(instance.uniqueID); PathGrid.Invalidate(); StatsForNerds.UpdateItemCount(items.Count); }
public static void ItemInstanciated(ItemData instance) { items.Add(instance.uniqueID, instance); PathGrid.Invalidate(); StatsForNerds.UpdateItemCount(items.Count); }
public static void ObstacleDestroyed(ObstacleData instance) { obstacles.Remove(instance.uniqueID); PathGrid.Invalidate(); StatsForNerds.UpdateObstacleCount(obstacles.Count); }
public static void ObstacleInstanciated(ObstacleData instance) { obstacles.Add(instance.uniqueID, instance); PathGrid.Invalidate(); StatsForNerds.UpdateObstacleCount(obstacles.Count); }
private static void GeneratePrototypeLibraries() { #region Models BuildModelPrototypes(); #endregion #region Foundations foundationPrototypes = new Dictionary <string, FoundationData>(); BuildFoundationPrototype(PStrings.pit); BuildFoundationPrototype(PStrings.pitGrate); BuildFoundationPrototype(PStrings.pool); BuildFoundationPrototype(PStrings.poolGrate); BuildFoundationPrototype(PStrings.ground); BuildFoundationPrototype(PStrings.groundGrass); #endregion #region Structures structurePrototypes = new Dictionary <string, StructureData>(); BuildStructurePrototype(PStrings.wall); BuildStructurePrototype(PStrings.window); BuildStructurePrototype(PStrings.doorway); BuildStructurePrototype(PStrings.cage); #endregion #region Ceilings ceilingPrototypes = new Dictionary <string, CeilingData>(); BuildCeilingPrototype(PStrings.ceiling); #endregion #region Obstacles obstaclePrototypes = new Dictionary <string, ObstacleData>(); //////////////////// Lights //////////////////// BuildObstaclePrototype(PStrings.torch, 1, 1, LightMode.Burn, DoorMode.Null, false, false); BuildObstaclePrototype(PStrings.lamp, 1, 1, LightMode.Standard, DoorMode.Null, false, false); //////////////////// Doors ///////////////////// BuildObstaclePrototype(PStrings.doorPhysicsSmall, 1, 1, LightMode.Null, DoorMode.Physics, false, false); BuildObstaclePrototype(PStrings.doorPhysicsLarge, 2, 1, LightMode.Null, DoorMode.Physics, false, false); //////////////////// Switches ////////////////// BuildObstaclePrototype(PStrings.switchSimple, 1, 1, LightMode.Null, DoorMode.Null, true, false); //////////////////// Statics /////////////////// BuildObstaclePrototype(PStrings.bench, 2, 1, LightMode.Null, DoorMode.Null, false, false); BuildObstaclePrototype(PStrings.table, 2, 1, LightMode.Null, DoorMode.Null, false, false); #endregion #region Items itemPrototypes = new Dictionary <string, ItemData>(); BuildItemPrototype(PStrings.shotgun, 1, LightMode.Null, true); BuildItemPrototype(PStrings.medLarge, 25, LightMode.Null, true); #endregion #region Entities entityPrototypes = new Dictionary <string, EntityData>(); BuildEntityPrototype(PStrings.playerSpawn, LightMode.Null, false); BuildEntityPrototype(PStrings.zombie, LightMode.Null, false); #endregion #region UI & Debug GameObject.FindObjectOfType <GridEditorUI>().BuildPanels( foundationPrototypes, structurePrototypes, ceilingPrototypes, obstaclePrototypes, itemPrototypes, entityPrototypes ); StatsForNerds.UpdatePrototypeCount( foundationPrototypes.Count + structurePrototypes.Count + ceilingPrototypes.Count + obstaclePrototypes.Count + itemPrototypes.Count + entityPrototypes.Count ); if (Metrics.debug == true) { Debug.Log("Prototype libraries generated with " + ( foundationPrototypes.Count + structurePrototypes.Count + ceilingPrototypes.Count + obstaclePrototypes.Count + itemPrototypes.Count + entityPrototypes.Count ) + " entries."); } #endregion }