RobotManager.cs 1018 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Random = UnityEngine.Random;
  6. public class RobotManager
  7. {
  8. #region Config
  9. public static List<Robot> Robots = new List<Robot>();
  10. #endregion
  11. public static void AddRobot(int sfsRoomID, int maxRobot, Vector3 position, PlayerDirection direction)
  12. {
  13. Robot.Initialize();
  14. Robot robot = new Robot(position, direction);
  15. robot.Connect(sfsRoomID, maxRobot);
  16. Robots.Add(robot);
  17. }
  18. public static void DeactivateAllRobots(bool delay)
  19. {
  20. for (int i = 0; i < Robots.Count; i++)
  21. {
  22. Robots[i].Deactivate(delay);
  23. if (!delay)
  24. {
  25. Robots.RemoveAt(i--);
  26. }
  27. }
  28. }
  29. public static void Update()
  30. {
  31. for (int i = 0; i < Robots.Count; i++)
  32. {
  33. if (Robots[i].Update())
  34. {
  35. Robots[i--].Deactivate(false);
  36. }
  37. }
  38. }
  39. }