// Use this for initialization void Start() { AllLevels allLevels = GameObject.Find("Persistent Data").GetComponent <AllLevels>(); BuildingBlockManager buildingBlockManager = GameObject.Find("Persistent Data").GetComponent <BuildingBlockManager>(); int currentLevelIndex = allLevels.currentLevel; if (currentLevelIndex < allLevels.BuiltInLevels.Count) { BuiltInLevel currentLevel = allLevels.BuiltInLevels[currentLevelIndex]; for (int i = 0; i < currentLevel.Prefabs.Count; i++) { Vector3 piecePosition = currentLevel.PiecePositions[i]; Quaternion pieceRotation = Quaternion.Euler( 0f, 0f, currentLevel.PieceRotations[i]); string tag = currentLevel.Prefabs[i]; Instantiate( buildingBlockManager.searchBuiltInPrefabs(tag), piecePosition, pieceRotation); } } else if (currentLevelIndex >= allLevels.BuiltInLevels.Count) { CustomLevel currentLevel = allLevels.CustomLevels[currentLevelIndex]; for (int i = 0; i < currentLevel.Prefabs.Count; i++) { Vector3 piecePosition = currentLevel.PiecePositions[i]; Quaternion pieceRotation = Quaternion.Euler( 0f, 0f, currentLevel.PieceRotations[i]); string tag = currentLevel.Prefabs[i]; Instantiate( buildingBlockManager.searchBuiltInPrefabs(tag), piecePosition, pieceRotation); } } }
private void Awake() { if (Instance != null && Instance != this) { Destroy(this.gameObject); } else { Instance = this; } }
private void OnEnable() { Debug.Log("There is a building block list manager component on: " + this.gameObject.name); buildingBlockManager = GameObject.Find("Persistent Data").GetComponent <BuildingBlockManager> (); bbCreator = GameObject.Find("UI Manager").GetComponent <BuildingBlockCreator>(); // "this" is Building Block List gameObject dropdownContent = this.transform.GetChild(0).GetChild(0).gameObject; dropdownContentRect = dropdownContent.GetComponent <RectTransform> (); RepopDelBbList(); }
private void createNewBuildingBlock(Transform pNewBuildingBlock, BuildingBlockManager pBuildingBlockManager, Text pBuildingBlockName, LevelBuilderActivator pLevelBuilderActivator, Animator pTooManyPiecesWarning) { const int PIECE_LIMIT = 150; if (pNewBuildingBlock.childCount < PIECE_LIMIT) { pBuildingBlockManager.addBuildingBlock(pNewBuildingBlock, pBuildingBlockName.text); pLevelBuilderActivator.deconfirmChoice(); updateBuildingBlockSelectorList(); } else { pTooManyPiecesWarning.Play("Warning", 0); } }
/* * -> Initialize references * -> Initialize template */ private void Start() { // UI dropdown used for selecting building blocks if (GameObject.Find("Building Block Selector") != null) { mBuildingBlockSelector = GameObject.Find("Building Block Selector").GetComponent <Dropdown>(); } if (GameObject.Find("Persistent Data") != null) { mBuildingBlockManager = GameObject.Find("Persistent Data").GetComponent <BuildingBlockManager>(); mCoinManager = GameObject.Find("Persistent Data").GetComponent <CoinManager>(); } updateBuildingBlockSelector(); changeTemplate(); }
//---------------------------------------------------------------------- private void Start() { // UI dropdown used for selecting building blocks if (GameObject.Find("Building Block Selector") != null) { mBuildingBlockSelector = GameObject.Find("Building Block Selector").GetComponent <Dropdown>(); } // Building block manager if (GameObject.Find("Persistent Data") != null) { mBuildingBlockManager = GameObject.Find("Persistent Data").GetComponent <BuildingBlockManager>(); } if (GameObject.Find("Confirm Button") != null) { mLevelBuilderActivator = GameObject.Find("Confirm Button").GetComponent <LevelBuilderActivator>(); } updateBuildingBlockSelectorList(); }
private void updateBuildingBlockSelectorList(Dropdown pBuildingBlockSelector, GameObject pPersistentData, BuildingBlockManager pBuildingBlockManager) { pBuildingBlockSelector.ClearOptions(); // Reference to list of building blocks saved by the player if (pPersistentData != null) { for (int i = 0; i < pBuildingBlockManager.Names.Count; i++) { string lName = pBuildingBlockManager.Names[i]; string lDisplayName = (i + 1).ToString() + ". " + lName; pBuildingBlockSelector.AddOptions(new List <string>() { lDisplayName }); } } }
private void changeTemplate(int pNewBuildingBlockIndex, bool pBuildingBlockExists, BuildingBlockManager pBuildingBlockManager, Vector3 pTemplatePosition) { clearTemplate(); if (pBuildingBlockExists) { for (int i = 0; i < pBuildingBlockManager.Positions[pNewBuildingBlockIndex].Count; i++) { Vector3 lPiecePosition = pBuildingBlockManager.Positions[pNewBuildingBlockIndex][i] + transform.position; Quaternion lPieceRotation = pBuildingBlockManager.Rotations[pNewBuildingBlockIndex][i]; string lPieceTag = pBuildingBlockManager.Tags[pNewBuildingBlockIndex][i]; // create each piece using one of a preset list of prefabs placePieceInTemplate(lPieceTag, lPiecePosition, lPieceRotation); } } initialize(); }
public void ChangeLevel() { AllLevels allLevels = GameObject.Find("Persistent Data").GetComponent <AllLevels>(); BuildingBlockManager buildingBlockManager = GameObject.Find("Persistent Data").GetComponent <BuildingBlockManager>(); Transform levelContainer = GameObject.Find("Level Container").transform; foreach (Transform child in levelContainer) { Destroy(child.gameObject); } int currentLevelIndex = allLevels.currentLevel; if (currentLevelIndex < allLevels.BuiltInLevels.Count) { BuiltInLevel currentLevel = allLevels.BuiltInLevels[currentLevelIndex]; for (int i = 0; i < currentLevel.Prefabs.Count; i++) { Vector3 piecePosition = currentLevel.PiecePositions[i]; Quaternion pieceRotation = Quaternion.Euler( 0f, 0f, currentLevel.PieceRotations[i]); string tag = currentLevel.Prefabs[i]; Transform piece = Instantiate( buildingBlockManager.searchBuiltInPrefabs(tag), piecePosition, pieceRotation); piece.parent = levelContainer; } } else if (currentLevelIndex >= allLevels.BuiltInLevels.Count) { CustomLevel currentLevel = allLevels.CustomLevels[currentLevelIndex]; for (int i = 0; i < currentLevel.Prefabs.Count; i++) { Vector3 piecePosition = currentLevel.PiecePositions[i]; Quaternion pieceRotation = Quaternion.Euler( 0f, 0f, currentLevel.PieceRotations[i]); string tag = currentLevel.Prefabs[i]; Transform piece = Instantiate( buildingBlockManager.searchBuiltInPrefabs(tag), piecePosition, pieceRotation); piece.parent = levelContainer; } } }