Close() public method

public Close ( ) : void
return void
 protected object Deserialize(TextReader reader, Type aType)
 {
     XmlSerializer xmlSerializer = new XmlSerializer(aType);
     object local = xmlSerializer.Deserialize(reader);
     reader.Close();
     return local;
 }
Example #2
0
		public static void GenerateResult (TextReader sr, TextWriter sw, Uri baseUri)
		{
			while (sr.Peek () > 0) {
				string uriString = sr.ReadLine ();
				if (uriString.Length == 0 || uriString [0] == '#')
					continue;
				Uri uri = (baseUri == null) ?
					new Uri (uriString) : new Uri (baseUri, uriString);

				sw.WriteLine ("-------------------------");
				sw.WriteLine (uriString);
				sw.WriteLine (uri.ToString ());
				sw.WriteLine (uri.AbsoluteUri);
				sw.WriteLine (uri.Scheme);
				sw.WriteLine (uri.Host);
				sw.WriteLine (uri.LocalPath);
				sw.WriteLine (uri.Query);
				sw.WriteLine (uri.Port);
				sw.WriteLine (uri.IsFile);
				sw.WriteLine (uri.IsUnc);
				sw.WriteLine (uri.IsLoopback);
				sw.WriteLine (uri.UserEscaped);
				sw.WriteLine (uri.HostNameType);
				sw.WriteLine (uri.AbsolutePath);
				sw.WriteLine (uri.PathAndQuery);
				sw.WriteLine (uri.Authority);
				sw.WriteLine (uri.Fragment);
				sw.WriteLine (uri.UserInfo);
				sw.Flush ();
			}
			sr.Close ();
			sw.Close ();
		}
Example #3
0
        public Terrain(Stage theStage, string label, string terrainDataFile)
            : base(theStage, label)
        {
            constructorInit(); // common constructor initialization code, base call sets "stage"
                               // read vertex data from "terrain.dat" file
            System.IO.TextReader file = System.IO.File.OpenText(terrainDataFile);
            file.ReadLine();   // skip the first description line x y z r g b
            int    i = 0;      // index for vertex[]
            string line;

            string[] token;


            for (int z = 0; z < height; z++)
            {
                for (int x = 0; x < width; x++)
                {
                    line  = file.ReadLine();
                    token = line.Split(' ');
                    terrainHeight[x, z] = int.Parse(token[1]) * multiplier;                                             // Y
                    vertex[i]           = new VertexPositionColor(
                        new Vector3(int.Parse(token[0]) * spacing, terrainHeight[x, z], int.Parse(token[2]) * spacing), // position
                        new Color(int.Parse(token[3]), int.Parse(token[4]), int.Parse(token[5])));                      // material
                    i++;
                }
            }


            file.Close();
            makeIndicesSetData();
        }
Example #4
0
        public void LoadDataFile()
        {
            fileReader = new StreamReader(filename);
            if (System.IO.File.Exists(filename) == false)
            {
                throw new System.InvalidOperationException("Error: " + filename + " could not be found.");
            }

            saveData.Clear();

            string line = "";
            string read = "";
            line = fileReader.ReadLine();
            while (line != null)
            {
                for (int i = 0; i < line.Length; i++)
                {
                    if (line[i] != '=')
                    {
                        read += line[i];
                    }
                    else
                    {
                        string status = line.Substring(i+1, (line.Length - (i+1) ));
                        saveData.Add(read, Convert.ToBoolean(status));

                    }
                }
                read = "";
                line = fileReader.ReadLine();
            }
            fileReader.Close();
        }
Example #5
0
        public List<Token> process(TextReader textReader)
        {
            Debug.Assert(textReader != null);

            m_tokens = new List<Token>();
            m_textReader = textReader;
            m_endOfFile = false;

            readNextChar();
            m_currentLine = 1;
            m_currentPosition = 0;
            m_currentTokenStartPosition = 0;

            Token t;

            do {
                t = readNextToken();
                t.LineNr = m_currentLine;
                t.LinePosition = m_currentTokenStartPosition;
                m_currentTokenStartPosition = m_currentPosition;

                m_tokens.Add(t);

                //Console.WriteLine(t.LineNr + ": " + t.getTokenType().ToString() + " " + t.getTokenString());

            } while(t.getTokenType() != Token.TokenType.EOF);

            m_textReader.Close();
            m_textReader.Dispose();

            return m_tokens;
        }
Example #6
0
        public List<Token> process(TextReader pTextReader)
        {
            D.isNull(pTextReader);

            _tokens = new List<Token>();
            _textReader = pTextReader;
            _endOfFile = false;

            readNextChar();
            _currentLine = 1;
            _currentPosition = 0;
            _currentTokenStartPosition = 0;

            Token t;

            do {
                t = readNextToken();
                t.LineNr = _currentLine;
                t.LinePosition = _currentTokenStartPosition;
                _currentTokenStartPosition = _currentPosition;

                _tokens.Add(t);

            #if WRITE_DEBUG
                Console.WriteLine(t.LineNr + ": " + t.getTokenType().ToString() + " " + t.getTokenString());
            #endif

            } while(t.getTokenType() != Token.TokenType.EOF);

            _textReader.Close();
            _textReader.Dispose();

            return _tokens;
        }
		protected static void MigrateUsingXslt(TextReader xslStream, TextReader xmlStream, string destinationFilePath)
		{
			var transform = new XslCompiledTransform();
			using (xslStream)
			{
				using (xmlStream)
				{
					using (var destinationStream = new StreamWriter(destinationFilePath))
					{
						var xslReader = XmlReader.Create(xslStream);
						transform.Load(xslReader);
						xslReader.Close();
						xslStream.Close();

						var reader = XmlReader.Create(xmlStream);

						var settings = new XmlWriterSettings { Indent = true };
						var writer = XmlWriter.Create(destinationStream, settings);

						transform.Transform(reader, writer);

						var tempfiles = transform.TemporaryFiles;
						if (tempfiles != null) // tempfiles will be null when debugging is not enabled
						{
							tempfiles.Delete();
						}
						writer.Close();
						reader.Close();
						destinationStream.Close();
					}
					xmlStream.Close();
				}
			}
		}
