public MapEditorTile CheckObject(float x, float y) { for (int i = 0; i < objects.childCount; i++) { MapEditorTile temp = objects.GetChild(i).GetComponent <MapEditorTile>(); if (temp.mapPos.x == x && temp.mapPos.y == y) { return(temp); } } return(null); }
public MapEditorTile CheckJackson(int x, int y) { for (int i = 0; i < jacksons.childCount; i++) { MapEditorTile temp = jacksons.GetChild(i).GetComponent <MapEditorTile>(); if (temp.mapPos.x == x && temp.mapPos.y == y) { return(temp); } } return(null); }
public MapSaveData SerializeMap() { if (jacksons.childCount == 0) { PrintDebugText("There is no start floor"); return(null); } else { int minX = 0, minY = 0, maxX = 0, maxY = 0; for (int i = 0; i < floors.childCount; i++) { MapEditorTile temp = floors.GetChild(i).GetComponent <MapEditorTile>(); if (temp.mapPos.x < minX) { minX = (int)temp.mapPos.x; } if (temp.mapPos.y < minY) { minY = (int)temp.mapPos.y; } if (temp.mapPos.x > maxX) { maxX = (int)temp.mapPos.x; } if (temp.mapPos.y > maxY) { maxY = (int)temp.mapPos.y; } } MapSaveData mapSaveData = new MapSaveData(); mapSaveData.AddObject(TileMode.None, new Vector2((Mathf.Max(maxX - minX, maxY - minY) + 1) * 5, 0)); for (int i = 0; i < walls.childCount; i++) { MapEditorTile temp = walls.GetChild(i).GetComponent <MapEditorTile>(); mapSaveData.AddObject(temp.thisTile, temp.mapPos, (int)temp.transform.eulerAngles.y); } for (int i = 0; i < floors.childCount; i++) { MapEditorTile temp = floors.GetChild(i).GetComponent <MapEditorTile>(); mapSaveData.AddObject(temp.thisTile, temp.mapPos); } for (int i = 0; i < jacksons.childCount; i++) { MapEditorTile temp = jacksons.GetChild(i).GetComponent <MapEditorTile>(); mapSaveData.AddObject(TileMode.StartFloor, temp.mapPos); } for (int i = 0; i < objects.childCount; i++) { MapEditorTile temp = objects.GetChild(i).GetComponent <MapEditorTile>(); mapSaveData.AddObject(temp.thisTile, temp.mapPos, (int)temp.transform.eulerAngles.y); } for (int i = 0; i < clearConditionButtons.Length; i++) { int goal = -1; if (i == (int)ClearType.AllCase || i == (int)ClearType.AllFloor || i == (int)ClearType.AllTurret) { goal = clearConditionButtons[i].transform.Find("Toggle").GetComponent <Toggle>().isOn ? 0 : goal; } else { goal = int.Parse(clearConditionButtons[i].transform.Find("InputField").GetComponent <InputField>().text); } if (goal != -1) { mapSaveData.AddClears((ClearType)i, goal); } } for (int i = 0; i < bullets.childCount; i++) { mapSaveData.bullets.Add(bullets.GetChild(i).GetComponent <MapEditorTile>().bulletCode); } mapSaveData.comments = comment; return(mapSaveData); } }