GigDataHelper.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class GigDataHelper : MonoBehaviour
  5. {
  6. public DataTools.DataGame dataGame;
  7. public DataTools.DataGigComments dataComments;
  8. public int chapterIndex = 0;
  9. private void GEN_CREW()
  10. {
  11. DataTools.Chapter chapter = dataGame.GameData.Chapters[chapterIndex];
  12. foreach(DataTools.Gig gig in chapter.Gigs)
  13. {
  14. string location = gig.Location;
  15. int table_i = dataComments.tablesList.FindIndex(t => t.locationId == location);
  16. if(table_i == -1)
  17. {
  18. dataComments.tablesList.Add(new DataTools.GigCommentsTable(location, new List<DataTools.GigCommentSheet>()));
  19. table_i = dataComments.tablesList.Count - 1;
  20. }
  21. string gigId = gig.Id;
  22. int sheet_i = dataComments.tablesList[table_i].sheetsList.FindIndex(s => s.gigId == gigId);
  23. if(sheet_i == -1)
  24. {
  25. dataComments.tablesList[table_i].sheetsList.Add(new DataTools.GigCommentSheet(gigId, new List<DataTools.GigComment>(), new List<string>()));
  26. sheet_i = dataComments.tablesList[table_i].sheetsList.Count - 1;
  27. }
  28. DataTools.Conversation c = dataGame.GameData.GetConversationById(gig.Conversation != null ? gig.Conversation : "", chapterIndex);
  29. List<string> crew = c!=null ? c.NpcId : null;
  30. if (crew != null)
  31. {
  32. dataComments.tablesList[table_i].sheetsList[sheet_i].crewList.Clear();
  33. dataComments.tablesList[table_i].sheetsList[sheet_i].crewList.AddRange(crew);
  34. }
  35. }
  36. #if UNITY_EDITOR
  37. UnityEditor.EditorUtility.SetDirty(dataComments);
  38. UnityEditor.AssetDatabase.SaveAssets();
  39. #endif
  40. }
  41. void Start ()
  42. {
  43. GEN_CREW();
  44. }
  45. }