generate simple room
This commit is contained in:
8
Assets/Escape Room Engine/Engine.meta
Normal file
8
Assets/Escape Room Engine/Engine.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 854b3997af63e8c42a88ca199fa50073
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/Escape Room Engine/Engine/Materials.meta
Normal file
8
Assets/Escape Room Engine/Engine/Materials.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1b250192375ce6843b577c4c5795a757
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
126
Assets/Escape Room Engine/Engine/Materials/Room.mat
Normal file
126
Assets/Escape Room Engine/Engine/Materials/Room.mat
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &-9085166077070560863
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 11
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
version: 5
|
||||||
|
--- !u!21 &2100000
|
||||||
|
Material:
|
||||||
|
serializedVersion: 8
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Room
|
||||||
|
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||||
|
m_ValidKeywords: []
|
||||||
|
m_InvalidKeywords: []
|
||||||
|
m_LightmapFlags: 4
|
||||||
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
|
m_CustomRenderQueue: -1
|
||||||
|
stringTagMap:
|
||||||
|
RenderType: Opaque
|
||||||
|
disabledShaderPasses: []
|
||||||
|
m_SavedProperties:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TexEnvs:
|
||||||
|
- _BaseMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _BumpMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailAlbedoMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailMask:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailNormalMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _EmissionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MainTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MetallicGlossMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _OcclusionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ParallaxMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _SpecGlossMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- unity_Lightmaps:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- unity_LightmapsInd:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- unity_ShadowMasks:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Ints: []
|
||||||
|
m_Floats:
|
||||||
|
- _AlphaClip: 0
|
||||||
|
- _Blend: 0
|
||||||
|
- _BumpScale: 1
|
||||||
|
- _ClearCoatMask: 0
|
||||||
|
- _ClearCoatSmoothness: 0
|
||||||
|
- _Cull: 2
|
||||||
|
- _Cutoff: 0.5
|
||||||
|
- _DetailAlbedoMapScale: 1
|
||||||
|
- _DetailNormalMapScale: 1
|
||||||
|
- _DstBlend: 0
|
||||||
|
- _EnvironmentReflections: 1
|
||||||
|
- _GlossMapScale: 0
|
||||||
|
- _Glossiness: 0
|
||||||
|
- _GlossyReflections: 0
|
||||||
|
- _Metallic: 0
|
||||||
|
- _OcclusionStrength: 1
|
||||||
|
- _Parallax: 0.005
|
||||||
|
- _QueueOffset: 0
|
||||||
|
- _ReceiveShadows: 1
|
||||||
|
- _Smoothness: 0.5
|
||||||
|
- _SmoothnessTextureChannel: 0
|
||||||
|
- _SpecularHighlights: 1
|
||||||
|
- _SrcBlend: 1
|
||||||
|
- _Surface: 0
|
||||||
|
- _WorkflowMode: 1
|
||||||
|
- _ZWrite: 1
|
||||||
|
m_Colors:
|
||||||
|
- _BaseColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||||
|
- _Color: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||||
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
|
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||||
|
m_BuildTextureStacks: []
|
||||||
8
Assets/Escape Room Engine/Engine/Materials/Room.mat.meta
Normal file
8
Assets/Escape Room Engine/Engine/Materials/Room.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 39e2ed014eda5d6408c16fbf0fa80781
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 2100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/Escape Room Engine/Engine/Scripts.meta
Normal file
8
Assets/Escape Room Engine/Engine/Scripts.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1565d4487d018a14a9efe05e18f111f6
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
18
Assets/Escape Room Engine/Engine/Scripts/DoorModule.cs
Normal file
18
Assets/Escape Room Engine/Engine/Scripts/DoorModule.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
namespace Escape_Room_Engine.Engine.Scripts
|
||||||
|
{
|
||||||
|
public enum DoorType
|
||||||
|
{
|
||||||
|
Entrance = ModuleType.DoorEntrance, Exit = ModuleType.DoorExit
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DoorModule : Module
|
||||||
|
{
|
||||||
|
public bool IsEntrance => IsType((ModuleType)DoorType.Entrance);
|
||||||
|
public bool IsExit => IsType((ModuleType)DoorType.Exit);
|
||||||
|
|
||||||
|
internal DoorModule(DoorType type)
|
||||||
|
{
|
||||||
|
_types.Add((ModuleType)type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 05af827f50ab469f952abbb62109877d
|
||||||
|
timeCreated: 1667226128
|
||||||
8
Assets/Escape Room Engine/Engine/Scripts/Editor.meta
Normal file
8
Assets/Escape Room Engine/Engine/Scripts/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 49bc52aa373de5f4a9be95d26b4050ce
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
namespace Escape_Room_Engine.Engine.Scripts.Editor
|
||||||
|
{
|
||||||
|
public class EngineEditor : EditorWindow
|
||||||
|
{
|
||||||
|
[MenuItem("Window/Engine/Engine Editor")]
|
||||||
|
public static void ShowEditor()
|
||||||
|
{
|
||||||
|
var window = GetWindow<EngineEditor>();
|
||||||
|
window.titleContent = new GUIContent("Engine Editor");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateGUI()
|
||||||
|
{
|
||||||
|
var generateRoom = new Button(GenerateRoom)
|
||||||
|
{
|
||||||
|
text = Engine.DefaultEngine.NumberOfRooms == 0 ? "Generate Room" : "Regenerate Room"
|
||||||
|
};
|
||||||
|
generateRoom.SetEnabled(EditorApplication.isPlaying);
|
||||||
|
|
||||||
|
rootVisualElement.Add(generateRoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GenerateRoom()
|
||||||
|
{
|
||||||
|
Debug.Log("Generating new room...");
|
||||||
|
Engine.DefaultEngine.DisposeOldestRoom();
|
||||||
|
Engine.DefaultEngine.GenerateRoom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b053e3376aa6ae646b82182855e23ead
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
49
Assets/Escape Room Engine/Engine/Scripts/Engine.cs
Normal file
49
Assets/Escape Room Engine/Engine/Scripts/Engine.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Escape_Room_Engine.Engine.Scripts
|
||||||
|
{
|
||||||
|
public class Engine : MonoBehaviour
|
||||||
|
{
|
||||||
|
public static Engine DefaultEngine => FindObjectOfType<Engine>();
|
||||||
|
|
||||||
|
public Material roomMaterial;
|
||||||
|
|
||||||
|
public int NumberOfRooms => _rooms.Count;
|
||||||
|
|
||||||
|
private List<Room> _rooms = new(1);
|
||||||
|
|
||||||
|
public void GenerateRoom()
|
||||||
|
{
|
||||||
|
// get the last entrance from the newest room or create a spawn passage with no entrance door for where the player will start
|
||||||
|
var entrance = NumberOfRooms > 0 ? _rooms[0].exit : new Passage();
|
||||||
|
|
||||||
|
var room = new Room(entrance);
|
||||||
|
_rooms.Add(room);
|
||||||
|
|
||||||
|
GenerateSpace(room, entrance); // TODO: rooms with more than one space
|
||||||
|
room.InstantiateRoom(transform, (_rooms.Count - 1).ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void GenerateSpace(Room room, Passage from)
|
||||||
|
{
|
||||||
|
var exit = new Passage();
|
||||||
|
var size = new SpaceSize(Random.Range(2, 6), Random.Range(2, 6)); // TODO: no hardcoded space size
|
||||||
|
var space = new Space(size, from, exit);
|
||||||
|
room.AddSpace(space, exit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dispose of the oldest room to save resources.
|
||||||
|
/// </summary>
|
||||||
|
public void DisposeOldestRoom()
|
||||||
|
{
|
||||||
|
if (NumberOfRooms > 0)
|
||||||
|
{
|
||||||
|
_rooms[NumberOfRooms - 1].Destroy();
|
||||||
|
_rooms.RemoveAt(NumberOfRooms - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Escape Room Engine/Engine/Scripts/Engine.cs.meta
Normal file
11
Assets/Escape Room Engine/Engine/Scripts/Engine.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9a9b6b8b557abbb4ab172444615ebf23
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
14
Assets/Escape Room Engine/Engine/Scripts/Module.cs
Normal file
14
Assets/Escape Room Engine/Engine/Scripts/Module.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Escape_Room_Engine.Engine.Scripts
|
||||||
|
{
|
||||||
|
public class Module
|
||||||
|
{
|
||||||
|
protected List<ModuleType> _types = new();
|
||||||
|
|
||||||
|
public bool IsType(ModuleType type)
|
||||||
|
{
|
||||||
|
return _types.Contains(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Escape Room Engine/Engine/Scripts/Module.cs.meta
Normal file
11
Assets/Escape Room Engine/Engine/Scripts/Module.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bef95c0b6e3be5847939fffa4294f99f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
7
Assets/Escape Room Engine/Engine/Scripts/ModuleType.cs
Normal file
7
Assets/Escape Room Engine/Engine/Scripts/ModuleType.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Escape_Room_Engine.Engine.Scripts
|
||||||
|
{
|
||||||
|
public enum ModuleType
|
||||||
|
{
|
||||||
|
DoorEntrance, DoorExit
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 602fa211234b4068bca5ff38a2f9593f
|
||||||
|
timeCreated: 1667230405
|
||||||
17
Assets/Escape Room Engine/Engine/Scripts/Passage.cs
Normal file
17
Assets/Escape Room Engine/Engine/Scripts/Passage.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
namespace Escape_Room_Engine.Engine.Scripts
|
||||||
|
{
|
||||||
|
public class Passage
|
||||||
|
{
|
||||||
|
internal DoorModule fromOut, toIn;
|
||||||
|
|
||||||
|
internal void ConnectFrom(DoorModule door)
|
||||||
|
{
|
||||||
|
fromOut = door;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ConnectTo(DoorModule door)
|
||||||
|
{
|
||||||
|
toIn = door;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Escape Room Engine/Engine/Scripts/Passage.cs.meta
Normal file
3
Assets/Escape Room Engine/Engine/Scripts/Passage.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 58b4bdd93b9843a29cf03b304553ad10
|
||||||
|
timeCreated: 1667222752
|
||||||
44
Assets/Escape Room Engine/Engine/Scripts/Room.cs
Normal file
44
Assets/Escape Room Engine/Engine/Scripts/Room.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Escape_Room_Engine.Engine.Scripts
|
||||||
|
{
|
||||||
|
public class Room
|
||||||
|
{
|
||||||
|
internal Passage entrance, exit;
|
||||||
|
|
||||||
|
private GameObject _roomObject;
|
||||||
|
private List<Space> _spaces = new();
|
||||||
|
|
||||||
|
internal Room(Passage entrance)
|
||||||
|
{
|
||||||
|
this.entrance = entrance;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void AddSpace(Space space, Passage spaceExit)
|
||||||
|
{
|
||||||
|
_spaces.Add(space);
|
||||||
|
exit = spaceExit;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void InstantiateRoom(Transform parent, string name)
|
||||||
|
{
|
||||||
|
_roomObject = new GameObject($"Room {name}");
|
||||||
|
_roomObject.transform.SetParent(parent);
|
||||||
|
|
||||||
|
for (var i = 0; i < _spaces.Count; i++)
|
||||||
|
{
|
||||||
|
_spaces[i].InstantiateSpace(_roomObject.transform, i.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Destroy()
|
||||||
|
{
|
||||||
|
foreach (var space in _spaces)
|
||||||
|
{
|
||||||
|
space.Destroy();
|
||||||
|
}
|
||||||
|
Object.Destroy(_roomObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Escape Room Engine/Engine/Scripts/Room.cs.meta
Normal file
11
Assets/Escape Room Engine/Engine/Scripts/Room.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ca3aaaca7b04a5049b5d327832fe6f0a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
84
Assets/Escape Room Engine/Engine/Scripts/Space.cs
Normal file
84
Assets/Escape Room Engine/Engine/Scripts/Space.cs
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Escape_Room_Engine.Engine.Scripts
|
||||||
|
{
|
||||||
|
public class Space
|
||||||
|
{
|
||||||
|
// public DoorModule Entrance => (DoorModule)_modules.Find(module => module.IsType((ModuleType)DoorType.Entrance));
|
||||||
|
// public DoorModule Exit => (DoorModule)_modules.Find(module => module.IsType((ModuleType)DoorType.Exit));
|
||||||
|
|
||||||
|
private readonly SpaceSize _size;
|
||||||
|
private GameObject _spaceObject;
|
||||||
|
private List<Module> _modules = new(2);
|
||||||
|
|
||||||
|
internal Space(SpaceSize size, Passage entrance, Passage exit)
|
||||||
|
{
|
||||||
|
_size = size;
|
||||||
|
|
||||||
|
// connect the space to its passages
|
||||||
|
entrance.ConnectTo(new DoorModule(DoorType.Entrance));
|
||||||
|
AddModule(entrance.toIn);
|
||||||
|
exit.ConnectFrom(new DoorModule(DoorType.Exit));
|
||||||
|
AddModule(exit.fromOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void AddModule(Module module)
|
||||||
|
{
|
||||||
|
_modules.Add(module);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void InstantiateSpace(Transform parent, string name)
|
||||||
|
{
|
||||||
|
_spaceObject = new GameObject($"Space {name}");
|
||||||
|
_spaceObject.transform.SetParent(parent);
|
||||||
|
|
||||||
|
var meshFilter = _spaceObject.AddComponent<MeshFilter>();
|
||||||
|
meshFilter.mesh = GenerateMesh();
|
||||||
|
|
||||||
|
var meshRenderer = _spaceObject.AddComponent<MeshRenderer>();
|
||||||
|
meshRenderer.material = Engine.DefaultEngine.roomMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Mesh GenerateMesh()
|
||||||
|
{
|
||||||
|
var mesh = new Mesh();
|
||||||
|
|
||||||
|
float halfWidth = _size.Width / 2f, halfHeight = _size.Height / 2f;
|
||||||
|
mesh.vertices = new[]
|
||||||
|
{
|
||||||
|
new Vector3(-halfWidth, 0, -halfHeight),
|
||||||
|
new Vector3(halfWidth, 0, -halfHeight),
|
||||||
|
new Vector3(-halfWidth, 0, halfHeight),
|
||||||
|
new Vector3(halfWidth, 0, halfHeight)
|
||||||
|
};
|
||||||
|
|
||||||
|
mesh.triangles = new[]
|
||||||
|
{
|
||||||
|
0, 2, 1,
|
||||||
|
2, 3, 1
|
||||||
|
};
|
||||||
|
|
||||||
|
var normal = Vector3.up;
|
||||||
|
mesh.normals = new[]
|
||||||
|
{
|
||||||
|
normal, normal, normal, normal
|
||||||
|
};
|
||||||
|
|
||||||
|
mesh.uv = new[]
|
||||||
|
{
|
||||||
|
new Vector2(0, 0),
|
||||||
|
new Vector2(1, 0),
|
||||||
|
new Vector2(0, 1),
|
||||||
|
new Vector2(1, 1)
|
||||||
|
};
|
||||||
|
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Destroy()
|
||||||
|
{
|
||||||
|
Object.Destroy(_spaceObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Escape Room Engine/Engine/Scripts/Space.cs.meta
Normal file
11
Assets/Escape Room Engine/Engine/Scripts/Space.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: acd43d28cfff2b640a01dd6f51f7393f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
18
Assets/Escape Room Engine/Engine/Scripts/SpaceSize.cs
Normal file
18
Assets/Escape Room Engine/Engine/Scripts/SpaceSize.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
namespace Escape_Room_Engine.Engine.Scripts
|
||||||
|
{
|
||||||
|
public readonly struct SpaceSize
|
||||||
|
{
|
||||||
|
internal SpaceSize(int width, int height)
|
||||||
|
{
|
||||||
|
Width = width;
|
||||||
|
Height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: intersections and unions of rectangles
|
||||||
|
|
||||||
|
public int Width { get; }
|
||||||
|
public int Height { get; }
|
||||||
|
|
||||||
|
public override string ToString() => $"({Width}, {Height})";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b70ad3679d5c48768c1d132f56dba4dd
|
||||||
|
timeCreated: 1667222427
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -5,9 +5,12 @@ EditorBuildSettings:
|
|||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Scenes:
|
m_Scenes:
|
||||||
- enabled: 1
|
- enabled: 0
|
||||||
path: Assets/Scenes/TestScene.unity
|
path: Assets/Scenes/TestScene.unity
|
||||||
guid: 99c9720ab356a0642a771bea13969a05
|
guid: 99c9720ab356a0642a771bea13969a05
|
||||||
|
- enabled: 1
|
||||||
|
path: Assets/Scenes/ImpossibleSpaces.unity
|
||||||
|
guid: 682c1d7d6103f0b44ba4e2e1bfd2114d
|
||||||
m_configObjects:
|
m_configObjects:
|
||||||
com.unity.xr.management.loader_settings: {fileID: 11400000, guid: 5038e8a8e7bee0a44a0c2892bcbf360e,
|
com.unity.xr.management.loader_settings: {fileID: 11400000, guid: 5038e8a8e7bee0a44a0c2892bcbf360e,
|
||||||
type: 2}
|
type: 2}
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ PlayerSettings:
|
|||||||
bundleVersion: 0.1.0
|
bundleVersion: 0.1.0
|
||||||
preloadedAssets:
|
preloadedAssets:
|
||||||
- {fileID: 0}
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
metroInputSource: 0
|
metroInputSource: 0
|
||||||
wsaTransparentSwapchain: 0
|
wsaTransparentSwapchain: 0
|
||||||
m_HolographicPauseOnTrackingLoss: 1
|
m_HolographicPauseOnTrackingLoss: 1
|
||||||
|
|||||||
Reference in New Issue
Block a user