public LevelLine(GameObject parent, GameObject segment, LevelLineTypes type, Vector2 anchor, float size = 0) { parentObject = parent; segmentObject = segment; segments = new List <GameObject>(); Type = type; Anchor = anchor; SetSegmentSize(); Size = size; }
public void AddLine(Vector2 anchor, LevelLineTypes type) { if (linesParent == null) { linesParent = transform.Find("Lines").gameObject; } if (type == LevelLineTypes.FLOOR) { Floors.Add(new LevelLine(linesParent, Floor, LevelLineTypes.FLOOR, transform.position)); } else { Walls.Add(new LevelLine(linesParent, Wall, LevelLineTypes.WALL, transform.position)); } }
public void RemoveLine(LevelLineTypes type, int index) { if (index < 0) { return; } if (type == LevelLineTypes.FLOOR && index < Floors.Count) { Floors[index].Clear(); Floors.RemoveAt(index); } else if (index < Walls.Count) { Walls[index].Clear(); Walls.RemoveAt(index); } }
public void ResizeLine(LevelLineTypes type, int index, float newSize) { if (index < 0) { return; } if ((type == LevelLineTypes.FLOOR && index >= Floors.Count) || (type == LevelLineTypes.WALL && index >= Walls.Count)) { return; } if (type == LevelLineTypes.FLOOR) { Floors[index].Size = newSize; } else { Walls[index].Size = newSize; } }
public void MoveLine(LevelLineTypes type, int index, Vector2 newAnchor) { if (index < 0) { return; } if ((type == LevelLineTypes.FLOOR && index >= Floors.Count) || (type == LevelLineTypes.WALL && index >= Walls.Count)) { return; } if (type == LevelLineTypes.FLOOR) { Floors[index].Anchor = newAnchor; } else { Walls[index].Anchor = newAnchor; } }
public override void OnInspectorGUI() { if (Application.isPlaying) { return; } if (GUILayout.Button("Clear")) { level.Clear(); return; } level.Floor = (GameObject)EditorGUILayout.ObjectField("Floor", level.Floor, typeof(GameObject), true); level.Wall = (GameObject)EditorGUILayout.ObjectField("Wall", level.Wall, typeof(GameObject), true); Vector2 size = level.Size; EditorGUI.BeginChangeCheck(); size = EditorGUILayout.Vector2Field("Level Size", size); if (EditorGUI.EndChangeCheck()) { level.Size = size; EditorUtility.SetDirty(level); } lineType = (LevelLineTypes)EditorGUILayout.EnumPopup(lineType); if ((lineType == LevelLineTypes.FLOOR && level.Floors.Count > 0) || (lineType == LevelLineTypes.WALL && level.Walls.Count > 0)) { selectedLine = EditorGUILayout.IntSlider(selectedLine, 0, lineType == LevelLineTypes.FLOOR ? level.Floors.Count - 1 : level.Walls.Count - 1); } else { selectedLine = -1; } if (GUILayout.Button("Add Line")) { level.AddLine(Vector2.zero, lineType); } LevelLine line = GetActiveLine(); if (line == null) { return; } if (GUILayout.Button("Remove Line")) { level.RemoveLine(lineType, selectedLine); return; } Vector2 anchor = line.Anchor; EditorGUI.BeginChangeCheck(); anchor = EditorGUILayout.Vector2Field("Line Anchor", anchor); if (EditorGUI.EndChangeCheck()) { line.Anchor = anchor; } float lineSize = line.Size; EditorGUI.BeginChangeCheck(); lineSize = EditorGUILayout.FloatField("Line Size", lineSize); if (EditorGUI.EndChangeCheck()) { line.Size = lineSize; } }