public void GenerateMap() { DataContainerScript.LevelDescriptionAnimalSudoku level = DataContainerScript.Instance.GetLevelDataAnimalSudoku(); endGamePanel.SetActive(false); foundObjects = new List <Enums.OBJECTS_IN_BOX>(); lifes = 3; PopulateGamePanel(level.x, level.y, 0, level); //GenerateHints(); LoadHintsJSON(level); hintsAndLife.Init(verticalHints, horizontalHints); }
private void SetObjectBoxes(int x, int y, int objectsInBoxesCount, DataContainerScript.LevelDescriptionAnimalSudoku _level) { float width = gamePanelRect.rect.width; float height = gamePanelRect.rect.height; float objWidth = width / (float)x; float objHeight = height / (float)y; float objSize = Mathf.Min(objWidth, objHeight); float offsetX = width - (x * objSize); float offsetY = height - (y * objSize); objectBoxes = new BoxScript2[x, y]; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { GameObject go = new GameObject("ObjectBox[" + i + "," + j + "]"); go.transform.SetParent(gamePanelRect); go.AddComponent <Image>(); go.GetComponent <Image>().sprite = temp; go.GetComponent <Image>().type = Image.Type.Sliced; RectTransform objRect = go.GetComponent <RectTransform>(); objRect.localScale = new Vector3(1, 1, 1); objRect.pivot = new Vector2(0, 1); objRect.anchorMin = new Vector2(0, 1); objRect.anchorMax = new Vector2(0, 1); objRect.sizeDelta = new Vector2(objSize, objSize); objRect.anchoredPosition = new Vector2(((i * objSize) + (offsetX / 2.0f)), (-(j * objSize) - (offsetY / 2.0f))); go.AddComponent <BoxScript2>(); /*go.GetComponent<BoxScript2>().PopulateBox(availableObjects, GetObjectFromPool(), * objectsInBoxesCount, buttonPrefab);*/ int index = i * y + j; go.GetComponent <BoxScript2>().PopulateBoxJSON(_level.boxes[index].correctAnimal, _level.boxes[index].animals, buttonPrefab); objectBoxes[i, j] = go.GetComponent <BoxScript2>(); } } }
private void LoadHintsJSON(DataContainerScript.LevelDescriptionAnimalSudoku _level) { verticalHints = new List <Hint>(); horizontalHints = new List <Hint>(); for (int i = 0; i < _level.hints.Count; i++) { Hint hint = new Hint(); hint.object1 = _level.hints[i].animal1; hint.object2 = _level.hints[i].animal2; hint.number = _level.hints[i].number; hint.done = false; if (_level.hints[i].vertical) { verticalHints.Add(hint); } else { horizontalHints.Add(hint); } } }
public void PopulateGamePanel(int x, int y, int objectsInBoxesCount, DataContainerScript.LevelDescriptionAnimalSudoku _level) { //ChooseAvailableGameObjects(x * y); SetObjectBoxes(x, y, objectsInBoxesCount, _level); }