// 入力処理を行う。 void Input() { // 移動処理 // 上キー Vector2 move = Vector2.zero; if (mKeyboard.IsMatchKeyInterval(KeyCode.UpArrow, 1)) { move += Vector2.up; // 下キー } else if (mKeyboard.IsMatchKeyInterval(KeyCode.DownArrow, 1)) { move += Vector2.down; } // 左キー if (mKeyboard.IsMatchKeyInterval(KeyCode.LeftArrow, 1)) { move += Vector2.left; } // 右キー else if (mKeyboard.IsMatchKeyInterval(KeyCode.RightArrow, 1)) { move += Vector2.right; } move = move.normalized; move *= MOVE_SPEED; // Shift(低速移動) if (mKeyboard.IsMatchKeyInterval(KeyCode.LeftShift, 1)) { move *= 0.5f; } Vector3 beforePos = gameObject.transform.position; Vector3 movedPos = new Vector3(beforePos.x + move.x, beforePos.y + move.y, 0.0f); // 左右の壁に接していた場合 if (mFieldController.IsOnBoundaryLeft(movedPos, mRect) || mFieldController.IsOnBoundaryRight(movedPos, mRect)) { // X方向の移動をキャンセルし、Y方向のみ移動する。 move.x = 0f; move = move.normalized * MOVE_SPEED; } if (mFieldController.IsOnBoundaryTop(movedPos, mRect) || mFieldController.IsOnBoundaryBottom(movedPos, mRect)) { // Y方向の移動をキャンセルし、Y方向のみ移動する。 move.y = 0f; move = move.normalized * MOVE_SPEED; } transform.Translate(move.x, move.y, 0.0f); // ショット処理 GameObject.Find("Log").GetComponent <Log>().AddMessage(mKeyboard.GetKeyPushTime(KeyCode.Z).ToString()); if (mKeyboard.IsMatchKeyInterval(KeyCode.Z, 5)) { mShoot.Calculate(); } // リップル処理 if (mKeyboard.GetKeyPushTime(KeyCode.X) > 0) { // スタミナが残っている場合 if (mCurrentStamina > 0.0) { mCurrentStamina -= 1.0f * mStaminaMax / STAMINA_CHARGE_TIME; } else { mRippleShoot.Deactive(); } } else { // チャージ時間かけてMAXまで回復する。 mCurrentStamina += 1.0f * mStaminaMax / STAMINA_CHARGE_TIME; if (mCurrentStamina > mStaminaMax) { mCurrentStamina = mStaminaMax; } mRippleShoot.Deactive(); } }