void Move() { // Move Left if (hoge.transform.localPosition.x > -11) { // Modify position transform.position += new Vector3(-1, 0, 0); // See if valid if (isValidGridPos()) { // Its valid. Update grid. updateGrid(); framecount = 20; AudioScript.Moved(); } else { // Its not valid. revert. transform.position += new Vector3(1, 0, 0); } } // Move Right else if (hoge.transform.localPosition.x < -20) { // Modify position transform.position += new Vector3(1, 0, 0); // See if valid if (isValidGridPos()) { // It's valid. Update grid. updateGrid(); framecount = -20; AudioScript.Moved(); } else { // It's not valid. revert. transform.position += new Vector3(-1, 0, 0); } } // Rotate else if (hoge.transform.localPosition.y > 4) { transform.Rotate(0, 0, -90); // See if valid if (isValidGridPos()) { // It's valid. Update grid. updateGrid(); framecount = -40; AudioScript.Rotated(); } else { // It's not valid. revert. transform.Rotate(0, 0, 90); } } // Move Downwards and Fall else if ((hoge.transform.localPosition.y < -4)) { // Modify position transform.position += new Vector3(0, -1, 0); // See if valid if (isValidGridPos()) { // It's valid. Update grid. updateGrid(); framecount = 45; } else { // It's not valid. revert. transform.position += new Vector3(0, 1, 0); // Clear filled horizontal lines Grid.deleteFullRows(); // Spawn next Group(デフォルトのブロックが落ちた場合は次のブロックを生成しない) if (ButtonPush.swich == 1) { FindObjectOfType <SpawnerScript>().spawnNext(); } // Disable script enabled = false; } lastFall = Time.time; } //1秒ごとに落下 if (Time.time - lastFall >= FallSpeed) { // 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 if (ButtonPush.swich == 1) { FindObjectOfType <SpawnerScript>().spawnNext(); } // Disable script enabled = false; } lastFall = Time.time; } }