Robot.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Xml;
  4. using Sfs2X;
  5. using UnityEngine;
  6. public class Robot
  7. {
  8. #region Config
  9. private static bool Initialized;
  10. private static int MinChestValue;
  11. private static int MaxChestValue;
  12. private static float MinLifetime;
  13. private static float MaxLifetime;
  14. private static float CreateChestRate;
  15. private static float ColorChestRate;
  16. private static float DigitChestRate;
  17. private static float MinMoveTime;
  18. private static float MaxMoveTime;
  19. private static float MinRobotCreateTime;
  20. private static float MaxRobotCreateTime;
  21. private static string MaxRobotAmtFml;
  22. private static string ConfigName = "robot_config";
  23. private static string RootNodeName = "data";
  24. private static string DataNodeName = "item";
  25. private float LifetimeTimer;
  26. private float MoveTimer;
  27. private SmartFox SmartFox;
  28. #endregion
  29. public static void Initialize()
  30. {
  31. if (Initialized)
  32. {
  33. Initialized = true;
  34. return;
  35. }
  36. XmlDocument document = ManaData.GetXmlDocument(ConfigName);
  37. XmlNode dataNode = document.SelectSingleNode(RootNodeName).SelectSingleNode(DataNodeName);
  38. XmlAttributeCollection attributes = dataNode.Attributes;
  39. int index = 1;
  40. List<int> ints = Auxiliary.IntListParse(',', attributes[index++].Value, null);
  41. MinRobotCreateTime = ints[0];
  42. MaxRobotCreateTime = ints[1];
  43. MaxRobotAmtFml = attributes[index++].Value;
  44. DigitChestRate = float.Parse(attributes[index++].Value);
  45. ColorChestRate = float.Parse(attributes[index++].Value);
  46. ints = Auxiliary.IntListParse(',', attributes[index++].Value, null);
  47. MinMoveTime = ints[0];
  48. MaxMoveTime = ints[1];
  49. CreateChestRate = float.Parse(attributes[index++].Value);
  50. ints = Auxiliary.IntListParse(',', attributes[index++].Value, null);
  51. MinChestValue = ints[0];
  52. MaxChestValue = ints[1];
  53. ints = Auxiliary.IntListParse(',', attributes[index++].Value, null);
  54. MinLifetime = ints[0];
  55. MaxLifetime = ints[1];
  56. Debug.Log($"RobotConfig {MinRobotCreateTime}");
  57. Debug.Log($"RobotConfig {MaxRobotCreateTime}");
  58. Debug.Log($"RobotConfig {MaxRobotAmtFml}");
  59. Debug.Log($"RobotConfig {DigitChestRate}");
  60. Debug.Log($"RobotConfig {ColorChestRate}");
  61. Debug.Log($"RobotConfig {MinMoveTime}");
  62. Debug.Log($"RobotConfig {MaxMoveTime}");
  63. Debug.Log($"RobotConfig {CreateChestRate}");
  64. Debug.Log($"RobotConfig {MinChestValue}");
  65. Debug.Log($"RobotConfig {MaxChestValue}");
  66. Debug.Log($"RobotConfig {MinLifetime}");
  67. Debug.Log($"RobotConfig {MaxLifetime}");
  68. }
  69. public void Start()
  70. {
  71. }
  72. public void Update()
  73. {
  74. }
  75. }