PhotoSoundData.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using System;
  2. using System.Collections.Generic;
  3. public class PhotoSoundData
  4. {
  5. private PhotoSoundData()
  6. {
  7. }
  8. public static void Create()
  9. {
  10. if (PhotoSoundData.sound_data_ != null)
  11. {
  12. return;
  13. }
  14. PhotoSoundData.sound_data_ = new List<PhotoSoundData>();
  15. using (AFileBase afileBase = GameUty.FileSystem.FileOpen("phot_sound_list.nei"))
  16. {
  17. using (CsvParser csvParser = new CsvParser())
  18. {
  19. bool condition = csvParser.Open(afileBase);
  20. NDebug.Assert(condition, "phot_sound_list.nei\nopen failed.");
  21. for (int i = 1; i < csvParser.max_cell_y; i++)
  22. {
  23. if (csvParser.IsCellToExistData(0, i))
  24. {
  25. int num = 0;
  26. PhotoSoundData photoSoundData = new PhotoSoundData();
  27. photoSoundData.id = (long)csvParser.GetCellAsInteger(num++, i);
  28. photoSoundData.name = csvParser.GetCellAsString(num++, i);
  29. photoSoundData.file_name = csvParser.GetCellAsString(num++, i);
  30. if (GameUty.FileSystem.IsExistentFile(photoSoundData.file_name))
  31. {
  32. PhotoSoundData.sound_data_.Add(photoSoundData);
  33. }
  34. }
  35. }
  36. }
  37. }
  38. }
  39. public static List<PhotoSoundData> data
  40. {
  41. get
  42. {
  43. return PhotoSoundData.sound_data_;
  44. }
  45. }
  46. public static PhotoSoundData Get(long id)
  47. {
  48. for (int i = 0; i < PhotoSoundData.sound_data_.Count; i++)
  49. {
  50. if (PhotoSoundData.sound_data_[i].id == id)
  51. {
  52. return PhotoSoundData.sound_data_[i];
  53. }
  54. }
  55. return null;
  56. }
  57. public static PhotoSoundData Get(string file_name)
  58. {
  59. for (int i = 0; i < PhotoSoundData.sound_data_.Count; i++)
  60. {
  61. if (PhotoSoundData.sound_data_[i].file_name == file_name)
  62. {
  63. return PhotoSoundData.sound_data_[i];
  64. }
  65. }
  66. return null;
  67. }
  68. public void Play()
  69. {
  70. GameMain.Instance.SoundMgr.PlayBGM(this.file_name, 0f, true);
  71. }
  72. public long id;
  73. public string name;
  74. public string file_name;
  75. private static List<PhotoSoundData> sound_data_;
  76. }