예제 #1
0
    int readCursor;      // 現在読む進めている位置

    public void LoadText(string fileName)
    {
        try
        {
            //oulFile.OutPutLog(Application.dataPath + "/log.txt", fileName + "\r\n");

            // これだと何故かexe実行の時だけSystem.ArgumentExceptionがでる。どうやらUnityはshift_jisをサポートしていないようだ
            // http://answers.unity3d.com/questions/42955/codepage-1252-not-supported-works-in-editor-but-no.html
            using (StreamReader reader = new StreamReader(fileName, Encoding.GetEncoding("shift_jis")))

            // テキストオープン
            //using (FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            //using (StreamReader reader = new StreamReader(file/*, Encoding.GetEncoding("shift_jis")*/))
            {
                // 全読み
                fileBuf = reader.ReadToEnd().ToCharArray();
                //str = "unko\r\n";

                // 値初期化
                readCursor = 0;
            }

            //oulFile.OutPutLog(Application.dataPath + "/log.txt", str);
        }
        catch (Exception e)
        {
            ExceptionMessage.Message("text file error", e);
        }
    }
        void OnrecebeGn(object source, string LeituraGN)
        {
            try
            {
                Model.CalculoGN(LeituraGN);
            }
            catch (ErroConversaoRecebe)
            {
                ExceptionMessage.Message(message);
            }

            menuPrincipal.SetCalculaLabel("Valor Calculado:" + leituraGN);
            menuPrincipal.HideChilds();
            menuPrincipal.Show();
        }
예제 #3
0
        static void Main()
        {
            using (game = new AutoDjogo())
            {
                try
                {
                    game.Tester();
                }
                catch (TestFileNotFoundException ex)
                {
                    ExceptionMessage.Message($"Error Starting Game:\n {ex.Message}\n {ex.FileName}");
                    return;
                }

                game.Run();
            }
        }
        void Onrecebetarifa(object source, string tarifa)
        {
            if (tarifa == "Tarifa Simples")
            {
                try
                {
                    Model.CalculoElecSimples(ContagemVazio, ContagemFora);
                }

                catch (ErroConversaoRecebe)
                {
                    ExceptionMessage.Message(message);
                }
            }

            else if (tarifa == "Tarifa Bi-Horária")
            {
                try
                {
                    Model.CalculoElecBi(ContagemVazio, ContagemFora);
                }

                catch (ErroConversaoRecebe)
                {
                    ExceptionMessage.Message(message);
                }
            }

            else if (tarifa == "Tarifa Tri-Horária")
            {
                try
                {
                    Model.CalculoElecTri(ContagemVazio, ContagemFora);
                }

                catch (ErroConversaoRecebe)
                {
                    ExceptionMessage.Message(message);
                }
            }
        }
예제 #5
0
파일: PngLoader.cs 프로젝트: WassyoiTCG/TCG
    public static Texture2D LoadPNG(string path)
    {
        try
        {
            // ファイルバッファ
            byte[] buf = oulFile.ReadAllBytes(path);

            // バイナリオープン
            //using (FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read))
            //using (BinaryReader reader = new BinaryReader(file))
            //{
            //    buf = reader.ReadBytes((int)reader.BaseStream.Length);

            // 16バイトから開始
            int pos = 16;

            // 画像幅計算
            int width = 0;
            for (int i = 0; i < 4; i++)
            {
                width = width * 256 + buf[pos++];
            }
            int height = 0;
            for (int i = 0; i < 4; i++)
            {
                height = height * 256 + buf[pos++];
            }

            // テクスチャ作成
            Texture2D texture = new Texture2D(width, height);
            texture.LoadImage(buf);

            return(texture);
        }
        catch (Exception e)
        {
            ExceptionMessage.Message("png load error!", e);
        }

        return(null);
    }
예제 #6
0
파일: oulFile.cs 프로젝트: WassyoiTCG/TCG
    static public byte[] ReadAllBytes(string path)
    {
        try
        {
            byte[] buf;
            // バイナリオープン
            using (FileStream file = new System.IO.FileStream(path, FileMode.Open, FileAccess.Read))
                using (BinaryReader reader = new System.IO.BinaryReader(file))
                {
                    buf = reader.ReadBytes((int)reader.BaseStream.Length);
                }

            return(buf);
        }

        catch (System.Exception e)
        {
            ExceptionMessage.Message("file error", e);
        }

        return(null);
    }