示例#1
0
    void PLAYSPELL(SOURCES source, AudioClip clip, float volume = 1.0f, bool loop = false)
    {
        AudioSource audioSource = audioSources[(int)source];

        audioSource.loop = loop;
        audioSource.PlayOneShot(clip, volume);
    }
示例#2
0
    void stopSource(SOURCES source)
    {
        AudioSource audioSource = audioSources[(int)source];

        if (audioSource.isPlaying)
        {
            audioSource.Stop();
        }
    }
示例#3
0
        //Load .SOURCES data from file
        public virtual void Load(string SOURCESFileName)
        {
            StreamReader SOURCESFile = File.OpenText(SOURCESFileName);
            var          warnings    = new List <string>();

            int    index           = SOURCESFileName.LastIndexOf("\\", StringComparison.Ordinal);
            string SOURCESFilePath = SOURCESFileName.Remove(index);

            //Number of sources groups in .SOURCES file:
            string nGroups        = SOURCESFile.ReadLine();
            int    numberOfGroups = Convert.ToInt32(nGroups);

            AddVariable("NUMBER_OF_SOURCES", numberOfGroups);

            //Reset data structs to store .LRAIN data in local memory:
            var mainTable = new List <string[]>();

            SOURCESFileContents.Clear();

            //
            //(Code space for individual variables)
            //

            for (int i = 0; i < numberOfGroups; ++i)
            { //Read all rest of data from .SOURCES file....
                try
                { string secondaryTableFileName;
                  //
                  //
                  //
                  //
                  //
                  //  Empty lines left intentionally
                  //Source name:
                  string sourceName = SOURCESFile.ReadLine().Trim();
                  //Source type:
                  string sourceType = SOURCESFile.ReadLine().Trim();
                  if (!int.TryParse(sourceType, out int intType))
                  {
                      // Expecting an integer. Maybe it is version previous to 2018.
                      secondaryTableFileName = sourceType;
                      sourceType             = "1";
                  }
                  else
                  {
                      //Secondary table file name:
                      secondaryTableFileName = SOURCESFile.ReadLine().Trim();
                  }

                  //X Y:
                  string   xy    = SOURCESFile.ReadLine().Trim();
                  string[] split = xy.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                  string   X     = split[0];
                  string   Y     = split[1];

                  //Create this group from data just read:
                  var group = new SOURCES();
                  group.SourceName        = sourceName;
                  group.SourceType        = sourceType;
                  group.SecondaryFileName = secondaryTableFileName;
                  group.XY = xy;

                  //Store data of this zone:
                  SOURCESFileContents.Add(group);

                  //Store in mainTable a row to be shown in zones table in DIP tab:
                  //(index, rain/evaporation hydrograph)
                  var row = new string[5];
                  row[0] = sourceName;
                  row[1] = sourceType;
                  row[2] = secondaryTableFileName;
                  row[3] = X;
                  row[4] = Y;

                  mainTable.Add(row);

                  //Potential new sources group (secundary dependant table). Sources data  (time, Elevations, Concentrations (various)) is
                  // stored in a file whose name could be repeated in the .SOURCES file for another group. Only one copy of the file contents is
                  //stored in memory in SecondaryGroups structure. If modified, only that copy is changed. It is permanently stored when
                  //the user clicks "Save .SOURCES".

                  Universal.LoadSecondaryTable("SOURCES", SOURCESFilePath + "\\" + secondaryTableFileName, ref warnings); }
                catch (Exception ex)
                {
                    MessageBox.Show(Universal.Idioma("ERROR 0208171811: error while proccessing  ", "ERROR 0208171811: error procesando  ") +
                                    SOURCESFileName + ". " +
                                    Environment.NewLine + ex.Message, "RiverFlow2D", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            SOURCESFile.Close();

            //Save variables associated to control tags:
            AddVariable("SOURCES_VALUES", mainTable);
            //
            //
            //
            //  Empty lines left intentionally

            if (warnings.Count > 0)
            {
                string warningsList = Universal.Idioma("WARNING 0208171813: The following sources files do not exist: \n\n", "WARNING 0208171813: Los siguientes archivos no existen: \n\n");
                for (int i = 0; i < warnings.Count; i++)
                {
                    warningsList += "   ° " + warnings[i] + "\n";
                }
                warningsList += Universal.Idioma("\nDefault files were created.", "\nAchivos por defecto fueron creados.");
                MessageBox.Show(warningsList, "RiverFlow2D", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }