void Start() { GameObject gameController = GameObject.FindGameObjectWithTag("GameController"); mainCamera = GameObject.FindGameObjectWithTag("MainCamera"); fieldMover = gameController.GetComponent <FieldMover> (); uiProcs = gameController.GetComponent <UIProcs> (); fieldProcs = GameObject.FindGameObjectWithTag("Field").GetComponent <FieldProcs> (); needcells = fieldProcs.GetFieldSize() * fieldProcs.GetFieldSize() * 6 - fieldProcs.GetMinesCount(); }
public void ResetFieldMover(bool isEndless) { SetGameOver(false); SetWin(false); UpdateTimer(0); time = 0; openedCells = 0; firstOpen = false; movingFieldStart = false; minBound = mainCamera.ScreenToWorldPoint(new Vector3(mainCamera.pixelRect.x, mainCamera.pixelRect.y, 0)); maxBound = mainCamera.ScreenToWorldPoint(new Vector3(mainCamera.pixelRect.width, mainCamera.pixelRect.height, 0)); fieldProcs = fieldTransform.gameObject.GetComponent <FieldProcs> (); bottomMenuSize = fieldProcs.triSideLen * 1.1f; if (fieldProcs != null) { if (isEndless) { minBound.x = minBound.z = -2000000; maxBound.x = maxBound.z = 2000000; } else { float fieldWidth = (fieldProcs.GetFieldSize() + 0.5f) * fieldProcs.triSideLen; float fieldHeight = fieldProcs.GetFieldSize() * fieldProcs.triHeight + bottomMenuSize; if (minBound.x > -fieldWidth) { minBound.x = -(minBound.x + fieldWidth); } else { minBound.x = (minBound.x + fieldWidth); } if (maxBound.x < fieldWidth) { maxBound.x = -(maxBound.x - fieldWidth); } else { maxBound.x = (maxBound.x - fieldWidth); } if (minBound.z > -fieldHeight) { minBound.z = -(minBound.z + fieldHeight); } else { minBound.z = (minBound.z + fieldHeight); } if (maxBound.z < fieldHeight) { maxBound.z = -(maxBound.z - fieldHeight); } else { maxBound.z = (maxBound.z - fieldHeight); } } fieldTransform.position = new Vector3((minBound.x + maxBound.x) / 2.0f, 0, (minBound.z + maxBound.z) / 2.0f); } }