Exemple #1
0
    /// <summary>
    /// キーの位置情報を取得(カナ文字の設定なし)
    /// キーボードの小文字のリスト
    /// </summary>
    static public Dictionary <string, KanaKeyPosInfo> ReadKeyPosInfo()
    {
        TextAsset    csvFile = Resources.Load("File/key_pos") as TextAsset; /* Resouces/CSV下のCSV読み込み */
        StringReader reader  = new StringReader(csvFile.text);

        Dictionary <string, KanaKeyPosInfo> kanaKeyPosInfo = new  Dictionary <string, KanaKeyPosInfo>();
        int height = 0;

        while (reader.Peek() > -1)
        {
            string line = reader.ReadLine();

            height++; // 行数加算
            if (height == 1)
            {
                continue;               //1行目はコメントのため飛ばす
            }
            KanaKeyPosInfo info = new KanaKeyPosInfo();

            string[] str = line.Split('\t');
            info.typeKey = str[0];
            info.yPos    = int.Parse(str[1]);
            info.xPos    = int.Parse(str[2]);


            kanaKeyPosInfo[info.typeKey] = info;
        }

        return(kanaKeyPosInfo);
    }
Exemple #2
0
    //初期化処理
    public void Initialization(KanaKeyPosInfo keyInfo)
    {
        //英語
        typeKey.text = keyInfo.typeKey.ToUpper();

        //下の段
        kana1.text = keyInfo.kana1;

        //上の段
        kana2.text = keyInfo.kana2;

        //逆シフト
        kana3.text = keyInfo.kana3;
    }
    /// <summary>
    /// 疑似キーボードを作成する
    /// </summary>
    void makeKeyPos()
    {
        //疑似キーボードの情報を保存しておく
        _keyButtons = new Dictionary <string, KeyButton>();

        float basePosX = -355.0f;
        float basePosY = 82.0f;

        float offsetX = 65.0f;


        //一列目作成
        foreach (var item in _model.KanaKeyPosInfoData)
        {
            KanaKeyPosInfo info = item.Value;

            if (info.yPos == 2)
            {
                var obj = GameObject.Instantiate(_keyButtonPrefab);
                obj.gameObject.transform.parent        = _keyboardController.gameObject.transform;
                obj.gameObject.transform.localPosition = new Vector3(basePosX + info.xPos * offsetX, basePosY);
                obj.gameObject.name = info.typeKey;
                obj.gameObject.transform.localScale = new Vector3(1, 1, 1);
                KeyButton infodata = obj.GetComponent <KeyButton>();
                //文字を設定する
                infodata.Initialization(item.Value);

                _keyButtons[item.Value.typeKey] = infodata;
                //infodata.SelectKey("る");
            }
        }

        //2列目の基本位置
        //basePosX = -420.0f;
        basePosY += -65.0f;



        //2列目作成
        foreach (var item in _model.KanaKeyPosInfoData)
        {
            KanaKeyPosInfo info = item.Value;

            if (info.yPos == 3)
            {
                var obj = GameObject.Instantiate(_keyButtonPrefab);
                obj.gameObject.transform.parent        = _keyboardController.gameObject.transform;
                obj.gameObject.transform.localPosition = new Vector3(basePosX + info.xPos * offsetX, basePosY);
                obj.gameObject.name = info.typeKey;
                obj.gameObject.transform.localScale = new Vector3(1, 1, 1);
                KeyButton infodata = obj.GetComponent <KeyButton>();
                //文字を設定する
                infodata.Initialization(item.Value);

                _keyButtons[item.Value.typeKey] = infodata;
            }
        }

        //3列目作成
        //2列目の基本位置
        //basePosX = -410.0f;
        basePosY += -65.0f;

        foreach (var item in _model.KanaKeyPosInfoData)
        {
            KanaKeyPosInfo info = item.Value;

            if (info.yPos == 4)
            {
                var obj = GameObject.Instantiate(_keyButtonPrefab);
                obj.gameObject.transform.parent        = _keyboardController.gameObject.transform;
                obj.gameObject.transform.localPosition = new Vector3(basePosX + info.xPos * offsetX, basePosY);
                obj.gameObject.name = info.typeKey;
                obj.gameObject.transform.localScale = new Vector3(1, 1, 1);
                KeyButton infodata = obj.GetComponent <KeyButton>();
                //文字を設定する
                infodata.Initialization(item.Value);

                _keyButtons[item.Value.typeKey] = infodata;
            }
        }
    }