Example #8
0
        static public TextReader NormalizeLineEndings(TextReader tr, bool maintainLineAccuracy)
        {
            string s = tr.ReadToEnd();
            TextReader reader = NormalizeLineEndings(s, maintainLineAccuracy);
            tr.Close();

            return reader;
        }
        static public TextReader NormalizeLineEndings(TextReader tr)
        {
            string s = tr.ReadToEnd();
            TextReader reader = NormalizeLineEndings(s);
            tr.Close();

            return reader;
        }
Example #10
0
        public static TextReader Normalize(TextReader tr, ISerializationContext ctx)
        {
            string s = tr.ReadToEnd();
            TextReader reader = Normalize(s, ctx);
            tr.Close();

            return reader;
        }
Example #11
0
 public Scanner(TextReader Input, string file = "main")
 {
     Result = new List<Token>();
     this.file = file;
     Line = 1;
     Column = 1;
     Scan(Input);
     Input.Close();
 }
Example #12
0
        public AssemblyQualifiedTypeName ParseTypeName(string text, string defaultNamespace, string defaultAssembly)
        {
            text = text.Trim();

            StringBuilder type = new StringBuilder(text.Length);
            string assembly = StringHelper.IsEmpty(defaultAssembly) ? null : defaultAssembly;

            try
            {
                bool seenNamespace = false;

                input = new StringReader(text);

                int code;
                while ((code = input.Peek()) != -1)
                {
                    char ch = (char) code;

                    if (ch == '.')
                    {
                        seenNamespace = true;
                    }

                    if (ch == ',')
                    {
                        input.Read();
                        assembly = AssemblyName();
                        if (input.Peek() != -1)
                        {
                            throw new ParserException("Extra characters found at the end of the type name");
                        }
                    }
                    else if (ch == '[')
                    {
                        type.Append(BracketedPart());
                    }
                    else
                    {
                        type.Append(PossiblyEscapedCharacter());
                    }
                }

                input.Close();

                if (!seenNamespace && StringHelper.IsNotEmpty(defaultNamespace))
                {
                    type.Insert(0, '.')
                        .Insert(0, defaultNamespace);
                }
                return new AssemblyQualifiedTypeName(type.ToString(), assembly);
            }
            catch (Exception e)
            {
                throw new ArgumentException("Invalid fully-qualified type name: " + text, "text", e);
            }
        }
Example #13
0
        /**
         * Closes the input stream.
         */
        public void yyclose()
        {
            zzAtEOF   = true;        /* indicate end of file */
            zzEndRead = zzStartRead; /* invalidate buffer    */

            if (zzReader != null)
            {
                zzReader.Close();
            }
        }
Example #14
0
        /* private void displayData(TextReader reader)
        {
            source.Text = "";
            string line = reader.ReadLine();
            while (line != null)
            {
                source.Text += line + '\n';
                line = reader.ReadLine();
            }
            reader.Close();*/
        private void displayData(TextReader reader)
        {
            source.Text = "";
            for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
            {
                source.Text += line + '\n';
            }

            reader.Close();
        }
