using System; using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Rendering; using UnityEngine.UI; namespace MyRoomCustom { public class CreativeRoom : MonoBehaviour { public int mapSizeX { get { return this.m_MapSizeX; } set { this.m_MapSizeX = Mathf.Clamp(value, 1, 32); } } public int mapSizeZ { get { return this.m_MapSizeZ; } set { this.m_MapSizeZ = Mathf.Clamp(value, 1, 32); } } public int mapSizeY { get { return this.m_MapSizeY; } set { this.m_MapSizeY = Mathf.Clamp(value, 2, 16); } } public float unitSize { get { return this.m_UnitSize; } set { this.m_UnitSize = Mathf.Clamp(value, 0.25f, 1f); CreativeRoomUIObjectSettings creativeRoomUIObjSetting = this.m_Manager.creativeRoomUIObjSetting; if (creativeRoomUIObjSetting) { creativeRoomUIObjSetting.snapValuePosition = this.m_UnitSize * 0.5f; } CreativeRoomUIPlacementMaid creativeRoomUIMaid = this.m_Manager.creativeRoomUIMaid; if (creativeRoomUIMaid) { creativeRoomUIMaid.snapValuePosition = this.m_UnitSize * 0.5f; } } } private static GameObject prefabUnit { get { if (CreativeRoom.m_PrefabUnit == null) { CreativeRoom.m_PrefabUnit = GameObject.CreatePrimitive(PrimitiveType.Quad); CreativeRoom.m_PrefabUnit.AddComponent().isKinematic = true; Renderer component = CreativeRoom.m_PrefabUnit.GetComponent(); component.reflectionProbeUsage = ReflectionProbeUsage.Off; component.shadowCastingMode = ShadowCastingMode.Off; component.receiveShadows = false; CreativeRoom.m_PrefabUnit.gameObject.SetActive(false); } return CreativeRoom.m_PrefabUnit; } } private static Transform parentTileObject { get { if (CreativeRoom.m_ParentTileObject == null) { CreativeRoom.m_ParentTileObject = new GameObject("Parent Tile Object"); } return CreativeRoom.m_ParentTileObject.transform; } } private static GameObject parentCombineMeshObject { get { if (CreativeRoom.m_ParentCombineMeshObject == null) { CreativeRoom.m_ParentCombineMeshObject = new GameObject("Combine Mesh Object Parent"); } return CreativeRoom.m_ParentCombineMeshObject; } } private void Start() { if (CreativeRoom.m_MatDefaultColor == null) { CreativeRoom.m_MatDefaultColor = new Material(Shader.Find("CM3D2/RoomPanel")); CreativeRoom.m_MatDefaultColor.SetColor("_Color", Color.white); CreativeRoom.m_MatDefaultColor.SetColor("_ShadowColor", Color.black); } if (CreativeRoom.m_MatHighlightColor == null) { CreativeRoom.m_MatHighlightColor = new Material(Shader.Find("CM3D2/RoomPanel")); CreativeRoom.m_MatHighlightColor.SetColor("_Color", new Color(1f, 0.75f, 1f, 1f)); CreativeRoom.m_MatHighlightColor.SetColor("_ShadowColor", Color.black); } if (CreativeRoom.m_MatDisableColor == null) { CreativeRoom.m_MatDisableColor = new Material(Shader.Find("CM3D2/RoomPanel")); CreativeRoom.m_MatDisableColor.SetColor("_Color", Color.white * 0.25f); CreativeRoom.m_MatDisableColor.SetColor("_ShadowColor", Color.black); } if (CreativeRoom.m_MatSelectColor == null) { CreativeRoom.m_MatSelectColor = new Material(Shader.Find("CM3D2/RoomPanelSelect")); } this.m_MaterialPropertyBlock = new MaterialPropertyBlock(); this.m_MaterialPropertyBlock.SetColor("_Color", new Color(0.5f, 1f, 1f, 1f)); CreativeRoom.LoadAllTextures(); Renderer component = CreativeRoom.prefabUnit.GetComponent(); if (component && CreativeRoom.m_Materials != null && CreativeRoom.m_Materials.Count > 0) { component.sharedMaterial = CreativeRoom.m_Materials[0]; } this.SetUpInputArea(); this.OnUpdateMap(); this.InvokeAllPanels(false, false, false, false, false, true, delegate(CreativeRoom.TileObject floorPanel) { this.AddEventQuad(floorPanel, new Action(this.EventPointerEnter), new Action(this.EventPointerExit), new Action(this.EventPointerClick)); }, delegate(CreativeRoom.TileObject otherPanel) { this.RemoveEventQuad(otherPanel); }); this.CreateMaterialButton(0); } private void SetUpInputArea() { this.m_UIInputRoomSizeX.contentType = InputField.ContentType.IntegerNumber; this.m_UIInputRoomSizeY.contentType = InputField.ContentType.IntegerNumber; this.m_UIInputRoomSizeZ.contentType = InputField.ContentType.IntegerNumber; this.m_UIInputUnitScale.contentType = InputField.ContentType.DecimalNumber; this.m_UIInputRoomSizeX.text = this.mapSizeX.ToString(); this.m_UIInputRoomSizeY.text = this.mapSizeY.ToString(); this.m_UIInputRoomSizeZ.text = this.mapSizeZ.ToString(); this.m_UIInputUnitScale.text = this.unitSize.ToString(); this.m_UIInputRoomSizeX.onValueChanged.AddListener(delegate(string str) { int num; if (int.TryParse(str, out num)) { if (num == this.mapSizeX) { return; } this.mapSizeX = num; this.m_UISliderRoomSizeX.value = (float)this.mapSizeX; } }); this.m_UIInputRoomSizeY.onValueChanged.AddListener(delegate(string str) { int num; if (int.TryParse(str, out num)) { if (num == this.mapSizeY) { return; } this.mapSizeY = num; this.m_UISliderRoomSizeY.value = (float)this.mapSizeY; } }); this.m_UIInputRoomSizeZ.onValueChanged.AddListener(delegate(string str) { int num; if (int.TryParse(str, out num)) { if (num == this.mapSizeZ) { return; } this.mapSizeZ = num; this.m_UISliderRoomSizeZ.value = (float)this.mapSizeZ; } }); this.m_UIInputUnitScale.onValueChanged.AddListener(delegate(string str) { float num; if (float.TryParse(str, out num)) { if (Mathf.Approximately(this.unitSize, num)) { return; } this.unitSize = num; this.m_UISliderUnitScale.value = this.unitSize; } }); this.m_UIInputRoomSizeX.onEndEdit.AddListener(delegate(string str) { this.m_UIInputRoomSizeX.text = this.mapSizeX.ToString(); }); this.m_UIInputRoomSizeY.onEndEdit.AddListener(delegate(string str) { this.m_UIInputRoomSizeY.text = this.mapSizeY.ToString(); }); this.m_UIInputRoomSizeZ.onEndEdit.AddListener(delegate(string str) { this.m_UIInputRoomSizeZ.text = this.mapSizeZ.ToString(); }); this.m_UIInputUnitScale.onEndEdit.AddListener(delegate(string str) { this.m_UIInputUnitScale.text = this.unitSize.ToString(); }); } public void OnUpdateMap() { this.SetFloorArraySize(this.mapSizeX, this.mapSizeY, this.mapSizeZ); CreativeRoom.OnUpdateMapWall(this.m_FloorArray, this.unitSize); this.InvokeAllPanels(false, false, false, false, false, true, delegate(CreativeRoom.TileObject floorPanel) { this.AddEventQuad(floorPanel, new Action(this.EventPointerEnter), new Action(this.EventPointerExit), new Action(this.EventPointerClick)); if (floorPanel.type == CreativeRoom.TileType.TempEnable) { this.SetPanelType(floorPanel, CreativeRoom.TileType.Enable); } else if (floorPanel.type == CreativeRoom.TileType.TempSelect) { this.SetPanelType(floorPanel, CreativeRoom.TileType.Select); } }, delegate(CreativeRoom.TileObject otherPanel) { this.RemoveEventQuad(otherPanel); if (otherPanel.type == CreativeRoom.TileType.Enable) { this.SetPanelType(otherPanel, CreativeRoom.TileType.TempEnable); } else if (otherPanel.type == CreativeRoom.TileType.Select) { this.SetPanelType(otherPanel, CreativeRoom.TileType.TempSelect); } }); this.InvokeAllPanels(true, true, true, true, true, true, delegate(CreativeRoom.TileObject tileObject) { this.SetPanelType(tileObject, tileObject.type); }, null); this.UpdateRoomSizeText(); if (CreativeRoom.m_CombineMeshObjectArray != null) { for (int i = 0; i < CreativeRoom.m_CombineMeshObjectArray.Count; i++) { if (CreativeRoom.m_CombineMeshObjectArray[i].activeSelf) { CreativeRoom.m_CombineMeshObjectArray[i].SetActive(false); } } } } private static void OnUpdateMapWall(List>> floorArray, float unitSize) { for (int i = 0; i < floorArray.Count; i++) { for (int j = 0; j < floorArray[i].Count; j++) { for (int k = 0; k < floorArray[i][j].Count; k++) { CreativeRoom.TileData tileData = CreativeRoom.GetTileData(floorArray, i, j, k); if (tileData != null) { CreativeRoom.TileData tileData2 = CreativeRoom.GetTileData(floorArray, i, 0, k); CreativeRoom.TileData tileData3 = CreativeRoom.GetTileData(floorArray, i, j - 1, k); tileData.enableDown = (tileData.down.type == CreativeRoom.TileType.Enable && tileData3 == null); tileData3 = CreativeRoom.GetTileData(floorArray, i + 1, 0, k); tileData.enableRight = (tileData2.down.type != CreativeRoom.TileType.Disable && (tileData3 == null || tileData3.down.type == CreativeRoom.TileType.Disable)); tileData3 = CreativeRoom.GetTileData(floorArray, i - 1, 0, k); tileData.enableLeft = (tileData2.down.type != CreativeRoom.TileType.Disable && (tileData3 == null || tileData3.down.type == CreativeRoom.TileType.Disable)); tileData3 = CreativeRoom.GetTileData(floorArray, i, 0, k + 1); tileData.enableFront = (tileData2.down.type != CreativeRoom.TileType.Disable && (tileData3 == null || tileData3.down.type == CreativeRoom.TileType.Disable)); tileData3 = CreativeRoom.GetTileData(floorArray, i, 0, k - 1); tileData.enableBack = (tileData2.down.type != CreativeRoom.TileType.Disable && (tileData3 == null || tileData3.down.type == CreativeRoom.TileType.Disable)); tileData3 = CreativeRoom.GetTileData(floorArray, i, j + 1, k); tileData.enableUp = (tileData2.down.type != CreativeRoom.TileType.Disable && tileData3 == null); } } } } for (int l = 0; l < floorArray.Count; l++) { for (int m = 0; m < floorArray[l].Count; m++) { for (int n = 0; n < floorArray[l][m].Count; n++) { if (CreativeRoom.GetTileData(floorArray, l, m, n) != null) { CreativeRoom.CreateSixPanel(floorArray, l, m, n, unitSize); } } } } } private static void CreateSixPanel(List>> floorArray, int x, int y, int z, float unitSize) { CreativeRoom.TileData tileData = CreativeRoom.GetTileData(floorArray, x, y, z); if (tileData == null) { return; } Transform parentTileObject = CreativeRoom.parentTileObject; if (tileData.enableRight) { GameObject gameObject = tileData.right.gameObject; if (gameObject == null) { gameObject = CreativeRoom.CreatePanel(parentTileObject); tileData.right.type = CreativeRoom.TileType.Enable; } if (!gameObject.activeSelf) { gameObject.SetActive(true); } Transform transform = gameObject.transform; transform.position = new Vector3((float)x + 0.5f, (float)y + 0.5f, (float)z) * unitSize; transform.rotation = Quaternion.AngleAxis(90f, Vector3.up); transform.localScale = Vector3.one * unitSize; tileData.right.gameObject = gameObject; } else { if (tileData.right.gameObject) { UnityEngine.Object.Destroy(tileData.right.gameObject); } tileData.right.Reset(); } if (tileData.enableLeft) { GameObject gameObject2 = tileData.left.gameObject; if (gameObject2 == null) { gameObject2 = CreativeRoom.CreatePanel(parentTileObject); tileData.left.type = CreativeRoom.TileType.Enable; } if (!gameObject2.activeSelf) { gameObject2.SetActive(true); } Transform transform2 = gameObject2.transform; transform2.position = new Vector3((float)x - 0.5f, (float)y + 0.5f, (float)z) * unitSize; transform2.rotation = Quaternion.AngleAxis(-90f, Vector3.up); transform2.localScale = Vector3.one * unitSize; tileData.left.gameObject = gameObject2; } else { if (tileData.left.gameObject) { UnityEngine.Object.Destroy(tileData.left.gameObject); } tileData.left.Reset(); } if (tileData.enableUp) { GameObject gameObject3 = tileData.up.gameObject; if (gameObject3 == null) { gameObject3 = CreativeRoom.CreatePanel(parentTileObject); tileData.up.type = CreativeRoom.TileType.Enable; } if (!gameObject3.activeSelf) { gameObject3.SetActive(true); } Transform transform3 = gameObject3.transform; transform3.position = new Vector3((float)x, (float)y + 1f, (float)z) * unitSize; transform3.rotation = Quaternion.AngleAxis(-90f, Vector3.right); transform3.localScale = Vector3.one * unitSize; tileData.up.gameObject = gameObject3; } else { if (tileData.up.gameObject) { UnityEngine.Object.Destroy(tileData.up.gameObject); } tileData.up.Reset(); } if (tileData.enableDown || y == 0) { GameObject gameObject4 = tileData.down.gameObject; if (gameObject4 == null) { gameObject4 = CreativeRoom.CreatePanel(parentTileObject); if (tileData.enableDown) { tileData.down.type = CreativeRoom.TileType.Enable; } } if (!gameObject4.activeSelf) { gameObject4.SetActive(true); } Transform transform4 = gameObject4.transform; transform4.position = new Vector3((float)x, (float)y, (float)z) * unitSize; transform4.rotation = Quaternion.AngleAxis(90f, Vector3.right); transform4.localScale = Vector3.one * unitSize; tileData.down.gameObject = gameObject4; } else { if (tileData.down.gameObject) { UnityEngine.Object.Destroy(tileData.down.gameObject); } tileData.down.Reset(); } if (tileData.enableFront) { GameObject gameObject5 = tileData.front.gameObject; if (gameObject5 == null) { gameObject5 = CreativeRoom.CreatePanel(parentTileObject); tileData.front.type = CreativeRoom.TileType.Enable; } if (!gameObject5.activeSelf) { gameObject5.SetActive(true); } Transform transform5 = gameObject5.transform; transform5.position = new Vector3((float)x, (float)y + 0.5f, (float)z + 0.5f) * unitSize; transform5.rotation = Quaternion.AngleAxis(0f, Vector3.up); transform5.localScale = Vector3.one * unitSize; tileData.front.gameObject = gameObject5; } else { if (tileData.front.gameObject) { UnityEngine.Object.Destroy(tileData.front.gameObject); } tileData.front.Reset(); } if (tileData.enableBack) { GameObject gameObject6 = tileData.back.gameObject; if (gameObject6 == null) { gameObject6 = CreativeRoom.CreatePanel(parentTileObject); tileData.back.type = CreativeRoom.TileType.Enable; } if (!gameObject6.activeSelf) { gameObject6.SetActive(true); } Transform transform6 = gameObject6.transform; transform6.position = new Vector3((float)x, (float)y + 0.5f, (float)z - 0.5f) * unitSize; transform6.rotation = Quaternion.AngleAxis(180f, Vector3.up); transform6.localScale = Vector3.one * unitSize; tileData.back.gameObject = gameObject6; } else { if (tileData.back.gameObject) { UnityEngine.Object.Destroy(tileData.back.gameObject); } tileData.back.Reset(); } } private static GameObject CreatePanel(Transform parent) { GameObject gameObject = UnityEngine.Object.Instantiate(CreativeRoom.prefabUnit); Transform transform = gameObject.transform; if (!gameObject.activeSelf) { gameObject.SetActive(true); } if (parent != null) { transform.SetParent(parent, false); } return gameObject; } public void SetMapSizeX(float x) { if (!this.m_UIInputRoomSizeX.isFocused) { this.m_UIInputRoomSizeX.text = ((int)x).ToString(); } this.mapSizeX = (int)x; this.OnUpdateMap(); this.InvokeAllPanels(false, false, false, false, false, true, delegate(CreativeRoom.TileObject floorPanel) { this.AddEventQuad(floorPanel, new Action(this.EventPointerEnter), new Action(this.EventPointerExit), new Action(this.EventPointerClick)); }, delegate(CreativeRoom.TileObject otherPanel) { this.RemoveEventQuad(otherPanel); }); } public void SetMapSizeZ(float z) { if (!this.m_UIInputRoomSizeZ.isFocused) { this.m_UIInputRoomSizeZ.text = ((int)z).ToString(); } this.mapSizeZ = (int)z; this.OnUpdateMap(); this.InvokeAllPanels(false, false, false, false, false, true, delegate(CreativeRoom.TileObject floorPanel) { this.AddEventQuad(floorPanel, new Action(this.EventPointerEnter), new Action(this.EventPointerExit), new Action(this.EventPointerClick)); }, delegate(CreativeRoom.TileObject otherPanel) { this.RemoveEventQuad(otherPanel); }); } public void SetMapSizeY(float y) { if (!this.m_UIInputRoomSizeY.isFocused) { this.m_UIInputRoomSizeY.text = ((int)y).ToString(); } this.mapSizeY = (int)y; this.OnUpdateMap(); this.InvokeAllPanels(false, false, false, false, false, true, delegate(CreativeRoom.TileObject floorPanel) { this.AddEventQuad(floorPanel, new Action(this.EventPointerEnter), new Action(this.EventPointerExit), new Action(this.EventPointerClick)); }, delegate(CreativeRoom.TileObject otherPanel) { this.RemoveEventQuad(otherPanel); }); } public void SetUnitSize(float size) { size = Mathf.Round(size * 20f); size *= 0.05f; this.m_UISliderUnitScale.value = size; if (!this.m_UIInputUnitScale.isFocused) { this.m_UIInputUnitScale.text = size.ToString(); } this.unitSize = size; this.OnUpdateMap(); this.InvokeAllPanels(false, false, false, false, false, true, delegate(CreativeRoom.TileObject floorPanel) { this.AddEventQuad(floorPanel, new Action(this.EventPointerEnter), new Action(this.EventPointerExit), new Action(this.EventPointerClick)); }, delegate(CreativeRoom.TileObject otherPanel) { this.RemoveEventQuad(otherPanel); }); } private void UpdateRoomSizeText() { this.m_UITextRoomSizeX.text = "横幅:" + string.Format("{0:#0.##}", (float)this.mapSizeX * this.unitSize) + "m"; this.m_UITextRoomSizeZ.text = "奥行:" + string.Format("{0:#0.##}", (float)this.mapSizeZ * this.unitSize) + "m"; this.m_UITextRoomSizeY.text = "高さ:" + string.Format("{0:#0.##}", (float)this.mapSizeY * this.unitSize) + "m"; } private void AddEventQuad(CreativeRoom.TileObject Obj, Action pointerEnter, Action pointerExit, Action pointerClick) { if (Obj.gameObject == null) { return; } CreativeRoom.MouseEvent mouseEvent = Obj.eventTrigger; if (mouseEvent == null) { mouseEvent = (Obj.eventTrigger = Obj.gameObject.AddComponent()); } if (pointerEnter != null) { mouseEvent.onPointerEnter = delegate(PointerEventData data) { pointerEnter(data, Obj); }; } if (pointerExit != null) { mouseEvent.onPointerExit = delegate(PointerEventData data) { pointerExit(data, Obj); }; } if (pointerClick != null) { mouseEvent.onPointerClick = delegate(PointerEventData data) { pointerClick(data, Obj); }; } mouseEvent.onPointerDown = delegate(PointerEventData data) { this.m_IsDraggingSelect = true; }; mouseEvent.onPointerUp = delegate(PointerEventData data) { this.m_IsDraggingSelect = false; }; } private void EventPointerEnter(BaseEventData eventData, CreativeRoom.TileObject Obj) { Renderer componentInChildren = Obj.gameObject.GetComponentInChildren(); if (componentInChildren == null) { return; } componentInChildren.material = CreativeRoom.m_MatHighlightColor; this.m_MaterialPropertyBlock.SetTexture("_MainTex", CreativeRoom.m_Materials[Obj.matID].mainTexture); componentInChildren.SetPropertyBlock(this.m_MaterialPropertyBlock); } private void EventPointerExit(BaseEventData eventData, CreativeRoom.TileObject Obj) { Renderer componentInChildren = Obj.gameObject.GetComponentInChildren(); if (componentInChildren == null) { return; } this.SetPanelType(Obj, Obj.type); } private void EventPointerEnterDrag(BaseEventData eventData, CreativeRoom.TileObject Obj) { if (!this.m_IsDraggingSelect) { return; } if (!NInput.GetMouseButton(0)) { return; } Renderer componentInChildren = Obj.gameObject.GetComponentInChildren(); if (componentInChildren == null) { return; } if (Obj.type == CreativeRoom.TileType.Enable) { this.SetPanelType(Obj, CreativeRoom.TileType.Select); } } private void EventPointerClick(BaseEventData eventData, CreativeRoom.TileObject Obj) { if (!NInput.GetMouseButtonUp(0)) { return; } Renderer componentInChildren = Obj.gameObject.GetComponentInChildren(); if (componentInChildren == null) { return; } if (Obj.type == CreativeRoom.TileType.Enable) { this.SetPanelType(Obj, CreativeRoom.TileType.Disable); } else if (Obj.type == CreativeRoom.TileType.Disable) { this.SetPanelType(Obj, CreativeRoom.TileType.Enable); } } private void EventPointerClickSelect(BaseEventData eventData, CreativeRoom.TileObject Obj) { Renderer componentInChildren = Obj.gameObject.GetComponentInChildren(); if (componentInChildren == null) { return; } if (!NInput.GetMouseButtonUp(0)) { return; } if (Obj.type == CreativeRoom.TileType.Enable) { this.SetPanelType(Obj, CreativeRoom.TileType.Select); } else if (Obj.type == CreativeRoom.TileType.Select) { this.SetPanelType(Obj, CreativeRoom.TileType.Enable); } } private void RemoveEventQuad(CreativeRoom.TileObject Obj) { if (Obj.gameObject == null) { return; } CreativeRoom.MouseEvent eventTrigger = Obj.eventTrigger; if (eventTrigger == null) { return; } eventTrigger.onPointerEnter = null; eventTrigger.onPointerExit = null; eventTrigger.onPointerClick = null; eventTrigger.onPointerDown = null; eventTrigger.onPointerUp = null; } private static CreativeRoom.TileData GetTileData(List>> floorArray, int x, int y, int z) { if (floorArray.Count <= x || x < 0) { return null; } if (floorArray[x].Count <= y || y < 0) { return null; } if (floorArray[x][y].Count <= z || z < 0) { return null; } return floorArray[x][y][z]; } private void SetFloorArraySize(int x, int y, int z) { List>> list = new List>>(); for (int i = 0; i < x; i++) { List> list2 = new List>(); for (int j = 0; j < y; j++) { List list3 = new List(); for (int k = 0; k < z; k++) { if (i < this.m_FloorArray.Count && j < this.m_FloorArray[i].Count && k < this.m_FloorArray[i][j].Count) { list3.Add(this.m_FloorArray[i][j][k]); } else { list3.Add(new CreativeRoom.TileData()); } } list2.Add(list3); } list.Add(list2); } for (int l = 0; l < this.m_FloorArray.Count; l++) { for (int m = 0; m < this.m_FloorArray[l].Count; m++) { for (int n = 0; n < this.m_FloorArray[l][m].Count; n++) { if (l >= x || m >= y || n >= z) { CreativeRoom.DestroyTileObject(this.m_FloorArray[l][m][n]); } } } } this.m_FloorArray = list; } private static void DestroyTileObject(CreativeRoom.TileData data) { UnityEngine.Object.Destroy(data.right.gameObject); UnityEngine.Object.Destroy(data.left.gameObject); UnityEngine.Object.Destroy(data.up.gameObject); UnityEngine.Object.Destroy(data.down.gameObject); UnityEngine.Object.Destroy(data.front.gameObject); UnityEngine.Object.Destroy(data.back.gameObject); } private static void GetAllPanels(List>> floorArray, out List floorPanels, out List otherPanels, bool right, bool left, bool front, bool back, bool up, bool down) { floorPanels = new List(); otherPanels = new List(); for (int i = 0; i < floorArray.Count; i++) { for (int j = 0; j < floorArray[i].Count; j++) { for (int k = 0; k < floorArray[i][j].Count; k++) { if (right) { floorPanels.Add(floorArray[i][j][k].right); } else { otherPanels.Add(floorArray[i][j][k].right); } if (left) { floorPanels.Add(floorArray[i][j][k].left); } else { otherPanels.Add(floorArray[i][j][k].left); } if (front) { floorPanels.Add(floorArray[i][j][k].front); } else { otherPanels.Add(floorArray[i][j][k].front); } if (back) { floorPanels.Add(floorArray[i][j][k].back); } else { otherPanels.Add(floorArray[i][j][k].back); } if (up) { floorPanels.Add(floorArray[i][j][k].up); } else { otherPanels.Add(floorArray[i][j][k].up); } if (down) { floorPanels.Add(floorArray[i][j][k].down); } else { otherPanels.Add(floorArray[i][j][k].down); } } } } } private void InvokeAllPanels(bool right, bool left, bool front, bool back, bool up, bool down, Action floorPanelsFunc, Action otherPanelsFunc) { List list; List list2; CreativeRoom.GetAllPanels(this.m_FloorArray, out list, out list2, right, left, front, back, up, down); if (floorPanelsFunc != null) { for (int i = 0; i < list.Count; i++) { if (list[i] != null) { floorPanelsFunc(list[i]); } } } if (otherPanelsFunc != null) { for (int j = 0; j < list2.Count; j++) { if (list2[j] != null) { otherPanelsFunc(list2[j]); } } } } public void CheckFloorPanel() { this.InvokeAllPanels(false, false, false, false, false, true, delegate(CreativeRoom.TileObject panel) { this.AddEventQuad(panel, delegate(BaseEventData eventData, CreativeRoom.TileObject Obj) { this.EventPointerEnter(eventData, Obj); this.EventPointerEnterDrag(eventData, Obj); }, new Action(this.EventPointerExit), new Action(this.EventPointerClickSelect)); if (panel.type == CreativeRoom.TileType.TempSelect) { this.SetPanelType(panel, CreativeRoom.TileType.Select); } else if (panel.type == CreativeRoom.TileType.TempEnable) { this.SetPanelType(panel, CreativeRoom.TileType.Enable); } }, delegate(CreativeRoom.TileObject panel) { this.RemoveEventQuad(panel); if (panel.type == CreativeRoom.TileType.Select) { this.SetPanelType(panel, CreativeRoom.TileType.TempSelect); } else if (panel.type == CreativeRoom.TileType.Enable) { this.SetPanelType(panel, CreativeRoom.TileType.TempEnable); } }); } public void CheckWallPanel() { this.InvokeAllPanels(true, true, true, true, false, false, delegate(CreativeRoom.TileObject panel) { this.AddEventQuad(panel, delegate(BaseEventData eventData, CreativeRoom.TileObject Obj) { this.EventPointerEnter(eventData, Obj); this.EventPointerEnterDrag(eventData, Obj); }, new Action(this.EventPointerExit), new Action(this.EventPointerClickSelect)); if (panel.type == CreativeRoom.TileType.TempSelect) { this.SetPanelType(panel, CreativeRoom.TileType.Select); } else if (panel.type == CreativeRoom.TileType.TempEnable) { this.SetPanelType(panel, CreativeRoom.TileType.Enable); } }, delegate(CreativeRoom.TileObject panel) { this.RemoveEventQuad(panel); if (panel.type == CreativeRoom.TileType.Select) { this.SetPanelType(panel, CreativeRoom.TileType.TempSelect); } else if (panel.type == CreativeRoom.TileType.Enable) { this.SetPanelType(panel, CreativeRoom.TileType.TempEnable); } }); } public void CheckCeilPanel() { this.InvokeAllPanels(false, false, false, false, true, false, delegate(CreativeRoom.TileObject panel) { this.AddEventQuad(panel, delegate(BaseEventData eventData, CreativeRoom.TileObject Obj) { this.EventPointerEnter(eventData, Obj); this.EventPointerEnterDrag(eventData, Obj); }, new Action(this.EventPointerExit), new Action(this.EventPointerClickSelect)); if (panel.type == CreativeRoom.TileType.TempSelect) { this.SetPanelType(panel, CreativeRoom.TileType.Select); } else if (panel.type == CreativeRoom.TileType.TempEnable) { this.SetPanelType(panel, CreativeRoom.TileType.Enable); } }, delegate(CreativeRoom.TileObject panel) { this.RemoveEventQuad(panel); if (panel.type == CreativeRoom.TileType.Select) { this.SetPanelType(panel, CreativeRoom.TileType.TempSelect); } else if (panel.type == CreativeRoom.TileType.Enable) { this.SetPanelType(panel, CreativeRoom.TileType.TempEnable); } }); } public void SelectAllFloorPanel() { this.InvokeAllPanels(false, false, false, false, false, true, delegate(CreativeRoom.TileObject panel) { if (panel.type == CreativeRoom.TileType.Enable) { this.SetPanelType(panel, CreativeRoom.TileType.Select); } }, null); this.CheckFloorPanel(); } public void SelectAllWallPanel() { this.InvokeAllPanels(true, true, true, true, false, false, delegate(CreativeRoom.TileObject panel) { if (panel.type == CreativeRoom.TileType.Enable) { this.SetPanelType(panel, CreativeRoom.TileType.Select); } }, null); this.CheckWallPanel(); } public void SelectAllCeilPanel() { this.InvokeAllPanels(false, false, false, false, true, false, delegate(CreativeRoom.TileObject panel) { if (panel.type == CreativeRoom.TileType.Enable) { this.SetPanelType(panel, CreativeRoom.TileType.Select); } }, null); this.CheckCeilPanel(); } public void DeselectAllFloorPanel() { this.InvokeAllPanels(false, false, false, false, false, true, delegate(CreativeRoom.TileObject panel) { if (panel.type == CreativeRoom.TileType.Select) { this.SetPanelType(panel, CreativeRoom.TileType.Enable); } }, null); this.CheckFloorPanel(); } public void DeselectAllWallPanel() { this.InvokeAllPanels(true, true, true, true, false, false, delegate(CreativeRoom.TileObject panel) { if (panel.type == CreativeRoom.TileType.Select) { this.SetPanelType(panel, CreativeRoom.TileType.Enable); } }, null); this.CheckWallPanel(); } public void DeselectAllCeilPanel() { this.InvokeAllPanels(false, false, false, false, true, false, delegate(CreativeRoom.TileObject panel) { if (panel.type == CreativeRoom.TileType.Select) { this.SetPanelType(panel, CreativeRoom.TileType.Enable); } }, null); this.CheckCeilPanel(); } private void SetPanelType(CreativeRoom.TileObject Obj, CreativeRoom.TileType type) { if (Obj.gameObject == null) { return; } Obj.type = type; Renderer componentInChildren = Obj.gameObject.GetComponentInChildren(); if (type == CreativeRoom.TileType.Disable) { componentInChildren.SetPropertyBlock(null); componentInChildren.material = CreativeRoom.m_MatDisableColor; } else if (type == CreativeRoom.TileType.Select) { componentInChildren.material = CreativeRoom.m_MatSelectColor; this.m_MaterialPropertyBlock.SetTexture("_MainTex", CreativeRoom.m_Materials[Obj.matID].mainTexture); componentInChildren.SetPropertyBlock(this.m_MaterialPropertyBlock); } else if (type == CreativeRoom.TileType.Enable) { componentInChildren.SetPropertyBlock(null); if (Obj.matID >= 0) { componentInChildren.material = CreativeRoom.m_Materials[Obj.matID]; } else { componentInChildren.material = CreativeRoom.m_MatDefaultColor; } } else if (type == CreativeRoom.TileType.TempSelect) { componentInChildren.SetPropertyBlock(null); if (Obj.matID >= 0) { componentInChildren.material = CreativeRoom.m_Materials[Obj.matID]; } else { componentInChildren.material = CreativeRoom.m_MatDefaultColor; } } else if (type == CreativeRoom.TileType.TempEnable) { componentInChildren.SetPropertyBlock(null); if (Obj.matID >= 0) { componentInChildren.material = CreativeRoom.m_Materials[Obj.matID]; } else { componentInChildren.material = CreativeRoom.m_MatDefaultColor; } } } private static void LoadAllTextures() { if (CreativeRoom.m_Materials != null && CreativeRoom.m_Materials.Count > 0) { return; } CreativeRoom.m_Materials = new List(); List allDatas = TextureData.GetAllDatas(true); Material material = new Material(Shader.Find("CM3D2/RoomPanel")); material.SetColor("_Color", Color.white); material.SetColor("_ShadowColor", Color.black); for (int i = 0; i < allDatas.Count; i++) { Texture texture = Resources.Load("SceneCreativeRoom/Debug/Textures/" + allDatas[i].resourceName); if (texture == null) { Debug.LogWarningFormat("テクスチャ「{0}」が見つからない", new object[] { allDatas[i].resourceName }); } else { Material material2 = new Material(material); material2.mainTexture = texture; CreativeRoom.m_Materials.Add(material2); } } UnityEngine.Object.Destroy(material); } public void CreateMaterialButton(int AddIndex) { int count = CreativeRoom.m_Materials.Count; this.m_UIParentTextureButtons.Show