//回転 void Rotation() { Rot = new Vector3(0, 0, 0); RotationAngle = new Vector3(0, 0, 0); if (Input.GetKeyDown(KeyCode.A)) { RotationAngle.z = 90; Rot.z = -90; canRotationCheck = true; } if (Input.GetKeyDown(KeyCode.S)) { RotationAngle.y = 90; Rot.y = -90; canRotationCheck = true; } if (Input.GetKeyDown(KeyCode.W)) { RotationAngle.x = 90; Rot.x = -90; canRotationCheck = true; } if (canRotationCheck == true) { //回転可能か RotationMove(RotationAngle); canRotation = PlayBlockManeger.RotationPos(); if (canRotation == false) { RotationMove(Rot); } canRotationCheck = false; } }
//移動 void Move() { x2 = 0; z2 = 0; if(PlayTime >= 30) { fallSpeed += 0.01f; PlayTime = 0; } players.transform.position -= new Vector3(0, fallSpeed, 0); if (Input.GetKey(KeyCode.D)) { players.transform.position -= new Vector3(0, 0.2f, 0); } movePosition = players.transform.position; if (Input.GetKeyDown(KeyCode.UpArrow)) { movePosition.z += 1; z2 = 1; canMoveCheck = true; } if (Input.GetKeyDown(KeyCode.DownArrow)) { movePosition.z += -1; z2 = -1; canMoveCheck = true; } if (Input.GetKeyDown(KeyCode.LeftArrow)) { movePosition.x += -1; x2 = -1; canMoveCheck = true; } if (Input.GetKeyDown(KeyCode.RightArrow)) { movePosition.x += 1; x2 = 1; canMoveCheck = true; } if (canMoveCheck == true) { canMove = PlayBlockManeger.MoveCheck(x2, z2); canMoveCheck = false; } if (canMove == true) { players.transform.position = Vector3.MoveTowards(players.transform.position, movePosition, 2.0f); canMove = false; } }
// Update is called once per frame void Update() { PlayTime += Time.deltaTime; if (playerCount == true) { DestroyBlock.InDestoryList(); DestroyBlock.destroyCheck(); BlockInstance(); } Move(); Rotation(); playerCount = PlayBlockManeger.BlockFall(); }