// Start is called before the first frame update void Start() { //All instantiation goes here GameState = new bool[GridX, GridY, GridZ]; TileLiterals = new GameObject[GridX, GridY, GridZ]; CurrentPiece = new GamePiece(); //Sets the pointer position to the top middle of the game board PointerX = GridX / 2; PointerY = GridY - 1; PointerZ = GridZ / 2; CurrentPiece.SetPosition(PointerX, PointerY, PointerZ); CurrentColor = GradientColors.Evaluate(Random.value); //Initializes camera settings CameraTarget = new Vector3(GridX / 2f, GridY / 2f, GridZ / 2f); CameraDistanceMin = GridY; CameraDistanceMax = GridY * 3; CameraDistance = GridY * 1.5f; CameraAngleXY = 135f; CameraAngleXZ = 0f; LastCameraAngleXY = CameraAngleXY; LastCameraAngleXZ = CameraAngleXZ; LastCameraTarget = CameraTarget; //Starts game on pause with the main menu active m_gameover.SetActive(false); m_mainmenu.SetActive(true); m_ingame.SetActive(false); m_pausemenu.SetActive(false); CurrentCanvas = m_mainmenu; CanvasHistory.Add(CurrentCanvas); Paused = true; FreeSpin = true; Score = 0; DropTime = DropTimeMax; DropTimeDefault = DropTimeMax; //Instantiates the bounding box and scales it to fit the whole grid BoundingBox = Instantiate(m_boundingbox, new Vector3(GridX / 2f - 0.5f, GridY / 2f - 0.5f, GridZ / 2f - 0.5f), Quaternion.identity); BoundingBox.transform.localScale = new Vector3(0.02f + GridX, 0.02f + GridY, 0.02f + GridZ); //Instantiates the baseplate and scales it to fit under the grid BasePlate = Instantiate(m_baseplate, new Vector3(GridX / 2f - 0.5f, -0.5f, GridZ / 2f - 0.5f), Quaternion.identity); BasePlate.transform.localScale = new Vector3(GridX - 0.01f, 0.05f, GridZ - 0.01f); //Sets all clearing levels to false, readying the ClearingLevels array ClearingLevels = new bool[GridY]; for (int i = 0; i < GridY; i++) { ClearingLevels[i] = false; } //Positions the camera looking down over the game board. m_camera.transform.SetPositionAndRotation(new Vector3(GridX / 2f, GridY / 2f + CameraDistance, GridZ / 2f), Quaternion.Euler(90, 0, 0)); //Loops through all values in the game state grid and initializes them for (int x = 0; x < GridX; x++) { for (int y = 0; y < GridY; y++) { for (int z = 0; z < GridZ; z++) { GameState[x, y, z] = false; } } } //Creates the actual grid of tile GameObjects which are used for rendering for (int x = 0; x < GridX; x++) { for (int y = 0; y < GridY; y++) { for (int z = 0; z < GridZ; z++) { TileLiterals[x, y, z] = Instantiate(m_tile, new Vector3(x, y, z), Quaternion.identity); TileLogic currentTileLogic = TileLiterals[x, y, z].GetComponent(typeof(TileLogic)) as TileLogic; currentTileLogic.SetPosition(x, y, z); } } } }