Beispiel #1
0
    /// <summary>
    /// 文字盤移動
    /// </summary>
    private void MoveWordCubes()
    {
        _localHandPosition = this.transform.position - _originHandPosition;

        // 水平に展開する文字
        float newCoodinateSystemPositionX = (_localHandPosition.x * Mathf.Cos(_originHandRotation.eulerAngles.y * Mathf.PI / 180)) +
                                            (_localHandPosition.z * Mathf.Sin(-_originHandRotation.eulerAngles.y * Mathf.PI / 180));

        newCoodinateSystemPositionX = Mathf.Min(Mathf.Max(newCoodinateSystemPositionX, WORDS_INTERVAL * -4), WORDS_INTERVAL * 5); // 飛び出し制限
        for (int h = 0; h < 10; h++)
        {
            _horizontalWords[h].GetComponentInChildren <TextMesh>().color = Color.black;
            _horizontalWords[h].transform.localPosition = new Vector3(-WORDS_INTERVAL * (float)(6 - h) + newCoodinateSystemPositionX,
                                                                      0,
                                                                      0);
        }

        int columnIowindex = 5 - (int)Mathf.Ceil((newCoodinateSystemPositionX - WORDS_INTERVAL / 2) / WORDS_INTERVAL);

        columnIowindex = Mathf.Min(Mathf.Max(columnIowindex, 0), 9);

        float newCoodinateSystemPositionZ = (_localHandPosition.x * Mathf.Sin(_originHandRotation.eulerAngles.y * Mathf.PI / 180)) +
                                            (_localHandPosition.z * Mathf.Cos(-_originHandRotation.eulerAngles.y * Mathf.PI / 180));

        newCoodinateSystemPositionZ = Mathf.Min(Mathf.Max(newCoodinateSystemPositionZ, WORDS_INTERVAL * -2), WORDS_INTERVAL * 2); // 飛び出し制限
        int rowIndex = (int)Mathf.Ceil((newCoodinateSystemPositionZ - WORDS_INTERVAL / 2) / WORDS_INTERVAL) + 2;

        rowIndex = rowIndex <= 2 ? 2 - rowIndex : rowIndex;
        rowIndex = Mathf.Min(Mathf.Max(rowIndex, 0), 4);

        // 垂直に展開する文字
        for (int v = 0; v < 5; v++)
        {
            if (v == 0)
            {
                _horizontalWords[columnIowindex].transform.localPosition = new Vector3(-WORDS_INTERVAL,
                                                                                       0,
                                                                                       newCoodinateSystemPositionZ);
                continue;
            }
            _verticalWords[v].GetComponentInChildren <TextMesh>().text  = _jpCharacters[columnIowindex, v];
            _verticalWords[v].GetComponentInChildren <TextMesh>().color = Color.black;
            _verticalWords[v].transform.localPosition = new Vector3(-WORDS_INTERVAL,
                                                                    0,
                                                                    WORDS_INTERVAL * (float)(v <= 2 ? v : 2 - v) + newCoodinateSystemPositionZ);
        }

        if (rowIndex != 0)
        {
            _verticalWords[rowIndex].GetComponentInChildren <TextMesh>().color = Color.red;
        }
        else
        {
            _horizontalWords[columnIowindex].GetComponentInChildren <TextMesh>().color = Color.red;
        }
        // 選択中の文字が変化したとき
        if (_nowCharacter != _jpCharacters[columnIowindex, rowIndex])
        {
            _nowCharacter = _jpCharacters[columnIowindex, rowIndex];
            Debug.Log("_nowCharacter=" + _nowCharacter);

            // 振動
            _vibrate.VibrateHand(isRightHand, 16, 64);
        }
    }