using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.UI.Extensions; using System.Globalization; public class SetPlan : MonoBehaviour { public static void newRooms() { _G.WIDE = 192; _G.DEPTH = 168; _G.HEIGHT = 96; DOIT.DELETEAllChild("Plan"); if (_G.ROOM == "R1") { _G.WallsWidth[1 - 1] = _G.WIDE; _G.WallsWidth[2 - 1] = _G.DEPTH; _G.WallsWidth[3 - 1] = _G.WIDE; _G.WallsWidth[4 - 1] = _G.DEPTH; } if (_G.ROOM == "R2") { _G.WallsWidth[2 - 1] = 67.875f; _G.WallsWidth[1 - 1] = _G.WIDE - _G.WallsWidth[2 - 1] * 0.707f; _G.WallsWidth[3 - 1] = _G.DEPTH - _G.WallsWidth[2 - 1] * 0.707f; _G.WallsWidth[4 - 1] = _G.WIDE; _G.WallsWidth[5 - 1] = _G.DEPTH; } if (_G.ROOM == "R3") { _G.WallsWidth[5 - 1] = 67.875f; _G.WallsWidth[1 - 1] = _G.WIDE - _G.WallsWidth[5 - 1] * 0.707f; _G.WallsWidth[4 - 1] = _G.DEPTH - _G.WallsWidth[5 - 1] * 0.707f; _G.WallsWidth[3 - 1] = _G.WIDE; _G.WallsWidth[2 - 1] = _G.WIDE; } if (_G.ROOM == "R4") { _G.WallsWidth[1 - 1] = _G.WIDE - 48; _G.WallsWidth[2 - 1] = 48; _G.WallsWidth[3 - 1] = 48; _G.WallsWidth[4 - 1] = _G.DEPTH - 48; _G.WallsWidth[5 - 1] = _G.WIDE; _G.WallsWidth[6 - 1] = _G.DEPTH; } if (_G.ROOM == "R5") { _G.WallsWidth[1 - 1] = _G.WIDE - 48; _G.WallsWidth[2 - 1] = _G.DEPTH; _G.WallsWidth[3 - 1] = _G.WIDE; _G.WallsWidth[4 - 1] = _G.DEPTH - 48; _G.WallsWidth[5 - 1] = 48; _G.WallsWidth[6 - 1] = 48; } if (_G.ROOM == "R6") { _G.WallsWidth[1 - 1] = 48; _G.WallsWidth[2 - 1] = 24; _G.WallsWidth[3 - 1] = 96; _G.WallsWidth[4 - 1] = 24; _G.WallsWidth[5 - 1] = 48; _G.WallsWidth[6 - 1] = _G.DEPTH; _G.WallsWidth[7 - 1] = _G.WIDE; _G.WallsWidth[8 - 1] = _G.DEPTH; } if (_G.ROOM == "R7") { _G.WallsWidth[1 - 1] = _G.WIDE; _G.WallsWidth[2 - 1] = _G.DEPTH; _G.WallsWidth[4 - 1] = _G.DEPTH; } if (_G.ROOM == "R8") { _G.WallsWidth[1 - 1] = _G.WIDE; _G.WallsWidth[4 - 1] = _G.DEPTH; } if (_G.ROOM == "R9") { _G.WallsWidth[1 - 1] = 24; _G.WallsWidth[2 - 1] = Mathf.Sqrt(24 * 24 + 24 * 24); _G.WallsWidth[4 - 1] = Mathf.Sqrt(24 * 24 + 24 * 24); _G.WallsWidth[5 - 1] = 24; _G.WallsWidth[3 - 1] = _G.WIDE - _G.WallsWidth[1 - 1] - _G.WallsWidth[5 - 1] - _G.WallsWidth[2 - 1] * 0.707f - _G.WallsWidth[4 - 1] * 0.707f; _G.WallsWidth[6 - 1] = _G.DEPTH - _G.WallsWidth[2 - 1] * 0.707f; _G.WallsWidth[7 - 1] = _G.WIDE; _G.WallsWidth[8 - 1] = _G.DEPTH - _G.WallsWidth[2 - 1] * 0.707f; } if (_G.ROOM == "R10") { _G.WallsWidth[1 - 1] = 48; _G.WallsWidth[2 - 1] = 24; _G.WallsWidth[3 - 1] = 96; _G.WallsWidth[4 - 1] = 24; _G.WallsWidth[5 - 1] = 48; _G.WallsWidth[6 - 1] = _G.DEPTH - _G.WallsWidth[4 - 1]; _G.WallsWidth[7 - 1] = _G.WIDE; _G.WallsWidth[8 - 1] = _G.DEPTH - _G.WallsWidth[2 - 1]; } Rooms(); } public void RESETDRAWROOM() { DRAWROOM(); } public static void DRAWROOM() { _G.Down = false; _G.Open = true; _G.WIDE = 192; _G.DEPTH = 168; _G.HEIGHT = 96; _G.closingWall = 1; Get.o2("Canvas", "Panel_DRAWPlan").SetActive(true); DOIT.DELETEAllChild("Plan"); Get.o2("Canvas", "Panel_ShowPlan").SetActive(false); _G.NW = 1; GameObject PNL = Get.o3("Canvas", "Panel_DRAWPlan", "Plan"); UILineRenderer pr = PNL.transform.GetComponent(); var pointlist = new List(); pr.Points = pointlist.ToArray(); DOIT.DELETEAllChild("Plan"); _G.WallsPointStart = new(new Vector2[24]); Get.o3("Panel_DRAWPlan", "StartHere", "T_Start").GetComponent().text = TRANS.This("T_StartHere"); } public static void Rooms() { //print("--------pass SetPlan.Rooms--------"); DOIT.DELETEAllChild("Plan"); if (_G.ROOM == "R1") { _G.WallsPointStart[1 - 1] = new Vector2(-_G.WIDE / 2, _G.DEPTH / 2); _G.WallsPointStart[2 - 1] = new Vector2(_G.WIDE / 2, _G.DEPTH / 2); _G.WallsPointStart[3 - 1] = new Vector2(_G.WIDE / 2, -_G.DEPTH / 2); _G.WallsPointStart[4 - 1] = new Vector2(-_G.WIDE / 2, -_G.DEPTH / 2); addpoints(4); addMesures(4); } if (_G.ROOM == "R2") { _G.WallsPointStart[1 - 1] = new Vector2(-_G.WIDE / 2, _G.DEPTH / 2); _G.WallsPointStart[2 - 1] = new Vector2(-_G.WIDE / 2 + _G.WallsWidth[1 - 1], _G.DEPTH / 2); _G.WallsPointStart[3 - 1] = new Vector2(_G.WIDE / 2, -_G.DEPTH / 2 + _G.WallsWidth[3 - 1]); _G.WallsPointStart[4 - 1] = new Vector2(_G.WIDE / 2, -_G.DEPTH / 2); _G.WallsPointStart[5 - 1] = new Vector2(-_G.WIDE / 2, -_G.DEPTH / 2); addpoints(5); addMesures(5); } if (_G.ROOM == "R3") { _G.WallsPointStart[1 - 1] = new Vector2(-_G.WIDE / 2 + _G.WallsWidth[5 - 1] * 0.707f, _G.DEPTH / 2); _G.WallsPointStart[2 - 1] = new Vector2(_G.WIDE / 2, _G.DEPTH / 2); _G.WallsPointStart[3 - 1] = new Vector2(_G.WIDE / 2, -_G.DEPTH / 2); _G.WallsPointStart[4 - 1] = new Vector2(-_G.WIDE / 2, -_G.DEPTH / 2); _G.WallsPointStart[5 - 1] = new Vector2(-_G.WIDE / 2, -_G.DEPTH / 2 + _G.WallsWidth[4 - 1]); addpoints(5); addMesures(5); } if (_G.ROOM == "R4") { _G.WallsPointStart[1 - 1] = new Vector2(-_G.WIDE / 2, _G.DEPTH / 2); _G.WallsPointStart[2 - 1] = new Vector2(-_G.WIDE / 2 + _G.WallsWidth[1 - 1], _G.DEPTH / 2); _G.WallsPointStart[3 - 1] = new Vector2(-_G.WIDE / 2 + _G.WallsWidth[1 - 1], _G.DEPTH / 2 - +_G.WallsWidth[2 - 1]); _G.WallsPointStart[4 - 1] = new Vector2(_G.WIDE / 2, -_G.DEPTH / 2 + _G.WallsWidth[4 - 1]); _G.WallsPointStart[5 - 1] = new Vector2(_G.WIDE / 2, -_G.DEPTH / 2); _G.WallsPointStart[6 - 1] = new Vector2(-_G.WIDE / 2, -_G.DEPTH / 2); addpoints(6); addMesures(6); } if (_G.ROOM == "R5") { _G.WallsPointStart[1 - 1] = new Vector2(_G.WIDE / 2 - _G.WallsWidth[1 - 1], _G.DEPTH / 2); _G.WallsPointStart[2 - 1] = new Vector2(_G.WIDE / 2, _G.DEPTH / 2); _G.WallsPointStart[3 - 1] = new Vector2(_G.WIDE / 2, -_G.DEPTH / 2); _G.WallsPointStart[4 - 1] = new Vector2(-_G.WIDE / 2, -_G.DEPTH / 2); _G.WallsPointStart[5 - 1] = new Vector2(-_G.WIDE / 2, _G.DEPTH / 2 - _G.WallsWidth[6 - 1]); _G.WallsPointStart[6 - 1] = new Vector2(-_G.WIDE / 2 + _G.WallsWidth[5 - 1], _G.DEPTH / 2 - _G.WallsWidth[6 - 1]); addpoints(6); addMesures(6); } if (_G.ROOM == "R6") { _G.WallsPointStart[1 - 1] = new Vector2(-_G.WIDE / 2, -_G.DEPTH / 2 + _G.WallsWidth[8 - 1]); _G.WallsPointStart[2 - 1] = new Vector2(-_G.WIDE / 2 + _G.WallsWidth[1 - 1], -_G.DEPTH / 2 + _G.WallsWidth[8 - 1]); _G.WallsPointStart[3 - 1] = new Vector2(-_G.WIDE / 2 + _G.WallsWidth[1 - 1], -_G.DEPTH / 2 + _G.WallsWidth[8 - 1] - _G.WallsWidth[2 - 1]); _G.WallsPointStart[4 - 1] = new Vector2(_G.WIDE / 2 - _G.WallsWidth[5 - 1], -_G.DEPTH / 2 + _G.WallsWidth[6 - 1] - _G.WallsWidth[4 - 1]); _G.WallsPointStart[5 - 1] = new Vector2(_G.WIDE / 2 - _G.WallsWidth[5 - 1], -_G.DEPTH / 2 + _G.WallsWidth[6 - 1]); _G.WallsPointStart[6 - 1] = new Vector2(_G.WIDE / 2, -_G.DEPTH / 2 + _G.WallsWidth[6 - 1]); _G.WallsPointStart[7 - 1] = new Vector2(_G.WIDE / 2, -_G.DEPTH / 2); _G.WallsPointStart[8 - 1] = new Vector2(-_G.WIDE / 2, -_G.DEPTH / 2); addpoints(8); addMesures(8); } if (_G.ROOM == "R7") { _G.WallsWidth[1 - 1] = _G.WIDE; _G.WallsWidth[2 - 1] = _G.DEPTH; _G.WallsWidth[4 - 1] = _G.DEPTH; _G.WallsPointStart[1 - 1] = new Vector2(-_G.WIDE / 2, _G.DEPTH / 2); _G.WallsPointStart[2 - 1] = new Vector2(_G.WIDE / 2, _G.DEPTH / 2); _G.WallsPointStart[3 - 1] = new Vector2(_G.WIDE / 2, -_G.DEPTH / 2); _G.WallsPointStart[4 - 1] = new Vector2(-_G.WIDE / 2, -_G.DEPTH / 2); _G. WallsAngle[1 - 1] = getA((_G.WallsPointStart[2 - 1] - _G.WallsPointStart[1 - 1]).normalized); _G. WallsAngle[2 - 1] = getA((_G.WallsPointStart[3 - 1] - _G.WallsPointStart[2 - 1]).normalized); _G. WallsAngle[4 - 1] = getA((_G.WallsPointStart[1 - 1] - _G.WallsPointStart[4 - 1]).normalized); GameObject p = Get.o2("Panel_ShowPlan", "Plan"); p.SetActive(true); UILineRenderer pr = p.transform.GetComponent(); var pointlist = new List(); pointlist.Add(_G.WallsPointStart[4 - 1] * 2); pointlist.Add(_G.WallsPointStart[1 - 1] * 2); pointlist.Add(_G.WallsPointStart[2 - 1] * 2); pointlist.Add(_G.WallsPointStart[3 - 1] * 2); pr.Points = pointlist.ToArray(); setM("M101", _G.WallsPointStart[1 - 1] * 2, _G.WallsPointStart[2 - 1] * 2); setM("M102", _G.WallsPointStart[2 - 1] * 2, _G.WallsPointStart[3 - 1] * 2); setM("M104", _G.WallsPointStart[4 - 1] * 2, _G.WallsPointStart[1 - 1] * 2); Create3D.SetMeasureNew(_G.WallsWidth[1 - 1], "m101"); Create3D.SetMeasureNew(_G.WallsWidth[2 - 1], "m102"); Create3D.SetMeasureNew(_G.WallsWidth[4 - 1], "m104"); //wCP _G. WallsPointCenter[1 - 1] = (_G.WallsPointStart[1 - 1] + _G.WallsPointStart[2 - 1]) / 2; _G. WallsPointCenter[2 - 1] = (_G.WallsPointStart[2 - 1] + _G.WallsPointStart[3 - 1]) / 2; _G. WallsPointCenter[4 - 1] = (_G.WallsPointStart[4 - 1] + _G.WallsPointStart[1 - 1]) / 2; } if (_G.ROOM == "R8") { _G.WallsWidth[1 - 1] = _G.WIDE; _G.WallsWidth[4 - 1] = _G.DEPTH; _G.WallsPointStart[1 - 1] = new Vector2(-_G.WIDE / 2, _G.DEPTH / 2); _G.WallsPointStart[2 - 1] = new Vector2(_G.WIDE / 2, _G.DEPTH / 2); _G.WallsPointStart[3 - 1] = new Vector2(_G.WIDE / 2, -_G.DEPTH / 2); _G.WallsPointStart[4 - 1] = new Vector2(-_G.WIDE / 2, -_G.DEPTH / 2); _G. WallsAngle[1 - 1] = getA((_G.WallsPointStart[2 - 1] - _G.WallsPointStart[1 - 1]).normalized); _G. WallsAngle[4 - 1] = getA((_G.WallsPointStart[1 - 1] - _G.WallsPointStart[4 - 1]).normalized); GameObject p = Get.o2("Panel_ShowPlan", "Plan"); p.SetActive(true); UILineRenderer pr = p.transform.GetComponent(); var pointlist = new List(); pointlist.Add(_G.WallsPointStart[4 - 1] * 2); pointlist.Add(_G.WallsPointStart[1 - 1] * 2); pointlist.Add(_G.WallsPointStart[2 - 1] * 2); pr.Points = pointlist.ToArray(); setM("M101", _G.WallsPointStart[1 - 1] * 2, _G.WallsPointStart[2 - 1] * 2); setM("M104", _G.WallsPointStart[4 - 1] * 2, _G.WallsPointStart[1 - 1] * 2); Create3D.SetMeasureNew(_G.WallsWidth[1 - 1], "m101"); Create3D.SetMeasureNew(_G.WallsWidth[4 - 1], "m104"); //wCP _G. WallsPointCenter[1 - 1] = (_G.WallsPointStart[1 - 1] + _G.WallsPointStart[2 - 1]) / 2; _G. WallsPointCenter[4 - 1] = (_G.WallsPointStart[4 - 1] + _G.WallsPointStart[1 - 1]) / 2; } if (_G.ROOM == "R9") { _G.WallsPointStart[1 - 1] = new Vector2(-_G.WIDE / 2, -_G.DEPTH / 2 + _G.WallsWidth[8 - 1]); _G.WallsPointStart[2 - 1] = new Vector2(-_G.WIDE / 2 + _G.WallsWidth[1 - 1], -_G.DEPTH / 2 + _G.WallsWidth[8 - 1]); _G.WallsPointStart[3 - 1] = new Vector2(-_G.WIDE / 2 + _G.WallsWidth[1 - 1] + _G.WallsWidth[2 - 1] * 0.707f, _G.DEPTH / 2); _G.WallsPointStart[4 - 1] = new Vector2(_G.WIDE / 2 - _G.WallsWidth[5 - 1] - _G.WallsWidth[4 - 1] * 0.707f, _G.DEPTH / 2); _G.WallsPointStart[5 - 1] = new Vector2(_G.WIDE / 2 - _G.WallsWidth[5 - 1], _G.DEPTH / 2 - _G.WallsWidth[4 - 1] * 0.707f); _G.WallsPointStart[6 - 1] = new Vector2(_G.WIDE / 2, _G.DEPTH / 2 - _G.WallsWidth[4 - 1] * 0.707f); _G.WallsPointStart[7 - 1] = new Vector2(_G.WIDE / 2, -_G.DEPTH / 2); _G.WallsPointStart[8 - 1] = new Vector2(-_G.WIDE / 2, -_G.DEPTH / 2); addpoints(8); addMesures(8); } if (_G.ROOM == "R10") { _G.WallsPointStart[1 - 1] = new Vector2(-_G.WIDE / 2, -_G.DEPTH / 2 + _G.WallsWidth[8 - 1]); _G.WallsPointStart[2 - 1] = new Vector2(-_G.WIDE / 2 + _G.WallsWidth[1 - 1], -_G.DEPTH / 2 + _G.WallsWidth[8 - 1]); _G.WallsPointStart[3 - 1] = new Vector2(-_G.WIDE / 2 + _G.WallsWidth[1 - 1], _G.DEPTH / 2); _G.WallsPointStart[4 - 1] = new Vector2(_G.WIDE / 2 - _G.WallsWidth[5 - 1], _G.DEPTH / 2); _G.WallsPointStart[5 - 1] = new Vector2(_G.WIDE / 2 - _G.WallsWidth[5 - 1], -_G.DEPTH / 2 + _G.WallsWidth[6 - 1]); _G.WallsPointStart[6 - 1] = new Vector2(_G.WIDE / 2, -_G.DEPTH / 2 + _G.WallsWidth[6 - 1]); _G.WallsPointStart[7 - 1] = new Vector2(_G.WIDE / 2, -_G.DEPTH / 2); _G.WallsPointStart[8 - 1] = new Vector2(-_G.WIDE / 2, -_G.DEPTH / 2); addpoints(8); addMesures(8); } if (_G.ROOM != "R7" && _G.ROOM != "R8") { for (int i = 1; i < _G.NW; i++) { _G. WallsDirection[i - 1] = DRAW.CalculateSense(_G.WallsPointStart[i - 1], _G.WallsPointStart[i]); } _G. WallsDirection[_G.NW - 1] = DRAW.CalculateSense(_G.WallsPointStart[_G.NW - 1], _G.WallsPointStart[1 - 1]); RoomSize(); } //print("end point "+_G.NW+" sense==="+_G. WallsDirection[_G.NW-1]); } public static void addpoints(int Q) { _G.NW = Q; GameObject p = Get.o3("Canvas", "Panel_ShowPlan", "Plan"); p.SetActive(true); UILineRenderer pr = p.transform.GetComponent(); var pointlist = new List(); int i = 1; if (_G.ROOM != "R3") { for (i = 1; i < Q + 1; i++) { pointlist.Add(_G.WallsPointStart[i - 1] * 2); } pointlist.Add(_G.WallsPointStart[1 - 1] * 2); } if (_G.ROOM == "R3") { for (i = 2; i < Q + 1; i++) { pointlist.Add(_G.WallsPointStart[i - 1] * 2); } pointlist.Add(_G.WallsPointStart[1 - 1] * 2); pointlist.Add(_G.WallsPointStart[2 - 1] * 2); } pr.Points = pointlist.ToArray(); for (i = 1; i < Q; i++) { setM("M" + (100 + i).ToString(), _G.WallsPointStart[i - 1] * 2, _G.WallsPointStart[i] * 2); _G. WallsPointCenter[i - 1] = (_G.WallsPointStart[i - 1] + _G.WallsPointStart[i]) / 2; _G. WallsAngle[i - 1] = getA((_G.WallsPointStart[i] - _G.WallsPointStart[i - 1]).normalized); _G.WallsWidth[i - 1] = Vector2.Distance(_G.WallsPointStart[i - 1], _G.WallsPointStart[i]); } setM("M" + (100 + Q).ToString(), _G.WallsPointStart[Q - 1] * 2, _G.WallsPointStart[0] * 2); _G. WallsPointCenter[Q - 1] = (_G.WallsPointStart[Q - 1] + _G.WallsPointStart[0]) / 2; _G. WallsAngle[Q - 1] = getA((_G.WallsPointStart[0] - _G.WallsPointStart[Q - 1]).normalized); _G.WallsWidth[Q - 1] = Vector2.Distance(_G.WallsPointStart[Q - 1], _G.WallsPointStart[0]); } public static void RedrawRoom(string Ms, float Value) { print("--------pass RedrawRoom---------"); int Mi = int.Parse(Ms.Substring(1, 3)) - 100; int i = 1; for (i = 1; i < _G.NW; i++) { _G. WallsDirection[i - 1] = DRAW.CalculateSense(_G.WallsPointStart[i - 1], _G.WallsPointStart[i]); } _G. WallsDirection[_G.NW - 1] = DRAW.CalculateSense(_G.WallsPointStart[_G.NW - 1], _G.WallsPointStart[1 - 1]); _G.WallsWidth[Mi - 1] = Value; float dis = _G.WallsWidth[1 - 1]; for (i = 1; i < _G.NW + 1; i++) { dis = _G.WallsWidth[i - 1]; if (_G. WallsDirection[i - 1] == 1) { _G.WallsPointStart[i] = new Vector2(_G.WallsPointStart[i - 1].x + dis, _G.WallsPointStart[i - 1].y); } if (_G. WallsDirection[i - 1] == 2) { _G.WallsPointStart[i] = new Vector2(_G.WallsPointStart[i - 1].x + dis * 0.707f, _G.WallsPointStart[i - 1].y - dis * 0.707f); } if (_G. WallsDirection[i - 1] == 3) { _G.WallsPointStart[i] = new Vector2(_G.WallsPointStart[i - 1].x, _G.WallsPointStart[i - 1].y - dis); } if (_G. WallsDirection[i - 1] == 4) { _G.WallsPointStart[i] = new Vector2(_G.WallsPointStart[i - 1].x - dis * 0.707f, -_G.WallsPointStart[i - 1].y - dis * 0.707f); } if (_G. WallsDirection[i - 1] == 5) { _G.WallsPointStart[i] = new Vector2(_G.WallsPointStart[i - 1].x - dis, _G.WallsPointStart[i - 1].y); } if (_G. WallsDirection[i - 1] == 6) { _G.WallsPointStart[i] = new Vector2(_G.WallsPointStart[i - 1].x - dis * 0.707f, _G.WallsPointStart[i - 1].y + dis * 0.707f); } if (_G. WallsDirection[i - 1] == 7) { _G.WallsPointStart[i] = new Vector2(_G.WallsPointStart[i - 1].x, _G.WallsPointStart[i - 1].y + dis); } if (_G. WallsDirection[i - 1] == 8) { _G.WallsPointStart[i] = new Vector2(_G.WallsPointStart[i - 1].x + dis * 0.707f, _G.WallsPointStart[i - 1].y + dis * 0.707f); } } if (_G. WallsDirection[_G.NW - 1] == 1) { _G.WallsPointStart[_G.NW - 1] = new Vector2(_G.WallsPointStart[1 - 1].x - dis, _G.WallsPointStart[1 - 1].y); } if (_G. WallsDirection[_G.NW - 1] == 2) { _G.WallsPointStart[_G.NW - 1] = new Vector2(_G.WallsPointStart[1 - 1].x - dis * 0.707f, _G.WallsPointStart[1 - 1].y + dis * 0.707f); } if (_G. WallsDirection[_G.NW - 1] == 3) { _G.WallsPointStart[_G.NW - 1] = new Vector2(_G.WallsPointStart[1 - 1].x, _G.WallsPointStart[1 - 1].y + dis); } if (_G. WallsDirection[_G.NW - 1] == 4) { _G.WallsPointStart[_G.NW - 1] = new Vector2(_G.WallsPointStart[1 - 1].x + dis * 0.707f, _G.WallsPointStart[1 - 1].y + dis * 0.707f); } if (_G. WallsDirection[_G.NW - 1] == 5) { _G.WallsPointStart[_G.NW - 1] = new Vector2(_G.WallsPointStart[1 - 1].x + dis, _G.WallsPointStart[1 - 1].y); } if (_G. WallsDirection[_G.NW - 1] == 6) { float disx = Mathf.Abs(_G.WallsPointStart[_G.NW - 1].x - _G.WallsPointStart[1 - 1].x); _G.WallsPointStart[_G.NW - 1] = new Vector2(_G.WallsPointStart[_G.NW - 1].x, _G.WallsPointStart[1 - 1].y - disx); } if (_G. WallsDirection[_G.NW - 1] == 7) { _G.WallsPointStart[_G.NW - 1] = new Vector2(_G.WallsPointStart[1 - 1].x, _G.WallsPointStart[_G.NW - 1].y); } if (_G. WallsDirection[_G.NW - 1] == 8) { float disx = Mathf.Abs(_G.WallsPointStart[_G.NW - 1].x - _G.WallsPointStart[1 - 1].x); _G.WallsPointStart[_G.NW - 1] = new Vector2(_G.WallsPointStart[_G.NW - 1].x, _G.WallsPointStart[1 - 1].y - disx); } GameObject p = Get.o2("Panel_ShowPlan", "Plan"); p.SetActive(true); UILineRenderer pr = p.transform.GetComponent(); var pointlist = new List(); for (i = 1; i < _G.NW + 1; i++) { pointlist.Add(_G.WallsPointStart[i - 1]); } pointlist.Add(_G.WallsPointStart[1 - 1]); pr.Points = pointlist.ToArray(); for (i = 1; i < _G.NW; i++) { setM("M10" + i.ToString(), _G.WallsPointStart[i - 1], _G.WallsPointStart[i]); _G. WallsPointCenter[i - 1] = (_G.WallsPointStart[i - 1] + _G.WallsPointStart[i]) / 2; _G.WallsWidth[i - 1] = Vector2.Distance(_G.WallsPointStart[i - 1], _G.WallsPointStart[i]) / 2; } setM("M10" + _G.NW.ToString(), _G.WallsPointStart[_G.NW - 1], _G.WallsPointStart[1 - 1] * 1); _G.WallsWidth[_G.NW - 1] = Vector2.Distance(_G.WallsPointStart[_G.NW - 1], _G.WallsPointStart[1 - 1]) / 2; _G. WallsPointCenter[_G.NW - 1] = (_G.WallsPointStart[_G.NW - 1] + _G.WallsPointStart[1 - 1]) / 2; for (i = 1; i < _G.NW + 1; i++) { Create3D.SetMeasureNew(Mathf.Abs(_G.WallsWidth[i - 1]), "m" + (100 + i).ToString()); } RoomSize(); } public static void RedrawRoom78(string Ms, float Value) { print("Ms====" + Ms); if (Ms == "m101") _G.WIDE = Value; if (Ms == "m104") _G.DEPTH = Value; if (Ms == "m102") _G.DEPTH = Value; Rooms(); } public static void setM(string M, Vector2 p1, Vector2 p2) { GameObject Mesure = (GameObject)Instantiate(Get.o2("HIDER", "Mesure")); Mesure.name = M; Mesure.SetActive(true); Mesure.transform.Find("m").name = M.Replace("M", "m"); Mesure.transform.SetParent(Get.o3("Canvas","Panel_ShowPlan", "Plan").transform, false); Mesure.transform.localPosition = (p1 + p2) / 2; int i = int.Parse(M.Substring(1, M.Length - 1)); Mesure.transform.Find("no").gameObject.GetComponent().text = (i - 100).ToString(); } public static void addMesures(int Q) { for (int i = 1; i < Q + 1; i++) { Create3D.SetMeasureNew(Mathf.Abs(_G.WallsWidth[i - 1]), "m" + (100 + i).ToString()); } if (_G.ROOM == "R1") { stopMesure("M103"); stopMesure("M104"); } if (_G.ROOM == "R2") { stopMesure("M104"); stopMesure("M105"); } if (_G.ROOM == "R3") { stopMesure("M104"); stopMesure("M105"); } if (_G.ROOM == "R4") { stopMesure("M105"); stopMesure("M106"); } if (_G.ROOM == "R5") { stopMesure("M105"); stopMesure("M106"); } if (_G.ROOM == "R6") { stopMesure("M107"); stopMesure("M108"); } if (_G.ROOM == "R9") { stopMesure("M107"); stopMesure("M108"); } if (_G.ROOM == "R10") { stopMesure("M107"); stopMesure("M108"); } } public static void stopMesure(string no) { GameObject go = Get.o1(no); if (go == null) { Debug.LogError("Couldn't find object for stop mesure"); return; } Color col = DOIT.CSc("C5C5C5", 255); go.GetComponent().color = col; Get.o1(no + "Rond").GetComponent().color = col; Get.o1(no + "no").GetComponent().color = col; Get.o1(no).GetComponent().blocksRaycasts = false; } public static float getA(Vector2 d) { float A = 0; d.x = Mathf.Round(d.x * 10f) / 10f; d.y = Mathf.Round(d.y * 10f) / 10f; if (d.x == 1 && d.y == 0.0f) A = 0; if (d.x == 0.7f && d.y == -0.7f) A = 45; if (d.x == 0.0f && d.y == -1.0f) A = 90; if (d.x == -1.0f && d.y == 0.0f) A = 180; if (d.x == 0.0f && d.y == 1.0f) A = 270; if (d.x == 0.7f && d.y == 0.7f) A = 315; return A; } public static void RoomSize() { for (int i = 1; i < _G.NW; i++) { _G.WallsWidth[i - 1] = Vector2.Distance(_G.WallsPointStart[i - 1], _G.WallsPointStart[i]); } _G.WallsWidth[_G.NW - 1] = Vector2.Distance(_G.WallsPointStart[_G.NW - 1], _G.WallsPointStart[0]); float Xmax = 0; float Xmin = 0; float Ymax = 0; float Ymin = 0; for (int i = 1; i < _G.NW + 1; i++) { if (_G.WallsPointStart[i - 1].x < Xmin) Xmin = _G.WallsPointStart[i - 1].x; if (_G.WallsPointStart[i - 1].x > Xmax) Xmax = _G.WallsPointStart[i - 1].x; if (_G.WallsPointStart[i - 1].y < Ymin) Ymin = _G.WallsPointStart[i - 1].y; if (_G.WallsPointStart[i - 1].y > Ymax) Ymax = _G.WallsPointStart[i - 1].y; } for (int i = 1; i < _G.NW; i++) { _G. WallsDirection[i - 1] = DRAW.CalculateSense(_G.WallsPointStart[i - 1], _G.WallsPointStart[i]); } _G. WallsDirection[_G.NW - 1] = DRAW.CalculateSense(_G.WallsPointStart[_G.NW - 1], _G.WallsPointStart[0]); for (int i = 1; i < _G.NW; i++) { _G. WallsPointCenter[i - 1] = (_G.WallsPointStart[i - 1] + _G.WallsPointStart[i]) / 2; } _G. WallsPointCenter[_G.NW - 1] = (_G.WallsPointStart[_G.NW - 1] + _G.WallsPointStart[0]) / 2; _G.WIDE = Xmax - Xmin; _G.DEPTH = Ymax - Ymin; } }