Example #15
0
 public void AddingColumns(DataTable table)
 {
     this.reader = new StreamReader(this.folderBrowserDialog.SelectedPath + @"\" + table.TableName + @"\main.txt");
     string column = reader.ReadLine();
     while (column != null)
     {
         table.Columns.Add(column);
         column = reader.ReadLine();
     }
     reader.Close();
 }
 public void Parse(TextReader reader)
 {
     while (true)
     {
         string str = reader.ReadLine();
         if (str == null)
             break;
         ParseLine(str);
     }
     reader.Close();
 }
Example #17
0
 public void AddingData(DataTable table)
 {
     this.reader = new StreamReader(this.folderBrowserDialog.SelectedPath + @"\" + table.TableName + @"\data.txt");
     string data = reader.ReadLine();
     while (data != null)
     {
         table.Rows.Add(data.Split(' '));
         data = reader.ReadLine();
     }
     reader.Close();
 }
Example #18
0
 private void displayData(TextReader reader)
 {
     source.Text = "";
     string line = reader.ReadLine();
     while (line != null)
     {
         source.Text += line + '\n';
         line = reader.ReadLine();
     }
     reader.Close();
 }
Example #19
0
		// Cribbed from mcs/driver.cs:LoadArgs(string)
		static IEnumerable<string> GetArguments(TextReader reader, bool close)
		{
			try
			{
				StringBuilder arg = new StringBuilder();

				string line;
				while ((line = reader.ReadLine()) != null)
				{
					int t = line.Length;

					for (int i = 0; i < t; i++)
					{
						char c = line[i];

						if (c == '"' || c == '\'')
						{
							char end = c;

							for (i++; i < t; i++)
							{
								c = line[i];

								if (c == end)
									break;
								arg.Append(c);
							}
						}
						else if (c == ' ')
						{
							if (arg.Length > 0)
							{
								yield return arg.ToString();
								arg.Length = 0;
							}
						}
						else
							arg.Append(c);
					}
					if (arg.Length > 0)
					{
						yield return arg.ToString();
						arg.Length = 0;
					}
				}
			}
			finally
			{
				if (close)
					reader.Close();
			}
		}
Example #20
0
    // Update is called once per frame
    IEnumerator Refresh()
    {
        while (true)
        {
            //Split command line input to only display message
            buf     = input.ReadLine();
            command = buf.Split(splitter)[buf.Split(splitter).Length - 1];
            //Display received irc message
            Debug.Log(buf);

            //Filter messages
            switch (command)
            {
            case "bomb":
                gameCommand = "bomb";
                break;

            case "up":
                gameCommand = "up";
                break;

            case "down":
                gameCommand = "down";
                break;

            case "left":
                gameCommand = "left";
                break;

            case "right":
                gameCommand = "right";
                break;

            //Close IRC Stream
            case "lolmotherfuckersyousuck":
                input.Close();
                output.Close();
                sock.Close();
                StopCoroutine("Refresh");
                break;
            }
            if (buf.Split(' ')[1] == "001")
            {
                output.Write(
                    "MODE " + nick + " +B\r\n" +
                    "JOIN " + chan + "\r\n"
                    );
                output.Flush();
            }
            yield return(new WaitForSeconds(0.1f));
        }
    }
Example #21
0
        /// <summary>
        /// Obtiene el texto de un TextReader
        /// </summary>
        /// <param name="reader">TextReader</param>
        /// <returns></returns>
        public static string GetTextFromReader(TextReader reader)
        {
            StringBuilder list = new StringBuilder();

            string line;
            while ((line = reader.ReadLine()) != null)
            {
                list.Append(line);
                
            }
            reader.Close();
            return list.ToString();
        }
Example #22
0
 internal UserEditable Deserialize(TextReader reader)
 {
     try
     {
         UserEditable o = (UserEditable)s.Deserialize(reader);
         reader.Close();
         return o;
     }
     catch (InvalidCastException)    // changed setting from long to int
     {
         return new UserEditable();
     }
 }
Example #23
0
 public SubsetParser(string prefix, TextReader tr)
 {
     string line;
     while ((line = tr.ReadLine()) != null)
     {
         if (line.StartsWith(prefix))
         {
             string[] l = line.Substring(prefix.Length).Split(',');
             defs.Add(l);
         }
     }
     tr.Close();
 }
Example #24
0
        public static string GetProperty(string propertyName)
        {
            string output = "PropertyNotFound (" + propertyName + ")";

            if (!loadedProperties.Contains(propertyName))
            {
                try
                {
                    textReader = new StreamReader(currentDirectory + "\\properties.txt");
                    fileContent = textReader.ReadToEnd().Split('\n');
                    textReader.Close();
                }
                catch
                {
                    textWriter = new StreamWriter(currentDirectory + "\\properties.txt");
                    textWriter.WriteLine("Directory=2DCraft");
                    textWriter.Close();

                    textReader = new StreamReader(currentDirectory + "\\properties.txt");
                    fileContent = textReader.ReadToEnd().Split('\n');
                    textReader.Close();
                }

                foreach (string line in fileContent)
                {
                    if (line.ToLower().StartsWith(propertyName.ToLower()))
                    {
                        output = line.Remove(0, propertyName.Length);
                        output = output.Replace("\r", "");
                        output = output.Replace(" ", "");
                        loadedProperties.Add(propertyName);

                        break;
                    }
                }
            }
            else
            {
                foreach (string _propertyName in loadedProperties)
                {
                    if (propertyName.ToLower() == _propertyName.ToLower())
                    {
                        output = _propertyName;
                        break;
                    }
                }
            }

            return output;
        }
Example #25
0
        private void butOpenFile_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            if (cdbOpen.ShowDialog() == DialogResult.OK)
            {
                this.txtFile.Clear();

                System.IO.TextReader tr = File.OpenText(cdbOpen.FileName);

                this.txtFile.Text = tr.ReadToEnd();

                tr.Close();
                tr = null;
            }
        }
Example #26
0
 public static void Close(TextReader reader)
 {
     if (reader != null)
     {
         try
         {
             reader.Close();
         }
         catch (IOException e)
         {
             ClosingFailed(e);
         }
     }
 }
Example #27
0
 public Kontroler()
 {
     czyt = new StreamReader("porty.txt");  
     String tekst;   
     tekst = czyt.ReadLine();
     Debug.WriteLine("pierwszy port : " + tekst);
     _receiver = new STMReceiver(tekst);
     tekst = czyt.ReadLine();
     Debug.WriteLine("drugi port : " + tekst);
     _receiver2 = new STMReceiver(tekst);
     czyt.Close();
     _receiver.StartListening();
     _receiver2.StartListening();
 }
Example #28
0
        public static Template parse(TextReader br)
        {
            var t = new Template();

            string temp = null;

            var lists = new List<string>();
            while ((temp = br.ReadLine()) != null)
            {
                if (string.IsNullOrWhiteSpace(temp) || temp.StartsWith("#"))
                {
                    continue;
                }
                lists.Add(temp);
            }
            br.Close();

            t.ft = new int[lists.Count - 1][];
            for (var i = 0; i < lists.Count - 1; i++)
            {
                temp = lists[i];
                var split = temp.Split(':');

                var index = int.Parse(split[0].Substring(1));

                split = split[1].Split(' ');
                var ints = new int[split.Length];

                for (var j = 0; j < ints.Length; j++)
                {
                    ints[j] = int.Parse(split[j].Substring(split[j].IndexOf('[') + 1, split[j].IndexOf(',')));
                }
                t.ft[index] = ints;
            }
            t.left = 0;
            t.right = 0;
            // find max and min
            foreach (var ints in t.ft)
            {
                foreach (var j in ints)
                {
                    t.left = t.left > j ? j : t.left;
                    t.right = t.right < j ? j : t.right;
                }
            }
            t.left = t.left;

            return t;
        }
        public ServerIcons Deserialize(TextReader reader)
        {
            try
            {
                var serverIcons = (ServerIcons)serializer.Deserialize(reader);
                reader.Close();
                return serverIcons;
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex, "Exception in Deserialize()");
            }

            return null;
        }
Example #30
0
        public static string[] CriaVetor()
        {
            reader = File.OpenText(xml);
            ds = new DataSet();
            ds.ReadXml(reader);
            data = ds.Tables[0];
            reader.Close();

            string[] vetor = new string[data.Rows.Count];

            for (int i = 0; i < data.Rows.Count; i++)
                vetor[i] = data.Rows[(data.Rows.Count - 1) - i].ItemArray[0].ToString();

            return vetor;
        }
        public AWSEnvironments Deserialize(TextReader reader)
        {
            try
            {
                var awsEnvironments = (AWSEnvironments)serializer.Deserialize(reader);
                reader.Close();
                return awsEnvironments;
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex, "Exception in Deserialize()");
            }

            return null;
        }
