1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702 |
- 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<Rigidbody>().isKinematic = true;
- Renderer component = CreativeRoom.m_PrefabUnit.GetComponent<Renderer>();
- 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<Renderer>();
- 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<BaseEventData, CreativeRoom.TileObject>(this.EventPointerEnter), new Action<BaseEventData, CreativeRoom.TileObject>(this.EventPointerExit), new Action<BaseEventData, CreativeRoom.TileObject>(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<BaseEventData, CreativeRoom.TileObject>(this.EventPointerEnter), new Action<BaseEventData, CreativeRoom.TileObject>(this.EventPointerExit), new Action<BaseEventData, CreativeRoom.TileObject>(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<List<List<CreativeRoom.TileData>>> 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<List<List<CreativeRoom.TileData>>> 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<GameObject>(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<BaseEventData, CreativeRoom.TileObject>(this.EventPointerEnter), new Action<BaseEventData, CreativeRoom.TileObject>(this.EventPointerExit), new Action<BaseEventData, CreativeRoom.TileObject>(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<BaseEventData, CreativeRoom.TileObject>(this.EventPointerEnter), new Action<BaseEventData, CreativeRoom.TileObject>(this.EventPointerExit), new Action<BaseEventData, CreativeRoom.TileObject>(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<BaseEventData, CreativeRoom.TileObject>(this.EventPointerEnter), new Action<BaseEventData, CreativeRoom.TileObject>(this.EventPointerExit), new Action<BaseEventData, CreativeRoom.TileObject>(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<BaseEventData, CreativeRoom.TileObject>(this.EventPointerEnter), new Action<BaseEventData, CreativeRoom.TileObject>(this.EventPointerExit), new Action<BaseEventData, CreativeRoom.TileObject>(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<BaseEventData, CreativeRoom.TileObject> pointerEnter, Action<BaseEventData, CreativeRoom.TileObject> pointerExit, Action<BaseEventData, CreativeRoom.TileObject> pointerClick)
- {
- if (Obj.gameObject == null)
- {
- return;
- }
- CreativeRoom.MouseEvent mouseEvent = Obj.eventTrigger;
- if (mouseEvent == null)
- {
- mouseEvent = (Obj.eventTrigger = Obj.gameObject.AddComponent<CreativeRoom.MouseEvent>());
- }
- 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<Renderer>();
- 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<Renderer>();
- 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<Renderer>();
- 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<Renderer>();
- 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<Renderer>();
- 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<List<List<CreativeRoom.TileData>>> 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<List<CreativeRoom.TileData>>> list = new List<List<List<CreativeRoom.TileData>>>();
- for (int i = 0; i < x; i++)
- {
- List<List<CreativeRoom.TileData>> list2 = new List<List<CreativeRoom.TileData>>();
- for (int j = 0; j < y; j++)
- {
- List<CreativeRoom.TileData> list3 = new List<CreativeRoom.TileData>();
- 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<List<List<CreativeRoom.TileData>>> floorArray, out List<CreativeRoom.TileObject> floorPanels, out List<CreativeRoom.TileObject> otherPanels, bool right, bool left, bool front, bool back, bool up, bool down)
- {
- floorPanels = new List<CreativeRoom.TileObject>();
- otherPanels = new List<CreativeRoom.TileObject>();
- 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<CreativeRoom.TileObject> floorPanelsFunc, Action<CreativeRoom.TileObject> otherPanelsFunc)
- {
- List<CreativeRoom.TileObject> list;
- List<CreativeRoom.TileObject> 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<BaseEventData, CreativeRoom.TileObject>(this.EventPointerExit), new Action<BaseEventData, CreativeRoom.TileObject>(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<BaseEventData, CreativeRoom.TileObject>(this.EventPointerExit), new Action<BaseEventData, CreativeRoom.TileObject>(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<BaseEventData, CreativeRoom.TileObject>(this.EventPointerExit), new Action<BaseEventData, CreativeRoom.TileObject>(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<Renderer>();
- 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<Material>();
- List<TextureData.Data> 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<Texture>("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<Button>(count, delegate(int index, Button button)
- {
- RawImage component = button.GetComponent<RawImage>();
- component.texture = CreativeRoom.m_Materials[index].mainTexture;
- button.onClick.AddListener(delegate
- {
- this.ButtonEvent_SetPanelsMaterial(index);
- });
- });
- uGUIScrollRect componentInParent = this.m_UIParentTextureButtons.GetComponentInParent<uGUIScrollRect>();
- if (componentInParent != null)
- {
- componentInParent.verticalNormalizedPosition = 1f;
- }
- }
- private void ButtonEvent_SetPanelsMaterial(int index)
- {
- if (CreativeRoom.m_Materials.Count <= index)
- {
- return;
- }
- if (index < 0)
- {
- return;
- }
- Material material = CreativeRoom.m_Materials[index];
- this.InvokeAllPanels(true, true, true, true, true, true, delegate(CreativeRoom.TileObject panel)
- {
- if (panel.type != CreativeRoom.TileType.Select)
- {
- return;
- }
- panel.matID = index;
- this.SetPanelType(panel, CreativeRoom.TileType.Select);
- }, null);
- }
- public void CombinePanelMesh()
- {
- this.OnUpdateMap();
- CreativeRoom.CombinePanelMesh(this.m_FloorArray);
- }
- private static void CombinePanelMesh(List<List<List<CreativeRoom.TileData>>> floorArray)
- {
- List<CreativeRoom.TileObject> list;
- List<CreativeRoom.TileObject> list2;
- CreativeRoom.GetAllPanels(floorArray, out list, out list2, true, true, true, true, true, true);
- List<CreativeRoom.TileObject> list3 = new List<CreativeRoom.TileObject>();
- for (int i = 0; i < list.Count; i++)
- {
- if (!(list[i].gameObject == null))
- {
- list[i].gameObject.SetActive(false);
- if (list[i].type != CreativeRoom.TileType.Disable)
- {
- list3.Add(list[i]);
- }
- }
- }
- Dictionary<Material, List<CombineInstance>> dictionary = new Dictionary<Material, List<CombineInstance>>();
- for (int j = 0; j < list3.Count; j++)
- {
- if (CreativeRoom.m_Materials.Count > list3[j].matID)
- {
- Material material;
- if (list3[j].matID < 0)
- {
- material = list3[j].gameObject.GetComponent<Renderer>().sharedMaterial;
- }
- else
- {
- material = CreativeRoom.m_Materials[list3[j].matID];
- }
- if (!(material == null))
- {
- if (!dictionary.ContainsKey(material))
- {
- dictionary.Add(material, new List<CombineInstance>());
- }
- List<CombineInstance> list4 = dictionary[material];
- list4.Add(new CombineInstance
- {
- transform = list3[j].gameObject.transform.localToWorldMatrix,
- mesh = list3[j].gameObject.GetComponent<MeshFilter>().sharedMesh
- });
- }
- }
- }
- if (CreativeRoom.m_CombineMeshObjectArray == null)
- {
- CreativeRoom.m_CombineMeshObjectArray = new List<GameObject>();
- }
- for (int k = 0; k < CreativeRoom.m_CombineMeshObjectArray.Count; k++)
- {
- CreativeRoom.m_CombineMeshObjectArray[k].SetActive(false);
- }
- GameObject parentCombineMeshObject = CreativeRoom.parentCombineMeshObject;
- List<Material> list5 = new List<Material>(dictionary.Keys);
- List<List<CombineInstance>> list6 = new List<List<CombineInstance>>(dictionary.Values);
- for (int l = 0; l < list5.Count; l++)
- {
- GameObject gameObject;
- MeshFilter meshFilter;
- MeshRenderer meshRenderer;
- if (CreativeRoom.m_CombineMeshObjectArray.Count > l)
- {
- gameObject = CreativeRoom.m_CombineMeshObjectArray[l];
- meshFilter = gameObject.GetComponent<MeshFilter>();
- meshRenderer = gameObject.GetComponent<MeshRenderer>();
- gameObject.SetActive(true);
- UnityEngine.Object.Destroy(meshFilter.sharedMesh);
- }
- else
- {
- gameObject = new GameObject();
- meshFilter = gameObject.AddComponent<MeshFilter>();
- meshRenderer = gameObject.AddComponent<MeshRenderer>();
- CreativeRoom.m_CombineMeshObjectArray.Add(gameObject);
- gameObject.transform.SetParent(parentCombineMeshObject.transform);
- }
- gameObject.name = "Combine Mesh [" + list5[l].name + "]";
- Mesh mesh = new Mesh();
- mesh.CombineMeshes(list6[l].ToArray());
- meshFilter.sharedMesh = mesh;
- meshRenderer.sharedMaterial = list5[l];
- meshRenderer.receiveShadows = true;
- meshRenderer.shadowCastingMode = ShadowCastingMode.Off;
- }
- for (int m = CreativeRoom.m_CombineMeshObjectArray.Count - 1; m >= 0; m--)
- {
- if (list5.Count <= m)
- {
- UnityEngine.Object.Destroy(CreativeRoom.m_CombineMeshObjectArray[m]);
- CreativeRoom.m_CombineMeshObjectArray.Remove(CreativeRoom.m_CombineMeshObjectArray[m]);
- }
- }
- }
- public void SavePanelData(BinaryWriter binary)
- {
- CreativeRoom.CombinePanelMesh(this.m_FloorArray);
- int count = this.m_FloorArray.Count;
- int count2 = this.m_FloorArray[0].Count;
- int count3 = this.m_FloorArray[0][0].Count;
- binary.Write(count);
- binary.Write(count2);
- binary.Write(count3);
- binary.Write(this.unitSize);
- for (int i = 0; i < count; i++)
- {
- for (int j = 0; j < count2; j++)
- {
- for (int k = 0; k < count3; k++)
- {
- CreativeRoom.TileData tileData = CreativeRoom.GetTileData(this.m_FloorArray, i, j, k);
- if (tileData != null)
- {
- for (int l = 0; l < 6; l++)
- {
- binary.Write((!(tileData[l].gameObject == null) && tileData[l].type != CreativeRoom.TileType.Disable) ? tileData[l].matID.ToString() : "-1");
- }
- }
- }
- }
- }
- }
- public void LoadPanelData(BinaryReader brRead)
- {
- int num = brRead.ReadInt32();
- int num2 = brRead.ReadInt32();
- int num3 = brRead.ReadInt32();
- float num4 = brRead.ReadSingle();
- this.m_UISliderRoomSizeX.value = (float)num;
- this.m_UISliderRoomSizeY.value = (float)num2;
- this.m_UISliderRoomSizeZ.value = (float)num3;
- this.m_UISliderUnitScale.value = num4;
- this.mapSizeX = num;
- this.mapSizeY = num2;
- this.mapSizeZ = num3;
- this.unitSize = num4;
- List<List<List<CreativeRoom.TileData>>> list = new List<List<List<CreativeRoom.TileData>>>();
- for (int i = 0; i < num; i++)
- {
- List<List<CreativeRoom.TileData>> list2 = new List<List<CreativeRoom.TileData>>();
- for (int j = 0; j < num2; j++)
- {
- List<CreativeRoom.TileData> list3 = new List<CreativeRoom.TileData>();
- for (int k = 0; k < num3; k++)
- {
- CreativeRoom.TileData tileData;
- if (i < this.m_FloorArray.Count && j < this.m_FloorArray[i].Count && k < this.m_FloorArray[i][j].Count)
- {
- tileData = this.m_FloorArray[i][j][k];
- }
- else
- {
- tileData = new CreativeRoom.TileData();
- }
- for (int l = 0; l < 6; l++)
- {
- tileData[l].matID = int.Parse(brRead.ReadString());
- tileData[l].type = ((tileData[l].matID >= 0) ? CreativeRoom.TileType.Enable : CreativeRoom.TileType.Disable);
- tileData[l].matID = ((tileData[l].matID >= 0) ? tileData[l].matID : 0);
- }
- list3.Add(tileData);
- }
- list2.Add(list3);
- }
- list.Add(list2);
- }
- this.m_FloorArray = list;
- this.OnUpdateMap();
- CreativeRoom.CombinePanelMesh(this.m_FloorArray);
- }
- public static GameObject Load(BinaryReader brRead)
- {
- int num = brRead.ReadInt32();
- int num2 = brRead.ReadInt32();
- int num3 = brRead.ReadInt32();
- float unitSize = brRead.ReadSingle();
- List<List<List<CreativeRoom.TileData>>> list = new List<List<List<CreativeRoom.TileData>>>();
- for (int i = 0; i < num; i++)
- {
- List<List<CreativeRoom.TileData>> list2 = new List<List<CreativeRoom.TileData>>();
- for (int j = 0; j < num2; j++)
- {
- List<CreativeRoom.TileData> list3 = new List<CreativeRoom.TileData>();
- for (int k = 0; k < num3; k++)
- {
- CreativeRoom.TileData tileData = new CreativeRoom.TileData();
- for (int l = 0; l < 6; l++)
- {
- tileData[l].matID = int.Parse(brRead.ReadString());
- tileData[l].type = ((tileData[l].matID >= 0) ? CreativeRoom.TileType.Enable : CreativeRoom.TileType.Disable);
- tileData[l].matID = ((tileData[l].matID >= 0) ? tileData[l].matID : 0);
- }
- list3.Add(tileData);
- }
- list2.Add(list3);
- }
- list.Add(list2);
- }
- CreativeRoom.LoadAllTextures();
- CreativeRoom.OnUpdateMapWall(list, unitSize);
- CreativeRoom.CombinePanelMesh(list);
- if (CreativeRoom.m_ParentTileObject != null)
- {
- UnityEngine.Object.Destroy(CreativeRoom.m_ParentTileObject);
- }
- UnityEngine.Object.Destroy(CreativeRoom.m_PrefabUnit);
- CreativeRoom.m_CombineMeshObjectArray = null;
- GameObject parentCombineMeshObject = CreativeRoom.m_ParentCombineMeshObject;
- CreativeRoom.m_ParentCombineMeshObject = null;
- return parentCombineMeshObject;
- }
- private void OnDestroy()
- {
- GameObject parentCombineMeshObject = CreativeRoom.m_ParentCombineMeshObject;
- if (parentCombineMeshObject != null)
- {
- UnityEngine.Object.Destroy(parentCombineMeshObject);
- }
- CreativeRoom.m_CombineMeshObjectArray = null;
- for (int i = 0; i < this.m_FloorArray.Count; i++)
- {
- for (int j = 0; j < this.m_FloorArray[i].Count; j++)
- {
- for (int k = 0; k < this.m_FloorArray[i][j].Count; k++)
- {
- CreativeRoom.DestroyTileObject(this.m_FloorArray[i][j][k]);
- }
- }
- }
- if (CreativeRoom.m_PrefabUnit != null)
- {
- UnityEngine.Object.Destroy(CreativeRoom.m_PrefabUnit);
- }
- if (CreativeRoom.m_ParentTileObject != null)
- {
- UnityEngine.Object.Destroy(CreativeRoom.m_ParentTileObject);
- }
- UnityEngine.Object.Destroy(CreativeRoom.m_MatDefaultColor);
- UnityEngine.Object.Destroy(CreativeRoom.m_MatHighlightColor);
- UnityEngine.Object.Destroy(CreativeRoom.m_MatSelectColor);
- UnityEngine.Object.Destroy(CreativeRoom.m_MatDisableColor);
- for (int l = 0; l < CreativeRoom.m_Materials.Count; l++)
- {
- UnityEngine.Object.Destroy(CreativeRoom.m_Materials[l]);
- }
- CreativeRoom.m_Materials = null;
- }
- private int m_MapSizeX = 1;
- private int m_MapSizeZ = 1;
- private int m_MapSizeY = 2;
- private float m_UnitSize = 1f;
- [SerializeField]
- private CreativeRoomManager m_Manager;
- private static GameObject m_PrefabUnit;
- private static GameObject m_ParentTileObject;
- private static GameObject m_ParentCombineMeshObject;
- [SerializeField]
- [Tooltip("親オブジェクト:テクスチャ一覧を表示しているUIオブジェクト")]
- private uGUIListViewer m_UIParentTextureButtons;
- [SerializeField]
- [Tooltip("テキスト:部屋の大きさを表示するUI")]
- private Text m_UITextRoomSizeX;
- [SerializeField]
- [Tooltip("テキスト:部屋の大きさを表示するUI")]
- private Text m_UITextRoomSizeY;
- [SerializeField]
- [Tooltip("テキスト:部屋の大きさを表示するUI")]
- private Text m_UITextRoomSizeZ;
- [SerializeField]
- [Tooltip("スライダー:部屋の大きさを変更するスライダー")]
- private Slider m_UISliderRoomSizeX;
- [SerializeField]
- [Tooltip("スライダー:部屋の大きさを変更するスライダー")]
- private Slider m_UISliderRoomSizeY;
- [SerializeField]
- [Tooltip("スライダー:部屋の大きさを変更するスライダー")]
- private Slider m_UISliderRoomSizeZ;
- [SerializeField]
- [Tooltip("スライダー:ユニット一つあたりの大きさを変更するスライダー")]
- private Slider m_UISliderUnitScale;
- [SerializeField]
- private InputField m_UIInputRoomSizeX;
- [SerializeField]
- private InputField m_UIInputRoomSizeY;
- [SerializeField]
- private InputField m_UIInputRoomSizeZ;
- [SerializeField]
- private InputField m_UIInputUnitScale;
- private static Material m_MatDefaultColor;
- private static Material m_MatHighlightColor;
- private static Material m_MatDisableColor;
- private static Material m_MatSelectColor;
- private List<List<List<CreativeRoom.TileData>>> m_FloorArray = new List<List<List<CreativeRoom.TileData>>>();
- private static List<Material> m_Materials = new List<Material>();
- private int m_PageIndexTexture;
- private bool m_IsDraggingSelect;
- private static List<GameObject> m_CombineMeshObjectArray = new List<GameObject>();
- private MaterialPropertyBlock m_MaterialPropertyBlock;
- public enum TileType
- {
- Enable,
- TempEnable,
- Disable,
- Select,
- TempSelect
- }
- private class TileData
- {
- public TileData()
- {
- this.right = new CreativeRoom.TileObject(CreativeRoom.TileType.Enable, null);
- this.left = new CreativeRoom.TileObject(CreativeRoom.TileType.Enable, null);
- this.up = new CreativeRoom.TileObject(CreativeRoom.TileType.Enable, null);
- this.down = new CreativeRoom.TileObject(CreativeRoom.TileType.Enable, null);
- this.front = new CreativeRoom.TileObject(CreativeRoom.TileType.Enable, null);
- this.back = new CreativeRoom.TileObject(CreativeRoom.TileType.Enable, null);
- this.enableRight = false;
- this.enableLeft = false;
- this.enableUp = false;
- this.enableDown = false;
- this.enableFront = false;
- this.enableBack = false;
- }
- public CreativeRoom.TileObject this[int i]
- {
- get
- {
- switch (i)
- {
- case 0:
- return this.right;
- case 1:
- return this.left;
- case 2:
- return this.up;
- case 3:
- return this.down;
- case 4:
- return this.front;
- case 5:
- return this.back;
- default:
- return null;
- }
- }
- set
- {
- switch (i)
- {
- case 0:
- this.right = value;
- break;
- case 1:
- this.left = value;
- break;
- case 2:
- this.up = value;
- break;
- case 3:
- this.down = value;
- break;
- case 4:
- this.front = value;
- break;
- case 5:
- this.back = value;
- break;
- }
- }
- }
- public CreativeRoom.TileObject right;
- public CreativeRoom.TileObject left;
- public CreativeRoom.TileObject up;
- public CreativeRoom.TileObject down;
- public CreativeRoom.TileObject front;
- public CreativeRoom.TileObject back;
- public bool enableRight;
- public bool enableLeft;
- public bool enableUp;
- public bool enableDown;
- public bool enableFront;
- public bool enableBack;
- }
- private class TileObject
- {
- public TileObject(CreativeRoom.TileType tileType, GameObject obj)
- {
- this.gameObject = obj;
- this.eventTrigger = null;
- this.type = tileType;
- this.matID = 0;
- }
- public void Reset()
- {
- UnityEngine.Object.Destroy(this.eventTrigger);
- UnityEngine.Object.Destroy(this.gameObject);
- this.gameObject = null;
- this.matID = 0;
- }
- public GameObject gameObject;
- public CreativeRoom.MouseEvent eventTrigger;
- public CreativeRoom.TileType type;
- public int matID;
- }
- private class MouseEvent : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler, IPointerDownHandler, IPointerUpHandler, IEventSystemHandler
- {
- public void OnPointerEnter(PointerEventData data)
- {
- if (this.onPointerEnter != null)
- {
- this.onPointerEnter(data);
- }
- }
- public void OnPointerExit(PointerEventData data)
- {
- if (this.onPointerExit != null)
- {
- this.onPointerExit(data);
- }
- }
- public void OnPointerClick(PointerEventData data)
- {
- if (this.onPointerClick != null)
- {
- this.onPointerClick(data);
- }
- }
- public void OnPointerDown(PointerEventData data)
- {
- if (this.onPointerDown != null)
- {
- this.onPointerDown(data);
- }
- }
- public void OnPointerUp(PointerEventData data)
- {
- if (this.onPointerUp != null)
- {
- this.onPointerUp(data);
- }
- }
- public Action<PointerEventData> onPointerEnter;
- public Action<PointerEventData> onPointerExit;
- public Action<PointerEventData> onPointerClick;
- public Action<PointerEventData> onPointerDown;
- public Action<PointerEventData> onPointerUp;
- }
- }
- }
|