RobotManager.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Random = UnityEngine.Random;
  6. public class RobotManager : Regist
  7. {
  8. #region Config
  9. public static List<Robot> Robots = new List<Robot>();
  10. #endregion
  11. public static void AddRobot(int currentRobotAmt, long robotConfigID, bool randomPos, string nickname, List<string> dressdatas)
  12. {
  13. Robot.Initialize();
  14. int sfsRoomID = SFSManager.GardenSmartFox.PlazaRoomManager.CurrentPlazaRoom.Id;
  15. int maxPlayer = SFSManager.GardenSmartFox.PlazaRoomManager.CurrentRoomData.MaxPlayer;
  16. int maxRobot = (int) Auxiliary.FmlParse(Robot.MaxRobotAmtFml, "p", maxPlayer.ToString());
  17. if (currentRobotAmt < maxRobot)
  18. {
  19. Robot robot = new Robot(robotConfigID, randomPos, nickname, dressdatas);
  20. robot.Connect(sfsRoomID);
  21. Robots.Add(robot);
  22. }
  23. }
  24. public static void DeactivateAllRobots(bool delay)
  25. {
  26. for (int i = 0; i < Robots.Count; i++)
  27. {
  28. Robots[i].Deactivate(delay);
  29. if (!delay)
  30. {
  31. i--;
  32. }
  33. }
  34. }
  35. public void Update()
  36. {
  37. for (int i = 0; i < Robots.Count; i++)
  38. {
  39. if (Robots[i].Update())
  40. {
  41. Robots[i--].Deactivate(false);
  42. }
  43. }
  44. }
  45. }