Example #32
0
 public Operations(TextReader source)
 {
     try
     {
         Parse(ref source);
     }
     catch (Exception ex)
     {
         var e = ex;
     }
     finally
     {
         if (source != null)
             source.Close();
     }
 }
Example #33
0
        private static List <Data.current_observation> Read()
        {
            string folder = MainWindow.folderPath;
            List <Data.current_observation> observations = new List <Data.current_observation>();

            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Data.current_observation));
            string[] vs = System.IO.Directory.GetFiles(folder);
            for (int i = 0; i < vs.Length; i++)
            {
                System.IO.TextReader     reader      = System.IO.File.OpenText(vs[i]);
                Data.current_observation observation = (Data.current_observation)serializer.Deserialize(reader);
                observations.Add(observation);
                reader.Close();
            }
            return(observations);
        }
Example #34
0
        static void readPEO()
        {
            tr = new StreamReader(inputPEO);
            peo = new Vertex[short.Parse(tr.ReadLine())];
            peoPointer = new short[peo.Length];

            //peoPointer[i] = PEO of i'th vertex
            short vertexNumber;
            for (short i = 0; i < peo.Length; i++)
            {
                vertexNumber = Int16.Parse(tr.ReadLine().Split('\t')[0]);
                peoPointer[vertexNumber] = i;
                peo[i] = new Vertex(vertexNumber);
            }
            tr.Close();
        }
Example #35
0
        public static void Load(TextReader reader)
        {
            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Settings));
                Settings loaded = (Settings)serializer.Deserialize(reader);
                reader.Close();

                if (loaded.Cache     != null) CacheSettings.Default = loaded.Cache;
                if (loaded.General   != null) GeneralSettings.Default = loaded.General;
                if (loaded.Network   != null) NetworkSettings.Default = loaded.Network;
                if (loaded.Optimizer != null) OptimizerSettings.Default = loaded.Optimizer;
                if (loaded.Recent    != null) RecentSettings.Default = loaded.Recent;
            }
            catch { }
        }
Example #36
0
/*************************************************************************************************************************/
        public void EndReplay()
        {
            Log.PushStackInfo("FMRS_THL.EndReply", "FMRS_THL_Rep: entering end_replay()");

            if (!replay)
            {
                return;
            }

            Log.dbg("FMRS_THL_Rep: End Replay");

            try { reader.Close(); }
            catch (Exception) {}

            replay        = false;
            debug_message = "replay ended";

            Log.PopStackInfo("FMRS_THL_Rep: leave end_replay()");
        }
Example #37
0
        /// <summary>
        /// 从文件流中读取
        /// </summary>
        /// <param name="reader">已经打开的流对象</param>
        public Graph(System.IO.TextReader reader)
        {
            //标准的图
            string V = reader.ReadLine();//点数

            adj = new Bag <Tuple <int, double> > [int.Parse(V)];
            for (int i = 0; i < adj.Length; ++i)
            {
                adj[i] = new Bag <Tuple <int, double> >();
            }
            string E  = reader.ReadLine();//边数
            int    ie = int.Parse(E);

            this.V = adj.Length;
            this.E = ie;
            for (int i = 0; i < ie; ++i)
            {
                AddEdge(reader.ReadLine());
            }
            reader.Close();
        }
Example #38
0
        /// <summary>
        /// A constructor to setup all the applicable fields.
        /// </summary>
        /// <param name="IO"></param>
        /// <param name="WorldLoader"></param>
        /// <param name="Algorithm"></param>
        /// <param name="Weight"></param>
        public AlgorithmRunner(System.IO.TextReader IO,
                               GridWorldLoader <GenericGridWorldStaticState,
                                                GenericGridWorldDynamicState> WorldLoader, String Algorithm,
                               Metric Weight, bool Batch, StateVisualizer <GenericGridWorldStaticState,
                                                                           GenericGridWorldDynamicState> vis, int Seed)
        {
            gen            = new Random(Seed);
            this.vis       = vis;
            this.Goal      = new DestinationsReachedGoal( );
            this.Algorithm = new GenericAlgorithmFactory <GenericGridWorldStaticState,
                                                          GenericGridWorldDynamicState>( ).SetRealTimeData(
                new SingleUnitOctileDistanceHeuristic( ), vis,
                new SingleUnitTransformer( ), Weight, 0.1).GetAlgorithm(
                Algorithm, null, 0);

            GenericGridWorldDynamicState InitialDynamicState;

            WorldLoader.Load(IO, out StaticState, out InitialDynamicState);
            IO.Close( );
            this.Actions = GridWorldOperator.Ops;
        }
Example #39
0
        // NB: This will currently return hvos
        private int[] GetWordformsInFile(string path)
        {
            // This is technically a Set, but we don't need to speed of the Set,
            // so the List is good enough.
            List <int> hvos = new List <int>();
            // Note: The GetUniqueWords uses the key for faster processing,
            // even though we don;t use it here.
            Dictionary <string, IWfiWordform> wordforms = new Dictionary <string, IWfiWordform>();

            System.IO.TextReader reader = null;
            try
            {
                reader = File.OpenText(path);
// do timing tests; try doing readtoend() to one string and then parsing that; see if more efficient
                // While there is a line to be read in the file
                // REVIEW: can this be broken by a very long line?
                // RR answer: Yes it can.
                // According to the ReadLine docs an ArgumentOutOfRangeException
                // exception will be thrown if the line length exceeds the MaxValue constant property of an Int32,
                // which is 2,147,483,647. I doubt you will run into this exception any time soon. :-)
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    GetUniqueWords(wordforms, line);
                }
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                    reader = null;
                }
            }
            foreach (IWfiWordform wf in wordforms.Values)
            {
                hvos.Add(wf.Hvo);
            }
            return(hvos.ToArray());
        }
