//z軸回転できるかチェック void checkRotateZaxis(bool dir) { if (dir) { transform.Rotate(0, 0, -90, Space.World); } else { transform.Rotate(0, 0, 90, Space.World); } // See if valid // if (isValidGridPos()) if (checkRotationPosition()) { // It's valid. Update grid. updateGrid(); } else // It's not valid. revert. if (dir) { transform.Rotate(0, 0, 90, Space.World); } else { transform.Rotate(0, 0, -90, Space.World); } //影を設置 FallPoint.setFallPoint(transform); }
// Use this for initialization void Start() { // Default position not valid? Then it's game over if (!isValidGridPos()) { Debug.Log("GAME OVER"); Destroy(gameObject); } FallPoint.setFallPoint(transform); }
//z軸回転できるかチェック void checkRotateZaxis() { transform.Rotate(0, 0, -90); // See if valid if (isValidGridPos()) { // It's valid. Update grid. updateGrid(); } else { // It's not valid. revert. transform.Rotate(0, 0, 90); } //影を設置 FallPoint.setFallPoint(transform); }
//後ろに進めるかチェック //チェックして進める場合、移動も行う void checkMoveBack() { // Modify position transform.position += new Vector3(0, 0, -1); // See if valid if (isValidGridPos()) { // It's valid. Update grid. updateGrid(); } else { // It's not valid. revert. transform.position += new Vector3(0, 0, 1); } //影を設置 FallPoint.setFallPoint(transform); }
// Use this for initialization void Start() { audiosource = GetComponent <AudioSource>(); if (0 <= transform.position.x && transform.position.x <= 6 && 0 <= transform.position.z && transform.position.z <= 6 && 0 <= transform.position.y && transform.position.y <= 15) { // Default position not valid? Then it's game over if (!isValidGridPos()) { Debug.Log("GAME OVER"); Destroy(gameObject); GameOverFlag.End_flag = true; FinishGameBtn.displayFinishBtn(); } FallPoint.setFallPoint(transform); } }
// Update is called once per frame void Update() { switch (CameraMove.getPositionNumber()) { case 0: // Move Front if (Input.GetKeyDown(KeyCode.UpArrow)) { checkMoveFront(); } // Move Back else if (Input.GetKeyDown(KeyCode.DownArrow)) { checkMoveBack(); } // Move Left else if (Input.GetKeyDown(KeyCode.LeftArrow)) { checkMoveLeft(); } // Move Right else if (Input.GetKeyDown(KeyCode.RightArrow)) { checkMoveRight(); } break; case 1: // Move Front if (Input.GetKeyDown(KeyCode.UpArrow)) { checkMoveRight(); } // Move Back else if (Input.GetKeyDown(KeyCode.DownArrow)) { checkMoveLeft(); } // Move Left else if (Input.GetKeyDown(KeyCode.LeftArrow)) { checkMoveFront(); } // Move Right else if (Input.GetKeyDown(KeyCode.RightArrow)) { checkMoveBack(); } break; case 2: // Move Front if (Input.GetKeyDown(KeyCode.UpArrow)) { checkMoveBack(); } // Move Back else if (Input.GetKeyDown(KeyCode.DownArrow)) { checkMoveFront(); } // Move Left else if (Input.GetKeyDown(KeyCode.LeftArrow)) { checkMoveRight(); } // Move Right else if (Input.GetKeyDown(KeyCode.RightArrow)) { checkMoveLeft(); } break; case 3: // Move Front if (Input.GetKeyDown(KeyCode.UpArrow)) { checkMoveLeft(); } // Move Back else if (Input.GetKeyDown(KeyCode.DownArrow)) { checkMoveRight(); } // Move Left else if (Input.GetKeyDown(KeyCode.LeftArrow)) { checkMoveBack(); } // Move Right else if (Input.GetKeyDown(KeyCode.RightArrow)) { checkMoveFront(); } break; } // Rotate if (Input.GetKeyDown(KeyCode.A)) { checkRotateXaxis(); } else if (Input.GetKeyDown(KeyCode.S)) { checkRotateYaxis(); } else if (Input.GetKeyDown(KeyCode.D)) { checkRotateZaxis(); } //時間経過で落ちる if (Time.time - lastFall >= 1) { // Modify position transform.position += new Vector3(0, -1, 0); // See if valid if (isValidGridPos()) { // It's valid. Update grid. updateGrid(); } else { // It's not valid. revert. transform.position += new Vector3(0, 1, 0); // Clear filled horizontal lines Grid.deleteFullRows(); // Spawn next Group FindObjectOfType <Spawner>().spawnNext(); //影を消す FallPoint.resetFallPoint(); // Disable script enabled = false; } lastFall = Time.time; } //一気に落ちる else if (Input.GetKeyDown(KeyCode.Space)) { while (true) { transform.position += new Vector3(0, -1, 0); if (!isValidGridPos()) { // It's not valid. revert. transform.position += new Vector3(0, 1, 0); break; } } updateGrid(); // Clear filled horizontal lines Grid.deleteFullRows(); // Spawn next Group FindObjectOfType <Spawner>().spawnNext(); //影を消す FallPoint.resetFallPoint(); // Disable script enabled = false; } }
// Update is called once per frame void fall_sequence() { switch (CameraMove3d.getPositionNumber()) { case 0: // Move Front if (Input.GetKeyDown(KeyCode.UpArrow)) { checkMoveFront(); } // Move Back else if (Input.GetKeyDown(KeyCode.DownArrow)) { checkMoveBack(); } // Move Left else if (Input.GetKeyDown(KeyCode.LeftArrow)) { checkMoveLeft(); } // Move Right else if (Input.GetKeyDown(KeyCode.RightArrow)) { checkMoveRight(); } // Rotate if (Input.GetKeyDown(KeyCode.A)) { checkRotateXaxis(true); } else if (Input.GetKeyDown(KeyCode.S)) { checkRotateYaxis(); } else if (Input.GetKeyDown(KeyCode.D)) { checkRotateZaxis(true); } break; case 1: // Move Front if (Input.GetKeyDown(KeyCode.UpArrow)) { checkMoveRight(); } // Move Back else if (Input.GetKeyDown(KeyCode.DownArrow)) { checkMoveLeft(); } // Move Left else if (Input.GetKeyDown(KeyCode.LeftArrow)) { checkMoveFront(); } // Move Right else if (Input.GetKeyDown(KeyCode.RightArrow)) { checkMoveBack(); } // Rotate if (Input.GetKeyDown(KeyCode.D)) { checkRotateXaxis(true); } else if (Input.GetKeyDown(KeyCode.S)) { checkRotateYaxis(); } else if (Input.GetKeyDown(KeyCode.A)) { checkRotateZaxis(true); } break; case 2: // Move Front if (Input.GetKeyDown(KeyCode.UpArrow)) { checkMoveBack(); } // Move Back else if (Input.GetKeyDown(KeyCode.DownArrow)) { checkMoveFront(); } // Move Left else if (Input.GetKeyDown(KeyCode.LeftArrow)) { checkMoveRight(); } // Move Right else if (Input.GetKeyDown(KeyCode.RightArrow)) { checkMoveLeft(); } // Rotate if (Input.GetKeyDown(KeyCode.A)) { checkRotateXaxis(false); } else if (Input.GetKeyDown(KeyCode.S)) { checkRotateYaxis(); } else if (Input.GetKeyDown(KeyCode.D)) { checkRotateZaxis(false); } break; case 3: // Move Front if (Input.GetKeyDown(KeyCode.UpArrow)) { checkMoveLeft(); } // Move Back else if (Input.GetKeyDown(KeyCode.DownArrow)) { checkMoveRight(); } // Move Left else if (Input.GetKeyDown(KeyCode.LeftArrow)) { checkMoveBack(); } // Move Right else if (Input.GetKeyDown(KeyCode.RightArrow)) { checkMoveFront(); } // Rotate if (Input.GetKeyDown(KeyCode.D)) { checkRotateXaxis(false); } else if (Input.GetKeyDown(KeyCode.S)) { checkRotateYaxis(); } else if (Input.GetKeyDown(KeyCode.A)) { checkRotateZaxis(false); } break; } //時間経過で落ちる if (Time.time - lastFall >= 1.5) { // Modify position transform.position += new Vector3(0, -1, 0); // See if valid if (isValidGridPos()) { // It's valid. Update grid. updateGrid(); } else { // It's not valid. revert. transform.position += new Vector3(0, 1, 0); audiosource.PlayOneShot(fallSE); // Clear filled horizontal lines Grid3d.deleteFullRows(); Spawner3d.second_ban = false; // Spawn next Group FindObjectOfType <Spawner3d>().spawnNext(); //影を消す FallPoint.resetFallPoint(); // Disable script enabled = false; } lastFall = Time.time; } //一気に落ちる else if (Input.GetKeyDown(KeyCode.Space)) { int score = 0; while (true) { transform.position += new Vector3(0, -1, 0); if (!isValidGridPos()) { // It's not valid. revert. transform.position += new Vector3(0, 1, 0); audiosource.PlayOneShot(fallSE); break; } score++; } updateGrid(); //スコア加算 ScoreText.addScore(score); // Clear filled horizontal lines Grid3d.deleteFullRows(); Spawner3d.second_ban = false; // Spawn next Group FindObjectOfType <Spawner3d>().spawnNext(); //影を消す FallPoint.resetFallPoint(); // Disable script enabled = false; } }