private void CreateLevelDatabase() { Debug.Log("Level Db Created"); var levelSection = _selectedObject.GetComponent <LevelSection>(); var probs = _selectedObject.GetComponentsInChildren <Probs>(); LevelSectionDatabase lvlDb = ScriptableObject.CreateInstance <LevelSectionDatabase>(); lvlDb.ProbPositions = probs.Select(x => x.transform.position).ToArray(); lvlDb.ProbType = probs.Select(x => x.ProbType).ToArray(); lvlDb.Level = levelSection.LevelIndex; lvlDb.ExpectedProb = levelSection.ExpectedProbCount; AssetDatabase.CreateAsset(lvlDb, $"Assets/Resources/ScriptableObjects/LevelSectionDatabase_{lvlDb.Level}.asset"); AssetDatabase.SaveAssets(); }
public void Init(LevelSectionDatabase levelSectionDb) { this.gameObject.SetActive(true); var poolManager = FindObjectOfType <ProbPooler>(); var probPositions = levelSectionDb.ProbPositions; ExpectedProbCount = levelSectionDb.ExpectedProb; LevelIndex = levelSectionDb.Level; ChangeMaterial(levelSectionDb.BoardMaterial); ActiveProbs.Clear(); for (int i = 0; i < probPositions.Length; i++) { var probGo = poolManager.Get(levelSectionDb.ProbType[i], this.transform.position + probPositions[i], Quaternion.identity); var prob = probGo.GetComponent <Probs>(); prob.Init(); ActiveProbs.Add(prob); } CurrentProbCount = 0; }