Example #40
0
        // Процедура получения свойств объекта
        public void GetObjectProperties()
        {
            // Путь к базовому файлу
            string baseFile;
            // Путь к файлу списка протофайлов
            string listFile;
            // Пусть к файлам прототипа
            string pathToProto;
            // Путь к файлу списка графики
            string artListFile;
            // Путь к файлам графики
            string pathToArt;
            // Временная строка №1
            string tempString = " ";
            // Временная строка №2
            string tempString1 = " ";

            // Определение путей для объекта
            baseFile    = GamePath + @"\MASTER.DAT\text\english\game\pro_tile.msg";
            listFile    = GamePath + @"\MASTER.DAT\proto\tiles\tiles.lst";
            pathToProto = GamePath + @"\MASTER.DAT\proto\tiles\";
            pathToArt   = @".\MASTER.DAT\art\tiles\";
            artListFile = GamePath + @"\MASTER.DAT\art\tiles\tiles.lst";

            // Получение файла прототипа объекта
            System.IO.TextReader fListFile = System.IO.File.OpenText(listFile);
            for (int i = 1; i <= ObjectId; i++)
            {
                tempString = fListFile.ReadLine();
            }
            fListFile.Close();

            // Путь к файлу прототипа объекта
            ObjectProto = pathToProto + tempString;

            //Загоняем весь прото-файл в байтовый массив

            FileStream fProtoFile = new FileStream(ObjectProto, FileMode.Open);

            byte[] buffer = new byte[Convert.ToInt32(fProtoFile.Length)];
            fProtoFile.Read(buffer, 0, Convert.ToInt16(fProtoFile.Length));
            fProtoFile.Close();

            System.IO.TextReader fArtListFile = System.IO.File.OpenText(artListFile);
            for (int i = 0; i <= (buffer[10] * 256 + buffer[11]); i++)
            {
                tempString = fArtListFile.ReadLine();
            }
            fListFile.Close();
            // Путь к файлу с графикой объекта
            ObjectFrame = tempString.Replace(".FRM", "");

            // Открытие базового файла объектов
            System.IO.TextReader fBaseFile = System.IO.File.OpenText(baseFile);
            if (!(fBaseFile.Peek() == -1))
            {
                do
                {
                    tempString = fBaseFile.ReadLine();
                }while (!(tempString.Substring(1, ObjectId.ToString().Length + 2) == (ObjectId * 100).ToString()) && !((fBaseFile.Peek() == -1)));
                if (!(tempString.Substring(1, ObjectId.ToString().Length) == ObjectId.ToString()))
                {
                    tempString = "      ";
                }
            }
            else
            {
                tempString = "     ";
            }
            if ((tempString.Substring(1, ObjectId.ToString().Length) == ObjectId.ToString()) && !(tempString == " "))
            {
                char[] aStrSplit = { '{', '}' };
                // Получение наименования объекта
                ObjectName = tempString.Split(aStrSplit)[5];
                if (!(fBaseFile.Peek() == -1))
                {
                    tempString1 = fBaseFile.ReadLine();
                    if (tempString1.Substring(1, tempString.Split(aStrSplit)[1].Length) == (ObjectId.ToString() + "01"))
                    {
                        // Получение описания объекта
                        ObjectDesc = tempString1.Split(aStrSplit)[5];
                    }
                    else
                    {
                        ObjectDesc = " ";
                    }
                    fBaseFile.Close();
                }
                else
                {
                    ObjectDesc = " ";
                }
            }
            else
            {
                ObjectDesc = " ";
                ObjectName = " ";
            }
            FrameIdType    = buffer[8];
            FrameIdOffset  = buffer[9];
            FrameId        = buffer[10] * 256 + buffer[11];
            LightDistance  = (buffer[12] << 24) + (buffer[13] << 16) + (buffer[14] << 8) + buffer[15];
            LightIntensity = (buffer[16] << 24) + (buffer[17] << 16) + (buffer[18] << 8) + buffer[19];
        }
Example #41
0
 public override void Close() => _in.Close();
Example #42
0
    void StartImp()
    {
        if (ImpType == ImpTypeEnum.ILamp)
        {
            ImpPlugin.Imp_Create_ILamp();
            ImpPlugin.Imp_ILamp_Setup(ILampParams.KdTreeCount, ILampParams.NumNeighbours, ILampParams.KnnSearchChecks);
        }
        else
        {
            ImpPlugin.Imp_Create_Rbp();
            ImpPlugin.Imp_Rbf_Setup((ushort)(RbfParams.Function), RbfParams.Constant);
        }


        System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
        customCulture.NumberFormat.NumberDecimalSeparator    = ".";
        System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;


        if (!ImpPlugin.Imp_ExecutePcaImages(FileNameImageList, FileNameNd))
        {
            Debug.LogError("Could not execute pca for images: " + FileNameImageList);
            enabled = false;
            return;
        }

        if (!ImpPlugin.Imp_ExecuteLamp(FileNameNd, FileName2d))
        {
            Debug.LogError("Could not run lamp for " + FileNameNd + ' ' + FileName2d);
            enabled = false;
            return;
        }


        if (!ImpPlugin.Imp_LoadInputFiles(FileName2d, FileNameNd))
        {
            Debug.LogError("Could not load input files: " + FileName2d + ' ' + FileNameNd);
            enabled = false;
            return;
        }

        if (!ImpPlugin.Imp_Build())
        {
            Debug.LogError("Could not build imp");
            enabled = false;
            return;
        }


        using (System.IO.TextReader reader = System.IO.File.OpenText(FileName2d))
        {
            string line;
            while ((line = reader.ReadLine()) != null)
            {
                string[] v_str = line.Split();

                float x, y = 0;
                if (float.TryParse(v_str[0], out x) && float.TryParse(v_str[1], out y))
                {
                    vertices2d.Add(new Vector2(x, y));
                }
            }

            reader.Close();
        }



        if (ImpPlugin.Imp_Execute(vertices2d[0].x, vertices2d[0].y))
        {
            if (q_data == null) // q_data.Count must be (3 * vertices.Length)
            {
                q_data   = new float[ImpPlugin.Imp_QRows() * ImpPlugin.Imp_QCols()];
                q_handle = GCHandle.Alloc(q_data, GCHandleType.Pinned);
            }
        }
        else
        {
            Debug.LogError("Could not run imp");
            enabled = false;
            return;
        }


        impUI = (ImpUI)FindObjectOfType(typeof(ImpUI));
        if (impUI)
        {
            impUI.Setup(vertices2d, MinCoords, MaxCoords);
        }
    }
