GigActionDataFiller.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #if UNITY_EDITOR
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using DataTools;
  5. using System.Linq;
  6. using UnityEditor;
  7. public class GigActionDataFiller : MonoBehaviour
  8. {
  9. public GigsGigActionsData data;
  10. public TextAsset text;
  11. public void CopyFormTextToData()
  12. {
  13. string[] cols;
  14. List<GigsGigActionChart> chartList = new List<GigsGigActionChart>();
  15. int i = -1;
  16. GigsGigActions current = null;
  17. string txt = text.text.Replace("\r", "");
  18. foreach(string row in txt.Split('\n'))
  19. {
  20. cols = row.Split(';');
  21. if(cols.Length == 1)
  22. {
  23. if(current != null)
  24. current.gigsGigActionChart = chartList.ToArray();
  25. if(cols[0] == "END")
  26. continue;
  27. DataTools.GigType type = WebTools.Phone.TweetBehaviour.GetGigTypeFromString(cols[0]);
  28. current = data.GigsGigActions.Where(x => x.type == type).First();
  29. chartList.Clear();
  30. }
  31. if(cols.Length == 6)
  32. {
  33. GigsGigActionChart temp = new GigsGigActionChart();
  34. temp.gigId = cols[0];
  35. temp.motivationCost = int.Parse(cols[1]);
  36. temp.starsAmmount = int.Parse(cols[2]);
  37. temp.motivationReward = int.Parse(cols[3]);
  38. temp.dollarsReward = int.Parse(cols[4]);
  39. temp.xpReward = int.Parse(cols[5]);
  40. chartList.Add(temp);
  41. }
  42. }
  43. CopyCharts(DataTools.GigType.Photoshoot, DataTools.GigType.Practice);
  44. EditorUtility.SetDirty(data);
  45. AssetDatabase.SaveAssets();
  46. }
  47. public void CopyCharts(DataTools.GigType t_from, DataTools.GigType t_to)
  48. {
  49. GigsGigActions g_from = data.GigsGigActions.Where(x => x.type == t_from).First();
  50. GigsGigActions g_to = data.GigsGigActions.Where(x => x.type == t_to).First();
  51. g_to.gigsGigActionChart = g_from.gigsGigActionChart;
  52. }
  53. }
  54. #endif