RobotManager.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.Init();
  14. int sfsRoomID = SFSManager.GardenSmartFox.PlazaRoomController.CurrentPlazaRoom.Id;
  15. int maxPlayer = SFSManager.GardenSmartFox.PlazaRoomController.CurrentRoomData.MaxPlayer;
  16. int maxRobot = (int) Auxiliary.FmlParse(Robot.MaxRobotAmtFml, "p", maxPlayer.ToString());
  17. //Debug.Log(currentRobotAmt + " " + maxRobot);
  18. if (currentRobotAmt < maxRobot)
  19. {
  20. Robot robot = new Robot(robotConfigID, randomPos, nickname, dressdatas);
  21. robot.Connect(sfsRoomID, maxRobot);
  22. Robots.Add(robot);
  23. }
  24. }
  25. public static void DeactivateAllRobots(bool delay)
  26. {
  27. for (int i = 0; i < Robots.Count; i++)
  28. {
  29. Robots[i].Deactivate(delay);
  30. if (!delay)
  31. {
  32. i--;
  33. }
  34. }
  35. }
  36. public void Update()
  37. {
  38. for (int i = 0; i < Robots.Count; i++)
  39. {
  40. if (Robots[i].Update())
  41. {
  42. Robots[i--].Deactivate(false);
  43. }
  44. }
  45. }
  46. }