ShuiZaiCtrl.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using FLOW;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Text;
  6. using UnityCommon;
  7. using UnityEngine;
  8. namespace DTYJ
  9. {
  10. public class ShuiZaiCtrl : MonoBehaviour
  11. {
  12. public static ShuiZaiCtrl Instance { get; private set; }
  13. public FlowSimulation flowSim_Up, flowSim_down;
  14. public FlowModifier flowModifierAddLiquid_Up, flowModifierAddLiquid_down1, flowModifierAddLiquid_down2, flowModifierAddLiquid_down3;
  15. private void Awake()
  16. {
  17. Instance = this;
  18. flowSim_Up.gameObject.SetActive(OnlineCtrl.Instance.mineRoleName != RoleName.Õ¾ÎñÔ±_վ̨);
  19. flowSim_down.gameObject.SetActive(OnlineCtrl.Instance.mineRoleName == RoleName.Õ¾ÎñÔ±_վ̨);
  20. Utility.Update(5, () =>
  21. {
  22. foreach (var kvp in dicDepth)
  23. {
  24. ControllerPanel.instance.CmdOnLevel(kvp.Key, kvp.Value);
  25. }
  26. });
  27. string filePath = Path.Combine(Application.streamingAssetsPath, "Data/Ë®ÔÖÔ¤°¸ÅäÖÃ.csv");
  28. string[] strLines = File.ReadAllLines(filePath, UnicodeEncoding.GetEncoding("GBK"));
  29. List<string> list = new List<string>();
  30. list.AddRange(strLines);
  31. //for (int i = 1; i < strLines.Length; i++)
  32. //{
  33. // string line = strLines[i];
  34. // var arr = line.Split(',');
  35. // if (arr.Length >= 2)
  36. // {
  37. // list.Add(arr[1]);
  38. // }
  39. //}
  40. UIYuAnCtrl.Instance.Init(list);
  41. UIYuAnCtrl.Instance.Show(true);
  42. }
  43. private void OnDestroy()
  44. {
  45. UIYuAnCtrl.Instance.Show(false);
  46. }
  47. public Dictionary<string, float> dicDepth = new Dictionary<string, float>();
  48. public void OnSampleDepth(FlowSample flowSample)
  49. {
  50. dicDepth[flowSample.name] = flowSample.FluidDepth;
  51. }
  52. public void SetFlowValue_up(float v)
  53. {
  54. flowModifierAddLiquid_Up.Strength = v;
  55. }
  56. public void OnFluidDepth(FlowSimulation simulation, float depth)
  57. {
  58. //flowModifierAddLiquid_down.Strength = depth;
  59. ControllerPanel.instance?.CmdSetShuiZai_down(depth);
  60. }
  61. public void OnFluidComing()
  62. {
  63. //flowModifierAddLiquid_down.Strength = depth;
  64. ControllerPanel.instance?.CmdSetShuiZai_down(1.5f);
  65. }
  66. public void OnFluidLeave()
  67. {
  68. ControllerPanel.instance?.CmdSetShuiZai_down(0);
  69. }
  70. public void SetFlowValue_down(float v)
  71. {
  72. flowModifierAddLiquid_down1.Strength = v;
  73. flowModifierAddLiquid_down2.Strength = v;
  74. flowModifierAddLiquid_down3.Strength = v;
  75. }
  76. public void UpdateGround()
  77. {
  78. flowSim_Up?.UpdateGround();
  79. flowSim_down?.UpdateGround();
  80. }
  81. }
  82. }