public void SpawnShape(List <Vector2> v, bool can) { var quad = Instantiate(quadZonePrefab); MapCreatorLoader.Instance.Attach(quad.gameObject); if (can) { quad.Color = Colors.PlaceColor; } else { quad.Color = Colors.CantPlace; } quad.Init(v[0], v[1], v[3], v[2]); var quadRender = quad.gameObject.GetComponent <MeshRenderer>(); int sorting = can ? SortingOrder.Is(Layer.Place) : SortingOrder.Is(Layer.WrongPlace); quadRender.sortingOrder = sorting; zone = quad; ShapeID = MapCreatorLoader.Instance.ParkingZone.AddShape(v, false); quad.name = "Place_shape_" + ShapeID; }
public void SetPosition(Vector3 p3d) { transform.localPosition = p3d; var shape = Shapes.Get(Shape.Edge8, NodeBaseScale, transform.localPosition.x, transform.localPosition.z); var platform = Instantiate(quadZonePrefab); platform.name = "NodeBase"; MapCreatorLoader.Instance.Attach(platform.gameObject); platform.Color = Colors.RoadColor; platform.Init(shape); var platformRender = platform.gameObject.GetComponent <MeshRenderer>(); platformRender.sortingOrder = SortingOrder.Is(Layer.NodeBase); PlatformObject = platform.gameObject; MagnetPoints = new List <Vector2>(); foreach (var i in shape) { MagnetPoints.Add(i); } SelfShape = MapCreatorLoader.Instance.ParkingZone.AddShape(shape, false); ReDraw(); }
private void MakeGround() { ground = MeshUtil.MakeSolidMesh("Ground", sizeX, sizeY, color); ground.transform.SetParent(baseMapObject.transform, false); MeshRenderer render = ground.GetComponent <MeshRenderer>(); render.sortingOrder = SortingOrder.Is(Layer.Ground); groundPlane = new Plane(Vector3.up, Vector3.zero); }
private void Awake() { vertices2D = new List <Vector2>(); vertices2D.Add(new Vector2(0, 0)); vertices2D.Add(new Vector2(0, 25)); vertices2D.Add(new Vector2(25, 25)); vertices2D.Add(new Vector2(25, 50)); vertices2D.Add(new Vector2(0, 50)); vertices2D.Add(new Vector2(0, 75)); vertices2D.Add(new Vector2(75, 75)); vertices2D.Add(new Vector2(75, 50)); vertices2D.Add(new Vector2(50, 50)); vertices2D.Add(new Vector2(50, 25)); vertices2D.Add(new Vector2(75, 25)); vertices2D.Add(new Vector2(75, 0)); mesh = new Mesh(); mesh.name = "parkingZoneMesh"; filter = gameObject.AddComponent <MeshFilter>(); filter.mesh = mesh; var meshRender = MeshUtil.ApplyMaterial(gameObject, new Color32(165, 165, 165, 255)); meshRender.sortingOrder = SortingOrder.Is(Layer.Polygon); spheres = new List <GameObject>(); GameObject sphereHolderObj = new GameObject("SphereHolder"); sphereHolderObj.transform.SetParent(transform, false); sphereHolder = sphereHolderObj.transform; nodes = new List <PathNode>(); GameObject nodeHolderObj = new GameObject("NodeHolder"); nodeHolderObj.transform.SetParent(transform, false); nodeHolder = nodeHolderObj.transform; shapeInfos = new List <ShapeInfo>(); UpdateSelfShape(); }
private GameObject MakeLine(Vector2 p1, Vector2 p2, Color color) { Vector3 start = GeometryUtil.V3(p1); Vector3 end = GeometryUtil.V3(p2); GameObject myLine = new GameObject("line"); myLine.transform.SetParent(ObjectsHolder, false); myLine.transform.position = start; LineRenderer lr = myLine.AddComponent <LineRenderer>(); lr.material = new Material(MeshUtil.ShaderSprite); lr.SetColors(color, color); lr.SetWidth(0.2f, 0.2f); lr.SetPosition(0, start); lr.SetPosition(1, end); lr.sortingOrder = SortingOrder.Is(Layer.NodeLine); Objects.Add(myLine); return(myLine); }
private void ReDraw() { CleanObjects(); foreach (var i in OutNodes) { Vector2 p1 = XZ; Vector2 p2 = i.XZ; GeometryUtil.LineOptions lineOpt = new GeometryUtil.LineOptions(p1, p2); lineOpt.CalcNormScale(NormScale); Vector2 q1 = lineOpt.MakeNormalOffset(p1, -1); Vector2 q2 = lineOpt.MakeNormalOffset(p1, +1); Vector2 q4 = lineOpt.MakeNormalOffset(p2, -1); Vector2 q3 = lineOpt.MakeNormalOffset(p2, +1); CorrectWithMagnetPoints(ref q1, ref q2); i.CorrectWithMagnetPoints(ref q3, ref q4); var quad = Instantiate(quadZonePrefab); MapCreatorLoader.Instance.Attach(quad.gameObject); quad.Color = Colors.RoadColor; quad.Init(q1, q2, q4, q3); var quadRender = quad.gameObject.GetComponent <MeshRenderer>(); quadRender.sortingOrder = SortingOrder.Is(Layer.Road); Objects.Add(quad.gameObject); List <Vector2> quadV = new List <Vector2>(); quadV.Add(q1); quadV.Add(q2); quadV.Add(q3); quadV.Add(q4); ObjectShapes.Add(MapCreatorLoader.Instance.ParkingZone.AddShape(quadV, false)); MakeLine(p1, p2, Colors.NodeLineColor); } }