Example #43
0
        public void GetObjectProperties()
        {
            // Путь к базовому файлу
            // Путь к файлу списка протофайлов
            // Пусть к файлам прототипа
            // Путь к файлу списка графики
            // Путь к файлам графики
            // Временная строка №1
            string TempString = " ";
            // Временная строка №2
            string TempString1 = " ";

            string baseFile    = GamePath + @"\MASTER.DAT\text\english\game\pro_item.msg";
            string listFile    = GamePath + @"\MASTER.DAT\proto\items\items.lst";
            string pathToProto = GamePath + @"\MASTER.DAT\proto\items\";
            string pathToArt   = string.Format(@"{0}\MASTER.DAT\art\items\", GamePath);
            string artListFile = GamePath + @"\MASTER.DAT\art\items\items.lst";

            // Получение файла прототипа объекта
            System.IO.TextReader fListFile = System.IO.File.OpenText(listFile);
            for (int i = 1; i <= ObjectId; i++)
            {
                TempString = fListFile.ReadLine();
            }
            fListFile.Close();

            // Путь к файлу прототипа объекта
            ObjectProto = pathToProto + TempString;

            //Загоняем весь прото-файл в байтовый массив

            FileStream fProtoFile = new FileStream(ObjectProto, FileMode.Open);

            _buffer = new byte[Convert.ToInt32(fProtoFile.Length)];
            fProtoFile.Read(_buffer, 0, Convert.ToInt16(fProtoFile.Length));
            fProtoFile.Close();

            System.IO.TextReader fArtListFile = System.IO.File.OpenText(artListFile);
            for (int i = 0; i <= (_buffer[10] * 256 + _buffer[11]); i++)
            {
                TempString = fArtListFile.ReadLine();
            }
            fListFile.Close();
            // Путь к файлу с графикой объекта
            ObjectFrame = TempString.Replace(".FRM", "");

            // Открытие базового файла объектов
            System.IO.TextReader fBaseFile = System.IO.File.OpenText(baseFile);
            if (!(fBaseFile.Peek() == -1))
            {
                do
                {
                    TempString = fBaseFile.ReadLine();
                }while (!(TempString.Substring(1, ObjectId.ToString().Length + 2) == (ObjectId * 100).ToString()) && !((fBaseFile.Peek() == -1)));
                if (!(TempString.Substring(1, ObjectId.ToString().Length) == ObjectId.ToString()))
                {
                    TempString = "      ";
                }
            }
            else
            {
                TempString = "     ";
            }
            if ((TempString.Substring(1, ObjectId.ToString().Length) == ObjectId.ToString()) && !(TempString == " "))
            {
                char[] aStrSplit = { '{', '}' };
                // Получение наименования объекта
                ObjectName = TempString.Split(aStrSplit)[5];
                if (!(fBaseFile.Peek() == -1))
                {
                    TempString1 = fBaseFile.ReadLine();
                    if (TempString1.Substring(1, TempString.Split(aStrSplit)[1].Length) == (ObjectId.ToString() + "01"))
                    {
                        // Получение описания объекта
                        ObjectDesc = TempString1.Split(aStrSplit)[5];
                    }
                    else
                    {
                        ObjectDesc = " ";
                    }
                    fBaseFile.Close();
                }
                else
                {
                    ObjectDesc = " ";
                }
            }
            else
            {
                ObjectDesc = " ";
                ObjectName = " ";
            }
            FrameIdType    = _buffer[8];
            FrameIdOffset  = _buffer[9];
            FrameId        = _buffer[10] * 256 + _buffer[11];
            LightDistance  = (_buffer[12] << 24) + (_buffer[13] << 16) + (_buffer[14] << 8) + _buffer[15];
            LightIntensity = (_buffer[16] << 24) + (_buffer[17] << 16) + (_buffer[18] << 8) + _buffer[19];
            AttackMode1    = (_buffer[27] & 15);
            AttackMode2    = (_buffer[27] & 240) >> 4;
            int offset = 0x1C;

            ScriptId     = (_buffer[offset] << 24) + (_buffer[offset + 1] << 16) + (_buffer[offset + 2] << 8) + _buffer[offset + 3];
            offset       = 0x20;
            ItemSubtype  = (ItemSubtype)(_buffer[offset] << 24) + (_buffer[offset + 1] << 16) + (_buffer[offset + 2] << 8) + _buffer[offset + 3];
            offset       = 0x24;
            MaterialType = (_buffer[offset] << 24) + (_buffer[offset + 1] << 16) + (_buffer[offset + 2] << 8) + _buffer[offset + 3];
            offset       = 0x28;
            Volume       = (_buffer[offset] << 24) + (_buffer[offset + 1] << 16) + (_buffer[offset + 2] << 8) + _buffer[offset + 3];
            offset       = 0x2C;
            Weight       = (_buffer[offset] << 24) + (_buffer[offset + 1] << 16) + (_buffer[offset + 2] << 8) + _buffer[offset + 3];
            offset       = 0x30;
            BasePrice    = (_buffer[offset] << 24) + (_buffer[offset + 1] << 16) + (_buffer[offset + 2] << 8) + _buffer[offset + 3];
            offset       = 0x34;
            InvenId      = _buffer[offset];
            offset       = 0x36;
            InvenFrame   = (_buffer[offset] << 8) + _buffer[offset + 1];
            offset       = 0x38;
            SoundId      = (_buffer[offset] << 24) + (_buffer[offset + 1] << 16) + (_buffer[offset + 2] << 8) + _buffer[offset + 3];
        }
Example #44
0
 public override void Close()
 {
     lock (this){
         reader.Close();
     }
 }
Example #45
0
        // Процедура получения свойств объекта
        public void GetObjectProperties()
        {
            // Путь к базовому файлу
            string baseFile;
            // Путь к файлу списка протофайлов
            string listFile;
            // Пусть к файлам прототипа
            string pathToProto;
            // Путь к файлу списка графики
            string artListFile;
            // Путь к файлам графики
            string pathToArt;
            // Временная строка №1
            string tempString = " ";
            // Временная строка №2
            string tempString1 = " ";

            // Определение путей для объекта
            baseFile    = GamePath + @"\MASTER.DAT\text\english\game\pro_crit.msg";
            listFile    = GamePath + @"\MASTER.DAT\proto\critters\critters.lst";
            pathToProto = GamePath + @"\MASTER.DAT\proto\critters\";
            pathToArt   = @".\CRITTER.DAT\art\critters\";
            artListFile = GamePath + @"\CRITTER.DAT\art\critters\critters.lst";

            // Получение файла прототипа объекта
            System.IO.TextReader fListFile = System.IO.File.OpenText(listFile);
            for (int i = 1; i <= ObjectId; i++)
            {
                tempString = fListFile.ReadLine();
            }
            fListFile.Close();

            // Путь к файлу прототипа объекта
            ObjectProto = pathToProto + tempString;

            //Загоняем весь прото-файл в байтовый массив

            FileStream fProtoFile = new FileStream(ObjectProto, FileMode.Open);

            byte[] buffer = new byte[Convert.ToInt32(fProtoFile.Length)];
            fProtoFile.Read(buffer, 0, Convert.ToInt16(fProtoFile.Length));
            fProtoFile.Close();

            System.IO.TextReader fArtListFile = System.IO.File.OpenText(artListFile);
            for (int i = 0; i <= (buffer[10] * 256 + buffer[11]); i++)
            {
                tempString = fArtListFile.ReadLine();
            }
            fListFile.Close();
            // Путь к файлу с графикой объекта
            ObjectFrame = tempString.Replace(".FRM", "");

            // Открытие базового файла объектов
            System.IO.TextReader fBaseFile = System.IO.File.OpenText(baseFile);
            if (!(fBaseFile.Peek() == -1))
            {
                do
                {
                    tempString = fBaseFile.ReadLine();
                }while (!(tempString.Substring(1, ObjectId.ToString().Length + 2) == (ObjectId * 100).ToString()) && !((fBaseFile.Peek() == -1)));
                if (!(tempString.Substring(1, ObjectId.ToString().Length) == ObjectId.ToString()))
                {
                    tempString = "      ";
                }
            }
            else
            {
                tempString = "     ";
            }
            if ((tempString.Substring(1, ObjectId.ToString().Length) == ObjectId.ToString()) && !(tempString == " "))
            {
                char[] aStrSplit = { '{', '}' };
                // Получение наименования объекта
                ObjectName = tempString.Split(aStrSplit)[5];
                if (!(fBaseFile.Peek() == -1))
                {
                    tempString1 = fBaseFile.ReadLine();
                    if (tempString1.Substring(1, tempString.Split(aStrSplit)[1].Length) == (ObjectId.ToString() + "01"))
                    {
                        // Получение описания объекта
                        ObjectDesc = tempString1.Split(aStrSplit)[5];
                    }
                    else
                    {
                        ObjectDesc = " ";
                    }
                    fBaseFile.Close();
                }
                else
                {
                    ObjectDesc = " ";
                }
            }
            else
            {
                ObjectDesc = " ";
                ObjectName = " ";
            }
            FrameIdType   = buffer[8];
            FrameIdOffset = buffer[9];
            FrameId       = buffer[10] * 256 + buffer[11];
            int offset = 0xc;

            LightDistance    = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset           = 0x10;
            LightIntensity   = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset           = 0x1C;
            ScriptId         = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset           = 0x20;
            TalkingHeadFrame = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset           = 0x24;
            AIPaket_num      = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset           = 0x28;
            TeamNumber       = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            // Базовые основные параметры
            offset          = 0x30;
            Strength        = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x34;
            Perception      = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x38;
            Endurance       = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x3C;
            Charisma        = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x40;
            Intelligence    = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x44;
            Agility         = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x48;
            Luck            = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x4C;
            HP              = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x50;
            AP              = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x54;
            AC              = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x58;
            UnarmedDamage   = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x5C;
            MeleeDamage     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x60;
            CarryWeight     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x64;
            Sequence        = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x68;
            HealingRate     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x6C;
            CriticalChance  = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset          = 0x70;
            BetterCriticals = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            // Базовые сопротивления и трешхолды(Tresholds)
            offset        = 0x74;
            DT_Normal     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset        = 0x78;
            DT_Laser      = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset        = 0x7C;
            DT_Fire       = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset        = 0x80;
            DT_Plasma     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset        = 0x84;
            DT_Electrical = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset        = 0x88;
            DT_EMP        = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset        = 0x8C;
            DT_Explode    = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset        = 0x90;
            DR_Normal     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset        = 0x94;
            DR_Laser      = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset        = 0x98;
            DR_Fire       = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset        = 0x9C;
            DR_Plasma     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset        = 0xA0;
            DR_Electrical = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset        = 0xA4;
            DR_EMP        = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset        = 0xA8;
            DR_Explode    = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset        = 0xAC;
            DR_Radiation  = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset        = 0xB0;
            DR_Poison     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            //Базовое разное
            offset  = 0xB4;
            BaseAge = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset  = 0xB8;
            BaseSex = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            //Дополнительные основные параметры
            offset               = 0xBC;
            ExtraStrenght        = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xC0;
            ExtraPerception      = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xC4;
            ExtraEndurance       = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xC8;
            ExtraCharisma        = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xCC;
            ExtraIntelligence    = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xD0;
            ExtraAgility         = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xD4;
            ExtraLuck            = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xD8;
            ExtraHP              = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xDC;
            ExtraAP              = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xE0;
            ExtraAC              = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xE4;
            ExtraUnarmedDamage   = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xE8;
            ExtraMeleeDamage     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xEC;
            ExtraCarryWeight     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xF0;
            ExtraSequence        = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xF4;
            ExtraHealingRate     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xF8;
            ExtraCriticalChance  = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset               = 0xFC;
            ExtraBetterCriticals = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            //Дополнительные сопротивления и трешхолды(Tresholds)
            offset             = 0x100;
            ExtraDT_Normal     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset             = 0x104;
            ExtraDT_Laser      = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset             = 0x108;
            ExtraDT_Fire       = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset             = 0x10C;
            ExtraDT_Plasma     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset             = 0x110;
            ExtraDT_Electrical = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset             = 0x114;
            ExtraDT_EMP        = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset             = 0x118;
            ExtraDT_Explode    = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset             = 0x11C;
            ExtraDR_Normal     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset             = 0x120;
            ExtraDR_Laser      = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset             = 0x124;
            ExtraDR_Fire       = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset             = 0x128;
            ExtraDR_Plasma     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset             = 0x12C;
            ExtraDR_Electrical = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset             = 0x130;
            ExtraDR_EMP        = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset             = 0x134;
            ExtraDR_Explode    = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset             = 0x138;
            ExtraDR_Radiation  = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset             = 0x13C;
            ExtraDR_Poison     = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            // Дополнительное разное
            offset   = 0x140;
            ExtraAge = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset   = 0x144;
            ExtraSex = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            // Навыки
            offset                = 0x148;
            Skill_SmallGuns       = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x14C;
            Skill_BigGuns         = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x150;
            Skill_EnergyWeapons   = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x154;
            Skill_Unarmed         = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x158;
            Skill_Melee           = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x15C;
            Skill_Throwing        = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x160;
            Skill_FirstAid        = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x164;
            Skill_Doctor          = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x168;
            Skill_Sneak           = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x16C;
            Skill_Lockpick        = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x170;
            Skill_Steal           = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x174;
            Skill_Traps           = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x178;
            Skill_Science         = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x17C;
            Skill_Repair          = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x180;
            Skill_Speech          = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x184;
            Skill_Barter          = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x188;
            Skill_Gambling        = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset                = 0x18C;
            Skill_Outdoorsmanship = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            // Остальное
            offset     = 0x190;
            BodyType   = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset     = 0x194;
            XPForKill  = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset     = 0x198;
            KillType   = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
            offset     = 0x19C;
            DamageType = (buffer[offset] << 24) + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3];
        }
