Exemplo n.º 1
0
 /// <summary>
 /// Object input constructor.
 /// </summary>
 /// <param name="_module"></param>
 public Module(Module _module)
 {
     iniParameter(_module.character, _module.height, _module.width, _module.green, _module.red, _module.score, _module.matrix);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Read template into memory.
        /// </summary>
        /// <param name="character"></param>
        /// <param name="inpath"></param>
        /// <returns></returns>
        public static Module read_Template_From_Text_To_Memory(char character, string inpath)
        {
            int i = 0, j = 0;
            int h = 0, w = 0;
            int g = 0, r = 0;
            int score = 0;
            string tmp = null;
            StreamReader sr = new StreamReader(inpath);

            string[] split = sr.ReadLine().Trim().Split(' ');

            try
            {
                h = Convert.ToByte(split[0]);
                w = Convert.ToByte(split[1]);
                g = Convert.ToByte(split[2]);
                r = Convert.ToByte(split[3]);
                score = Convert.ToInt32(split[4]);

                Module module = new Module(character, h, w, g, r, score, null);

                for (i = 0; i < h; i++)
                {
                    tmp = sr.ReadLine();
                    for (j = 0; j < w; j++)
                    {
                        module.matrix[j, i] = Convert.ToByte(tmp[j] - '0');
                    }
                }

                return module;
            }
            catch (Exception ex)
            {
                throw new Exception("read_Template_From_Text_To_Memory:" + ex.Message);
            }
        }