/// <summary> /// Listens for and applies snap action (positions block at the top of the game field) /// </summary> void CheckSnap() { //Snap orientated group to top of play field if (CustomInput("down")) { //Don't allow snap if orientation is wrong if (!FindObjectOfType <FamiliarizationController>().CorrectOrientation()) { return; } //Check for correct orientation orientation = false; bool snap = true; while (snap) { //Check if block is at the top foreach (Transform child in transform) { if (Grid.ToGrid(child.position).y == snapPos) { snap = false; } } //Move down one and update if still snapping if (snap) { transform.position += new Vector3(0, -1, 0); UpdateGrid(); } } LoggerCSV.GetInstance().AddEvent(LoggerCSV.EVENT_FAMI_BLOCK_POS, FamiliarizationController.PositionAverage(transform).ToString()); SwapGhosts(); } }
/// <summary> /// Listens for and applies move right action /// </summary> void CheckMoveRight() { // Move Right if (CustomInput("right")) { // Modify position transform.position += new Vector3(1, 0, 0); // See if valid if (LegalGridPos()) { // It's valid. Update grid. UpdateGrid(); } else { // It's not valid. revert. transform.position += new Vector3(-1, 0, 0); } LoggerCSV.GetInstance().AddEvent(LoggerCSV.EVENT_BLOCK_RIGHT, FamiliarizationController.PositionAverage(transform).ToString()); } }