Example #46
0
 public void Close()
 {
     rdr.Close();
 }
Example #47
0
 public override void Close()
 {
     _in.Close();
 }
Example #48
0
    void Start()
    {
        if (templateMesh == null)
        {
            Debug.LogError("Template Mesh is null. Did you forget to fill inspector fields?");
            enabled = false;
            return;
        }

        //
        // Check if the number of meshes and vertices matches
        //
        foreach (var m in baseMeshes)
        {
            if (m == null)
            {
                Debug.LogError("Mesh is null. Did you forget to fill inspector fields?");
                enabled = false;
                return;
            }
        }
        foreach (var ml in laplaceMeshes)
        {
            if (baseMeshes.Length != ml.MeshList.Length)
            {
                Debug.LogError("The number of meshes does not match: " + baseMeshes.Length + " != " + ml.MeshList.Length);
                enabled = false;
                return;
            }

            if (ml.MeshList[0] == null)
            {
                Debug.LogError("Mesh is null. Did you forget to fill inspector fields?");
                enabled = false;
                return;
            }

            var vertCount = ml.MeshList[0].mesh.vertexCount;
            for (int i = 1; i < ml.MeshList.Length; ++i)
            {
                if (ml.MeshList[i] == null)
                {
                    Debug.LogError("Mesh null. Did you forget to fill inspector fields?");
                    enabled = false;
                    return;
                }

                if (vertCount != ml.MeshList[i].mesh.vertexCount)
                {
                    Debug.LogError("The number of vertices does not match: " + ml.MeshList[i].name);
                    enabled = false;
                    return;
                }
            }
        }

        //Debug.Log("Building ILamp for base meshes: " + FileNameNd);
        if (!BuildILamp(baseMeshes, FileName2d, FileNameNd))
        {
            enabled = false;
            return;
        }

        foreach (var ml in laplaceMeshes)
        {
            //Debug.Log("Building ILamp for laplace meshes: " + ml.FileName);
            if (!BuildILamp(ml.MeshList, FileName2d, ml.FileName))
            {
                enabled = false;
                return;
            }
        }
        ImpPlugin.Imp_SetCurrent(0);


        using (System.IO.TextReader reader = System.IO.File.OpenText(FileName2d))
        {
            string line;
            while ((line = reader.ReadLine()) != null)
            {
                string[] v_str = line.Split();

                float x, y = 0;
                if (float.TryParse(v_str[0], out x) && float.TryParse(v_str[1], out y))
                {
                    vertices2d.Add(new Vector2(x, y));
                }
            }

            reader.Close();
        }


        if (ImpPlugin.Imp_Execute(vertices2d[0].x, vertices2d[0].y))
        {
            if (q_data == null) // q_data.Count must be (3 * vertices.Length)
            {
                //q_data = new float[ImpPlugin.Imp_QRows() * ImpPlugin.Imp_QCols()];
                q_data   = new Vector3[templateMesh.mesh.vertexCount];
                q_handle = GCHandle.Alloc(q_data, GCHandleType.Pinned);
            }

            if (q_data_laplace == null)
            {
                q_data_laplace   = new Vector3[templateMesh.mesh.vertexCount];
                q_handle_laplace = GCHandle.Alloc(q_data_laplace, GCHandleType.Pinned);
            }
        }
        else
        {
            Debug.LogError("Could not run imp");
            enabled = false;
            return;
        }


        impUI = (ImpUI)FindObjectOfType(typeof(ImpUI));
        if (impUI)
        {
            impUI.Setup(vertices2d, MinCoords, MaxCoords);
        }
    }
 public override void Close()
 {
     // So that any overriden Close() gets run
     _in.Close();
 }
Example #50
0
 /// <summary>
 /// 关闭文件句柄
 /// </summary>
 public void CloseFile()
 {
     _reader.Close();
 }